What's new

unmount script not running on AC86U

  • SNBForums Code of Conduct

    SNBForums is a community for everyone, no matter what their level of experience.

    Please be tolerant and patient of others, especially newcomers. We are all here to share and learn!

    The rules are simple: Be patient, be nice, be helpful or be gone!

cmkelley

Very Senior Member
I have "chmod a+rx *" in the /jffs/scripts directory.
I've tried using logger to verify it's running - nothing in syslog.
I've tried touching a file to verify it's running - doesn't seem to work.
It has "#!/bin/sh" as the first line.
I created it by copying my post-mount script (which I know runs) and changing some lines using vi, so it's not a dos/unix eol issue.

I'm stumped.

Also, I can verify by other means that my init-start is working, but logger doesn't seem to work in init-start. Can anyone verify that it does or doesn't? I'm calling logger explicitly "/usr/bin/logger -t Init "Starting init ..." "
 
How are you testing your unmount script? It won't run until you click the Eject option in the router's GUI (or invoke a similar router function that calls it indirectly). It doesn't run at startup (obviously).
 
Last edited:
I have "chmod a+rx *" in the /jffs/scripts directory.
I've tried using logger to verify it's running - nothing in syslog.
I've tried touching a file to verify it's running - doesn't seem to work.
It has "#!/bin/sh" as the first line.
I created it by copying my post-mount script (which I know runs) and changing some lines using vi, so it's not a dos/unix eol issue.

I'm stumped.

Also, I can verify by other means that my init-start is working, but logger doesn't seem to work in init-start. Can anyone verify that it does or doesn't? I'm calling logger explicitly "/usr/bin/logger -t Init "Starting init ..." "
When init-start is run, there isn't any logging support yet. I have tried the same thing as you. No syslog entry for the logger command.
 
I have "chmod a+rx *" in the /jffs/scripts directory.
I've tried using logger to verify it's running - nothing in syslog.
I've tried touching a file to verify it's running - doesn't seem to work.
It has "#!/bin/sh" as the first line.
I created it by copying my post-mount script (which I know runs) and changing some lines using vi, so it's not a dos/unix eol issue.

I'm stumped.

Also, I can verify by other means that my init-start is working, but logger doesn't seem to work in init-start. Can anyone verify that it does or doesn't? I'm calling logger explicitly "/usr/bin/logger -t Init "Starting init ..." "
You can use just:
Code:
logger "string_to_log"
 
How are you testing your unmount script? It won't run until you click the Eject option in the router's GUI (or invoke a similar router function that calls it indirectly). It doesn't run at startup (obviously).
Ah-ha! The missing piece! It runs when I unmount the drive in the GUI.

That means that unmount doesn't run during a reboot!

That would be useful information to add to the user scripts page on the wiki ...
 
logger doesn't seem to work in init-start.
Can anyone verify that it does or doesn't? I'm calling logger explicitly "/usr/bin/logger -t Init "Starting init ..." "

I've never experienced 'logger' not working from within init-start, but I have to use the following in services-stop
Code:
if [ -z "$(ps | grep -v grep | grep -m 1 syslog-ng)" ];then
 LOGFILE="/tmp/syslog.log"
else
 LOGFILE="/opt/var/log/messages"
fi

# logger works for the first two or three messages.....

<snip>

# At this point no further logger statements are recorded in Syslog / syslog-ng?
#    so spoof a logger message!

echo `date "+%b   %d %T"` $MYROUTER "Spoof.logger (services-stop): Martineau Services shutdown doin' stuff......"  >> $LOGFILE
 
I've never experienced 'logger' not working from within init-start, but I have to use the following in services-stop
Code:
if [ -z "$(ps | grep -v grep | grep -m 1 syslog-ng)" ];then
 LOGFILE="/tmp/syslog.log"
else
 LOGFILE="/opt/var/log/messages"
fi

# logger works for the first two or three messages.....

<snip>

# At this point no further logger statements are recorded in Syslog / syslog-ng?
#    so spoof a logger message!

echo `date "+%b   %d %T"` $MYROUTER "Spoof.logger (services-stop): Martineau Services shutdown doin' stuff......"  >> $LOGFILE
logger isn't working at all for me in services-stop.
 
That means that unmount doesn't run during a reboot!
I think it does attempt to run the script but it's not always possible. I'm pretty sure I remember it working in the past, because I wrote some code in there that does some housekeeping. I'll test it later when the family aren't using the internet.
 
logger isn't working at all for me in services-stop.

Did a shutdown, and everything I expected from 'logger' and notification that 'unmount' executed successfully was in 'Syslog'

