Author
Message
mwchang DD-WRT Guru Joined: 26 Mar 2013 Posts: 1858 Location: Hung Hom, Hong Kong
Posted: Sat May 14, 2022 7:40 Post subject: USB script executed during sysinit, ntp_timer setup
How many times had rc_usb been executed?
It seemed that my check [[ "$xx" > "1" ]] failed despite that there were indeed multiple entries of '{.rc_usb}' in the process list...
This was the USB script:
Code: #!/bin/sh
#
pslog=/var/log/ps.log.txt
is-mounted.sh
logger "changmw: starting .rc_usb"
ps | grep -i usb >> $pslog
echo -n >> $pslog
xx=`ps | grep '{.rc_usb}' | grep -v grep | wc -l`
echo $xx >> $pslog
echo -n >> $pslog
if [[ "$xx" > "1" ]] ; then
logger "changmw: .rc_usb already started($xx)"
exit 1
fi
And here was /var/log/ps.log.txt:
Code: > cat ps.log.txt
2489 root [usb-storage]
2734 root startservice run_rc_usb -f
2735 root startservice run_rc_usb -f
2736 root /sbin/service run_rc_usb start -f
2739 root /sbin/service run_rc_usb start -f
2741 root {.rc_usb} /bin/sh /tmp/.rc_usb blockdev_add /opt
2742 root {.rc_usb} /bin/sh /tmp/.rc_usb blockdev_add /opt
2851 root grep -i usb
2489 root [usb-storage]
3
2734 root startservice run_rc_usb -f
2735 root startservice run_rc_usb -f
2736 root /sbin/service run_rc_usb start -f
2739 root /sbin/service run_rc_usb start -f
2741 root {.rc_usb} /bin/sh /tmp/.rc_usb blockdev_add /opt
2742 root {.rc_usb} /bin/sh /tmp/.rc_usb blockdev_add /opt
2856 root {.rc_usb} /bin/sh /tmp/.rc_usb blockdev_add /opt
2858 root grep {.rc_usb}
2862 root grep -i usb
4
And here was /var/log/messages:
Code: > grep changmw messages
May 14 15:27:41 RT-N18U-HST user.notice root: changmw: starting .rc_usb
May 14 15:27:41 RT-N18U-HST user.notice root: changmw: starting .rc_usb
...
_________________ Router: Asus RT-N18U (rev. A1)
Drink, Blink, Stretch! Live long and prosper! May the Force and farces be with you!
Facebook: https://www.facebook.com/changmanwai
Website: https://sites.google.com/site/changmw
SETI@Home profile: http://setiathome.berkeley.edu/view_profile.php?userid=211832
GitHub: https://github.com/changmw/changmw
Back to top
Sponsor
ho1Aetoo DD-WRT Guru Joined: 19 Feb 2019 Posts: 3004 Location: Germany
Posted: Sat May 14, 2022 8:12 Post subject:
With one mounted USB drive/partition it will run 1x.
With multiple drives it may be executed multiple times. Last edited by ho1Aetoo on Sat May 14, 2022 8:16; edited 1 time in total
Back to top
mwchang DD-WRT Guru Joined: 26 Mar 2013 Posts: 1858 Location: Hung Hom, Hong Kong
Back to top
ho1Aetoo DD-WRT Guru Joined: 19 Feb 2019 Posts: 3004 Location: Germany
Posted: Sat May 14, 2022 8:19 Post subject:
But you can also mount the USB stick twice.
Simply by assigning a suitable label + mount by UUID
a screenshot of WebIF > Services > USB gives some information
Back to top
mwchang DD-WRT Guru Joined: 26 Mar 2013 Posts: 1858 Location: Hung Hom, Hong Kong
Posted: Sat May 14, 2022 8:23 Post subject:
ho1Aetoo wrote: But you can also mount the USB stick twice.
Simply by assigning a suitable label + mount by UUID
a screenshot of WebIF > Services > USB gives some information
Well, as you said, I had 2 partitions, mounted as /opt and /jffs respectively, each had it's UUID. Because /dev/sda was also mounted with a failure, I guess it meant rc_usb was indeed executed 3 times (sda, sda1, sda2) according to your saying.
Here was the USB tab:
Code: --- /dev/sda
Block device, size 14.91 GiB (16008609792 bytes)
DOS/MBR partition map
Partition 1: 2 GiB (2147483648 bytes, 4194304 sectors from 32)
Type 0x83 (Linux)
Ext4 file system
UUID D75E81C7-527A-427D-xxxxx (DCE, v4)
Last mounted at "/jffs"
Volume size 2 GiB (2147483648 bytes, 524288 blocks of 4 KiB)
Partition 2: 12.91 GiB (13861109760 bytes, 27072480 sectors from 4194336)
Type 0x83 (Linux)
Ext4 file system
UUID 4BCEF791-82FC-487F-xxxxx (DCE, v4)
Last mounted at "/opt"
Volume size 12.91 GiB (13861109760 bytes, 3384060 blocks of 4 KiB)
FAT32 file system (hints score 4 of 5)
Volume size 14.89 GiB (15992987648 bytes, 1952269 clusters of 8 KiB)
Volume name ""
/dev/sda not mounted Unsupported Filesystem
--- /dev/sda1
Block device, size 2 GiB (2147483648 bytes)
Ext4 file system
UUID D75E81C7-527A-427D-xxxxx (DCE, v4)
Last mounted at "/jffs"
Volume size 2 GiB (2147483648 bytes, 524288 blocks of 4 KiB)
/dev/sda1 mounted to /jffs
--- /dev/sda2
Block device, size 12.91 GiB (13861109760 bytes)
Ext4 file system
UUID 4BCEF791-82FC-487F-xxxxxx (DCE, v4)
Last mounted at "/opt"
Volume size 12.91 GiB (13861109760 bytes, 3384060 blocks of 4 KiB)
/dev/sda2 mounted to /opt
_________________ Router: Asus RT-N18U (rev. A1)
Drink, Blink, Stretch! Live long and prosper! May the Force and farces be with you!
Facebook: https://www.facebook.com/changmanwai
Website: https://sites.google.com/site/changmw
SETI@Home profile: http://setiathome.berkeley.edu/view_profile.php?userid=211832
GitHub: https://github.com/changmw/changmw Last edited by mwchang on Sat May 14, 2022 8:32; edited 2 times in total
Back to top
ho1Aetoo DD-WRT Guru Joined: 19 Feb 2019 Posts: 3004 Location: Germany
Posted: Sat May 14, 2022 8:29 Post subject:
BS said to me then I must write my script so that a multiple execution does not interfere
Well I only see 2 mounted drives.
The script should be executed only 2x.
(in my opinion still 1x too much)
Back to top
the-joker DD-WRT Developer/Maintainer Joined: 31 Jul 2021 Posts: 2146 Location: All over YOUR webs
Back to top
mwchang DD-WRT Guru Joined: 26 Mar 2013 Posts: 1858 Location: Hung Hom, Hong Kong
Posted: Sat May 14, 2022 9:33 Post subject:
ho1Aetoo wrote: BS said to me then I must write my script so that a multiple execution does not interfere
Well I only see 2 mounted drives.
The script should be executed only 2x.
(in my opinion still 1x too much)
Even more horrifying is sfe ...
Code: > grep -E 'sfe|changmw|cleanup' /var/log/messages
Jan 1 08:00:12 RT-N18U-HST kern.info kernel: [ 0.942366] PCI: bus0: Fast back to back transfers disabled
Jan 1 08:00:12 RT-N18U-HST kern.info kernel: [ 0.942820] PCI: bus1: Fast back to back transfers disabled
Jan 1 08:00:14 RT-N18U-HST user.info : [sfe] : shortcut forwarding engine successfully stopped
Jan 1 08:00:19 RT-N18U-HST user.info : [sfe] : shortcut forwarding engine successfully started
Jan 1 08:00:22 RT-N18U-HST user.info : [sfe] : shortcut forwarding engine successfully started
Jan 1 08:00:28 RT-N18U-HST user.info : [sfe] : shortcut forwarding engine successfully stopped
Jan 1 08:00:28 RT-N18U-HST user.info : [sfe] : shortcut forwarding engine successfully started
Jan 1 08:00:29 RT-N18U-HST user.info : [sfe] : shortcut forwarding engine successfully stopped
Jan 1 08:00:30 RT-N18U-HST user.info : [sfe] : shortcut forwarding engine successfully started
Jan 1 08:00:33 RT-N18U-HST user.info : [sfe] : shortcut forwarding engine successfully started
May 14 17:25:37 RT-N18U-HST user.info : [sfe] : shortcut forwarding engine successfully stopped
May 14 17:25:37 RT-N18U-HST user.info : [sfe] : shortcut forwarding engine successfully started
May 14 17:25:39 RT-N18U-HST user.info : [sfe] : shortcut forwarding engine successfully stopped
May 14 17:25:42 RT-N18U-HST user.info : [sfe] : shortcut forwarding engine successfully started
May 14 17:25:45 RT-N18U-HST user.info : [sfe] : shortcut forwarding engine successfully started
May 14 17:25:48 RT-N18U-HST daemon.info process_monitor[1863]: [process_monitor] : cleanup timers
May 14 17:25:51 RT-N18U-HST user.notice root: changmw: starting .rc_usb
May 14 17:25:51 RT-N18U-HST user.notice root: changmw: starting .rc_usb
May 14 17:25:51 RT-N18U-HST user.notice root: changmw: .rc_usb already started
May 14 17:25:51 RT-N18U-HST user.notice root: 0: changmw waiting for init for 5 seconds
May 14 17:25:56 RT-N18U-HST user.notice root: 1: changmw waiting for init for 5 seconds
May 14 17:26:01 RT-N18U-HST user.notice root: 2: changmw waiting for init for 5 seconds
May 14 17:26:06 RT-N18U-HST user.notice root: 3: changmw waiting for init for 5 seconds
May 14 17:26:11 RT-N18U-HST user.notice root: 4: changmw re-starting unbound
May 14 17:26:13 RT-N18U-HST user.notice root: 4: changmw re-starting minidlna
_________________ Router: Asus RT-N18U (rev. A1)
Drink, Blink, Stretch! Live long and prosper! May the Force and farces be with you!
Facebook: https://www.facebook.com/changmanwai
Website: https://sites.google.com/site/changmw
SETI@Home profile: http://setiathome.berkeley.edu/view_profile.php?userid=211832
GitHub: https://github.com/changmw/changmw
Back to top
the-joker DD-WRT Developer/Maintainer Joined: 31 Jul 2021 Posts: 2146 Location: All over YOUR webs
Back to top
kernel-panic69 DD-WRT Guru Joined: 08 May 2018 Posts: 14246 Location: Texas, USA
Back to top
egc DD-WRT Guru Joined: 18 Mar 2014 Posts: 12917 Location: Netherlands
Posted: Sat May 14, 2022 10:45 Post subject:
The problem is that services rely on each other, lets take DNSMasq, you want it to start early to get a WAN ip address.
If you have Dot enabled then that starts after DNSMasq, but in order to work DNSMasq has to restart.
There are probably more services which are connected to DNSMasq and trigger restarts.
Maybe my example is not exactly true but you get the meaning.
Not saying all restarts are necessary though _________________ Routers:Netgear R7000, R6400v1, R6400v2, EA6900 (XvortexCFE), E2000, E1200v1, WRT54GS v1.
Install guide R6400v2, R6700v3,XR300:https://forum.dd-wrt.com/phpBB2/viewtopic.php?t=316399
Install guide R7800/XR500: https://forum.dd-wrt.com/phpBB2/viewtopic.php?t=320614
Forum Guide Lines (important read): https://forum.dd-wrt.com/phpBB2/viewtopic.php?t=324087
Back to top
egc DD-WRT Guru Joined: 18 Mar 2014 Posts: 12917 Location: Netherlands
Back to top
kernel-panic69 DD-WRT Guru Joined: 08 May 2018 Posts: 14246 Location: Texas, USA
Back to top
egc DD-WRT Guru Joined: 18 Mar 2014 Posts: 12917 Location: Netherlands
Back to top
mwchang DD-WRT Guru Joined: 26 Mar 2013 Posts: 1858 Location: Hung Hom, Hong Kong
Posted: Sat May 14, 2022 12:19 Post subject: Re: USB script executed during sysinit... how many times?
mwchang wrote:
It seemed that my check [[ "$xx" > "1" ]] failed despite that there were indeed multiple entries of '{.rc_usb}' in the process list...
This was the USB script:
Code:
xx=`ps | grep '{.rc_usb}' | grep -v grep | wc -l`
if [[ "$xx" > "1" ]] ; then
logger "changmw: .rc_usb already started($xx)"
exit 1
fi
My bad, I needed to use "-gt" instead of ">". Anyway, I now use a pid file to do the instance check. Counting the number of "rc_usb" in the process list to detect multiple instances of rc_usb isn't reliable....
Code: pidfile=/tmp/var/run/rc_usb.pid
if [[ -f $pidfile ]] ; then
logger "changmw: .rc_usb already started"
exit 1
fi
touch $pidfile
....
rm -f $pidfile
logger "$i: changmw exiting .rc_usb
It would be great if DD-WRT's Busybox could enable the "flock" command. Then we could use file locking to avoid multiple instancecs of a certain process.
_________________ Router: Asus RT-N18U (rev. A1)
Drink, Blink, Stretch! Live long and prosper! May the Force and farces be with you!
Facebook: https://www.facebook.com/changmanwai
Website: https://sites.google.com/site/changmw
SETI@Home profile: http://setiathome.berkeley.edu/view_profile.php?userid=211832
GitHub: https://github.com/changmw/changmw
Back to top