aboutsummaryrefslogtreecommitdiff
path: root/functions
diff options
context:
space:
mode:
authorKurt J. Bosch <kjb-temp-2009@alpenjodel.de>2011-06-22 12:07:43 +0200
committerTom Gundersen <teg@jklm.no>2011-06-22 23:17:01 +0200
commit495832e09c060ce3327cd19c1ddc2160182e82f8 (patch)
tree2a6a6e69775584005bbccefef63bd5ba14260d02 /functions
parent5e4b8e09b2027ec58a089becdc156d6efb5484ed (diff)
downloadinitscripts-495832e09c060ce3327cd19c1ddc2160182e82f8.tar.xz
Move fsck stuff into functions to allow custom overrides (FS#18736)
Diffstat (limited to 'functions')
-rw-r--r--functions58
1 files changed, 58 insertions, 0 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 #
###############################