rc revision 1.34
11.26Sderaadt#	@(#)rc	5.27 (Berkeley) 6/5/91
21.34Scgd#	$Id: rc,v 1.34 1994/02/26 03:29:27 cgd Exp $
31.1Scgd
41.1Scgd# System startup script run by init on autoboot
51.1Scgd# or after single-user.
61.1Scgd# Output and error are redirected to console by init,
71.1Scgd# and the console is the controlling terminal.
81.1Scgd
91.1Scgdstty status '^T'
101.1Scgd
111.1Scgd# Set shell to ignore SIGINT (2), but not children;
121.1Scgd# shell catches SIGQUIT (3) and returns to single user after fsck.
131.1Scgdtrap : 2
141.1Scgdtrap : 3	# shouldn't be needed
151.1Scgd
161.1ScgdHOME=/; export HOME
171.1ScgdPATH=/sbin:/bin:/usr/sbin:/usr/bin
181.1Scgdexport PATH
191.1Scgd
201.17Smycroftif [ -e /fastboot ]
211.1Scgdthen
221.1Scgd	echo Fast boot ... skipping disk checks
231.1Scgdelif [ $1x = autobootx ]
241.1Scgdthen
251.1Scgd	echo Automatic reboot in progress...
261.1Scgd	fsck -p
271.1Scgd	case $? in
281.1Scgd	0)
291.1Scgd		;;
301.1Scgd	2)
311.1Scgd		exit 1
321.1Scgd		;;
331.1Scgd	4)
341.1Scgd		reboot
351.1Scgd		echo "reboot failed... help!"
361.1Scgd		exit 1
371.1Scgd		;;
381.1Scgd	8)
391.1Scgd		echo "Automatic file system check failed... help!"
401.1Scgd		exit 1
411.1Scgd		;;
421.1Scgd	12)
431.1Scgd		echo "Reboot interrupted"
441.1Scgd		exit 1
451.1Scgd		;;
461.1Scgd	130)
471.1Scgd		# interrupt before catcher installed
481.1Scgd		exit 1
491.1Scgd		;;
501.1Scgd	*)
511.1Scgd		echo "Unknown error in reboot"
521.1Scgd		exit 1
531.1Scgd		;;
541.1Scgd	esac
551.1Scgdfi
561.1Scgd
571.1Scgdtrap "echo 'Reboot interrupted'; exit 1" 3
581.1Scgd
591.1Scgdswapon -a
601.1Scgd
611.1Scgdumount -a >/dev/null 2>&1
621.1Scgdmount -a -t nonfs
631.1Scgdrm -f /fastboot		# XXX (root now writeable)
641.1Scgd
651.1Scgd# set hostname, turn on network
661.1Scgdecho 'starting network'
671.1Scgd. /etc/netstart
681.1Scgd
691.26Sderaadtmount /usr >/dev/null 2>&1
701.26Sderaadt
711.26Sderaadtecho -n 'starting rpc daemons:'
721.26Sderaadtecho -n ' portmap';		portmap
731.26Sderaadt
741.26Sderaadtif [ -f /usr/sbin/ypbind -a -d /var/yp ]; then
751.26Sderaadt	echo -n ' ypbind';		ypbind
761.26Sderaadtfi
771.26Sderaadt
781.26Sderaadt# $nfs_server is imported from /etc/netstart;
791.26Sderaadt# if $nfs_server == YES, the machine is setup for being an nfs server
801.26Sderaadtif [ X${nfs_server} = X"YES" -a -r /etc/exports ]; then
811.26Sderaadt	rm -f /var/db/mountdtab	
821.26Sderaadt	echo -n ' mountd';		mountd
831.26Sderaadt	echo -n ' nfsd';		nfsd -u 0,0,4 -t 0,0
841.26Sderaadtfi
851.26Sderaadt
861.26Sderaadt# $nfs_client is imported from /etc/netstart;
871.26Sderaadt# if $nfs_client == YES, the machine is setup for being an nfs client
881.26Sderaadtif [ X${nfs_client} = X"YES" ]; then
891.26Sderaadt	echo -n ' nfsiod';		nfsiod 4
901.26Sderaadtfi
911.26Sderaadt
921.27Sderaadtif [ X${amd} = X"YES" ]; then
931.27Sderaadt	echo -n ' amd'
941.27Sderaadt	amd -x error,noinfo,nostats -a /tmp_mnt /home amd.home
951.27Sderaadtfi
961.27Sderaadt
971.26Sderaadtecho '.'
981.27Sderaadtmount -a -t nfs
991.1Scgd
1001.1Scgd# clean up left-over files
1011.1Scgdrm -f /etc/nologin
1021.1Scgdrm -f /var/spool/uucp/LCK.*
1031.1Scgdrm -f /var/spool/uucp/STST/*
1041.1Scgd(cd /var/run && { rm -rf -- *; cp /dev/null utmp; chmod 644 utmp; })
1051.23Smycroft
1061.23Smycroftecho 'runtime link editor directory cache'
1071.23Smycroftrm -f /var/run/ld.so.hints
1081.23Smycroftldconfig
1091.1Scgd
1101.1Scgdecho -n 'starting system logger'
1111.1Scgdrm -f /dev/log
1121.1Scgdsyslogd
1131.1Scgd
1141.19Scgd# $timed_flags is imported from /etc/netstart;
1151.19Scgd# if $timed_flags == NO, timed isn't run.
1161.21Scgdif [ "X${timed_flags}" != X"NO" ]; then
1171.19Scgd	echo -n ', time daemon'; timed $timed_flags
1181.1Scgdfi
1191.1Scgdecho '.'
1201.1Scgd
1211.1Scgd# /var/crash should be a directory or a symbolic link
1221.1Scgd# to the crash directory if core dumps are to be saved.
1231.1Scgdif [ -d /var/crash ]; then
1241.1Scgd	echo checking for core dump...
1251.1Scgd	savecore /var/crash
1261.1Scgdfi
1271.1Scgd
1281.1Scgd#				echo -n 'checking quotas:'
1291.1Scgd#quotacheck -a
1301.1Scgd#				echo ' done.'
1311.1Scgd#quotaon -a
1321.1Scgd
1331.1Scgd# build ps databases
1341.2Scgdecho 'building databases...'
1351.11Scgdkvm_mkdb /netbsd
1361.1Scgddev_mkdb
1371.1Scgd
1381.1Scgdchmod 666 /dev/tty[pqrs]*
1391.1Scgd
1401.1Scgd# check the password temp/lock file
1411.1Scgdif [ -f /etc/ptmp ]
1421.1Scgdthen
1431.1Scgd	logger -s -p auth.err \
1441.1Scgd	'password file may be incorrect -- /etc/ptmp exists'
1451.1Scgdfi
1461.1Scgd
1471.32Smycroftvirecovery=/var/tmp/vi.recover/recover.*
1481.32Smycroftif [ "$virecovery" != "/var/tmp/vi.recover/recover.*" ]; then
1491.32Smycroft	echo preserving editor files
1501.32Smycroft	for i in $virecovery; do
1511.32Smycroft		sendmail -t < $i
1521.32Smycroft	done
1531.32Smycroftfi
1541.1Scgd
1551.1Scgdecho clearing /tmp
1561.1Scgd
1571.1Scgd# prune quickly with one rm, then use find to clean up /tmp/[lq]*
1581.1Scgd# (not needed with mfs /tmp, but doesn't hurt there...)
1591.1Scgd(cd /tmp && rm -rf [a-km-pr-zA-Z]* &&
1601.13Scgd    find . ! -name . ! -name lost+found ! -name quotas \
1611.13Scgd	-exec rm -rf -- {} \; -type d -prune)
1621.1Scgd
1631.34Scgdif [ -f /var/account/acct ]; then
1641.34Scgd	echo 'turning on accounting';	accton /var/account/acct
1651.34Scgdfi
1661.1Scgd
1671.1Scgdecho -n standard daemons:
1681.1Scgdecho -n ' update';		update
1691.31Sjtcecho -n ' cron';		cron
1701.1Scgdecho '.'
1711.1Scgd
1721.1Scgdecho -n starting network daemons:
1731.1Scgd
1741.19Scgd# $gated and $routed_flags are imported from /etc/netstart.
1751.1Scgd# If $gated == YES, gated is used; otherwise routed.
1761.19Scgd# If $routed_flags == NO, routed isn't run.
1771.1Scgdif [ X${gated} = X"YES" -a -r /etc/gated.conf ]; then
1781.19Scgd	echo -n ' gated';	gated $gated_flags
1791.21Scgdelif [ "X${routed_flags}" != X"NO" ]; then
1801.19Scgd	echo -n ' routed';	routed $routed_flags
1811.1Scgdfi
1821.1Scgd
1831.19Scgd# $name_server is imported from /etc/netstart;
1841.19Scgd# if $name_server == YES, named is run.
1851.1Scgdif [ X${name_server} = X"YES" -a -r /etc/named.boot ]; then
1861.1Scgd	echo -n ' named';		named
1871.29Smycroftfi
1881.29Smycroft
1891.1Scgd# $rwhod is imported from /etc/netstart;
1901.2Scgd# if $rwhod == YES, rwhod is run.
1911.5Scgdif [ X${rwhod} = X"YES" ]; then
1921.1Scgd	echo -n ' rwhod';	rwhod
1931.1Scgdfi
1941.1Scgd
1951.1Scgdecho -n ' printer';		lpd
1961.6Scgd
1971.19Scgd# $sendmail_flags is imported from /etc/netstart;
1981.24Scgd# If $sendmail_flags == NO or /etc/sendmail.cf doesn't exist, then
1991.24Scgd# sendmail isn't run.
2001.24Scgdif [ "X${sendmail_flags}" != X"NO" -a -r /etc/sendmail.cf ]; then
2011.19Scgd	echo -n ' sendmail';		sendmail ${sendmail_flags}
2021.19Scgdfi
2031.19Scgd
2041.1Scgdecho -n ' inetd';		inetd
2051.30Smycroft
2061.30Smycroft# $rarpd_flags is importent from /etc/netstart;
2071.30Smycroft# If $rarpd_flags == NO or /etc/ethers doesn't exist, then
2081.30Smycroft# rarpd isn't run.
2091.30Smycroftif [ "X${rarpd_flags}" != X"NO" -a -r /etc/ethers ]; then
2101.30Smycroft	echo -n ' rarpd';		rarpd ${rarpd_flags}
2111.30Smycroftfi
2121.30Smycroft
2131.30Smycroft# $bootparamd_flags is importent from /etc/netstart;
2141.30Smycroft# If $bootparamd_flags == NO or /etc/bootparams doesn't exist, then
2151.30Smycroft# bootparamd isn't run.
2161.30Smycroftif [ "X${bootparamd_flags}" != X"NO" -a -r /etc/bootparams ]; then
2171.30Smycroft	echo -n ' rpc.bootparamd';	rpc.bootparamd ${bootparamd_flags}
2181.30Smycroftfi
2191.30Smycroft
2201.1Scgdecho '.'
2211.1Scgd
2221.25Smycroft. /etc/rc.local
2231.1Scgd
2241.1Scgddate
2251.1Scgd
2261.1Scgdexit 0
227