2.11BSD/src/etc/rc


#
#	@(#)rc	2.1 (2.111BSD) 1996/10/21
#
HOME=/; export HOME
PATH=/bin:/sbin:/usr/sbin:/usr/ucb:/usr/bin; export PATH

# If you have a ram disk configured into your system which is listed in
# /etc/fstab, you'll have to do a mkfs on it here and probably change the
# ownership and modes below after the standard file systems have been
# mounted.
#
RAMSIZE=0
RAMFS=/tmp
RAMOWNER=root
RAMGROUP=wheel
RAMMODE=1777

if [ ${RAMSIZE} != 0 ]
then
	mkfs /dev/ram ${RAMSIZE} 1 2
fi

if [ "$2" = powerfail ]
then
	echo REBOOTING AFTER POWER FAILURE >/dev/console 2>&1
fi
if [ "$1" = fastboot ]
then
	echo ''
	echo Fast boot ... skipping disk checks		>/dev/console 2>&1
elif [ "$1" = autoboot ]
then
	echo Automatic reboot in progress... 		>/dev/console 2>&1
	date						>/dev/console 2>&1
	# this will *only* work if fsck can do your root file system
	# without a temporary file, and if the root file system is
	# checked alone in a pass by itself -- be careful!  This can
	# *seriously* mess you up.
	fsck -p -t /_FSCK_TMP_FILE			>/dev/console 2>&1
	case $? in
	0)
		date					>/dev/console 2>&1
		;;
	2)
		exit 1
		;;
	4)
		reboot -n
		;;
	8)
		echo "Automatic reboot failed... help!"	>/dev/console 2>&1
		exit 1
		;;
	12)
		echo "Reboot interrupted"		>/dev/console 2>&1
		exit 1
		;;
	*)
		echo "Unknown error in reboot"		>/dev/console 2>&1
		exit 1
		;;
	esac
else
	date >/dev/console 2>&1
fi

# attempt to rationally recover the passwd file if needed
if [ -s /etc/ptmp ]
then
 	echo 'password file may be incorrect' > /dev/console
fi

#
# First umount everything in case the system is going back into multiuser
# mode.  If the system is being booted for the first time nothing is mounted
# except the root filesystem and umount ignores attempts to unmount /.
#
umount -a
#
# Now mount everything mentioned in /etc/fstab *except* filesystems with the
# 'na' (noauto) option.
#
mount -a						>/dev/console 2>&1

if [ ${RAMSIZE} != 0 ]
then
	chown ${RAMOWNER}.${RAMGROUP} ${RAMFS}
	chmod ${RAMMODE} ${RAMFS}
fi

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

dev_mkdb

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

# set hostname and INET, turn on network
. /etc/netstart

if [ $INET = YES ]; then
			echo 'starting system logger'	>/dev/console 2>&1
	rm -f /dev/log
	syslogd
fi

# /etc/crash should be a symbolic link to the crash directory
# if core dumps are to be saved.
if [ -d /etc/crash ]; then
	echo		'checking for core dump... '	>/dev/console 2>&1
	savecore /etc/crash			>/dev/console 2>&1
fi

		echo preserving editor files 	>/dev/console 2>&1
		(cd /tmp; /usr/sbin/expreserve -a)
		echo clearing /tmp 		>/dev/console 2>&1
(cd /tmp; find . ! -name . ! -name lost+found ! -name quotas -exec rm -r {} \; )

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

if [ $INET = YES ]; then
		echo -n starting network daemons:	>/dev/console 2>&1

	# $routedflags is imported from /etc/netstart;
	# if $routedflags == NO, routed isn't run.
	if [ "${routedflags-NO}" != NO ]; then
		routed $routedflags; echo -n ' routed' >/dev/console 2>&1
	fi

	# $named is imported from /etc/netstart;
	# if $named is set to something other than NO, named is run.
	if [ "${named-NO}" != NO ]; then
		named;		echo -n ' named'>/dev/console 2>&1
	fi
	/usr/sbin/inetd;		echo -n ' inetd'>/dev/console 2>&1

	# $rwhod is imported from /etc/netstart;
	# if $rwhod is set to something other than NO, rwhod is run.
	if [ "${rwhod}" != NO ]; then
		rwhod;	echo -n ' rwhod'	>/dev/console 2>&1
	fi
	rm -f /dev/printer
	/usr/sbin/lpd;		echo -n ' printer'	>/dev/console 2>&1
				echo '.'		>/dev/console 2>&1
else
	# lpd will run even with out networking.
	echo starting lpd			>/dev/console 2>&1
	/usr/sbin/lpd
fi

/etc/rc.local

date				>/dev/console 2>&1
exit 0