vp-build/templates/initscripts/files/rc.d/checkfs
Juan RP ed07259681 Added initscripts-2009.01 template.
This package contains all files required for booting the lsXL
linux system built through xbps.

Currently it uses the NetBSD rc.d(8) system, sysvinit and
modified BSD style scripts modified from Arch linux.

--HG--
extra : convert_revision : 4584be26dd672ba33f9b1d76534a22d4715664ea
2009-03-06 05:17:46 +01:00

67 lines
1.9 KiB
Bash
Executable File

#!/bin/sh
#
# PROVIDE: checkfs
# REQUIRE: SERVERS
# BEFORE: NETWORKING
$_rc_subr_loaded . /etc/rc.subr
name="checkfs"
start_cmd="checkfs_start"
stop_cmd=":"
NETFS="nonfs,nonfs4,nosmbfs,nocifs,nocodafs,noncpfs,nosysfs,noshfs,nofuse,nofuseblk"
checkfs_start()
{
echo -n "=> Mounting root read-only... "
mount -n -o remount,ro /
show_rval
FORCEFSCK=
[ -f /forcefsck ] && FORCEFSCK="-- -f"
echo -n "=> Checking filesystems... "
if grep -qw quiet /proc/cmdline; then
fsck -A -T -C -a -t $NETFS $FORCEFSCK >/dev/null 2>&1
else
fsck -A -T -C -a -t $NETFS $FORCEFSCK 2>/dev/null
fi
fsckret=$?
if [ ${fsckret} -gt 1 ]; then
echo "failed!"
if [ $((${fsckret}&2)) -eq 2 ]; then
echo
echo "********************** REBOOT REQUIRED *********************"
echo "* *"
echo "* The system will be rebooted automatically in 15 seconds. *"
echo "* *"
echo "************************************************************"
echo
sleep 15
else
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
fi
echo "Automatic reboot in progress..."
umount -a
mount -n -o remount,ro /
reboot -f
exit 0
fi
show_rval
}
load_rc_config $name
run_rc_command "$1"