rc revision 1.60
11.60Stls# $NetBSD: rc,v 1.60 1996/08/26 06:02:21 tls 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.29Smycroftfi 1731.29Smycroft 1741.1Scgd# $rwhod is imported from /etc/netstart; 1751.2Scgd# if $rwhod == YES, rwhod is run. 1761.5Scgdif [ X${rwhod} = X"YES" ]; then 1771.48Smycroft echo -n ' rwhod'; rwhod 1781.1Scgdfi 1791.1Scgd 1801.1Scgdecho -n ' printer'; lpd 1811.6Scgd 1821.19Scgd# $sendmail_flags is imported from /etc/netstart; 1831.24Scgd# If $sendmail_flags == NO or /etc/sendmail.cf doesn't exist, then 1841.57Smrg# sendmail isn't run. We call sendmail with a full path so that 1851.57Smrg# SIGHUP works. 1861.24Scgdif [ "X${sendmail_flags}" != X"NO" -a -r /etc/sendmail.cf ]; then 1871.56Smrg echo -n ' sendmail'; /usr/sbin/sendmail ${sendmail_flags} 1881.19Scgdfi 1891.19Scgd 1901.1Scgdecho -n ' inetd'; inetd 1911.30Smycroft 1921.51Sthorpej# $rarpd_flags is imported from /etc/netstart; 1931.30Smycroft# If $rarpd_flags == NO or /etc/ethers doesn't exist, then 1941.30Smycroft# rarpd isn't run. 1951.30Smycroftif [ "X${rarpd_flags}" != X"NO" -a -r /etc/ethers ]; then 1961.30Smycroft echo -n ' rarpd'; rarpd ${rarpd_flags} 1971.30Smycroftfi 1981.30Smycroft 1991.60Stls# $rbootd_flags is imported from /etc/netstart; 2001.60Stls# If $rbootd_flags == NO or /etc/rbootd.conf doesn't exist, then 2011.60Stls# rbootd isn't run. 2021.60Stlsif [ "X${rbootd_flags}" != X"NO" -a -r /etc/rbootd.conf ]; then 2031.60Stls echo -n ' rbootd'; rbootd ${rbootd_flags} 2041.60Stlsfi 2051.60Stls 2061.60Stlsecho '.' 2071.60Stls 2081.60Stlsecho -n 'starting rpc daemons:' 2091.60Stlsecho -n ' portmap'; portmap 2101.60Stls 2111.51Sthorpej# $bootparamd_flags is imported from /etc/netstart; 2121.30Smycroft# If $bootparamd_flags == NO or /etc/bootparams doesn't exist, then 2131.30Smycroft# bootparamd isn't run. 2141.30Smycroftif [ "X${bootparamd_flags}" != X"NO" -a -r /etc/bootparams ]; then 2151.60Stls echo -n ' rpc.bootparamd'; rpc.bootparamd ${bootparamd_flags} 2161.60Stlsfi 2171.60Stls 2181.60Stlsif [ "X${ypserv_flags}" != X"NO" ]; then 2191.60Stls echo -n ' ypserv'; ypserv ${ypserv_flags} 2201.60Stlsfi 2211.60Stls 2221.60Stlsif [ "X${yppasswdd_flags}" != X"NO" ]; then 2231.60Stls echo -n ' rpc.yppasswdd'; rpc.yppasswdd ${yppasswdd_flags} 2241.60Stlsfi 2251.60Stls 2261.60Stlsif [ "X${ypbind_flags}" != X"NO" ]; then 2271.60Stls echo -n ' ypbind'; ypbind ${ypbind_flags} 2281.60Stlsfi 2291.60Stls 2301.60Stls# $nfs_server is imported from /etc/netstart; 2311.60Stls# if $nfs_server == YES, the machine is setup for being an nfs server 2321.60Stlsif [ X${nfs_server} = X"YES" -a -r /etc/exports ]; then 2331.60Stls rm -f /var/db/mountdtab 2341.60Stls echo -n > /var/db/mountdtab 2351.60Stls echo -n ' mountd'; mountd 2361.60Stls echo -n ' nfsd'; nfsd -tun 4 2371.60Stlsfi 2381.60Stls 2391.60Stls# $nfs_client is imported from /etc/netstart; 2401.60Stls# if $nfs_client == YES, the machine is setup for being an nfs client 2411.60Stlsif [ X${nfs_client} = X"YES" ]; then 2421.60Stls echo -n ' nfsiod'; nfsiod -n 4 2431.52Sthorpejfi 2441.52Sthorpej 2451.60Stlsif [ X${amd} = X"YES" -a -d ${amd_dir} -a -r ${amd_master} ]; then 2461.60Stls echo -n ' amd' 2471.60Stls amd -l syslog -x error,noinfo,nostats -p \ 2481.60Stls -a ${amd_dir} `cat ${amd_master}` > /var/run/amd.pid 2491.30Smycroftfi 2501.30Smycroft 2511.1Scgdecho '.' 2521.60Stlsmount -a -t nfs 2531.1Scgd 2541.25Smycroft. /etc/rc.local 2551.1Scgd 2561.1Scgddate 2571.1Scgdexit 0 258