rc revision 1.67
11.67Smycroft# $NetBSD: rc,v 1.67 1997/03/10 09:16:13 mycroft 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.67Smycroftif [ "$lkm_init" != NO ] && [ -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.67Smycroftif [ "$syslogd_flags" != NO ]; then 991.67Smycroft if [ "$syslogd_flags" = DEFAULT ]; then 1001.67Smycroft syslogd_flags="" 1011.67Smycroft fi 1021.63Smrg echo 'starting system logger' 1031.63Smrg rm -f /dev/log 1041.63Smrg syslogd $syslogd_flags 1051.63Smrgfi 1061.63Smrg 1071.67Smycroftif [ "$named_flags" != NO ]; then 1081.67Smycroft if [ "$named_flags" = DEFAULT ]; then 1091.67Smycroft named_flags="" 1101.67Smycroft fi 1111.63Smrg echo 'starting name server'; named $named_flags 1121.63Smrgfi 1131.63Smrg 1141.63Smrg# now start the rpc servers, for YP server/client, NFS. 1151.63Smrgecho -n 'starting rpc daemons:' 1161.63Smrg 1171.63Smrg# note that portmap is generally required for all other rpc services. 1181.67Smycroftif [ "$portmap" != NO ]; then 1191.63Smrg echo -n ' portmap'; portmap 1201.63Smrgfi 1211.63Smrg 1221.67Smycroftif [ "$ypserv_flags" != NO ]; then 1231.67Smycroft if [ "$ypserv_flags" = DEFAULT ]; then 1241.67Smycroft ypserv_flags="-d" 1251.67Smycroft fi 1261.63Smrg echo -n ' ypserv'; ypserv $ypserv_flags 1271.63Smrgfi 1281.63Smrg 1291.67Smycroftif [ "$ypbind_flags" != NO ]; then 1301.67Smycroft if [ "$ypbind_flags" = DEFAULT ]; then 1311.67Smycroft ypbind_flags="" 1321.67Smycroft fi 1331.63Smrg echo -n ' ypbind'; ypbind $ypbind_flags 1341.63Smrgfi 1351.63Smrg 1361.67Smycroftif [ "$yppasswdd_flags" != NO ]; then 1371.67Smycroft if [ "$yppasswdd_flags" = DEFAULT ]; then 1381.67Smycroft yppasswdd_flags="" 1391.67Smycroft fi 1401.63Smrg echo -n ' rpc.yppasswdd'; rpc.yppasswdd $yppasswdd_flags 1411.63Smrgfi 1421.63Smrg 1431.67Smycroftif [ "$bootparamd_flags" != NO ] && [ -r /etc/bootparams ]; then 1441.67Smycroft if [ "$bootparamd_flags" = DEFAULT ]; then 1451.67Smycroft bootparamd_flags="" 1461.67Smycroft fi 1471.63Smrg echo -n ' rpc.bootparamd'; rpc.bootparamd $bootparamd_flags 1481.63Smrgfi 1491.63Smrg 1501.67Smycroftnfs_locking=NO 1511.67Smycroft 1521.67Smycroftif [ "$nfs_server" = YES ] && [ -r /etc/exports ]; then 1531.67Smycroft if [ "$nfsd_flags" = DEFAULT ]; then 1541.63Smrg nfsd_flags="-tun 4" 1551.63Smrg fi 1561.63Smrg rm -f /var/db/mountdtab 1571.63Smrg echo -n > /var/db/mountdtab 1581.63Smrg echo -n ' mountd'; mountd $mountd_flags 1591.63Smrg echo -n ' nfsd'; nfsd $nfsd_flags 1601.67Smycroft nfs_locking=MAYBE 1611.1Scgdfi 1621.63Smrg 1631.67Smycroftif [ "$nfs_client" = YES ]; then 1641.67Smycroft if [ "$nfsiod_flags" = DEFAULT ]; then 1651.63Smrg nfsiod_flags="-n 4" 1661.63Smrg fi 1671.63Smrg echo -n ' nfsiod'; nfsiod $nfsiod_flags 1681.67Smycroft nfs_locking=MAYBE 1691.66Sscottrfi 1701.66Sscottr 1711.67Smycroftif [ "$nfs_locking" != NO ]; then 1721.67Smycroft if [ "$statd_flags" != NO ]; then 1731.67Smycroft if [ "$statd_flags" = DEFAULT ]; then 1741.67Smycroft statd_flags="" 1751.67Smycroft fi 1761.66Sscottr echo ' statd'; rpc.statd $statd_flags 1771.66Sscottr fi 1781.66Sscottr 1791.67Smycroft if [ "$lockd_flags" != NO ]; then 1801.67Smycroft if [ "$lockd_flags" = DEFAULT ]; then 1811.67Smycroft lockd_flags="" 1821.67Smycroft fi 1831.66Sscottr echo ' lockd'; rpc.lockd $lockd_flags 1841.66Sscottr fi 1851.63Smrgfi 1861.63Smrg 1871.67Smycroftif [ "$amd_flags" != NO ] && [ -d "$amd_dir" -a -r "$amd_master" ]; then 1881.67Smycroft if [ "$amd_flags" = DEFAULT ]; then 1891.67Smycroft amd_flags="-l syslog -x error,noinfo,nostats" 1901.67Smycroft fi 1911.63Smrg echo -n ' amd' 1921.63Smrg amd $amd_flags -p -a $amd_dir `cat $amd_master` > /var/run/amd.pid 1931.63Smrgfi 1941.63Smrg 1951.1Scgdecho '.' 1961.63Smrgmount -a -t nfs 1971.63Smrg 1981.63Smrgif [ -f /sbin/ldconfig ]; then 1991.63Smrg echo 'creating runtime link editor directory cache.' 2001.63Smrg if [ -s /etc/ld.so.conf ]; then 2011.63Smrg ldconfig `cat /etc/ld.so.conf` 2021.63Smrg else 2031.63Smrg ldconfig 2041.63Smrg fi 2051.63Smrgfi 2061.1Scgd 2071.1Scgd# /var/crash should be a directory or a symbolic link 2081.1Scgd# to the crash directory if core dumps are to be saved. 2091.67Smycroftif [ "$savecore_flags" != NO ] && [ -d /var/crash ]; then 2101.67Smycroft if [ "$savecore_flags" = DEFAULT ]; then 2111.67Smycroft savecore_flags="" 2121.67Smycroft fi 2131.1Scgd echo checking for core dump... 2141.63Smrg savecore $savecore_flags /var/crash 2151.1Scgdfi 2161.1Scgd 2171.47Sderaadt echo -n 'checking quotas:' 2181.47Sderaadtquotacheck -a 2191.47Sderaadt echo ' done.' 2201.47Sderaadtquotaon -a 2211.1Scgd 2221.1Scgd# build ps databases 2231.2Scgdecho 'building databases...' 2241.11Scgdkvm_mkdb /netbsd 2251.1Scgddev_mkdb 2261.1Scgd 2271.1Scgdchmod 666 /dev/tty[pqrs]* 2281.1Scgd 2291.1Scgd# check the password temp/lock file 2301.1Scgdif [ -f /etc/ptmp ] 2311.1Scgdthen 2321.1Scgd logger -s -p auth.err \ 2331.1Scgd 'password file may be incorrect -- /etc/ptmp exists' 2341.1Scgdfi 2351.1Scgd 2361.32Smycroftvirecovery=/var/tmp/vi.recover/recover.* 2371.32Smycroftif [ "$virecovery" != "/var/tmp/vi.recover/recover.*" ]; then 2381.32Smycroft echo preserving editor files 2391.32Smycroft for i in $virecovery; do 2401.32Smycroft sendmail -t < $i 2411.32Smycroft done 2421.32Smycroftfi 2431.1Scgd 2441.1Scgdecho clearing /tmp 2451.1Scgd 2461.65Smikel# Prune quickly with one rm, then use find to clean up /tmp/[lq]* (this 2471.65Smikel# is not needed with mfs /tmp, but doesn't hurt anything). 2481.1Scgd(cd /tmp && rm -rf [a-km-pr-zA-Z]* && 2491.46Sderaadt find . ! -name . ! -name lost+found ! -name quota.user \ 2501.46Sderaadt ! -name quota.group -exec rm -rf -- {} \; -type d -prune) 2511.1Scgd 2521.34Scgdif [ -f /var/account/acct ]; then 2531.34Scgd echo 'turning on accounting'; accton /var/account/acct 2541.34Scgdfi 2551.1Scgd 2561.1Scgdecho -n standard daemons: 2571.1Scgdecho -n ' update'; update 2581.31Sjtcecho -n ' cron'; cron 2591.1Scgdecho '.' 2601.1Scgd 2611.63Smrg# now start all the other daemons 2621.1Scgdecho -n starting network daemons: 2631.1Scgd 2641.67Smycroftif [ "$gated_flags" != NO ] && [ -r /etc/gated.conf ]; then 2651.67Smycroft if [ "$gated_flags" = DEFAULT ]; then 2661.67Smycroft gated_flags="" 2671.67Smycroft fi 2681.48Smycroft echo -n ' gated'; gated $gated_flags 2691.67Smycroftelif [ "$routed_flags" != NO ]; then 2701.67Smycroft if [ "$routed_flags" = DEFAULT ]; then 2711.67Smycroft routed_flags="-q" 2721.67Smycroft fi 2731.48Smycroft echo -n ' routed'; routed $routed_flags 2741.1Scgdfi 2751.1Scgd 2761.67Smycroftif [ "$mrouted_flags" != NO ]; then 2771.67Smycroft if [ "$mrouted_flags" = DEFAULT ]; then 2781.67Smycroft mrouted_flags="" 2791.67Smycroft fi 2801.55Sthorpej echo -n ' mrouted'; mrouted $mrouted_flags 2811.55Sthorpejfi 2821.55Sthorpej 2831.67Smycroftif [ "$timed_flags" != NO ]; then 2841.67Smycroft if [ "$timed_flags" = DEFAULT ]; then 2851.67Smycroft timed_flags="" 2861.67Smycroft fi 2871.67Smycroft echo -n ' timed'; timed $timed_flags 2881.63Smrgfi 2891.63Smrg 2901.67Smycroftif [ "$xntpd_flags" != NO ]; then 2911.67Smycroft if [ "$xntpd_flags" = DEFAULT ]; then 2921.67Smycroft xntpd_flags="" 2931.67Smycroft fi 2941.67Smycroft echo -n ' xntpd'; xntpd $xntpd_flags 2951.61Smrgfi 2961.61Smrg 2971.67Smycroftif [ "$dhcpd_flags" != NO ] && [ -r /etc/dhcpd.conf ]; then 2981.67Smycroft if [ "$dhcpd_flags" = DEFAULT ]; then 2991.67Smycroft dhcpd_flags="" 3001.67Smycroft fi 3011.61Smrg echo -n ' dhcpd'; dhcpd $dhcpd_flags 3021.29Smycroftfi 3031.29Smycroft 3041.67Smycroftif [ "$rwhod" = YES ]; then 3051.48Smycroft echo -n ' rwhod'; rwhod 3061.1Scgdfi 3071.1Scgd 3081.67Smycroftif [ "$lpd_flags" != NO ]; then 3091.67Smycroft if [ "$lpd_flags" = DEFAULT ]; then 3101.67Smycroft lpd_flags="" 3111.67Smycroft fi 3121.63Smrg echo -n ' printer'; lpd $lpd_flags 3131.60Stlsfi 3141.60Stls 3151.63Smrg# We call sendmail with a full path so that SIGHUP works. 3161.67Smycroftif [ "$sendmail_flags" != NO ] && [ -r /etc/sendmail.cf ]; then 3171.67Smycroft if [ "$sendmail_flags" = DEFAULT ]; then 3181.67Smycroft sendmail_flags="-bd -q30m" 3191.67Smycroft fi 3201.63Smrg echo -n ' sendmail'; /usr/sbin/sendmail $sendmail_flags 3211.60Stlsfi 3221.60Stls 3231.67Smycroftif [ "$rarpd_flags" != NO ] && [ -r /etc/ethers ]; then 3241.67Smycroft if [ "$rarpd_flags" = DEFAULT ]; then 3251.67Smycroft rarpd_flags="-a" 3261.67Smycroft fi 3271.63Smrg echo -n ' rarpd'; rarpd $rarpd_flags 3281.60Stlsfi 3291.60Stls 3301.67Smycroftif [ "$rbootd_flags" != NO ] && [ -r /etc/rbootd.conf ]; then 3311.67Smycroft if [ "$rbootd_flags" = DEFAULT ]; then 3321.67Smycroft rbootd_flags="" 3331.67Smycroft fi 3341.63Smrg echo -n ' rbootd'; rbootd $rbootd_flags 3351.52Sthorpejfi 3361.52Sthorpej 3371.67Smycroftif [ "$inetd_flags" != NO ] && [ -r /etc/inetd.conf ]; then 3381.67Smycroft if [ "$inetd_flags" = DEFAULT ]; then 3391.67Smycroft inetd_flags="" 3401.67Smycroft fi 3411.63Smrg echo -n ' inetd'; inetd $inetd_flags 3421.30Smycroftfi 3431.30Smycroft 3441.1Scgdecho '.' 3451.1Scgd 3461.25Smycroft. /etc/rc.local 3471.1Scgd 3481.1Scgddate 3491.1Scgdexit 0 350