rc revision 1.13
11.1Scgd#	@(#)rc	5.27 (Berkeley) 6/5/91
21.1Scgd
31.1Scgd# System startup script run by init on autoboot
41.1Scgd# or after single-user.
51.1Scgd# Output and error are redirected to console by init,
61.1Scgd# and the console is the controlling terminal.
71.1Scgd
81.1Scgdstty status '^T'
91.1Scgd
101.1Scgd# Set shell to ignore SIGINT (2), but not children;
111.1Scgd# shell catches SIGQUIT (3) and returns to single user after fsck.
121.1Scgdtrap : 2
131.1Scgdtrap : 3	# shouldn't be needed
141.1Scgd
151.1ScgdHOME=/; export HOME
161.1ScgdPATH=/sbin:/bin:/usr/sbin:/usr/bin
171.1Scgdexport PATH
181.1Scgd
191.1Scgdif [ -r /fastboot ]
201.1Scgdthen
211.1Scgd	echo Fast boot ... skipping disk checks
221.1Scgdelif [ $1x = autobootx ]
231.1Scgdthen
241.1Scgd	echo Automatic reboot in progress...
251.1Scgd	fsck -p
261.1Scgd	case $? in
271.1Scgd	0)
281.1Scgd		;;
291.1Scgd	2)
301.1Scgd		exit 1
311.1Scgd		;;
321.1Scgd	4)
331.1Scgd		reboot
341.1Scgd		echo "reboot failed... help!"
351.1Scgd		exit 1
361.1Scgd		;;
371.1Scgd	8)
381.1Scgd		echo "Automatic file system check failed... help!"
391.1Scgd		exit 1
401.1Scgd		;;
411.1Scgd	12)
421.1Scgd		echo "Reboot interrupted"
431.1Scgd		exit 1
441.1Scgd		;;
451.1Scgd	130)
461.1Scgd		# interrupt before catcher installed
471.1Scgd		exit 1
481.1Scgd		;;
491.1Scgd	*)
501.1Scgd		echo "Unknown error in reboot"
511.1Scgd		exit 1
521.1Scgd		;;
531.1Scgd	esac
541.1Scgdfi
551.1Scgd
561.1Scgdtrap "echo 'Reboot interrupted'; exit 1" 3
571.1Scgd
581.1Scgdswapon -a
591.1Scgd
601.1Scgdumount -a >/dev/null 2>&1
611.1Scgdmount -a -t nonfs
621.1Scgdrm -f /fastboot		# XXX (root now writeable)
631.1Scgd
641.1Scgd# set hostname, turn on network
651.1Scgdecho 'starting network'
661.1Scgd. /etc/netstart
671.1Scgd
681.1Scgdmount -a -t nfs >/dev/null 2>&1 &	# XXX shouldn't need background
691.1Scgd
701.1Scgd# clean up left-over files
711.1Scgdrm -f /etc/nologin
721.1Scgdrm -f /var/spool/uucp/LCK.*
731.1Scgdrm -f /var/spool/uucp/STST/*
741.1Scgd(cd /var/run && { rm -rf -- *; cp /dev/null utmp; chmod 644 utmp; })
751.1Scgd
761.1Scgdecho -n 'starting system logger'
771.1Scgdrm -f /dev/log
781.1Scgdsyslogd
791.1Scgd
801.1Scgd# $timedflags is imported from /etc/netstart;
811.1Scgd# if $timedflags == NO, timed isn't run.
821.1Scgdif [ X${timedflags} != X"NO" ]; then
831.1Scgd	echo -n ', time daemon'; timed $timedflags
841.1Scgdfi
851.1Scgdecho '.'
861.1Scgd
871.1Scgd# /var/crash should be a directory or a symbolic link
881.1Scgd# to the crash directory if core dumps are to be saved.
891.1Scgdif [ -d /var/crash ]; then
901.1Scgd	echo checking for core dump...
911.1Scgd	savecore /var/crash
921.1Scgdfi
931.1Scgd
941.1Scgd#				echo -n 'checking quotas:'
951.1Scgd#quotacheck -a
961.1Scgd#				echo ' done.'
971.1Scgd#quotaon -a
981.1Scgd
991.1Scgd# build ps databases
1001.2Scgdecho 'building databases...'
1011.11Scgdkvm_mkdb /netbsd
1021.1Scgddev_mkdb
1031.1Scgd
1041.1Scgdchmod 666 /dev/tty[pqrs]*
1051.1Scgd
1061.1Scgd# check the password temp/lock file
1071.1Scgdif [ -f /etc/ptmp ]
1081.1Scgdthen
1091.1Scgd	logger -s -p auth.err \
1101.1Scgd	'password file may be incorrect -- /etc/ptmp exists'
1111.1Scgdfi
1121.1Scgd
1131.1Scgdecho preserving editor files
1141.1Scgd(cd /var/tmp && /usr/libexec/elvispreserve "-the system rebooted" elvis* &&
1151.1Scgd     rm -f elvis[0-9a-f][0-9a-f][0-9a-f][0-9a-f]* \
1161.1Scgd	 elvis_[0-9a-f][0-9a-f][0-9a-f][0-9a-f]*)
1171.1Scgd
1181.1Scgdecho clearing /tmp
1191.1Scgd
1201.1Scgd# prune quickly with one rm, then use find to clean up /tmp/[lq]*
1211.1Scgd# (not needed with mfs /tmp, but doesn't hurt there...)
1221.1Scgd(cd /tmp && rm -rf [a-km-pr-zA-Z]* &&
1231.13Scgd    find . ! -name . ! -name lost+found ! -name quotas \
1241.13Scgd	-exec rm -rf -- {} \; -type d -prune)
1251.1Scgd
1261.12Scgdif [ -d /var/account ]; then
1271.12Scgd	echo 'turning on accounting'
1281.12Scgd	accountant
1291.12Scgd	accton
1301.12Scgdfi
1311.1Scgd
1321.1Scgdecho -n standard daemons:
1331.1Scgdecho -n ' update';		update
1341.1Scgdecho -n ' crond';		/usr/libexec/crond
1351.1Scgdecho '.'
1361.1Scgd
1371.1Scgdecho -n starting network daemons:
1381.1Scgd
1391.1Scgd# $gated and $routedflags are imported from /etc/netstart.
1401.1Scgd# If $gated == YES, gated is used; otherwise routed.
1411.1Scgd# If $routedflags == NO, routed isn't run.
1421.1Scgdif [ X${gated} = X"YES" -a -r /etc/gated.conf ]; then
1431.1Scgd	echo -n ' gated';	gated $gatedflags
1441.1Scgdelif [ X${routedflags} != X"NO" ]; then
1451.1Scgd	echo -n ' routed';	routed $routedflags
1461.1Scgdfi
1471.1Scgd
1481.1Scgdif [ X${name_server} = X"YES" -a -r /etc/named.boot ]; then
1491.1Scgd	echo -n ' named';		named
1501.1Scgdfi
1511.1Scgd
1521.1Scgd# $rwhod is imported from /etc/netstart;
1531.2Scgd# if $rwhod == YES, rwhod is run.
1541.5Scgdif [ X${rwhod} = X"YES" ]; then
1551.1Scgd	echo -n ' rwhod';	rwhod
1561.1Scgdfi
1571.1Scgd
1581.1Scgdecho -n ' printer';		lpd
1591.1Scgd
1601.8Scgdecho -n ' portmap';		portmap
1611.7Sglass
1621.9Sglass# if $nfs_server == YES, the machine is setup for being an nfs server
1631.1Scgdif [ X${nfs_server} = X"YES" -a -r /etc/exports ]; then
1641.7Sglass	rm -f /var/db/mountdtab	
1651.1Scgd	echo -n ' mountd';		mountd
1661.1Scgd	echo -n ' nfsd';		nfsd -u 0,0,4 -t 0,0
1671.9Sglassfi
1681.9Sglass
1691.9Sglass# if $nfs_client == YES, the machine is setup for being an nfs client
1701.9Sglassif [ X${nfs_client} = X"YES" ]; then
1711.1Scgd	echo -n ' nfsiod';		nfsiod 4
1721.1Scgdfi
1731.6Scgd
1741.6Scgd# $rwalld is imported from /etc/netstart;
1751.6Scgd# if $rwalld == YES, rwalld is run.
1761.6Scgdif [ X${rwalld} = X"YES" ]; then
1771.6Scgd	echo -n ' rwalld';	rwalld
1781.6Scgdfi
1791.1Scgd
1801.1Scgdecho -n ' sendmail';		sendmail -bd -q30m
1811.1Scgdecho -n ' inetd';		inetd
1821.1Scgdecho '.'
1831.1Scgd
1841.1Scgdsh /etc/rc.local
1851.1Scgd
1861.1Scgddate
1871.1Scgd
1881.1Scgdexit 0
189