Bekijk de volledige versie : Emergency bypass of rc.local

08-03-2007, 03:34
I'm sure I'm not the only person who has messed up his rc.local file resulting in a brain-dead router. When this happens, the only way out has been to reflash the original Asus firmware, install the telnet hack, fix the rc.local file, reload the custom firmware, and continue where I left off 1/2 hour earler.

To rectify that, I now start the telnet server at the very beginning of rc.local then check to see if the copy button is pressed. If so, I immediately exit rc.local. The top of my rc.local file now looks like:


# Always start utelnetd on local interface
if [ ! -f /var/run/utelnetd.pid ]; then
/apps/bin/utelnetd -d -i br0
/bin/echo "unknown" > /var/run/utelnetd.pid

# If the copy button is pressed, bypass rc.local
bypass=`/bin/cat /proc/miscio/gpio_6`
if test $bypass -eq "1"; then
exit -1

To activate the bypass, just press and hold the copy button during the boot sequence. You can then telnet in to fix whatever was wrong.

- K.C.

08-03-2007, 20:53
Simple but brilliant.


09-03-2007, 06:42
i like that approach. But i will move the start of utelnetd inside the if $bypass .. block. This way i only need telnet when something goes wrong.
Most of the time (actually allways since several month) i use ssh and leave telnet disabled.

By the way, there is a simple solution for exchanging binaries without recompiling the whole firmware. I use the same method kfurge used to mount /opt (mount -o bind) and make copy of every directory (/etc /var /apps ...) I want to replace. I mount these copies from rc.local and can exchange links binaries libs as I like. Also this leaves you with persistent directories for /etc and /var wich makes using other apps much more comfortable. I think the few megabytes (even hundrets if neede) don't hurt this gigabyte monster of HDD.
I tried this trick with an USB-flashdrive and it works realy nice, but i need my large thumbdrive. I will buy a new one and continue with this method. The advantage of the flashdrive is that i can use a very small rc.local which tries to mount the thumbdrive and than loads an rc.local from there. This way the router almost stays in its original state (even passwd group ...) unless the flashdrive is inserted on startup. Also the hdd is not used frequently even when running programs.

cu Harald