diff options
author | Roy Marples <roy@marples.name> | 2008-03-02 21:13:21 +0000 |
---|---|---|
committer | Roy Marples <roy@marples.name> | 2008-03-02 21:13:21 +0000 |
commit | a12dbdc6c93a7d63591610378e3e570b7c7d2143 (patch) | |
tree | 22cd968f4bb32bedf82e091c9ffee798d247c51e /init.d/fsck.in | |
parent | 7c092fbc7904be18510eed08c72cbad974db8adc (diff) |
Don't check for root in prefix.
Diffstat (limited to 'init.d/fsck.in')
-rw-r--r-- | init.d/fsck.in | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/init.d/fsck.in b/init.d/fsck.in new file mode 100644 index 00000000..f34a8522 --- /dev/null +++ b/init.d/fsck.in @@ -0,0 +1,76 @@ +#!/sbin/runscript +# Copyright 2007-2008 Roy Marples <roy@marples.name> +# All rights reserved. Released under the 2-clause BSD license. + +description="Check and repair filesystems according to /etc/fstab" +_ISF=" +" + +depend() +{ + after clock modules + keyword nojail noprefix notimeout +} + +_abort() { + rc-abort + return 1 +} + +# We should only reboot when first booting +_reboot() { + if [ "${RC_SOFTLEVEL}" = "${RC_BOOTLEVEL}" ]; then + reboot "$@" + _abort || return 1 + fi +} + +start() +{ + local reboot_opts= fsck_opts= p= + + ebegin "Checking local filesystems" + for p in ${fsck_passno}; do + local IFS="${_IFS}" + case "${p}" in + [0-9]*) p="=${p}";; + esac + set -- "$@" "$(fstabinfo --passno "${p}")" + unset IFS + done + + if [ "${RC_UNAME}" = "Linux" ]; then + fsck_opts="-C0 -T" + if [ -z "${fsck_passno}" ]; then + fsck_args=${fsck_args--A -p} + if echo 2>/dev/null >/.test.$$; then + rm -f /.test.$$ + fsck_opts="${fsck_args} -R" + fi + fi + reboot_opts="-f" + fi + + trap : QUIT + fsck ${fsck_args--p} ${fsck_opts} "$@" + case $? in + 0) eend 0; return 0;; + 1) ewend 1 "Filesystems repaired"; return 0;; + 2|3|4) ewend 1 "Filesystems repaired, but reboot needed" + _reboot ${reboot_opts} || return 1;; + 8) ewend 1 "Operational error"; return 0;; + 12) ewend 1 "fsck interupted"; return 1;; + *) eend 2 "Filesystems couldn't be fixed" + _abort || return 1;; + esac +} + +stop() +{ + # Fake function so we always shutdown correctly. + _abort() { return 0; } + _reboot() { return 0; } + + yesno "${fsck_shutdown}" && start + return 0 +} |