rc revision 1.79
11.79Sthorpej# $NetBSD: rc,v 1.79 1997/06/25 23:30:28 thorpej Exp $ 21.73Sperry# originally 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.68Smycroftexport HOME=/ 171.68Smycroftexport PATH=/sbin:/bin:/usr/sbin:/usr/bin 181.50Sthorpej 191.50Sthorpej# Configure ccd devices. 201.63Smrgif [ -f /etc/ccd.conf ]; then 211.50Sthorpej ccdconfig -C 221.50Sthorpejfi 231.1Scgd 241.79Sthorpej# Add all block-type swap devices; these might be necessary 251.79Sthorpej# during disk checks. 261.79Sthorpejswapctl -A -t blk 271.79Sthorpej 281.63Smrgif [ -e /fastboot ]; then 291.38Scgd echo "Fast boot: skipping disk checks." 301.68Smycroftelif [ "$1" = autoboot ]; then 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.1Scgdumount -a >/dev/null 2>&1 671.1Scgdmount -a -t nonfs 681.1Scgdrm -f /fastboot # XXX (root now writeable) 691.40Scgd 701.71Smycroftif [ -f /etc/rc.conf ]; then 711.63Smrg . /etc/rc.conf 721.63Smrgfi 731.63Smrg 741.40Scgd# set flags on ttys. (do early, in case they use tty for SLIP in netstart) 751.40Scgdecho 'setting tty flags' 761.40Scgdttyflags -a 771.1Scgd 781.63Smrg# load any kernel modules specified in /etc/lkm.conf 791.67Smycroftif [ "$lkm_init" != NO ] && [ -f /etc/rc.lkm ]; then 801.63Smrg . /etc/rc.lkm 811.63Smrgfi 821.63Smrg 831.1Scgd# set hostname, turn on network 841.1Scgdecho 'starting network' 851.76Sscottrsh /etc/netstart 861.76Sscottrif [ $? -ne 0 ]; then 871.76Sscottr exit 1 881.76Sscottrfi 891.1Scgd 901.26Sderaadtmount /usr >/dev/null 2>&1 911.42Smycroftmount /var >/dev/null 2>&1 921.79Sthorpej 931.79Sthorpej# "Critical" file systems are now mounted. Go ahead and swap 941.79Sthorpej# to files now, since they will be residing in the critical file 951.79Sthorpej# systems (or, at least, better). 961.79Sthorpejswapctl -A -t noblk 971.26Sderaadt 981.41Sjtc# clean up left-over files 991.41Sjtcrm -f /etc/nologin 1001.41Sjtcrm -f /var/spool/lock/LCK.* 1011.41Sjtcrm -f /var/spool/uucp/STST/* 1021.45Scgd(cd /var/run && { rm -rf -- *; install -c -m 664 -g utmp /dev/null utmp; }) 1031.41Sjtc 1041.63Smrg# start the system logger first, so that all messages 1051.63Smrg# from daemons are logged, and the name server next. 1061.63Smrg 1071.67Smycroftif [ "$syslogd_flags" != NO ]; then 1081.67Smycroft if [ "$syslogd_flags" = DEFAULT ]; then 1091.67Smycroft syslogd_flags="" 1101.67Smycroft fi 1111.63Smrg echo 'starting system logger' 1121.63Smrg rm -f /dev/log 1131.63Smrg syslogd $syslogd_flags 1141.63Smrgfi 1151.63Smrg 1161.67Smycroftif [ "$named_flags" != NO ]; then 1171.67Smycroft if [ "$named_flags" = DEFAULT ]; then 1181.67Smycroft named_flags="" 1191.67Smycroft fi 1201.63Smrg echo 'starting name server'; named $named_flags 1211.63Smrgfi 1221.63Smrg 1231.63Smrg# now start the rpc servers, for YP server/client, NFS. 1241.63Smrgecho -n 'starting rpc daemons:' 1251.63Smrg 1261.63Smrg# note that portmap is generally required for all other rpc services. 1271.67Smycroftif [ "$portmap" != NO ]; then 1281.63Smrg echo -n ' portmap'; portmap 1291.63Smrgfi 1301.63Smrg 1311.67Smycroftif [ "$ypserv_flags" != NO ]; then 1321.67Smycroft if [ "$ypserv_flags" = DEFAULT ]; then 1331.67Smycroft ypserv_flags="-d" 1341.67Smycroft fi 1351.63Smrg echo -n ' ypserv'; ypserv $ypserv_flags 1361.63Smrgfi 1371.63Smrg 1381.67Smycroftif [ "$ypbind_flags" != NO ]; then 1391.67Smycroft if [ "$ypbind_flags" = DEFAULT ]; then 1401.67Smycroft ypbind_flags="" 1411.67Smycroft fi 1421.63Smrg echo -n ' ypbind'; ypbind $ypbind_flags 1431.63Smrgfi 1441.63Smrg 1451.67Smycroftif [ "$yppasswdd_flags" != NO ]; then 1461.67Smycroft if [ "$yppasswdd_flags" = DEFAULT ]; then 1471.67Smycroft yppasswdd_flags="" 1481.67Smycroft fi 1491.63Smrg echo -n ' rpc.yppasswdd'; rpc.yppasswdd $yppasswdd_flags 1501.63Smrgfi 1511.63Smrg 1521.67Smycroftif [ "$bootparamd_flags" != NO ] && [ -r /etc/bootparams ]; then 1531.67Smycroft if [ "$bootparamd_flags" = DEFAULT ]; then 1541.67Smycroft bootparamd_flags="" 1551.67Smycroft fi 1561.63Smrg echo -n ' rpc.bootparamd'; rpc.bootparamd $bootparamd_flags 1571.63Smrgfi 1581.63Smrg 1591.67Smycroftnfs_locking=NO 1601.67Smycroft 1611.67Smycroftif [ "$nfs_server" = YES ] && [ -r /etc/exports ]; then 1621.69Smycroft if [ "$mountd_flags" = DEFAULT ]; then 1631.69Smycroft mountd_flags="" 1641.63Smrg fi 1651.63Smrg rm -f /var/db/mountdtab 1661.63Smrg echo -n > /var/db/mountdtab 1671.63Smrg echo -n ' mountd'; mountd $mountd_flags 1681.69Smycroft if [ "$nfsd_flags" = DEFAULT ]; then 1691.69Smycroft nfsd_flags="-tun 4" 1701.69Smycroft fi 1711.63Smrg echo -n ' nfsd'; nfsd $nfsd_flags 1721.67Smycroft nfs_locking=MAYBE 1731.1Scgdfi 1741.63Smrg 1751.67Smycroftif [ "$nfs_client" = YES ]; then 1761.67Smycroft if [ "$nfsiod_flags" = DEFAULT ]; then 1771.63Smrg nfsiod_flags="-n 4" 1781.63Smrg fi 1791.63Smrg echo -n ' nfsiod'; nfsiod $nfsiod_flags 1801.67Smycroft nfs_locking=MAYBE 1811.66Sscottrfi 1821.66Sscottr 1831.67Smycroftif [ "$nfs_locking" != NO ]; then 1841.67Smycroft if [ "$statd_flags" != NO ]; then 1851.67Smycroft if [ "$statd_flags" = DEFAULT ]; then 1861.67Smycroft statd_flags="" 1871.67Smycroft fi 1881.71Smycroft echo -n ' rpc.statd'; rpc.statd $statd_flags 1891.66Sscottr fi 1901.66Sscottr 1911.67Smycroft if [ "$lockd_flags" != NO ]; then 1921.67Smycroft if [ "$lockd_flags" = DEFAULT ]; then 1931.67Smycroft lockd_flags="" 1941.67Smycroft fi 1951.71Smycroft echo -n ' rpc.lockd'; rpc.lockd $lockd_flags 1961.66Sscottr fi 1971.63Smrgfi 1981.63Smrg 1991.67Smycroftif [ "$amd_flags" != NO ] && [ -d "$amd_dir" -a -r "$amd_master" ]; then 2001.67Smycroft if [ "$amd_flags" = DEFAULT ]; then 2011.67Smycroft amd_flags="-l syslog -x error,noinfo,nostats" 2021.67Smycroft fi 2031.63Smrg echo -n ' amd' 2041.63Smrg amd $amd_flags -p -a $amd_dir `cat $amd_master` > /var/run/amd.pid 2051.63Smrgfi 2061.63Smrg 2071.1Scgdecho '.' 2081.63Smrgmount -a -t nfs 2091.63Smrg 2101.63Smrgif [ -f /sbin/ldconfig ]; then 2111.63Smrg echo 'creating runtime link editor directory cache.' 2121.71Smycroft if [ -f /etc/ld.so.conf ]; then 2131.63Smrg ldconfig `cat /etc/ld.so.conf` 2141.63Smrg else 2151.63Smrg ldconfig 2161.63Smrg fi 2171.63Smrgfi 2181.1Scgd 2191.1Scgd# /var/crash should be a directory or a symbolic link 2201.1Scgd# to the crash directory if core dumps are to be saved. 2211.67Smycroftif [ "$savecore_flags" != NO ] && [ -d /var/crash ]; then 2221.67Smycroft if [ "$savecore_flags" = DEFAULT ]; then 2231.67Smycroft savecore_flags="" 2241.67Smycroft fi 2251.1Scgd echo checking for core dump... 2261.63Smrg savecore $savecore_flags /var/crash 2271.1Scgdfi 2281.1Scgd 2291.47Sderaadt echo -n 'checking quotas:' 2301.47Sderaadtquotacheck -a 2311.47Sderaadt echo ' done.' 2321.47Sderaadtquotaon -a 2331.1Scgd 2341.1Scgd# build ps databases 2351.2Scgdecho 'building databases...' 2361.11Scgdkvm_mkdb /netbsd 2371.1Scgddev_mkdb 2381.1Scgd 2391.1Scgdchmod 666 /dev/tty[pqrs]* 2401.1Scgd 2411.1Scgd# check the password temp/lock file 2421.1Scgdif [ -f /etc/ptmp ] 2431.1Scgdthen 2441.1Scgd logger -s -p auth.err \ 2451.1Scgd 'password file may be incorrect -- /etc/ptmp exists' 2461.1Scgdfi 2471.1Scgd 2481.32Smycroftvirecovery=/var/tmp/vi.recover/recover.* 2491.32Smycroftif [ "$virecovery" != "/var/tmp/vi.recover/recover.*" ]; then 2501.32Smycroft echo preserving editor files 2511.32Smycroft for i in $virecovery; do 2521.32Smycroft sendmail -t < $i 2531.32Smycroft done 2541.32Smycroftfi 2551.1Scgd 2561.1Scgdecho clearing /tmp 2571.1Scgd 2581.65Smikel# Prune quickly with one rm, then use find to clean up /tmp/[lq]* (this 2591.65Smikel# is not needed with mfs /tmp, but doesn't hurt anything). 2601.1Scgd(cd /tmp && rm -rf [a-km-pr-zA-Z]* && 2611.46Sderaadt find . ! -name . ! -name lost+found ! -name quota.user \ 2621.46Sderaadt ! -name quota.group -exec rm -rf -- {} \; -type d -prune) 2631.1Scgd 2641.74Sperry# Update kernel info in /etc/motd 2651.74Sperry# Must be done *before* interactive logins are possible to prevent 2661.74Sperry# possible race conditions. 2671.74Sperryif [ "$update_motd" != NO ]; then 2681.74Sperry echo 'updating motd.' 2691.74Sperry if [ ! -f /etc/motd ]; then 2701.74Sperry install -c -o root -g wheel -m 664 /dev/null /etc/motd 2711.74Sperry fi 2721.74Sperry T=/tmp/_motd 2731.74Sperry rm -f $T 2741.74Sperry sysctl -n kern.version | sed 1q > $T 2751.74Sperry echo "" >> $T 2761.74Sperry sed '1,/^$/d' < /etc/motd >> $T 2771.74Sperry cmp -s $T /etc/motd || cp $T /etc/motd 2781.74Sperry rm -f $T 2791.74Sperryfi 2801.74Sperry 2811.34Scgdif [ -f /var/account/acct ]; then 2821.34Scgd echo 'turning on accounting'; accton /var/account/acct 2831.34Scgdfi 2841.1Scgd 2851.1Scgdecho -n standard daemons: 2861.70Smycroftif [ "$update_flags" != NO ]; then 2871.70Smycroft if [ "$update_flags" = DEFAULT ]; then 2881.70Smycroft update_flags="30" 2891.70Smycroft fi 2901.70Smycroft echo -n ' update'; update $update_flags 2911.70Smycroftfi 2921.31Sjtcecho -n ' cron'; cron 2931.1Scgdecho '.' 2941.1Scgd 2951.63Smrg# now start all the other daemons 2961.1Scgdecho -n starting network daemons: 2971.1Scgd 2981.67Smycroftif [ "$gated_flags" != NO ] && [ -r /etc/gated.conf ]; then 2991.67Smycroft if [ "$gated_flags" = DEFAULT ]; then 3001.67Smycroft gated_flags="" 3011.67Smycroft fi 3021.48Smycroft echo -n ' gated'; gated $gated_flags 3031.67Smycroftelif [ "$routed_flags" != NO ]; then 3041.67Smycroft if [ "$routed_flags" = DEFAULT ]; then 3051.67Smycroft routed_flags="-q" 3061.67Smycroft fi 3071.48Smycroft echo -n ' routed'; routed $routed_flags 3081.1Scgdfi 3091.1Scgd 3101.67Smycroftif [ "$mrouted_flags" != NO ]; then 3111.67Smycroft if [ "$mrouted_flags" = DEFAULT ]; then 3121.67Smycroft mrouted_flags="" 3131.67Smycroft fi 3141.55Sthorpej echo -n ' mrouted'; mrouted $mrouted_flags 3151.55Sthorpejfi 3161.55Sthorpej 3171.67Smycroftif [ "$timed_flags" != NO ]; then 3181.67Smycroft if [ "$timed_flags" = DEFAULT ]; then 3191.67Smycroft timed_flags="" 3201.67Smycroft fi 3211.67Smycroft echo -n ' timed'; timed $timed_flags 3221.75Sperryfi 3231.75Sperry 3241.75Sperryif [ "$ntpdate_hosts" != NO ]; then 3251.75Sperry if [ "$ntpdate_hosts" = DEFAULT ]; then 3261.75Sperry ntpdate_hosts=`awk '/^server/ {print $2}' </etc/ntp.conf` 3271.75Sperry fi 3281.75Sperry 3291.75Sperry if [ -n "$ntpdate_hosts" ]; then 3301.75Sperry echo -n 'ntpdate:' 3311.75Sperry ntpdate -b $ntpdate_hosts 3321.75Sperry fi 3331.63Smrgfi 3341.63Smrg 3351.67Smycroftif [ "$xntpd_flags" != NO ]; then 3361.67Smycroft if [ "$xntpd_flags" = DEFAULT ]; then 3371.77Scjs xntpd_flags="-p /var/run/xntpd.pid" 3381.67Smycroft fi 3391.67Smycroft echo -n ' xntpd'; xntpd $xntpd_flags 3401.61Smrgfi 3411.61Smrg 3421.67Smycroftif [ "$dhcpd_flags" != NO ] && [ -r /etc/dhcpd.conf ]; then 3431.67Smycroft if [ "$dhcpd_flags" = DEFAULT ]; then 3441.67Smycroft dhcpd_flags="" 3451.67Smycroft fi 3461.61Smrg echo -n ' dhcpd'; dhcpd $dhcpd_flags 3471.29Smycroftfi 3481.29Smycroft 3491.67Smycroftif [ "$rwhod" = YES ]; then 3501.48Smycroft echo -n ' rwhod'; rwhod 3511.1Scgdfi 3521.1Scgd 3531.67Smycroftif [ "$lpd_flags" != NO ]; then 3541.67Smycroft if [ "$lpd_flags" = DEFAULT ]; then 3551.67Smycroft lpd_flags="" 3561.67Smycroft fi 3571.63Smrg echo -n ' printer'; lpd $lpd_flags 3581.60Stlsfi 3591.60Stls 3601.63Smrg# We call sendmail with a full path so that SIGHUP works. 3611.67Smycroftif [ "$sendmail_flags" != NO ] && [ -r /etc/sendmail.cf ]; then 3621.67Smycroft if [ "$sendmail_flags" = DEFAULT ]; then 3631.67Smycroft sendmail_flags="-bd -q30m" 3641.67Smycroft fi 3651.63Smrg echo -n ' sendmail'; /usr/sbin/sendmail $sendmail_flags 3661.60Stlsfi 3671.60Stls 3681.67Smycroftif [ "$rarpd_flags" != NO ] && [ -r /etc/ethers ]; then 3691.67Smycroft if [ "$rarpd_flags" = DEFAULT ]; then 3701.67Smycroft rarpd_flags="-a" 3711.67Smycroft fi 3721.63Smrg echo -n ' rarpd'; rarpd $rarpd_flags 3731.60Stlsfi 3741.60Stls 3751.67Smycroftif [ "$rbootd_flags" != NO ] && [ -r /etc/rbootd.conf ]; then 3761.67Smycroft if [ "$rbootd_flags" = DEFAULT ]; then 3771.67Smycroft rbootd_flags="" 3781.67Smycroft fi 3791.63Smrg echo -n ' rbootd'; rbootd $rbootd_flags 3801.72Scjsfi 3811.72Scjs 3821.72Scjsif [ "$mopd_flags" != NO ]; then 3831.72Scjs if [ "$mopd_flags" = DEFAULT ]; then 3841.72Scjs mopd_flags="-a" 3851.72Scjs fi 3861.72Scjs echo -n ' mopd'; mopd $mopd_flags 3871.52Sthorpejfi 3881.52Sthorpej 3891.67Smycroftif [ "$inetd_flags" != NO ] && [ -r /etc/inetd.conf ]; then 3901.67Smycroft if [ "$inetd_flags" = DEFAULT ]; then 3911.67Smycroft inetd_flags="" 3921.67Smycroft fi 3931.63Smrg echo -n ' inetd'; inetd $inetd_flags 3941.30Smycroftfi 3951.30Smycroft 3961.1Scgdecho '.' 3971.73Sperry 3981.73Sperry# Kerberos runs ONLY on the Kerberos server machine 3991.73Sperryif [ "$kerberos_server" = YES ]; then 4001.73Sperry echo -n 'starting kerberos daemons:' 4011.73Sperry echo -n ' kerberos'; kerberos >> /var/log/kerberos.log & 4021.73Sperry echo -n ' kadmind'; kadmind -n >> /var/log/kadmind.log & 4031.73Sperry echo '.' 4041.73Sperryfi 4051.1Scgd 4061.25Smycroft. /etc/rc.local 4071.1Scgd 4081.1Scgddate 4091.1Scgdexit 0 410