rc revision 1.61
11.61Smrg#	$NetBSD: rc,v 1.61 1996/10/03 07:11:35 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.50Sthorpejif [ -f /etc/ccd.conf ]
221.50Sthorpejthen
231.50Sthorpej	ccdconfig -C
241.50Sthorpejfi
251.1Scgd
261.17Smycroftif [ -e /fastboot ]
271.1Scgdthen
281.38Scgd	echo "Fast boot: skipping disk checks."
291.1Scgdelif [ $1x = autobootx ]
301.1Scgdthen
311.38Scgd	echo "Automatic boot in progress: starting file system checks."
321.1Scgd	fsck -p
331.1Scgd	case $? in
341.1Scgd	0)
351.1Scgd		;;
361.1Scgd	2)
371.1Scgd		exit 1
381.1Scgd		;;
391.1Scgd	4)
401.35Scgd		echo "Rebooting..."
411.1Scgd		reboot
421.38Scgd		echo "Reboot failed; help!"
431.1Scgd		exit 1
441.1Scgd		;;
451.1Scgd	8)
461.38Scgd		echo "Automatic file system check failed; help!"
471.1Scgd		exit 1
481.1Scgd		;;
491.1Scgd	12)
501.38Scgd		echo "Boot interrupted."
511.1Scgd		exit 1
521.1Scgd		;;
531.1Scgd	130)
541.1Scgd		# interrupt before catcher installed
551.1Scgd		exit 1
561.1Scgd		;;
571.1Scgd	*)
581.38Scgd		echo "Unknown error; help!"
591.1Scgd		exit 1
601.1Scgd		;;
611.1Scgd	esac
621.1Scgdfi
631.1Scgd
641.38Scgdtrap "echo 'Boot interrupted.'; exit 1" 3
651.1Scgd
661.1Scgdswapon -a
671.1Scgd
681.1Scgdumount -a >/dev/null 2>&1
691.1Scgdmount -a -t nonfs
701.1Scgdrm -f /fastboot		# XXX (root now writeable)
711.40Scgd
721.40Scgd# set flags on ttys.  (do early, in case they use tty for SLIP in netstart)
731.40Scgdecho 'setting tty flags'
741.40Scgdttyflags -a
751.1Scgd
761.1Scgd# set hostname, turn on network
771.1Scgdecho 'starting network'
781.1Scgd. /etc/netstart
791.1Scgd
801.26Sderaadtmount /usr >/dev/null 2>&1
811.42Smycroftmount /var >/dev/null 2>&1
821.26Sderaadt
831.41Sjtc# clean up left-over files
841.41Sjtcrm -f /etc/nologin
851.41Sjtcrm -f /var/spool/lock/LCK.*
861.41Sjtcrm -f /var/spool/uucp/STST/*
871.45Scgd(cd /var/run && { rm -rf -- *; install -c -m 664 -g utmp /dev/null utmp; })
881.41Sjtc
891.1Scgdecho -n 'starting system logger'
901.1Scgdrm -f /dev/log
911.1Scgdsyslogd
921.1Scgd
931.19Scgd# $timed_flags is imported from /etc/netstart;
941.19Scgd# if $timed_flags == NO, timed isn't run.
951.21Scgdif [ "X${timed_flags}" != X"NO" ]; then
961.19Scgd	echo -n ', time daemon'; timed $timed_flags
971.1Scgdfi
981.1Scgdecho '.'
991.1Scgd
1001.1Scgd# /var/crash should be a directory or a symbolic link
1011.1Scgd# to the crash directory if core dumps are to be saved.
1021.1Scgdif [ -d /var/crash ]; then
1031.1Scgd	echo checking for core dump...
1041.1Scgd	savecore /var/crash
1051.1Scgdfi
1061.1Scgd
1071.47Sderaadt				echo -n 'checking quotas:'
1081.47Sderaadtquotacheck -a
1091.47Sderaadt				echo ' done.'
1101.47Sderaadtquotaon -a
1111.1Scgd
1121.1Scgd# build ps databases
1131.2Scgdecho 'building databases...'
1141.11Scgdkvm_mkdb /netbsd
1151.1Scgddev_mkdb
1161.1Scgd
1171.1Scgdchmod 666 /dev/tty[pqrs]*
1181.1Scgd
1191.1Scgd# check the password temp/lock file
1201.1Scgdif [ -f /etc/ptmp ]
1211.1Scgdthen
1221.1Scgd	logger -s -p auth.err \
1231.1Scgd	'password file may be incorrect -- /etc/ptmp exists'
1241.1Scgdfi
1251.1Scgd
1261.32Smycroftvirecovery=/var/tmp/vi.recover/recover.*
1271.32Smycroftif [ "$virecovery" != "/var/tmp/vi.recover/recover.*" ]; then
1281.32Smycroft	echo preserving editor files
1291.32Smycroft	for i in $virecovery; do
1301.32Smycroft		sendmail -t < $i
1311.32Smycroft	done
1321.32Smycroftfi
1331.1Scgd
1341.1Scgdecho clearing /tmp
1351.1Scgd
1361.1Scgd# prune quickly with one rm, then use find to clean up /tmp/[lq]*
1371.1Scgd# (not needed with mfs /tmp, but doesn't hurt there...)
1381.1Scgd(cd /tmp && rm -rf [a-km-pr-zA-Z]* &&
1391.46Sderaadt    find . ! -name . ! -name lost+found ! -name quota.user \
1401.46Sderaadt	! -name quota.group -exec rm -rf -- {} \; -type d -prune)
1411.1Scgd
1421.34Scgdif [ -f /var/account/acct ]; then
1431.34Scgd	echo 'turning on accounting';	accton /var/account/acct
1441.34Scgdfi
1451.1Scgd
1461.1Scgdecho -n standard daemons:
1471.1Scgdecho -n ' update';		update
1481.31Sjtcecho -n ' cron';		cron
1491.1Scgdecho '.'
1501.1Scgd
1511.1Scgdecho -n starting network daemons:
1521.1Scgd
1531.19Scgd# $gated and $routed_flags are imported from /etc/netstart.
1541.1Scgd# If $gated == YES, gated is used; otherwise routed.
1551.19Scgd# If $routed_flags == NO, routed isn't run.
1561.1Scgdif [ X${gated} = X"YES" -a -r /etc/gated.conf ]; then
1571.48Smycroft	echo -n ' gated';		gated $gated_flags
1581.21Scgdelif [ "X${routed_flags}" != X"NO" ]; then
1591.48Smycroft	echo -n ' routed';		routed $routed_flags
1601.1Scgdfi
1611.1Scgd
1621.55Sthorpej# $mrouted_flags is imported from /etc/netstart;
1631.55Sthorpej# If $mrouted_flags == NO, then mrouted isn't run.
1641.55Sthorpejif [ "X${mrouted_flags}" != X"NO" ]; then
1651.55Sthorpej	echo -n ' mrouted';		mrouted $mrouted_flags
1661.55Sthorpejfi
1671.55Sthorpej
1681.55Sthorpej# $named_flags is imported from /etc/netstart;
1691.48Smycroft# if $named_flags != NO, named is run.
1701.48Smycroftif [ "X${named_flags}" != X"NO" ]; then
1711.48Smycroft	echo -n ' named';		named $named_flags
1721.61Smrgfi
1731.61Smrg
1741.61Smrg# $dhcpd_flags is imported from /etc/netstart;
1751.61Smrg# if $dhcpd_flags != NO, dhcpd is run.
1761.61Smrgif [ "X${dhcpd_flags}" != X"NO" -a -r /etc/dhcpd.conf ]; then
1771.61Smrg	echo -n ' dhcpd';		dhcpd $dhcpd_flags
1781.29Smycroftfi
1791.29Smycroft
1801.1Scgd# $rwhod is imported from /etc/netstart;
1811.2Scgd# if $rwhod == YES, rwhod is run.
1821.5Scgdif [ X${rwhod} = X"YES" ]; then
1831.48Smycroft	echo -n ' rwhod';		rwhod
1841.1Scgdfi
1851.1Scgd
1861.1Scgdecho -n ' printer';		lpd
1871.6Scgd
1881.19Scgd# $sendmail_flags is imported from /etc/netstart;
1891.24Scgd# If $sendmail_flags == NO or /etc/sendmail.cf doesn't exist, then
1901.57Smrg# sendmail isn't run.  We call sendmail with a full path so that
1911.57Smrg# SIGHUP works.
1921.24Scgdif [ "X${sendmail_flags}" != X"NO" -a -r /etc/sendmail.cf ]; then
1931.56Smrg	echo -n ' sendmail';		/usr/sbin/sendmail ${sendmail_flags}
1941.19Scgdfi
1951.19Scgd
1961.1Scgdecho -n ' inetd';		inetd
1971.30Smycroft
1981.51Sthorpej# $rarpd_flags is imported from /etc/netstart;
1991.30Smycroft# If $rarpd_flags == NO or /etc/ethers doesn't exist, then
2001.30Smycroft# rarpd isn't run.
2011.30Smycroftif [ "X${rarpd_flags}" != X"NO" -a -r /etc/ethers ]; then
2021.30Smycroft	echo -n ' rarpd';		rarpd ${rarpd_flags}
2031.30Smycroftfi
2041.30Smycroft
2051.60Stls# $rbootd_flags is imported from /etc/netstart;
2061.60Stls# If $rbootd_flags == NO or /etc/rbootd.conf doesn't exist, then
2071.60Stls# rbootd isn't run.
2081.60Stlsif [ "X${rbootd_flags}" != X"NO" -a -r /etc/rbootd.conf ]; then
2091.60Stls	echo -n ' rbootd';		rbootd ${rbootd_flags}
2101.60Stlsfi
2111.60Stls
2121.60Stlsecho '.'
2131.60Stls
2141.60Stlsecho -n 'starting rpc daemons:'
2151.60Stlsecho -n ' portmap';             portmap
2161.60Stls
2171.51Sthorpej# $bootparamd_flags is imported 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.60Stls        echo -n ' rpc.bootparamd';      rpc.bootparamd ${bootparamd_flags}
2221.60Stlsfi
2231.60Stls
2241.60Stlsif [ "X${ypserv_flags}" != X"NO" ]; then
2251.60Stls        echo -n ' ypserv';              ypserv ${ypserv_flags}
2261.60Stlsfi
2271.60Stls
2281.60Stlsif [ "X${yppasswdd_flags}" != X"NO" ]; then
2291.60Stls        echo -n ' rpc.yppasswdd';       rpc.yppasswdd ${yppasswdd_flags}
2301.60Stlsfi
2311.60Stls
2321.60Stlsif [ "X${ypbind_flags}" != X"NO" ]; then
2331.60Stls        echo -n ' ypbind';              ypbind ${ypbind_flags}
2341.60Stlsfi
2351.60Stls
2361.60Stls# $nfs_server is imported from /etc/netstart;
2371.60Stls# if $nfs_server == YES, the machine is setup for being an nfs server
2381.60Stlsif [ X${nfs_server} = X"YES" -a -r /etc/exports ]; then
2391.60Stls        rm -f /var/db/mountdtab
2401.60Stls        echo -n > /var/db/mountdtab
2411.60Stls        echo -n ' mountd';              mountd
2421.60Stls        echo -n ' nfsd';                nfsd -tun 4
2431.60Stlsfi
2441.60Stls
2451.60Stls# $nfs_client is imported from /etc/netstart;
2461.60Stls# if $nfs_client == YES, the machine is setup for being an nfs client
2471.60Stlsif [ X${nfs_client} = X"YES" ]; then
2481.60Stls        echo -n ' nfsiod';              nfsiod -n 4
2491.52Sthorpejfi
2501.52Sthorpej
2511.60Stlsif [ X${amd} = X"YES" -a -d ${amd_dir} -a -r ${amd_master} ]; then
2521.60Stls        echo -n ' amd'
2531.60Stls        amd -l syslog -x error,noinfo,nostats -p \
2541.60Stls            -a ${amd_dir} `cat ${amd_master}` > /var/run/amd.pid
2551.30Smycroftfi
2561.30Smycroft
2571.1Scgdecho '.'
2581.60Stlsmount -a -t nfs
2591.1Scgd
2601.25Smycroft. /etc/rc.local
2611.1Scgd
2621.1Scgddate
2631.1Scgdexit 0
264