Just a tad of handholding needed here. I'm using the openwrt build system to compile OpenWrt from source code with NSS support for OnHub routers and all is going well and I've figured out the basics of how to do it and all. I'm still just a little uncertain about where exactly on the build machine I locate the script to run on first boot. Does it go in a particular, specific directory and need a specific name and does it have to be chmod +x and all that stuff before the compile?
Here's what I'm working on. I'm making a nice Mesh system with two OnHub routers and I'll be using the new debugged version of mesh11sd when it's released soon. I want to add this first boot script:
# UCI configuration
uci set mesh11sd.setup.auto_config='0'
uci set mesh11sd.setup.country='JP'
uci set mesh11sd.setup.ssid_suffix_enable='1'
uci set mesh11sd.setup.vtun_enable='1'
uci set mesh11sd.setup.auto_mesh_id='karla-mesh'
uci set mesh11sd.setup.auto_mesh_key='MyOptionalMeshKeySeed'
uci set mesh11sd.setup.mesh_gate_base_ssid='Karla'
uci set mesh11sd.setup.mesh_gate_encryption='3'
uci set mesh11sd.setup.mesh_gate_key='secret_wifi_password'
uci set mesh11sd.setup.vtun_gate_encryption='3'
uci set mesh11sd.setup.vtun_base_ssid 'GuestNetworkSSIDHere'
uci set mesh11sd.setup.vtun_gate_key='GuestWifiPasswordHere'
uci commit mesh11sd
uci commit network
# Set root password
rootpassword="secret_admin_password"
/bin/passwd root << EOF
$rootpassword
$rootpassword
EOF
# Critical exit code
exit 0
Where exactly does this go in the build system? The firmware selector makes it easy, but I don't quite know exactly how I add this to my compiled binary I'm making on my own computer.
Do I have to chmod +x 10_your_script before compiling or is that automatic? I'm going to use 99_your_script because I want to insure it runs last in sequence. Does the script have to have any particular name to work? Can just name it 99_mesh11sd? Does it need a shebang on the first line? Any little tricky things newbies miss? Does the exit 0 go after or before the EOF that's at the end of the script now?
exit 0 after you've done what you need .. always good to check for failure, in this case you can either exit 1, the script will remain in uci-defaults and be fired on each boot until success ..exit 0
or you can just print a error msg to log and exit 0 anyway preventing retries.
logger "my script failed :( " && exit 0
or
echo "my script failed :(" && exit 0
EDIT
return 0 and return 1 work the same as exit as you can see in the example provided
Raises question about the executable bit being set in the script since it's run in the shell interpreter and not directly invoked as an executable. "The OpenWrt boot process does not rely on the executable bit." I'm going to delete the shebang too. "Because the shell is specified directly, the kernel never looks for a shebang line."
Thanks to all. I appreciate the quick answers and help. You really helped me help myself.