2008-03-03 02:44:01 +05:30
|
|
|
#!@PREFIX@/sbin/runscript
|
2008-01-31 21:40:18 +05:30
|
|
|
# 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"
|
2008-05-26 04:00:31 +05:30
|
|
|
_IFS="
|
2008-02-20 06:03:38 +05:30
|
|
|
"
|
2008-01-31 21:40:18 +05:30
|
|
|
|
|
|
|
depend()
|
|
|
|
{
|
2008-10-10 14:07:21 +05:30
|
|
|
use dev clock modules
|
2008-03-03 22:49:56 +05:30
|
|
|
keyword nojail noopenvz noprefix notimeout novserver
|
2008-01-31 21:40:18 +05:30
|
|
|
}
|
|
|
|
|
2008-02-29 00:13:47 +05:30
|
|
|
_abort() {
|
2008-02-29 02:44:59 +05:30
|
|
|
rc-abort
|
|
|
|
return 1
|
2008-02-29 00:13:47 +05:30
|
|
|
}
|
|
|
|
|
2008-02-29 00:43:36 +05:30
|
|
|
# We should only reboot when first booting
|
|
|
|
_reboot() {
|
2008-03-19 22:41:50 +05:30
|
|
|
if [ "${RC_RUNLEVEL}" = "${RC_BOOTLEVEL}" ]; then
|
2008-02-29 02:44:59 +05:30
|
|
|
reboot "$@"
|
|
|
|
_abort || return 1
|
2008-02-29 00:43:36 +05:30
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2008-01-31 21:40:18 +05:30
|
|
|
start()
|
|
|
|
{
|
2008-04-17 05:39:34 +05:30
|
|
|
local reboot_opts= fsck_opts= p= check_extra=
|
2008-02-20 06:03:38 +05:30
|
|
|
|
2008-04-09 05:51:49 +05:30
|
|
|
if [ -e /fastboot ]; then
|
|
|
|
ewarn "Skipping fsck due to /fastboot"
|
|
|
|
return 0
|
|
|
|
fi
|
2008-09-22 18:02:11 +05:30
|
|
|
if [ -e /forcefsck ] || get_bootparam forcefsck; then
|
2008-04-17 05:39:34 +05:30
|
|
|
fsck_opts="${fsck_opts} -f"
|
|
|
|
check_extra="(check forced)"
|
|
|
|
fi
|
2008-04-09 05:51:49 +05:30
|
|
|
|
2008-04-22 19:16:53 +05:30
|
|
|
if [ -n "${fsck_passno}" ]; then
|
|
|
|
check_extra="[passno ${fsck_passno}] ${check_extra}"
|
|
|
|
fi
|
2008-04-17 05:39:34 +05:30
|
|
|
ebegin "Checking local filesystems ${check_extra}"
|
2008-02-20 06:03:38 +05:30
|
|
|
for p in ${fsck_passno}; do
|
|
|
|
local IFS="${_IFS}"
|
|
|
|
case "${p}" in
|
|
|
|
[0-9]*) p="=${p}";;
|
|
|
|
esac
|
2008-05-26 04:00:31 +05:30
|
|
|
set -- "$@" $(fstabinfo --passno "${p}")
|
2008-02-20 06:03:38 +05:30
|
|
|
unset IFS
|
|
|
|
done
|
2008-02-01 16:18:21 +05:30
|
|
|
|
2008-01-31 21:40:18 +05:30
|
|
|
if [ "${RC_UNAME}" = "Linux" ]; then
|
2008-04-17 05:39:34 +05:30
|
|
|
fsck_opts="${fsck_opts} -C0 -T"
|
2008-02-20 06:03:38 +05:30
|
|
|
if [ -z "${fsck_passno}" ]; then
|
|
|
|
fsck_args=${fsck_args--A -p}
|
|
|
|
if echo 2>/dev/null >/.test.$$; then
|
|
|
|
rm -f /.test.$$
|
2008-03-04 22:28:26 +05:30
|
|
|
fsck_opts="${fsck_opts} -R"
|
2008-02-20 06:03:38 +05:30
|
|
|
fi
|
2008-01-31 21:40:18 +05:30
|
|
|
fi
|
2008-02-01 16:18:21 +05:30
|
|
|
reboot_opts="-f"
|
2008-01-31 21:40:18 +05:30
|
|
|
fi
|
|
|
|
|
2008-05-27 15:55:29 +05:30
|
|
|
trap : INT QUIT
|
2008-02-20 06:03:38 +05:30
|
|
|
fsck ${fsck_args--p} ${fsck_opts} "$@"
|
2008-01-31 21:40:18 +05:30
|
|
|
case $? in
|
2008-02-01 16:18:21 +05:30
|
|
|
0) eend 0; return 0;;
|
|
|
|
1) ewend 1 "Filesystems repaired"; return 0;;
|
|
|
|
2|3|4) ewend 1 "Filesystems repaired, but reboot needed"
|
2008-02-29 00:43:36 +05:30
|
|
|
_reboot ${reboot_opts} || return 1;;
|
2008-02-01 16:18:21 +05:30
|
|
|
8) ewend 1 "Operational error"; return 0;;
|
|
|
|
12) ewend 1 "fsck interupted"; return 1;;
|
|
|
|
*) eend 2 "Filesystems couldn't be fixed"
|
2008-02-29 00:13:47 +05:30
|
|
|
_abort || return 1;;
|
2008-01-31 21:40:18 +05:30
|
|
|
esac
|
|
|
|
}
|
2008-01-31 22:42:54 +05:30
|
|
|
|
|
|
|
stop()
|
|
|
|
{
|
2008-02-29 00:43:36 +05:30
|
|
|
# Fake function so we always shutdown correctly.
|
|
|
|
_abort() { return 0; }
|
|
|
|
_reboot() { return 0; }
|
2008-02-29 00:13:47 +05:30
|
|
|
|
2008-01-31 22:42:54 +05:30
|
|
|
yesno "${fsck_shutdown}" && start
|
|
|
|
return 0
|
|
|
|
}
|