#	ATT:#ident	"initpkg:init.d/firstcheck	1.1"	
	
#ident	"@(#)initpkg/init.d:firstcheck	25.1"

#	Perform the "never have been run before" checks.

if [ -f /etc/init.d/.firstchecklck ]
then
	exit
fi

set `who -r`
if [ $9 != "S" ]
then
	exit
fi

echo "
This machine has not been used in multi-user mode yet.  If all the file
systems have not been checked with fsck, they should be.  Do you want to
check the file systems ("\'"y"\'" or "\'"n"\'") ? \c"

while :; do
	read ans
	if [ "$ans" = "y" -o "$ans" = "n" ]
	then
		break
	fi
	echo \'"y"\'" or "\'"n"\'" ? \c"
done

if [ "$ans" = "y" ]
then
	echo '
If the root file system was modified, fsck will print the message,
"***** BOOT /syst (NO SYNC!) *****".  The machine should be reset
without further keyboard input.'
	sleep 5
	echo 'Checking file systems:'
	sync
	a=`/etc/devnm / | /bin/sed 's/ .*//'`
	b=`/bin/cat /etc/checklist | /bin/sed \
		-e 's/#.*//' \
		-e 's/^ *//' \
		-e 's/^	*//' \
		-e 's/ .*//' \
		-e 's/	.*//' |/bin/grep -v $a`
	# $a and $b exist to make sure we don't fsck root twice
	/etc/fsck -y -D $a $b
fi

/etc/init.d/acdbsetup
/etc/init.d/setup
echo "firstcheck completed" > /etc/init.d/.firstchecklck
