From 495832e09c060ce3327cd19c1ddc2160182e82f8 Mon Sep 17 00:00:00 2001 From: "Kurt J. Bosch" Date: Wed, 22 Jun 2011 12:07:43 +0200 Subject: Move fsck stuff into functions to allow custom overrides (FS#18736) --- functions | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ rc.sysinit | 51 ++------------------------------------------------- 2 files changed, 60 insertions(+), 49 deletions(-) diff --git a/functions b/functions index d0747ba..a5d87dc 100644 --- a/functions +++ b/functions @@ -316,6 +316,64 @@ read_crypttab() { return $failed } +fsck_all() { + stat_busy "Checking Filesystems" + FSCK_OUT=/dev/stdout + FSCK_ERR=/dev/stdout + FSCK_FD= + FORCEFSCK= + [[ -f /forcefsck ]] && FORCEFSCK="-- -f" + local cmdarg + for cmdarg in $(< /proc/cmdline); do + [[ "$cmdarg" == forcefsck ]] && FORCEFSCK="-- -f" && break + done + run_hook sysinit_prefsck + fsck -A -T -C$FSCK_FD -a -t "$NETFS,noopts=_netdev" $FORCEFSCK >$FSCK_OUT 2>$FSCK_ERR + local fsckret=$? + if ((fsckret > 1)); then + stat_fail + else + stat_done + fi + run_hook sysinit_postfsck + return $fsckret +} + +fsck_reboot() { + # $1 = exit code returned by fsck + local fsckret=$1 + if (( ( fsckret & 2) == 2)); then + echo + echo "********************** REBOOT REQUIRED *********************" + echo "* *" + echo "* The system will be rebooted automatically in 15 seconds. *" + echo "* *" + echo "************************************************************" + echo + sleep 15 + elif ((fsckret > 1 && fsckret != 32)); then + echo + echo "***************** FILESYSTEM CHECK FAILED ****************" + echo "* *" + echo "* Please repair manually and reboot. Note that the root *" + echo "* file system is currently mounted read-only. To remount *" + echo "* it read-write type: mount -n -o remount,rw / *" + echo "* When you exit the maintenance shell the system will *" + echo "* reboot automatically. *" + echo "* *" + echo "************************************************************" + echo + sulogin -p + else + return + fi + echo "Automatic reboot in progress..." + umount -a + mount -n -o remount,ro / + reboot -f + exit 0 +} + ############################### # Custom hooks in initscripts # ############################### diff --git a/rc.sysinit b/rc.sysinit index b5d63ea..e08adc6 100755 --- a/rc.sysinit +++ b/rc.sysinit @@ -214,55 +214,8 @@ fi NETFS="nonfs,nonfs4,nosmbfs,nocifs,nocodafs,noncpfs,nosysfs,noshfs,nofuse,nofuseblk,noglusterfs,nodavfs" if [[ -x $(type -P fsck) ]]; then - stat_busy "Checking Filesystems" - fsck_reboot() { - echo "Automatic reboot in progress..." - umount -a - mount -n -o remount,ro / - reboot -f - exit 0 - } - FSCK_OUT=/dev/stdout - FSCK_ERR=/dev/stdout - FSCK_FD= - FORCEFSCK= - [[ -f /forcefsck ]] && FORCEFSCK="-- -f" - for cmdarg in $(< /proc/cmdline); do - [[ "$cmdarg" == forcefsck ]] && FORCEFSCK="-- -f" && break - done - run_hook sysinit_prefsck - fsck -A -T -C$FSCK_FD -a -t "$NETFS,noopts=_netdev" $FORCEFSCK >$FSCK_OUT 2>$FSCK_ERR - fsckret=$? - if ((fsckret > 1)); then - stat_fail - fi - run_hook sysinit_postfsck - if (( ( fsckret & 2) == 2)); then - echo - echo "********************** REBOOT REQUIRED *********************" - echo "* *" - echo "* The system will be rebooted automatically in 15 seconds. *" - echo "* *" - echo "************************************************************" - echo - sleep 15 - fsck_reboot - elif ((fsckret > 1 && fsckret != 32)); then - echo - echo "***************** FILESYSTEM CHECK FAILED ****************" - echo "* *" - echo "* Please repair manually and reboot. Note that the root *" - echo "* file system is currently mounted read-only. To remount *" - echo "* it read-write type: mount -n -o remount,rw / *" - echo "* When you exit the maintenance shell the system will *" - echo "* reboot automatically. *" - echo "* *" - echo "************************************************************" - echo - sulogin -p - fsck_reboot - fi - stat_done + fsck_all + fsck_reboot $? fi stat_busy "Mounting Local Filesystems" -- cgit v1.2.3