2008-01-31 21:40:18 +05:30
|
|
|
#!/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"
|
|
|
|
|
|
|
|
depend()
|
|
|
|
{
|
|
|
|
after clock modules
|
2008-02-19 19:45:53 +05:30
|
|
|
keywords nojail notimeout
|
2008-01-31 21:40:18 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
start()
|
|
|
|
{
|
2008-02-01 16:18:21 +05:30
|
|
|
local reboot_opts= fsck_opts=
|
|
|
|
|
2008-01-31 21:40:18 +05:30
|
|
|
if [ "${RC_UNAME}" = "Linux" ]; then
|
2008-02-01 16:18:21 +05:30
|
|
|
fsck_opts="-A -C0 -T"
|
2008-01-31 21:40:18 +05:30
|
|
|
if echo 2>/dev/null >/.test.$$; then
|
|
|
|
rm -f /.test.$$
|
2008-02-01 16:18:21 +05:30
|
|
|
fsck_opts="${fsck_opts} -R"
|
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
|
|
|
|
|
|
|
|
ebegin "Checking local filesystems"
|
2008-02-01 16:18:21 +05:30
|
|
|
trap : QUIT
|
|
|
|
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"
|
|
|
|
reboot ${reboot_opts}; exec rc-abort; return 1;;
|
|
|
|
8) ewend 1 "Operational error"; return 0;;
|
|
|
|
12) ewend 1 "fsck interupted"; return 1;;
|
|
|
|
*) eend 2 "Filesystems couldn't be fixed"
|
|
|
|
exec rc-abort; return 1;;
|
2008-01-31 21:40:18 +05:30
|
|
|
esac
|
|
|
|
}
|
2008-01-31 22:42:54 +05:30
|
|
|
|
|
|
|
stop()
|
|
|
|
{
|
|
|
|
yesno "${fsck_shutdown}" && start
|
|
|
|
return 0
|
|
|
|
}
|