#
# $Header: rc,v 4.300 91/06/08 23:35:28 root Rel41 $ SONY;
#

HOME=/
PATH=/sbin:/etc:/bin:/usr/etc:/usr/bin:/usr/ucb:/usr/sony/bin

. /etc/rc.custom

if [ -r /fastboot ]
then
	rm -f /fastboot
			echo Fast boot ... skipping disk checks	> /dev/console
elif [ $1x = autobootx ]
then
			echo Automatic reboot in progress...	> /dev/console
	date							> /dev/console
	fsck -p							> /dev/console
	case $? in
	0)
		date						> /dev/console
		;;
	2)
		exit 1
		;;
	4)
		reboot -n
		;;
	8)
		echo "Automatic reboot failed... help!"		> /dev/console
		exit 1
		;;
	12)
		echo "Reboot interrupted"			> /dev/console
		exit 1
		;;
	*)
		echo "Unknown error in reboot"			> /dev/console
		exit 1
		;;
	esac
else
	date							> /dev/console
fi

# use 'smount' instead of 'mount' before networks and name servers work well.
umount -a
> /etc/mtab
smount -f /
smount -at 4.3						   2>&1	> /dev/console

hostname $HOSTNAME
ifconfig lo0 localhost
ifconfig lo0							> /dev/console

			echo 'starting port mapper'		> /dev/console
portmap

case "$NET" in
off)			echo 'starting system logger'		> /dev/console
	rm -f /dev/log
	/etc/syslogd
	;;
*)
	sh /etc/rc.net
	;;
esac

route add $HOSTNAME localhost 0

# attempt to rationally recover the passwd file if needed
if [ -s /etc/ptmp ]
then
	if [ -s /etc/passwd ]
	then
		ls -l /etc/passwd /etc/ptmp			> /dev/console
		rm -f /etc/ptmp		# should really remove the shorter
	else
		echo 'passwd file recovered from ptmp'		> /dev/console
		mv /etc/ptmp /etc/passwd
		rm -f /etc/passwd.dir /etc/passwd.pag
		mkpasswd /etc/passwd
	fi
elif [ -r /etc/ptmp ]
then
	echo 'removing passwd lock file'			> /dev/console
	rm -f /etc/ptmp
fi

#			echo -n 'checking for core dump... '	> /dev/console
#savecore /a/crash					   2>&1	> /dev/console
#			echo ''					> /dev/console

swapon -a						   2>&1	> /dev/console

			echo -n 'checking quotas:'		> /dev/console
quotacheck -a -p					   2>&1	> /dev/console
			echo ' done.'				> /dev/console
quotaon -a

ps U							   2>&1	> /dev/console
rm -f /etc/nologin
rm -f /usr/spool/uucp/LCK/LCK.*
chmod 666 /dev/tty[p-z]*
chzone localtime

strings /vmunix | grep NEWS-OS | grep -v '@(#)' > /tmp/t1
tail +2 /etc/motd >>/tmp/t1
mv /tmp/t1 /etc/motd
chmod 666 /etc/motd

			echo preserving editor files 		> /dev/console
(cd /tmp; /usr/lib/ex3.7preserve -a)
			echo clearing /tmp 			> /dev/console
(cd /tmp; find . ! -name . ! -name lost+found ! -name quotas -exec rm -r {} \; )

			echo -n standard daemons:		> /dev/console
/etc/update;				echo -n ' update'	> /dev/console
/etc/cron;				echo -n ' cron'		> /dev/console
/etc/accton /usr/adm/acct;		echo -n ' accounting'	> /dev/console
/etc/inetd;				echo -n ' inetd'	> /dev/console
			echo '.'				> /dev/console

sh /etc/rc.local

exit 0