Code:
Dec  9 18:17:15 RT-AC68U kernel: [BADAlexa]IN=br0 OUT=eth0 SRC=10.88.8.16 DST=192.168.0.3 LEN=60 TOS=0x00 PREC=0x00 TTL=63 ID=17275 DF PROTO=TCP SPT=42637 DPT=35471 SEQ=1292553649 ACK=0 WINDOW=65535 RES=0x00 SYN URGP=0 OPT (020405B40402080A322D92B40000000001030306)

    ********************Manual REBOOT requested********************

Dec  9 18:17:16 RT-AC68U rc_service: service 21651:notify_rc start_reboot

Dec  9 18:17:16 RT-AC68U dropbear[12617]: Exit (admin): Exited normally
Dec  9 18:17:17 RT-AC68U custom_script: Running /jffs/scripts/service-event (args: start reboot) - max timeout = 120s
Dec  9 18:17:17 RT-AC68U (service-event): 21657 User service-event running
Dec  9 18:17:17 RT-AC68U (service-event): 21657 Script not defined for service event: start-reboot

Dec  9 18:17:19 RT-AC68U WAN_Connection: ISP's DHCP did not function properly.

Dec  9 18:17:26 RT-AC68U custom_script: Running /jffs/scripts/services-stop
Dec  9 18:17:26 RT-AC68U (services-stop): 21948 Martineau Services shutdown cleanup starting...... []
Dec  9 18:17:26 RT-AC68U (services-stop): 21948 Stopping rstats.....
Dec  9 18:17:26 RT-AC68U rc_service: service 21977:notify_rc stop_rstats
Dec  9 18:17:26 RT-AC68U (services-stop): 21948 Stopping cstats.....
Dec  9 18:17:26 RT-AC68U rc_service: service 21985:notify_rc stop_cstats
Dec  9 18:17:26 RT-AC68U rc_service: waitting "stop_rstats" via  …

Dec  9 18:17:36 RT-AC68U (nat-start): 22056 Martineau NAT customisation Starting.... []
Dec  9 18:17:36 RT-AC68U (nat-start): 22056 **WARNING: Shutdown in progress: '/tmp/SHUTDOWNINPROGRESS' skipping processing!


Dec  9 18:17:39 RT-AC68U custom_script: Running /jffs/scripts/unmount (args: /tmp/mnt/RT-AC68U ) - max timeout = 120s
Dec  9 18:17:39 RT-AC68U (unmount): 22187 Martineau unmount processing.....
Dec  9 18:17:39 RT-AC68U (unmount): 22187 Martineau unmount processing complete.


Dec  9 18:17:40 RT-AC68U ntpd[11112]: 85.199.214.101 local addr 10.88.8.1 -> <null>
Dec  9 18:17:40 RT-AC68U syslog: USB partition unmounted from /tmp/mnt/RT-AC68U fail. (return -1, Bad file descriptor)
Dec  9 18:17:40 RT-AC68U FTP_Server: daemon is stopped
Dec  9 18:17:40 RT-AC68U Samba_Server: smb daemon is stopped
Dec  9 18:17:40 RT-AC68U Timemachine: daemon is stopped
Dec  9 18:17:41 RT-AC68U syslog: USB partition unmounted from /tmp/mnt/RT-AC68U fail. (return -1, Bad file descriptor)
Dec  9 18:17:42 RT-AC68U rc_service: skip the event: stop_cstats.

Dec  9 18:17:42 RT-AC68U (services-stop): 21948 Stopping Entware apps.....

Dec  9 18:17:54 RT-AC68U netdata[11206]: EXIT: all done - netdata is now exiting - bye bye...
Dec  9 18:17:54 RT-AC68U syslog: USB partition unmounted from /tmp/mnt/RT-AC68U fail. (return -1, Bad file descriptor)
Dec  9 18:17:55 RT-AC68U syslog-ng[11247]: syslog-ng shutting down; version='3.16.1'
Dec  9 18:17:55 RT-AC68U syslog: USB partition unmounted from /tmp/mnt/RT-AC68U fail. (return -1, Bad file descriptor)

Dec 09 18:17:56 RT-AC68U Spoof.logger (services-stop): Martineau Services shutdown cleanup complete.
Dec 09 18:17:56 RT-AC68U Spoof.logger (services-stop): Saving syslog-ng before Reboot.....
 
