rc revision 1.66
11.66Sscottr#	$NetBSD: rc,v 1.66 1997/03/10 06:32:37 scottr Exp $
21.45Scgd#	from: @(#)rc	8.2 (Berkeley) 3/17/94
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.50Sthorpej
201.50Sthorpej# Configure ccd devices.
211.63Smrgif [ -f /etc/ccd.conf ]; then
221.50Sthorpej	ccdconfig -C
231.50Sthorpejfi
241.1Scgd
251.63Smrgif [ -e /fastboot ]; then
261.38Scgd	echo "Fast boot: skipping disk checks."
271.63Smrgelif [ $1x = autobootx ]; then
281.38Scgd	echo "Automatic boot in progress: starting file system checks."
291.1Scgd	fsck -p
301.1Scgd	case $? in
311.1Scgd	0)
321.1Scgd		;;
331.1Scgd	2)
341.1Scgd		exit 1
351.1Scgd		;;
361.1Scgd	4)
371.35Scgd		echo "Rebooting..."
381.1Scgd		reboot
391.38Scgd		echo "Reboot failed; help!"
401.1Scgd		exit 1
411.1Scgd		;;
421.1Scgd	8)
431.38Scgd		echo "Automatic file system check failed; help!"
441.1Scgd		exit 1
451.1Scgd		;;
461.1Scgd	12)
471.38Scgd		echo "Boot interrupted."
481.1Scgd		exit 1
491.1Scgd		;;
501.1Scgd	130)
511.1Scgd		# interrupt before catcher installed
521.1Scgd		exit 1
531.1Scgd		;;
541.1Scgd	*)
551.38Scgd		echo "Unknown error; help!"
561.1Scgd		exit 1
571.1Scgd		;;
581.1Scgd	esac
591.1Scgdfi
601.1Scgd
611.38Scgdtrap "echo 'Boot interrupted.'; exit 1" 3
621.1Scgd
631.1Scgdswapon -a
641.1Scgd
651.1Scgdumount -a >/dev/null 2>&1
661.1Scgdmount -a -t nonfs
671.1Scgdrm -f /fastboot		# XXX (root now writeable)
681.40Scgd
691.63Smrgif [ -s /etc/rc.conf ]; then
701.63Smrg	. /etc/rc.conf
711.63Smrgfi
721.63Smrg
731.40Scgd# set flags on ttys.  (do early, in case they use tty for SLIP in netstart)
741.40Scgdecho 'setting tty flags'
751.40Scgdttyflags -a
761.1Scgd
771.63Smrg# load any kernel modules specified in /etc/lkm.conf
781.63Smrgif [ X"$lkm_init" != XNO -a -f /etc/rc.lkm ]; then
791.63Smrg	. /etc/rc.lkm
801.63Smrgfi
811.63Smrg
821.1Scgd# set hostname, turn on network
831.1Scgdecho 'starting network'
841.1Scgd. /etc/netstart
851.1Scgd
861.26Sderaadtmount /usr >/dev/null 2>&1
871.42Smycroftmount /var >/dev/null 2>&1
881.26Sderaadt
891.41Sjtc# clean up left-over files
901.41Sjtcrm -f /etc/nologin
911.41Sjtcrm -f /var/spool/lock/LCK.*
921.41Sjtcrm -f /var/spool/uucp/STST/*
931.45Scgd(cd /var/run && { rm -rf -- *; install -c -m 664 -g utmp /dev/null utmp; })
941.41Sjtc
951.63Smrg# start the system logger first, so that all messages
961.63Smrg# from daemons are logged, and the name server next.
971.63Smrg
981.63Smrgif [ "X$syslogd_flags" != XNO ]; then
991.63Smrg	echo 'starting system logger'
1001.63Smrg	rm -f /dev/log
1011.63Smrg	syslogd $syslogd_flags
1021.63Smrgfi
1031.63Smrg
1041.63Smrgif [ "X$named_flags" != XNO ]; then
1051.63Smrg	echo 'starting name server';	named $named_flags
1061.63Smrgfi
1071.63Smrg
1081.63Smrg# now start the rpc servers, for YP server/client, NFS.
1091.63Smrgecho -n 'starting rpc daemons:'
1101.63Smrg
1111.63Smrg# note that portmap is generally required for all other rpc services.
1121.63Smrgif [ "X$portmap" != XNO ]; then
1131.63Smrg	echo -n ' portmap';             portmap
1141.63Smrgfi
1151.63Smrg
1161.63Smrgif [ "X$ypserv_flags" != XNO ]; then
1171.63Smrg        echo -n ' ypserv';              ypserv $ypserv_flags
1181.63Smrgfi
1191.63Smrg
1201.63Smrgif [ "X$ypbind_flags" != XNO ]; then
1211.63Smrg        echo -n ' ypbind';              ypbind $ypbind_flags
1221.63Smrgfi
1231.63Smrg
1241.63Smrgif [ "X$yppasswdd_flags" != XNO ]; then
1251.63Smrg        echo -n ' rpc.yppasswdd';       rpc.yppasswdd $yppasswdd_flags
1261.63Smrgfi
1271.63Smrg
1281.63Smrgif [ "X$bootparamd_flags" != XNO -a -r /etc/bootparams ]; then
1291.63Smrg        echo -n ' rpc.bootparamd';      rpc.bootparamd $bootparamd_flags
1301.63Smrgfi
1311.63Smrg
1321.63Smrgif [ "X$nfs_server" = XYES -a -r /etc/exports ]; then
1331.63Smrg	if [ "X$nfsd_flags" = X ]; then
1341.63Smrg		nfsd_flags="-tun 4"
1351.63Smrg	fi
1361.63Smrg        rm -f /var/db/mountdtab
1371.63Smrg        echo -n > /var/db/mountdtab
1381.63Smrg        echo -n ' mountd';              mountd $mountd_flags
1391.63Smrg        echo -n ' nfsd';                nfsd $nfsd_flags
1401.1Scgdfi
1411.63Smrg
1421.63Smrgif [ "X$nfs_client" = XYES ]; then
1431.63Smrg	if [ "X$nfsiod_flags" = X ]; then
1441.63Smrg		nfsiod_flags="-n 4"
1451.63Smrg	fi
1461.63Smrg        echo -n ' nfsiod';              nfsiod $nfsiod_flags
1471.66Sscottrfi
1481.66Sscottr
1491.66Sscottrif [ "X$nfs_server" = XYES -a -r /etc/exports -o "X$nfs_client" = XYES ]; then
1501.66Sscottr	if [ "X$statd_flags" != XNO ]; then
1511.66Sscottr		echo ' statd';		rpc.statd $statd_flags
1521.66Sscottr	fi
1531.66Sscottr
1541.66Sscottr	if [ "X$lockd_flags" != XNO ]; then
1551.66Sscottr		echo ' lockd';		rpc.lockd $lockd_flags
1561.66Sscottr	fi
1571.63Smrgfi
1581.63Smrg
1591.63Smrgif [ "X$amd" = XYES -a -d "$amd_dir" -a -r "$amd_master" ]; then
1601.63Smrg        echo -n ' amd'
1611.63Smrg        amd $amd_flags -p -a $amd_dir `cat $amd_master` > /var/run/amd.pid
1621.63Smrgfi
1631.63Smrg
1641.1Scgdecho '.'
1651.63Smrgmount -a -t nfs
1661.63Smrg
1671.63Smrgif [ -f /sbin/ldconfig ]; then
1681.63Smrg	echo 'creating runtime link editor directory cache.'
1691.63Smrg	if [ -s /etc/ld.so.conf ]; then
1701.63Smrg		ldconfig `cat /etc/ld.so.conf`
1711.63Smrg	else
1721.63Smrg		ldconfig
1731.63Smrg	fi
1741.63Smrgfi 
1751.1Scgd
1761.1Scgd# /var/crash should be a directory or a symbolic link
1771.1Scgd# to the crash directory if core dumps are to be saved.
1781.64Smrgif [ X"$savecore_flags" != XNO -a -d /var/crash ]; then
1791.1Scgd	echo checking for core dump...
1801.63Smrg	savecore $savecore_flags /var/crash
1811.1Scgdfi
1821.1Scgd
1831.47Sderaadt				echo -n 'checking quotas:'
1841.47Sderaadtquotacheck -a
1851.47Sderaadt				echo ' done.'
1861.47Sderaadtquotaon -a
1871.1Scgd
1881.1Scgd# build ps databases
1891.2Scgdecho 'building databases...'
1901.11Scgdkvm_mkdb /netbsd
1911.1Scgddev_mkdb
1921.1Scgd
1931.1Scgdchmod 666 /dev/tty[pqrs]*
1941.1Scgd
1951.1Scgd# check the password temp/lock file
1961.1Scgdif [ -f /etc/ptmp ]
1971.1Scgdthen
1981.1Scgd	logger -s -p auth.err \
1991.1Scgd	'password file may be incorrect -- /etc/ptmp exists'
2001.1Scgdfi
2011.1Scgd
2021.32Smycroftvirecovery=/var/tmp/vi.recover/recover.*
2031.32Smycroftif [ "$virecovery" != "/var/tmp/vi.recover/recover.*" ]; then
2041.32Smycroft	echo preserving editor files
2051.32Smycroft	for i in $virecovery; do
2061.32Smycroft		sendmail -t < $i
2071.32Smycroft	done
2081.32Smycroftfi
2091.1Scgd
2101.1Scgdecho clearing /tmp
2111.1Scgd
2121.65Smikel# Prune quickly with one rm, then use find to clean up /tmp/[lq]* (this
2131.65Smikel# is not needed with mfs /tmp, but doesn't hurt anything).
2141.1Scgd(cd /tmp && rm -rf [a-km-pr-zA-Z]* &&
2151.46Sderaadt    find . ! -name . ! -name lost+found ! -name quota.user \
2161.46Sderaadt	! -name quota.group -exec rm -rf -- {} \; -type d -prune)
2171.1Scgd
2181.34Scgdif [ -f /var/account/acct ]; then
2191.34Scgd	echo 'turning on accounting';	accton /var/account/acct
2201.34Scgdfi
2211.1Scgd
2221.1Scgdecho -n standard daemons:
2231.1Scgdecho -n ' update';		update
2241.31Sjtcecho -n ' cron';		cron
2251.1Scgdecho '.'
2261.1Scgd
2271.63Smrg# now start all the other daemons
2281.1Scgdecho -n starting network daemons:
2291.1Scgd
2301.63Smrgif [ X$gated_flags != XNO -a -r /etc/gated.conf ]; then
2311.48Smycroft	echo -n ' gated';		gated $gated_flags
2321.63Smrgelif [ "X$routed_flags" != XNO ]; then
2331.48Smycroft	echo -n ' routed';		routed $routed_flags
2341.1Scgdfi
2351.1Scgd
2361.63Smrgif [ "X$mrouted_flags" != XNO ]; then
2371.55Sthorpej	echo -n ' mrouted';		mrouted $mrouted_flags
2381.55Sthorpejfi
2391.55Sthorpej
2401.63Smrgif [ "X$timed_flags" != XNO ]; then
2411.63Smrg	echo -n ' time daemon'; 	timed $timed_flags
2421.63Smrgfi
2431.63Smrg
2441.63Smrgif [ "X$xntpd_flags" != XNO ]; then
2451.63Smrg	echo -n ' ntp daemon';		xntpd $xntpd_flags
2461.61Smrgfi
2471.61Smrg
2481.63Smrgif [ "X$dhcpd_flags" != XNO -a -r /etc/dhcpd.conf ]; then
2491.61Smrg	echo -n ' dhcpd';		dhcpd $dhcpd_flags
2501.29Smycroftfi
2511.29Smycroft
2521.63Smrgif [ X$rwhod = XYES ]; then
2531.48Smycroft	echo -n ' rwhod';		rwhod
2541.1Scgdfi
2551.1Scgd
2561.63Smrgif [ "X$lpd_flags" != XNO ]; then
2571.63Smrg	echo -n ' printer';		lpd $lpd_flags
2581.60Stlsfi
2591.60Stls
2601.63Smrg# We call sendmail with a full path so that SIGHUP works.
2611.63Smrgif [ "X$sendmail_flags" != XNO -a -r /etc/sendmail.cf ]; then
2621.63Smrg	echo -n ' sendmail';		/usr/sbin/sendmail $sendmail_flags
2631.60Stlsfi
2641.60Stls
2651.63Smrgif [ "X$rarpd_flags" != XNO -a -r /etc/ethers ]; then
2661.63Smrg	echo -n ' rarpd';		rarpd $rarpd_flags
2671.60Stlsfi
2681.60Stls
2691.63Smrgif [ "X$rbootd_flags" != XNO -a -r /etc/rbootd.conf ]; then
2701.63Smrg	echo -n ' rbootd';		rbootd $rbootd_flags
2711.52Sthorpejfi
2721.52Sthorpej
2731.63Smrgif [ "X$inetd_flags" != XNO -a -r /etc/inetd.conf ]; then
2741.63Smrg	echo -n ' inetd';		inetd $inetd_flags
2751.30Smycroftfi
2761.30Smycroft
2771.1Scgdecho '.'
2781.1Scgd
2791.25Smycroft. /etc/rc.local
2801.1Scgd
2811.1Scgddate
2821.1Scgdexit 0
283