#!/bin/sh
# Taken in part from Miquel van Smoorenburg's bcheckrc.
# rc.4 : fsck 

PATH=/usr/bin:/bin:/sbin

# mount /usr
. /etc/color
setup usr

if [ $? -ne 0 ] ; then  # user not want /usr
    exec init -t 2 1  # go limbo
fi

umount /proc
mount -n  -o remount,ro /

#echo "Activate swap partition"
#swapon -a

if [ "`mount|fgrep /startup`" ]
then
	echo -e "\nChecking startup filesystem.\n"
	mount -o remount,ro /startup
	fsck -V -a /dev/startup
	mount -o remount,rw /startup
	sleep 1
fi

	echo -e "\nChecking root filesystems.\n"
	fsck -V -a /
	sleep 1
	rc=$?

	# A return of 2 or higher means there were serious problems.
	[ $rc -gt 1 ] && init 1

# Remount the root filesystem read-write.
echo "Remounting root filesystem in read-write mode."

mount -n -o remount,rw /

# Check filesystems

	echo -e "\nChecking filesystems.\n"
	fsck -R -A -V -a
	sleep 1

	# A return of 2 or higher means there were serious problems.
	[ $? -gt 1 ] && init 1

# Mount all other filesystems (except for NFS).

echo "Mounting local filesystems (if any)."
mount -a -t nonfs

# Clean out /etc.
rm -f /etc/mtab~ 
>/var/run/utmp

echo
exec init -t 1 5
