rc revision 1.26
11.26Sderaadt#	@(#)rc	5.27 (Berkeley) 6/5/91
21.26Sderaadt#	$Id: rc,v 1.26 1993/12/16 04:02:24 deraadt 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.26Sderaadtmount -a -t nfs >/dev/null 2>&1
711.26Sderaadt
721.26Sderaadtecho -n 'starting rpc daemons:'
731.26Sderaadtecho -n ' portmap';		portmap
741.26Sderaadt
751.26Sderaadtif [ -f /usr/sbin/ypbind -a -d /var/yp ]; then
761.26Sderaadt	echo -n ' ypbind';		ypbind
771.26Sderaadtfi
781.26Sderaadt
791.26Sderaadt# $nfs_server is imported from /etc/netstart;
801.26Sderaadt# if $nfs_server == YES, the machine is setup for being an nfs server
811.26Sderaadtif [ X${nfs_server} = X"YES" -a -r /etc/exports ]; then
821.26Sderaadt	rm -f /var/db/mountdtab	
831.26Sderaadt	echo -n ' mountd';		mountd
841.26Sderaadt	echo -n ' nfsd';		nfsd -u 0,0,4 -t 0,0
851.26Sderaadtfi
861.26Sderaadt
871.26Sderaadt# $nfs_client is imported from /etc/netstart;
881.26Sderaadt# if $nfs_client == YES, the machine is setup for being an nfs client
891.26Sderaadtif [ X${nfs_client} = X"YES" ]; then
901.26Sderaadt	echo -n ' nfsiod';		nfsiod 4
911.26Sderaadtfi
921.26Sderaadt
931.26Sderaadtecho '.'
941.1Scgd
951.1Scgd# clean up left-over files
961.1Scgdrm -f /etc/nologin
971.1Scgdrm -f /var/spool/uucp/LCK.*
981.1Scgdrm -f /var/spool/uucp/STST/*
991.1Scgd(cd /var/run && { rm -rf -- *; cp /dev/null utmp; chmod 644 utmp; })
1001.23Smycroft
1011.23Smycroftecho 'runtime link editor directory cache'
1021.23Smycroftrm -f /var/run/ld.so.hints
1031.23Smycroftldconfig
1041.1Scgd
1051.1Scgdecho -n 'starting system logger'
1061.1Scgdrm -f /dev/log
1071.1Scgdsyslogd
1081.1Scgd
1091.19Scgd# $timed_flags is imported from /etc/netstart;
1101.19Scgd# if $timed_flags == NO, timed isn't run.
1111.21Scgdif [ "X${timed_flags}" != X"NO" ]; then
1121.19Scgd	echo -n ', time daemon'; timed $timed_flags
1131.1Scgdfi
1141.1Scgdecho '.'
1151.1Scgd
1161.1Scgd# /var/crash should be a directory or a symbolic link
1171.1Scgd# to the crash directory if core dumps are to be saved.
1181.1Scgdif [ -d /var/crash ]; then
1191.1Scgd	echo checking for core dump...
1201.1Scgd	savecore /var/crash
1211.1Scgdfi
1221.1Scgd
1231.1Scgd#				echo -n 'checking quotas:'
1241.1Scgd#quotacheck -a
1251.1Scgd#				echo ' done.'
1261.1Scgd#quotaon -a
1271.1Scgd
1281.1Scgd# build ps databases
1291.2Scgdecho 'building databases...'
1301.11Scgdkvm_mkdb /netbsd
1311.1Scgddev_mkdb
1321.1Scgd
1331.1Scgdchmod 666 /dev/tty[pqrs]*
1341.1Scgd
1351.1Scgd# check the password temp/lock file
1361.1Scgdif [ -f /etc/ptmp ]
1371.1Scgdthen
1381.1Scgd	logger -s -p auth.err \
1391.1Scgd	'password file may be incorrect -- /etc/ptmp exists'
1401.1Scgdfi
1411.1Scgd
1421.1Scgdecho preserving editor files
1431.1Scgd(cd /var/tmp && /usr/libexec/elvispreserve "-the system rebooted" elvis* &&
1441.1Scgd     rm -f elvis[0-9a-f][0-9a-f][0-9a-f][0-9a-f]* \
1451.1Scgd	 elvis_[0-9a-f][0-9a-f][0-9a-f][0-9a-f]*)
1461.1Scgd
1471.1Scgdecho clearing /tmp
1481.1Scgd
1491.1Scgd# prune quickly with one rm, then use find to clean up /tmp/[lq]*
1501.1Scgd# (not needed with mfs /tmp, but doesn't hurt there...)
1511.1Scgd(cd /tmp && rm -rf [a-km-pr-zA-Z]* &&
1521.13Scgd    find . ! -name . ! -name lost+found ! -name quotas \
1531.13Scgd	-exec rm -rf -- {} \; -type d -prune)
1541.1Scgd
1551.18Scgd#echo 'turning on accounting';	accton /var/account/acct
1561.1Scgd
1571.1Scgdecho -n standard daemons:
1581.1Scgdecho -n ' update';		update
1591.1Scgdecho -n ' crond';		/usr/libexec/crond
1601.1Scgdecho '.'
1611.1Scgd
1621.1Scgdecho -n starting network daemons:
1631.1Scgd
1641.19Scgd# $gated and $routed_flags are imported from /etc/netstart.
1651.1Scgd# If $gated == YES, gated is used; otherwise routed.
1661.19Scgd# If $routed_flags == NO, routed isn't run.
1671.1Scgdif [ X${gated} = X"YES" -a -r /etc/gated.conf ]; then
1681.19Scgd	echo -n ' gated';	gated $gated_flags
1691.21Scgdelif [ "X${routed_flags}" != X"NO" ]; then
1701.19Scgd	echo -n ' routed';	routed $routed_flags
1711.1Scgdfi
1721.1Scgd
1731.19Scgd# $name_server is imported from /etc/netstart;
1741.19Scgd# if $name_server == YES, named is run.
1751.1Scgdif [ X${name_server} = X"YES" -a -r /etc/named.boot ]; then
1761.1Scgd	echo -n ' named';		named
1771.1Scgdfi
1781.1Scgd
1791.1Scgd# $rwhod is imported from /etc/netstart;
1801.2Scgd# if $rwhod == YES, rwhod is run.
1811.5Scgdif [ X${rwhod} = X"YES" ]; then
1821.1Scgd	echo -n ' rwhod';	rwhod
1831.1Scgdfi
1841.1Scgd
1851.1Scgdecho -n ' printer';		lpd
1861.6Scgd
1871.19Scgd# $sendmail_flags is imported from /etc/netstart;
1881.24Scgd# If $sendmail_flags == NO or /etc/sendmail.cf doesn't exist, then
1891.24Scgd# sendmail isn't run.
1901.24Scgdif [ "X${sendmail_flags}" != X"NO" -a -r /etc/sendmail.cf ]; then
1911.19Scgd	echo -n ' sendmail';		sendmail ${sendmail_flags}
1921.19Scgdfi
1931.19Scgd
1941.1Scgdecho -n ' inetd';		inetd
1951.1Scgdecho '.'
1961.1Scgd
1971.25Smycroft. /etc/rc.local
1981.1Scgd
1991.1Scgddate
2001.1Scgd
2011.1Scgdexit 0
202