rc revision 1.48
11.45Scgd#	from: @(#)rc	8.2 (Berkeley) 3/17/94
21.48Smycroft#	$Id: rc,v 1.48 1994/09/16 23:38:01 mycroft 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.38Scgd	echo "Fast boot: skipping disk checks."
231.1Scgdelif [ $1x = autobootx ]
241.1Scgdthen
251.38Scgd	echo "Automatic boot in progress: starting file system checks."
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.35Scgd		echo "Rebooting..."
351.1Scgd		reboot
361.38Scgd		echo "Reboot failed; help!"
371.1Scgd		exit 1
381.1Scgd		;;
391.1Scgd	8)
401.38Scgd		echo "Automatic file system check failed; help!"
411.1Scgd		exit 1
421.1Scgd		;;
431.1Scgd	12)
441.38Scgd		echo "Boot interrupted."
451.1Scgd		exit 1
461.1Scgd		;;
471.1Scgd	130)
481.1Scgd		# interrupt before catcher installed
491.1Scgd		exit 1
501.1Scgd		;;
511.1Scgd	*)
521.38Scgd		echo "Unknown error; help!"
531.1Scgd		exit 1
541.1Scgd		;;
551.1Scgd	esac
561.1Scgdfi
571.1Scgd
581.38Scgdtrap "echo 'Boot interrupted.'; exit 1" 3
591.1Scgd
601.1Scgdswapon -a
611.1Scgd
621.1Scgdumount -a >/dev/null 2>&1
631.1Scgdmount -a -t nonfs
641.1Scgdrm -f /fastboot		# XXX (root now writeable)
651.40Scgd
661.40Scgd# set flags on ttys.  (do early, in case they use tty for SLIP in netstart)
671.40Scgdecho 'setting tty flags'
681.40Scgdttyflags -a
691.1Scgd
701.1Scgd# set hostname, turn on network
711.1Scgdecho 'starting network'
721.1Scgd. /etc/netstart
731.1Scgd
741.26Sderaadtmount /usr >/dev/null 2>&1
751.42Smycroftmount /var >/dev/null 2>&1
761.26Sderaadt
771.41Sjtc# clean up left-over files
781.41Sjtcrm -f /etc/nologin
791.41Sjtcrm -f /var/spool/lock/LCK.*
801.41Sjtcrm -f /var/spool/uucp/STST/*
811.45Scgd(cd /var/run && { rm -rf -- *; install -c -m 664 -g utmp /dev/null utmp; })
821.41Sjtc
831.26Sderaadtecho -n 'starting rpc daemons:'
841.26Sderaadtecho -n ' portmap';		portmap
851.26Sderaadt
861.26Sderaadtif [ -f /usr/sbin/ypbind -a -d /var/yp ]; then
871.26Sderaadt	echo -n ' ypbind';		ypbind
881.26Sderaadtfi
891.26Sderaadt
901.26Sderaadt# $nfs_server is imported from /etc/netstart;
911.26Sderaadt# if $nfs_server == YES, the machine is setup for being an nfs server
921.26Sderaadtif [ X${nfs_server} = X"YES" -a -r /etc/exports ]; then
931.26Sderaadt	rm -f /var/db/mountdtab	
941.48Smycroft	echo -n > /var/db/mountdtab
951.26Sderaadt	echo -n ' mountd';		mountd
961.44Smycroft	echo -n ' nfsd';		nfsd -tun 4
971.26Sderaadtfi
981.26Sderaadt
991.26Sderaadt# $nfs_client is imported from /etc/netstart;
1001.26Sderaadt# if $nfs_client == YES, the machine is setup for being an nfs client
1011.26Sderaadtif [ X${nfs_client} = X"YES" ]; then
1021.44Smycroft	echo -n ' nfsiod';		nfsiod -n 4
1031.26Sderaadtfi
1041.26Sderaadt
1051.36Scgdif [ X${amd} = X"YES" -a -d ${amd_dir} -a -r ${amd_master} ]; then
1061.27Sderaadt	echo -n ' amd'
1071.39Scgd	amd -l syslog -x error,noinfo,nostats -p > /var/run/amd.pid \
1081.39Scgd	    -a ${amd_dir} `cat ${amd_master}`
1091.27Sderaadtfi
1101.27Sderaadt
1111.26Sderaadtecho '.'
1121.27Sderaadtmount -a -t nfs
1131.1Scgd
1141.1Scgdecho -n 'starting system logger'
1151.1Scgdrm -f /dev/log
1161.1Scgdsyslogd
1171.1Scgd
1181.19Scgd# $timed_flags is imported from /etc/netstart;
1191.19Scgd# if $timed_flags == NO, timed isn't run.
1201.21Scgdif [ "X${timed_flags}" != X"NO" ]; then
1211.19Scgd	echo -n ', time daemon'; timed $timed_flags
1221.1Scgdfi
1231.1Scgdecho '.'
1241.1Scgd
1251.1Scgd# /var/crash should be a directory or a symbolic link
1261.1Scgd# to the crash directory if core dumps are to be saved.
1271.1Scgdif [ -d /var/crash ]; then
1281.1Scgd	echo checking for core dump...
1291.1Scgd	savecore /var/crash
1301.1Scgdfi
1311.1Scgd
1321.47Sderaadt				echo -n 'checking quotas:'
1331.47Sderaadtquotacheck -a
1341.47Sderaadt				echo ' done.'
1351.47Sderaadtquotaon -a
1361.1Scgd
1371.1Scgd# build ps databases
1381.2Scgdecho 'building databases...'
1391.11Scgdkvm_mkdb /netbsd
1401.1Scgddev_mkdb
1411.1Scgd
1421.1Scgdchmod 666 /dev/tty[pqrs]*
1431.1Scgd
1441.1Scgd# check the password temp/lock file
1451.1Scgdif [ -f /etc/ptmp ]
1461.1Scgdthen
1471.1Scgd	logger -s -p auth.err \
1481.1Scgd	'password file may be incorrect -- /etc/ptmp exists'
1491.1Scgdfi
1501.1Scgd
1511.32Smycroftvirecovery=/var/tmp/vi.recover/recover.*
1521.32Smycroftif [ "$virecovery" != "/var/tmp/vi.recover/recover.*" ]; then
1531.32Smycroft	echo preserving editor files
1541.32Smycroft	for i in $virecovery; do
1551.32Smycroft		sendmail -t < $i
1561.32Smycroft	done
1571.32Smycroftfi
1581.1Scgd
1591.1Scgdecho clearing /tmp
1601.1Scgd
1611.1Scgd# prune quickly with one rm, then use find to clean up /tmp/[lq]*
1621.1Scgd# (not needed with mfs /tmp, but doesn't hurt there...)
1631.1Scgd(cd /tmp && rm -rf [a-km-pr-zA-Z]* &&
1641.46Sderaadt    find . ! -name . ! -name lost+found ! -name quota.user \
1651.46Sderaadt	! -name quota.group -exec rm -rf -- {} \; -type d -prune)
1661.1Scgd
1671.34Scgdif [ -f /var/account/acct ]; then
1681.34Scgd	echo 'turning on accounting';	accton /var/account/acct
1691.34Scgdfi
1701.1Scgd
1711.1Scgdecho -n standard daemons:
1721.1Scgdecho -n ' update';		update
1731.31Sjtcecho -n ' cron';		cron
1741.1Scgdecho '.'
1751.1Scgd
1761.1Scgdecho -n starting network daemons:
1771.1Scgd
1781.19Scgd# $gated and $routed_flags are imported from /etc/netstart.
1791.1Scgd# If $gated == YES, gated is used; otherwise routed.
1801.19Scgd# If $routed_flags == NO, routed isn't run.
1811.1Scgdif [ X${gated} = X"YES" -a -r /etc/gated.conf ]; then
1821.48Smycroft	echo -n ' gated';		gated $gated_flags
1831.21Scgdelif [ "X${routed_flags}" != X"NO" ]; then
1841.48Smycroft	echo -n ' routed';		routed $routed_flags
1851.1Scgdfi
1861.1Scgd
1871.19Scgd# $name_server is imported from /etc/netstart;
1881.48Smycroft# if $named_flags != NO, named is run.
1891.48Smycroftif [ "X${named_flags}" != X"NO" ]; then
1901.48Smycroft	echo -n ' named';		named $named_flags
1911.29Smycroftfi
1921.29Smycroft
1931.1Scgd# $rwhod is imported from /etc/netstart;
1941.2Scgd# if $rwhod == YES, rwhod is run.
1951.5Scgdif [ X${rwhod} = X"YES" ]; then
1961.48Smycroft	echo -n ' rwhod';		rwhod
1971.1Scgdfi
1981.1Scgd
1991.1Scgdecho -n ' printer';		lpd
2001.6Scgd
2011.19Scgd# $sendmail_flags is imported from /etc/netstart;
2021.24Scgd# If $sendmail_flags == NO or /etc/sendmail.cf doesn't exist, then
2031.24Scgd# sendmail isn't run.
2041.24Scgdif [ "X${sendmail_flags}" != X"NO" -a -r /etc/sendmail.cf ]; then
2051.19Scgd	echo -n ' sendmail';		sendmail ${sendmail_flags}
2061.19Scgdfi
2071.19Scgd
2081.1Scgdecho -n ' inetd';		inetd
2091.30Smycroft
2101.30Smycroft# $rarpd_flags is importent from /etc/netstart;
2111.30Smycroft# If $rarpd_flags == NO or /etc/ethers doesn't exist, then
2121.30Smycroft# rarpd isn't run.
2131.30Smycroftif [ "X${rarpd_flags}" != X"NO" -a -r /etc/ethers ]; then
2141.30Smycroft	echo -n ' rarpd';		rarpd ${rarpd_flags}
2151.30Smycroftfi
2161.30Smycroft
2171.30Smycroft# $bootparamd_flags is importent from /etc/netstart;
2181.30Smycroft# If $bootparamd_flags == NO or /etc/bootparams doesn't exist, then
2191.30Smycroft# bootparamd isn't run.
2201.30Smycroftif [ "X${bootparamd_flags}" != X"NO" -a -r /etc/bootparams ]; then
2211.30Smycroft	echo -n ' rpc.bootparamd';	rpc.bootparamd ${bootparamd_flags}
2221.30Smycroftfi
2231.30Smycroft
2241.1Scgdecho '.'
2251.1Scgd
2261.25Smycroft. /etc/rc.local
2271.1Scgd
2281.1Scgddate
2291.1Scgdexit 0
230