I think it does attempt to run the script but it's not always possible. I'm pretty sure I remember it working in the past, because I wrote some code in there that does some housekeeping. I'll test it later when the family aren't using the internet.
I thought the same thing...but looking at the code in my fork yesterday it had a really strange set of conditions on when to umount the drives (and run the unmount script). Most times it would not run on shutdown/reboot. I did a fork fix yesterday (haven't had the opportunity to check the Merlin.ng code)
* FIXED: usb: ensure usb devices are always unmounted during shutdown/reboot

Drop me a PM if you want to try it.
 
I thought the same thing...but looking at the code in my fork yesterday it had a really strange set of conditions on when to umount the drives (and run the unmount script). Most times it would not run on shutdown/reboot. I did a fork fix yesterday (haven't had the opportunity to check the Merlin.ng code)
* FIXED: usb: ensure usb devices are always unmounted during shutdown/reboot

Drop me a PM if you want to try it.
The wife is up, no more rebooting the router over and over this morning ... :)

After rebooting many, many times, I'd say that with my configuration, the conditions to run the unmount script on shutdown are never met. :)
 
Well, thanks to @ColinTaylor was able to find a second sequence that does the unmount, but it was running after the logger was shutdown. So, it was working as we all thought it should, just not being logged. Was able to write a patch that keeps the logger up just a bit longer so that it can successfully log the unmount and unmount script.

I checked and the same sequence exists on the Merlin code. @cmkelley - I'll do a test build for the AC86 for you to verify and send you a PM.
 
@john9527 - tried your test build tonight, your changes didn't keep logger running long enough, and I'm fairly convinced that at least in my set-up, unmount is not being run, except, in the special case of the reboot that is part of a firmware update. Before installing your firmware, I added the following to unmount:
Code:
echo `date "+%b   %d %T"` "Unmount.Spoof: Unmounting $1 ..."  >> /jffs/syslog.log
/usr/bin/logger -t Unmount "Umounting $1 ..."
When I looked at the log right after installing your update, the "Unmount.Spoof" entry was in syslog, but not the logger "Unmount" entry. Okay, so that was expected - we already "know" that logger gets shut down too early with merlin firmware. I then rebooted the router a few times after doing some minor tasks in-between reboots, and neither entry ever showed up in syslog. Lastly, I reverted back to straight merlin 384.8_2, and once again, only the "Unmount.Spoof" entry was in syslog, but not the logger "Unmount" entry. So at least in the case of a firmware update, logger had stopped before unmount was run, regardless if I was straight merlin or your patches. And as noted, I really think unmount doesn't run except for the automatic reboot after firmware update.

Note that for me, the exercise is only a matter of interest - since my "$1" in this case is an SSD formatted ext4 with journaling, I don't really worry about data loss from a commanded or un-commanded (e.g. power failure) reboot. People using usb flash drives might be slightly more interested in ensuring unmount runs in commanded reboots.
 
tried your test build tonight, your changes didn't keep logger running long enough
Sorry, but I don't see how that could be with the change....logger is definitely stopped AFTER the unmount...

Take out your logger adds to unmount, and just reboot. Post the syslog when the reboot occurs, capturing the time transition to the default date/time....the unmount should be the last thing before that.
 
Sorry, but I don't see how that could be with the change....logger is definitely stopped AFTER the unmount...

Take out your logger adds to unmount, and just reboot. Post the syslog when the reboot occurs, capturing the time transition to the default date/time....the unmount should be the last thing before that.
I went to bed right after posting, and I'm at work now.. Will try to get at it tonight, but I can already tell you what it will be since I've looked at it so many times; the last entry in the log will be dropbear accepting my ssh login. :)

What log level would you like?
 
Or instead of logger try dumping debug info to jffs:

Code:
date >> /jffs/000debug

Look for the presence of that file after the reboot.
 
What log level would you like?
Default log levels.....you should see something like this (this is from my fork, but the change to ng code was a direct port). You need to scroll back in the syslog to see the reboot.
Code:
Dec  9 14:35:01 kernel: device eth1 left promiscuous mode
Dec  9 14:35:01 kernel: br0: port 2(eth1) entering disabled state
Dec  9 14:35:01 kernel: device eth2 left promiscuous mode
Dec  9 14:35:01 kernel: br0: port 3(eth2) entering disabled state
Dec  9 14:35:01 kernel: device wl0.1 left promiscuous mode
Dec  9 14:35:01 kernel: br0: port 4(wl0.1) entering disabled state
Dec  9 14:35:01 kernel: device wl1.1 left promiscuous mode
Dec  9 14:35:01 kernel: br0: port 5(wl1.1) entering disabled state
Dec  9 14:35:01 NFS_Server: daemon is stopped
Dec  9 14:35:01 Timemachine: daemon is stopped
Dec  9 14:35:01 MediaServer: daemon is stopped
Dec  9 14:35:01 FTP_Server: daemon is stopped
Dec  9 14:35:01 Samba_Server: smb daemon is stopped
Dec  9 14:35:01 custom_script: Running /jffs/scripts/unmount (args: /tmp/mnt/extsys )
Dec  9 14:35:02 syslog: USB partition unmounted from /tmp/mnt/extsys
Dec  9 14:35:02 custom_script: Running /jffs/scripts/unmount (args: /tmp/mnt/ASUS )
Dec  9 14:35:03 syslog: USB partition unmounted from /tmp/mnt/ASUS
Dec  9 14:35:03 Cloudsync_client: daemon is stopped
Dec  9 14:35:03 custom_script: Running /jffs/scripts/unmount (args: /tmp/mnt/Router_Share )
Dec  9 14:35:04 syslog: USB partition unmounted from /tmp/mnt/Router_Share
Dec 31 17:00:14 syslogd started: BusyBox v1.25.1
Dec 31 17:00:14 kernel: klogd started: BusyBox v1.25.1 (2018-12-09 13:58:20 MST)
Dec 31 17:00:14 kernel: Linux version 2.6.36.4brcmarm (root@ASUS-AJ082535) (gcc version 4.5.3 (Buildroot 2012.02) ) #1 SMP PREEMPT Sun Dec 9 14:03:01 MST 2018
Dec 31 17:00:14 kernel: CPU: ARMv7 Processor [413fc090] revision 0 (ARMv7), cr=10c53c7f
 
