From 27d4e2b83f9955b4cc6e941f589bd4a6db99bcc1 Mon Sep 17 00:00:00 2001 From: Davin McCall Date: Wed, 21 Sep 2016 08:23:30 +0100 Subject: [PATCH] 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. --- doc/linux/services/rootfscheck | 2 +- doc/linux/services/rootfscheck.sh | 20 +++++++++++++++----- 2 files changed, 16 insertions(+), 6 deletions(-) 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; -- 2.25.1