From: Davin McCall Date: Wed, 21 Sep 2016 07:23:30 +0000 (+0100) Subject: rootfscheck service: use the passed-from-parent control socket file descriptor X-Git-Tag: v0.04~4 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=27d4e2b83f9955b4cc6e941f589bd4a6db99bcc1;p=oweals%2Fdinit.git rootfscheck service: use the passed-from-parent control socket file descriptor to issue reboot commands (--use-passed-cfd option to reboot). This may be necessary since the control socket may not have been created yet, due to the root filesystem being read-only at this point. --- diff --git a/doc/linux/services/rootfscheck b/doc/linux/services/rootfscheck index 83d0bca..236cc1f 100644 --- a/doc/linux/services/rootfscheck +++ b/doc/linux/services/rootfscheck @@ -3,7 +3,7 @@ type = scripted command = /etc/dinit.d/rootfscheck.sh start restart = false -options = runs-on-console +options = runs-on-console pass-cs-fd depends-on = early-filesystems depends-on = udevd diff --git a/doc/linux/services/rootfscheck.sh b/doc/linux/services/rootfscheck.sh index f67db80..8a19384 100755 --- a/doc/linux/services/rootfscheck.sh +++ b/doc/linux/services/rootfscheck.sh @@ -2,21 +2,31 @@ export PATH=/usr/bin:/usr/sbin:/bin:/sbin if [ "$1" != "stop" ]; then - + + ROOTDEV=`findmnt -o SOURCE -n -M /` + echo "Checking root file system..." if [ -x /sbin/fsck ]; then - /sbin/fsck -C -a / + /sbin/fsck -C -a "$ROOTDEV" fsckresult=$? - if [ $(($fsckresult & 2)) -eq 2 ]; then + if [ $((fsckresult & 4)) -eq 4 ]; then echo "***********************" echo "WARNING WARNING WARNING" echo "***********************" - echo "root file system has problems: rebooting..." + echo "The root file system has problems which require user attention." + echo "A maintennance shell will now be started; system will then be rebooted." + /sbin/sulogin + /sbin/reboot --system -r + elif [ $(($fsckresult & 2)) -eq 2 ]; then + echo "***********************" + echo "WARNING WARNING WARNING" + echo "***********************" + echo "The root file system had problems (now repaired): rebooting..." sleep 10 /sbin/reboot --system -r fi else echo "WARNING - Could not find /sbin/fsck" fi - + fi;