rc revision 1.63
11.63Smrg#	$NetBSD: rc,v 1.63 1997/01/05 12:01:55 mrg 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.63Smrgfi
1481.63Smrg
1491.63Smrgif [ "X$amd" = XYES -a -d "$amd_dir" -a -r "$amd_master" ]; then
1501.63Smrg        echo -n ' amd'
1511.63Smrg        amd $amd_flags -p -a $amd_dir `cat $amd_master` > /var/run/amd.pid
1521.63Smrgfi
1531.63Smrg
1541.1Scgdecho '.'
1551.63Smrgmount -a -t nfs
1561.63Smrg
1571.63Smrgif [ -f /sbin/ldconfig ]; then
1581.63Smrg	echo 'creating runtime link editor directory cache.'
1591.63Smrg	if [ -s /etc/ld.so.conf ]; then
1601.63Smrg		ldconfig `cat /etc/ld.so.conf`
1611.63Smrg	else
1621.63Smrg		ldconfig
1631.63Smrg	fi
1641.63Smrgfi 
1651.1Scgd
1661.1Scgd# /var/crash should be a directory or a symbolic link
1671.1Scgd# to the crash directory if core dumps are to be saved.
1681.63Smrgif [ X"savecore_flags" != XNO -a -d /var/crash ]; then
1691.1Scgd	echo checking for core dump...
1701.63Smrg	savecore $savecore_flags /var/crash
1711.1Scgdfi
1721.1Scgd
1731.47Sderaadt				echo -n 'checking quotas:'
1741.47Sderaadtquotacheck -a
1751.47Sderaadt				echo ' done.'
1761.47Sderaadtquotaon -a
1771.1Scgd
1781.1Scgd# build ps databases
1791.2Scgdecho 'building databases...'
1801.11Scgdkvm_mkdb /netbsd
1811.1Scgddev_mkdb
1821.1Scgd
1831.1Scgdchmod 666 /dev/tty[pqrs]*
1841.1Scgd
1851.1Scgd# check the password temp/lock file
1861.1Scgdif [ -f /etc/ptmp ]
1871.1Scgdthen
1881.1Scgd	logger -s -p auth.err \
1891.1Scgd	'password file may be incorrect -- /etc/ptmp exists'
1901.1Scgdfi
1911.1Scgd
1921.32Smycroftvirecovery=/var/tmp/vi.recover/recover.*
1931.32Smycroftif [ "$virecovery" != "/var/tmp/vi.recover/recover.*" ]; then
1941.32Smycroft	echo preserving editor files
1951.32Smycroft	for i in $virecovery; do
1961.32Smycroft		sendmail -t < $i
1971.32Smycroft	done
1981.32Smycroftfi
1991.1Scgd
2001.1Scgdecho clearing /tmp
2011.1Scgd
2021.1Scgd# prune quickly with one rm, then use find to clean up /tmp/[lq]*
2031.1Scgd# (not needed with mfs /tmp, but doesn't hurt there...)
2041.1Scgd(cd /tmp && rm -rf [a-km-pr-zA-Z]* &&
2051.46Sderaadt    find . ! -name . ! -name lost+found ! -name quota.user \
2061.46Sderaadt	! -name quota.group -exec rm -rf -- {} \; -type d -prune)
2071.1Scgd
2081.34Scgdif [ -f /var/account/acct ]; then
2091.34Scgd	echo 'turning on accounting';	accton /var/account/acct
2101.34Scgdfi
2111.1Scgd
2121.1Scgdecho -n standard daemons:
2131.1Scgdecho -n ' update';		update
2141.31Sjtcecho -n ' cron';		cron
2151.1Scgdecho '.'
2161.1Scgd
2171.63Smrg# now start all the other daemons
2181.1Scgdecho -n starting network daemons:
2191.1Scgd
2201.63Smrgif [ X$gated_flags != XNO -a -r /etc/gated.conf ]; then
2211.48Smycroft	echo -n ' gated';		gated $gated_flags
2221.63Smrgelif [ "X$routed_flags" != XNO ]; then
2231.48Smycroft	echo -n ' routed';		routed $routed_flags
2241.1Scgdfi
2251.1Scgd
2261.63Smrgif [ "X$mrouted_flags" != XNO ]; then
2271.55Sthorpej	echo -n ' mrouted';		mrouted $mrouted_flags
2281.55Sthorpejfi
2291.55Sthorpej
2301.63Smrgif [ "X$timed_flags" != XNO ]; then
2311.63Smrg	echo -n ' time daemon'; 	timed $timed_flags
2321.63Smrgfi
2331.63Smrg
2341.63Smrgif [ "X$xntpd_flags" != XNO ]; then
2351.63Smrg	echo -n ' ntp daemon';		xntpd $xntpd_flags
2361.61Smrgfi
2371.61Smrg
2381.63Smrgif [ "X$dhcpd_flags" != XNO -a -r /etc/dhcpd.conf ]; then
2391.61Smrg	echo -n ' dhcpd';		dhcpd $dhcpd_flags
2401.29Smycroftfi
2411.29Smycroft
2421.63Smrgif [ X$rwhod = XYES ]; then
2431.48Smycroft	echo -n ' rwhod';		rwhod
2441.1Scgdfi
2451.1Scgd
2461.63Smrgif [ "X$lpd_flags" != XNO ]; then
2471.63Smrg	echo -n ' printer';		lpd $lpd_flags
2481.60Stlsfi
2491.60Stls
2501.63Smrg# We call sendmail with a full path so that SIGHUP works.
2511.63Smrgif [ "X$sendmail_flags" != XNO -a -r /etc/sendmail.cf ]; then
2521.63Smrg	echo -n ' sendmail';		/usr/sbin/sendmail $sendmail_flags
2531.60Stlsfi
2541.60Stls
2551.63Smrgif [ "X$rarpd_flags" != XNO -a -r /etc/ethers ]; then
2561.63Smrg	echo -n ' rarpd';		rarpd $rarpd_flags
2571.60Stlsfi
2581.60Stls
2591.63Smrgif [ "X$rbootd_flags" != XNO -a -r /etc/rbootd.conf ]; then
2601.63Smrg	echo -n ' rbootd';		rbootd $rbootd_flags
2611.52Sthorpejfi
2621.52Sthorpej
2631.63Smrgif [ "X$inetd_flags" != XNO -a -r /etc/inetd.conf ]; then
2641.63Smrg	echo -n ' inetd';		inetd $inetd_flags
2651.30Smycroftfi
2661.30Smycroft
2671.1Scgdecho '.'
2681.1Scgd
2691.25Smycroft. /etc/rc.local
2701.1Scgd
2711.1Scgddate
2721.1Scgdexit 0
273