Dear friends, happy 2022! I have an issue I don't really know how to fix.
I'm a long time builder of openwrt firmware, been building from git since 2014. Not a stranger to the process. I normally set up additional steps under the files/ folder so that upon first successful boot, things can run and set up automatically via UCI.
I made a mistake though that has me stumped, I erroneously didn't remove a command from the very bottom of the script, which was, this very last line:
# Restart firewall echo -en "\nRestarting firewall... " /etc/init.d/firewall restart >/dev/null 2>&1 echo "Done" reboot && exit
This reboot && exit is causing my build to reboot every single time I start up. I get ping and can ssh into the router for a scarce 5 or 6 seconds before the command gets to the reboot, and now I can't stop it. Normally, I'd just be able to tftp a factory image and be done with it, but in this particular router I can't, SO:
I tried sending an ssh script to stop the script from loading (called /etc/startup.sh), or killing it. but I've tried many things unsuccessfully such as:
a. Renaming /sbin/reboot to something else
b. killing busybox with killall -9 busybox
c. running a script that extracts the PID of any scripts running via ash and killing them with kill -9, but I just can't seem to stop it in time before the reboot, and It just bootloops like crazy. (but again, not bricked, I do manage to get a good 4 or 5 seconds in the terminal before it bootloops).
Given this 5 second window, I've even run remote scripts with ssh -s root@target < suchandsoscript.sh to automate these steps.
So, anyway, my million dollar question is:
What creative way that I haven't thought of yet, with a 4-5 second windows to act upon via ssh could I run to stop the script from going on, and/or what could I rename so that reboot is paused, or somehow the system doesn't loop, so I can go in, and send a new sysupgrade -n -v with the proper build without my terrible mistake?
Thanks for chiming in!