I am using Tomato Firmware v1.28.7486 MIPSR2-Toastman-RT K26 USB VPN. Even I put in something in the Shutdown script box, it seems that it is not working!. Any ideas?
Some others have reported a fault with the Tomato shutdown procedure, this happened long, long ago. Nobody bothered to fix it because few people ever use it. I have no idea if it ever did have a problem, because I also never used it.
I'll take a look see if I can spot the problem, if those who use it can explain what exactly doesn't work and what you are trying to do. Maybe some things are not doable.
Anyone else, please do the same if you are able !
Download site http://www.4shared.com/dir/v1BuINP3/Toastman_Builds.html (inc. torrent downloads)
Make a Paypal Donation http://toastmanfirmware.yolasite.com/donations.php
I have the same problem. My script tries to backup ipt database on a remote server before shutting down (My router has no USB nor jffs space).
The script ran by itself works flawlessly, however in shutdown it does not work.
if [ -e "/tmp/ipt.db" ]
service cstats stop
ftpput -u mika -p pass host.net ipt.db
I saw that kcheon reported that service may be the culprit. However, it's useless if I do not force cstats to update its file before uploading (only way I found is by stopping it)
Is there any other way to detect a shutdown and run my script? I run it in a cron every two hours, but two hours worth of BW here can be over one hundred gigabytes.
Short version: unfortunately, you cannot run things like 'service XXX stop' from inside the a script such as script_shut.
Long version: according to what I've been able to learn from the sources, the 'shutdown' process is triggered by sending SIGQUIT to the 'init' process. As soon as it's picked up by init, it runs the shutdown procedure stored on NVRAM var script_shut and waits up to 10 seconds before moving on. So far so good, right?
Well… as it turns out, 'init' and 'service' are actually two applets inside 'rc':
root@unknown:/tmp/home/root# ls -l /sbin/init /sbin/service /sbin/rc
lrwxrwxrwx 1 root root 2 Jan 25 11:56 /sbin/init -> rc
-r-x-- 1 root root 225960 Jan 25 11:56 /sbin/rc
lrwxrwxrwx 1 root root 2 Jan 25 11:56 /sbin/service -> rc
Simply put: as both of them handle signals their own way, they don't play well together :(
You might still have options as you could try a few different things:
- saving to a CIFS share has been working fine on my routers for quite a while…
- if using a CIFS mount is not an option, you could try to mimic what 'service cstats stop' would do on your script:
killall cstats ; wait ; check if still running, repeat if necessary (until stopped and/or datafile is dumped?); copy/push/ftp datafile to new location
Best of luck!
Thank you for the explanations, I can now understand why it does not work. I will eventually try to replace service by a real shell script, but for now a loop with killall was the way to go.
if [ -e "/tmp/ipt.db" ]; then
while killall cstats 2>/dev/null
if [ "$running" = "1" ]; then
ftpput -u mika -p mika host.net ipt.db
Thanks Teaman for the help