bigeyes0x0
Senior Member
So using @Fitz Mutch bind mount script I modify it a little to this:
with my unmount script being:
I then attach rc in init-start by async polling for ntp updated event.
It works fine from commandline by either calling "reboot" or "service reboot" but does not work correctly from the webui reboot button. Looking at the log I see a difference with how notify_rc reboot is called:
- Calling "service reboot" has it print: rc_service: service 1140:notify_rc reboot
- Using reboot button in webui has it print: rc_service: httpds 1137:notify_rc reboot
IOW webui running inside httpds is actually calling rc directly somehow. I guess this would need firmware modification after all. From the evidences I gathered I believe Fitz Mutch's method to replace reboot/halt binary with script won't work either.
Code:
#!/bin/sh
CMD=$(basename $0)
SELF="/jffs/scripts/rc"
run_unmount () {
for DIR in /tmp/mnt/sd*; do
/jffs/scripts/unmount $DIR
umount $DIR && logger "unmount $DIR" || logger "unable to unmount $DIR"
done
}
case $CMD in
rc)
ATTACHED=0
mount | grep -q /sbin/rc && ATTACHED=1
case $1 in
attach)
if [ $ATTACHED -eq 0 ]; then
mount -o bind $SELF /sbin/rc && logger "rc attached"
else
logger "rc already attached"
fi
;;
detach)
if [ $ATTACHED -eq 1 ]; then
umount /sbin/rc && logger "rc detached"
else
logger "rc already not attached"
fi
;;
*)
logger "rc bad option"
;;
esac
CMDLEVEL=0
;;
reboot|halt)
run_unmount
CMDLEVEL=1
;;
service)
if [ "$1" == "reboot" ]; then
run_unmount
CMDLEVEL=1
else
CMDLEVEL=2
fi
;;
*)
CMDLEVEL=2
;;
esac
if [ $CMDLEVEL -gt 0 ]; then
(
sleep 1
/bin/umount /sbin/rc
"/sbin/$CMD" "$@"
[ $CMDLEVEL -eq 2 ] && mount -o bind $SELF /sbin/rc
)&
fi
with my unmount script being:
Code:
#!/bin/sh
[ -f /opt/etc/init.d/rc.unslung ] && /opt/etc/init.d/rc.unslung stop
fuser -csk $1
rm -f /mnt/usb
sleep 1
I then attach rc in init-start by async polling for ntp updated event.
It works fine from commandline by either calling "reboot" or "service reboot" but does not work correctly from the webui reboot button. Looking at the log I see a difference with how notify_rc reboot is called:
- Calling "service reboot" has it print: rc_service: service 1140:notify_rc reboot
- Using reboot button in webui has it print: rc_service: httpds 1137:notify_rc reboot
IOW webui running inside httpds is actually calling rc directly somehow. I guess this would need firmware modification after all. From the evidences I gathered I believe Fitz Mutch's method to replace reboot/halt binary with script won't work either.