Default log levels.....you should see something like this (this is from my fork, but the change to ng code was a direct port). You need to scroll back in the syslog to see the reboot.
Code:
Dec  9 14:35:01 kernel: device eth1 left promiscuous mode
Dec  9 14:35:01 kernel: br0: port 2(eth1) entering disabled state
Dec  9 14:35:01 kernel: device eth2 left promiscuous mode
Dec  9 14:35:01 kernel: br0: port 3(eth2) entering disabled state
Dec  9 14:35:01 kernel: device wl0.1 left promiscuous mode
Dec  9 14:35:01 kernel: br0: port 4(wl0.1) entering disabled state
Dec  9 14:35:01 kernel: device wl1.1 left promiscuous mode
Dec  9 14:35:01 kernel: br0: port 5(wl1.1) entering disabled state
Dec  9 14:35:01 NFS_Server: daemon is stopped
Dec  9 14:35:01 Timemachine: daemon is stopped
Dec  9 14:35:01 MediaServer: daemon is stopped
Dec  9 14:35:01 FTP_Server: daemon is stopped
Dec  9 14:35:01 Samba_Server: smb daemon is stopped
Dec  9 14:35:01 custom_script: Running /jffs/scripts/unmount (args: /tmp/mnt/extsys )
Dec  9 14:35:02 syslog: USB partition unmounted from /tmp/mnt/extsys
Dec  9 14:35:02 custom_script: Running /jffs/scripts/unmount (args: /tmp/mnt/ASUS )
Dec  9 14:35:03 syslog: USB partition unmounted from /tmp/mnt/ASUS
Dec  9 14:35:03 Cloudsync_client: daemon is stopped
Dec  9 14:35:03 custom_script: Running /jffs/scripts/unmount (args: /tmp/mnt/Router_Share )
Dec  9 14:35:04 syslog: USB partition unmounted from /tmp/mnt/Router_Share
Dec 31 17:00:14 syslogd started: BusyBox v1.25.1
Dec 31 17:00:14 kernel: klogd started: BusyBox v1.25.1 (2018-12-09 13:58:20 MST)
Dec 31 17:00:14 kernel: Linux version 2.6.36.4brcmarm (root@ASUS-AJ082535) (gcc version 4.5.3 (Buildroot 2012.02) ) #1 SMP PREEMPT Sun Dec 9 14:03:01 MST 2018
Dec 31 17:00:14 kernel: CPU: ARMv7 Processor [413fc090] revision 0 (ARMv7), cr=10c53c7f
Even easier for me to find the reboot, I echo a big (3-line) flag to syslog as the first line of init-start to make the reboots easy to find. :) I certainly don't get the level of logs you're showing above, but I don't recall changing the log level. Is that what I should expect to see?
 
Or instead of logger try dumping debug info to jffs:

Code:
date >> /jffs/000debug

Look for the presence of that file after the reboot.
I already tried a variation of that - I tried using touch to create a file in /jffs, and it didn't create the file. But I'll give it another go.
 
I went to bed right after posting, and I'm at work now.. Will try to get at it tonight, but I can already tell you what it will be since I've looked at it so many times; the last entry in the log will be dropbear accepting my ssh login. :)
I'm starting to think that your router isn't actually shutting down at all but just crashing as soon as the shutdown/reboot command is issued.
 

Similar threads

Latest threads

Sign Up For SNBForums Daily Digest

Get an update of what's new every day delivered to your mailbox. Sign up here!
Top