rc revision 1.76
11.76Sscottr# $NetBSD: rc,v 1.76 1997/04/29 04:58:38 scottr 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.63Smrgif [ -e /fastboot ]; then 251.38Scgd echo "Fast boot: skipping disk checks." 261.68Smycroftelif [ "$1" = autoboot ]; then 271.38Scgd echo "Automatic boot in progress: starting file system checks." 281.1Scgd fsck -p 291.1Scgd case $? in 301.1Scgd 0) 311.1Scgd ;; 321.1Scgd 2) 331.1Scgd exit 1 341.1Scgd ;; 351.1Scgd 4) 361.35Scgd echo "Rebooting..." 371.1Scgd reboot 381.38Scgd echo "Reboot failed; help!" 391.1Scgd exit 1 401.1Scgd ;; 411.1Scgd 8) 421.38Scgd echo "Automatic file system check failed; help!" 431.1Scgd exit 1 441.1Scgd ;; 451.1Scgd 12) 461.38Scgd echo "Boot interrupted." 471.1Scgd exit 1 481.1Scgd ;; 491.1Scgd 130) 501.1Scgd # interrupt before catcher installed 511.1Scgd exit 1 521.1Scgd ;; 531.1Scgd *) 541.38Scgd echo "Unknown error; help!" 551.1Scgd exit 1 561.1Scgd ;; 571.1Scgd esac 581.1Scgdfi 591.1Scgd 601.38Scgdtrap "echo 'Boot interrupted.'; exit 1" 3 611.1Scgd 621.1Scgdswapon -a 631.1Scgd 641.1Scgdumount -a >/dev/null 2>&1 651.1Scgdmount -a -t nonfs 661.1Scgdrm -f /fastboot # XXX (root now writeable) 671.40Scgd 681.71Smycroftif [ -f /etc/rc.conf ]; then 691.63Smrg . /etc/rc.conf 701.63Smrgfi 711.63Smrg 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.63Smrg# load any kernel modules specified in /etc/lkm.conf 771.67Smycroftif [ "$lkm_init" != NO ] && [ -f /etc/rc.lkm ]; then 781.63Smrg . /etc/rc.lkm 791.63Smrgfi 801.63Smrg 811.1Scgd# set hostname, turn on network 821.1Scgdecho 'starting network' 831.76Sscottrsh /etc/netstart 841.76Sscottrif [ $? -ne 0 ]; then 851.76Sscottr exit 1 861.76Sscottrfi 871.1Scgd 881.26Sderaadtmount /usr >/dev/null 2>&1 891.42Smycroftmount /var >/dev/null 2>&1 901.26Sderaadt 911.41Sjtc# clean up left-over files 921.41Sjtcrm -f /etc/nologin 931.41Sjtcrm -f /var/spool/lock/LCK.* 941.41Sjtcrm -f /var/spool/uucp/STST/* 951.45Scgd(cd /var/run && { rm -rf -- *; install -c -m 664 -g utmp /dev/null utmp; }) 961.41Sjtc 971.63Smrg# start the system logger first, so that all messages 981.63Smrg# from daemons are logged, and the name server next. 991.63Smrg 1001.67Smycroftif [ "$syslogd_flags" != NO ]; then 1011.67Smycroft if [ "$syslogd_flags" = DEFAULT ]; then 1021.67Smycroft syslogd_flags="" 1031.67Smycroft fi 1041.63Smrg echo 'starting system logger' 1051.63Smrg rm -f /dev/log 1061.63Smrg syslogd $syslogd_flags 1071.63Smrgfi 1081.63Smrg 1091.67Smycroftif [ "$named_flags" != NO ]; then 1101.67Smycroft if [ "$named_flags" = DEFAULT ]; then 1111.67Smycroft named_flags="" 1121.67Smycroft fi 1131.63Smrg echo 'starting name server'; named $named_flags 1141.63Smrgfi 1151.63Smrg 1161.63Smrg# now start the rpc servers, for YP server/client, NFS. 1171.63Smrgecho -n 'starting rpc daemons:' 1181.63Smrg 1191.63Smrg# note that portmap is generally required for all other rpc services. 1201.67Smycroftif [ "$portmap" != NO ]; then 1211.63Smrg echo -n ' portmap'; portmap 1221.63Smrgfi 1231.63Smrg 1241.67Smycroftif [ "$ypserv_flags" != NO ]; then 1251.67Smycroft if [ "$ypserv_flags" = DEFAULT ]; then 1261.67Smycroft ypserv_flags="-d" 1271.67Smycroft fi 1281.63Smrg echo -n ' ypserv'; ypserv $ypserv_flags 1291.63Smrgfi 1301.63Smrg 1311.67Smycroftif [ "$ypbind_flags" != NO ]; then 1321.67Smycroft if [ "$ypbind_flags" = DEFAULT ]; then 1331.67Smycroft ypbind_flags="" 1341.67Smycroft fi 1351.63Smrg echo -n ' ypbind'; ypbind $ypbind_flags 1361.63Smrgfi 1371.63Smrg 1381.67Smycroftif [ "$yppasswdd_flags" != NO ]; then 1391.67Smycroft if [ "$yppasswdd_flags" = DEFAULT ]; then 1401.67Smycroft yppasswdd_flags="" 1411.67Smycroft fi 1421.63Smrg echo -n ' rpc.yppasswdd'; rpc.yppasswdd $yppasswdd_flags 1431.63Smrgfi 1441.63Smrg 1451.67Smycroftif [ "$bootparamd_flags" != NO ] && [ -r /etc/bootparams ]; then 1461.67Smycroft if [ "$bootparamd_flags" = DEFAULT ]; then 1471.67Smycroft bootparamd_flags="" 1481.67Smycroft fi 1491.63Smrg echo -n ' rpc.bootparamd'; rpc.bootparamd $bootparamd_flags 1501.63Smrgfi 1511.63Smrg 1521.67Smycroftnfs_locking=NO 1531.67Smycroft 1541.67Smycroftif [ "$nfs_server" = YES ] && [ -r /etc/exports ]; then 1551.69Smycroft if [ "$mountd_flags" = DEFAULT ]; then 1561.69Smycroft mountd_flags="" 1571.63Smrg fi 1581.63Smrg rm -f /var/db/mountdtab 1591.63Smrg echo -n > /var/db/mountdtab 1601.63Smrg echo -n ' mountd'; mountd $mountd_flags 1611.69Smycroft if [ "$nfsd_flags" = DEFAULT ]; then 1621.69Smycroft nfsd_flags="-tun 4" 1631.69Smycroft fi 1641.63Smrg echo -n ' nfsd'; nfsd $nfsd_flags 1651.67Smycroft nfs_locking=MAYBE 1661.1Scgdfi 1671.63Smrg 1681.67Smycroftif [ "$nfs_client" = YES ]; then 1691.67Smycroft if [ "$nfsiod_flags" = DEFAULT ]; then 1701.63Smrg nfsiod_flags="-n 4" 1711.63Smrg fi 1721.63Smrg echo -n ' nfsiod'; nfsiod $nfsiod_flags 1731.67Smycroft nfs_locking=MAYBE 1741.66Sscottrfi 1751.66Sscottr 1761.67Smycroftif [ "$nfs_locking" != NO ]; then 1771.67Smycroft if [ "$statd_flags" != NO ]; then 1781.67Smycroft if [ "$statd_flags" = DEFAULT ]; then 1791.67Smycroft statd_flags="" 1801.67Smycroft fi 1811.71Smycroft echo -n ' rpc.statd'; rpc.statd $statd_flags 1821.66Sscottr fi 1831.66Sscottr 1841.67Smycroft if [ "$lockd_flags" != NO ]; then 1851.67Smycroft if [ "$lockd_flags" = DEFAULT ]; then 1861.67Smycroft lockd_flags="" 1871.67Smycroft fi 1881.71Smycroft echo -n ' rpc.lockd'; rpc.lockd $lockd_flags 1891.66Sscottr fi 1901.63Smrgfi 1911.63Smrg 1921.67Smycroftif [ "$amd_flags" != NO ] && [ -d "$amd_dir" -a -r "$amd_master" ]; then 1931.67Smycroft if [ "$amd_flags" = DEFAULT ]; then 1941.67Smycroft amd_flags="-l syslog -x error,noinfo,nostats" 1951.67Smycroft fi 1961.63Smrg echo -n ' amd' 1971.63Smrg amd $amd_flags -p -a $amd_dir `cat $amd_master` > /var/run/amd.pid 1981.63Smrgfi 1991.63Smrg 2001.1Scgdecho '.' 2011.63Smrgmount -a -t nfs 2021.63Smrg 2031.63Smrgif [ -f /sbin/ldconfig ]; then 2041.63Smrg echo 'creating runtime link editor directory cache.' 2051.71Smycroft if [ -f /etc/ld.so.conf ]; then 2061.63Smrg ldconfig `cat /etc/ld.so.conf` 2071.63Smrg else 2081.63Smrg ldconfig 2091.63Smrg fi 2101.63Smrgfi 2111.1Scgd 2121.1Scgd# /var/crash should be a directory or a symbolic link 2131.1Scgd# to the crash directory if core dumps are to be saved. 2141.67Smycroftif [ "$savecore_flags" != NO ] && [ -d /var/crash ]; then 2151.67Smycroft if [ "$savecore_flags" = DEFAULT ]; then 2161.67Smycroft savecore_flags="" 2171.67Smycroft fi 2181.1Scgd echo checking for core dump... 2191.63Smrg savecore $savecore_flags /var/crash 2201.1Scgdfi 2211.1Scgd 2221.47Sderaadt echo -n 'checking quotas:' 2231.47Sderaadtquotacheck -a 2241.47Sderaadt echo ' done.' 2251.47Sderaadtquotaon -a 2261.1Scgd 2271.1Scgd# build ps databases 2281.2Scgdecho 'building databases...' 2291.11Scgdkvm_mkdb /netbsd 2301.1Scgddev_mkdb 2311.1Scgd 2321.1Scgdchmod 666 /dev/tty[pqrs]* 2331.1Scgd 2341.1Scgd# check the password temp/lock file 2351.1Scgdif [ -f /etc/ptmp ] 2361.1Scgdthen 2371.1Scgd logger -s -p auth.err \ 2381.1Scgd 'password file may be incorrect -- /etc/ptmp exists' 2391.1Scgdfi 2401.1Scgd 2411.32Smycroftvirecovery=/var/tmp/vi.recover/recover.* 2421.32Smycroftif [ "$virecovery" != "/var/tmp/vi.recover/recover.*" ]; then 2431.32Smycroft echo preserving editor files 2441.32Smycroft for i in $virecovery; do 2451.32Smycroft sendmail -t < $i 2461.32Smycroft done 2471.32Smycroftfi 2481.1Scgd 2491.1Scgdecho clearing /tmp 2501.1Scgd 2511.65Smikel# Prune quickly with one rm, then use find to clean up /tmp/[lq]* (this 2521.65Smikel# is not needed with mfs /tmp, but doesn't hurt anything). 2531.1Scgd(cd /tmp && rm -rf [a-km-pr-zA-Z]* && 2541.46Sderaadt find . ! -name . ! -name lost+found ! -name quota.user \ 2551.46Sderaadt ! -name quota.group -exec rm -rf -- {} \; -type d -prune) 2561.1Scgd 2571.74Sperry# Update kernel info in /etc/motd 2581.74Sperry# Must be done *before* interactive logins are possible to prevent 2591.74Sperry# possible race conditions. 2601.74Sperryif [ "$update_motd" != NO ]; then 2611.74Sperry echo 'updating motd.' 2621.74Sperry if [ ! -f /etc/motd ]; then 2631.74Sperry install -c -o root -g wheel -m 664 /dev/null /etc/motd 2641.74Sperry fi 2651.74Sperry T=/tmp/_motd 2661.74Sperry rm -f $T 2671.74Sperry sysctl -n kern.version | sed 1q > $T 2681.74Sperry echo "" >> $T 2691.74Sperry sed '1,/^$/d' < /etc/motd >> $T 2701.74Sperry cmp -s $T /etc/motd || cp $T /etc/motd 2711.74Sperry rm -f $T 2721.74Sperryfi 2731.74Sperry 2741.34Scgdif [ -f /var/account/acct ]; then 2751.34Scgd echo 'turning on accounting'; accton /var/account/acct 2761.34Scgdfi 2771.1Scgd 2781.1Scgdecho -n standard daemons: 2791.70Smycroftif [ "$update_flags" != NO ]; then 2801.70Smycroft if [ "$update_flags" = DEFAULT ]; then 2811.70Smycroft update_flags="30" 2821.70Smycroft fi 2831.70Smycroft echo -n ' update'; update $update_flags 2841.70Smycroftfi 2851.31Sjtcecho -n ' cron'; cron 2861.1Scgdecho '.' 2871.1Scgd 2881.63Smrg# now start all the other daemons 2891.1Scgdecho -n starting network daemons: 2901.1Scgd 2911.67Smycroftif [ "$gated_flags" != NO ] && [ -r /etc/gated.conf ]; then 2921.67Smycroft if [ "$gated_flags" = DEFAULT ]; then 2931.67Smycroft gated_flags="" 2941.67Smycroft fi 2951.48Smycroft echo -n ' gated'; gated $gated_flags 2961.67Smycroftelif [ "$routed_flags" != NO ]; then 2971.67Smycroft if [ "$routed_flags" = DEFAULT ]; then 2981.67Smycroft routed_flags="-q" 2991.67Smycroft fi 3001.48Smycroft echo -n ' routed'; routed $routed_flags 3011.1Scgdfi 3021.1Scgd 3031.67Smycroftif [ "$mrouted_flags" != NO ]; then 3041.67Smycroft if [ "$mrouted_flags" = DEFAULT ]; then 3051.67Smycroft mrouted_flags="" 3061.67Smycroft fi 3071.55Sthorpej echo -n ' mrouted'; mrouted $mrouted_flags 3081.55Sthorpejfi 3091.55Sthorpej 3101.67Smycroftif [ "$timed_flags" != NO ]; then 3111.67Smycroft if [ "$timed_flags" = DEFAULT ]; then 3121.67Smycroft timed_flags="" 3131.67Smycroft fi 3141.67Smycroft echo -n ' timed'; timed $timed_flags 3151.75Sperryfi 3161.75Sperry 3171.75Sperryif [ "$ntpdate_hosts" != NO ]; then 3181.75Sperry if [ "$ntpdate_hosts" = DEFAULT ]; then 3191.75Sperry ntpdate_hosts=`awk '/^server/ {print $2}' </etc/ntp.conf` 3201.75Sperry fi 3211.75Sperry 3221.75Sperry if [ -n "$ntpdate_hosts" ]; then 3231.75Sperry echo -n 'ntpdate:' 3241.75Sperry ntpdate -b $ntpdate_hosts 3251.75Sperry fi 3261.63Smrgfi 3271.63Smrg 3281.67Smycroftif [ "$xntpd_flags" != NO ]; then 3291.67Smycroft if [ "$xntpd_flags" = DEFAULT ]; then 3301.67Smycroft xntpd_flags="" 3311.67Smycroft fi 3321.67Smycroft echo -n ' xntpd'; xntpd $xntpd_flags 3331.61Smrgfi 3341.61Smrg 3351.67Smycroftif [ "$dhcpd_flags" != NO ] && [ -r /etc/dhcpd.conf ]; then 3361.67Smycroft if [ "$dhcpd_flags" = DEFAULT ]; then 3371.67Smycroft dhcpd_flags="" 3381.67Smycroft fi 3391.61Smrg echo -n ' dhcpd'; dhcpd $dhcpd_flags 3401.29Smycroftfi 3411.29Smycroft 3421.67Smycroftif [ "$rwhod" = YES ]; then 3431.48Smycroft echo -n ' rwhod'; rwhod 3441.1Scgdfi 3451.1Scgd 3461.67Smycroftif [ "$lpd_flags" != NO ]; then 3471.67Smycroft if [ "$lpd_flags" = DEFAULT ]; then 3481.67Smycroft lpd_flags="" 3491.67Smycroft fi 3501.63Smrg echo -n ' printer'; lpd $lpd_flags 3511.60Stlsfi 3521.60Stls 3531.63Smrg# We call sendmail with a full path so that SIGHUP works. 3541.67Smycroftif [ "$sendmail_flags" != NO ] && [ -r /etc/sendmail.cf ]; then 3551.67Smycroft if [ "$sendmail_flags" = DEFAULT ]; then 3561.67Smycroft sendmail_flags="-bd -q30m" 3571.67Smycroft fi 3581.63Smrg echo -n ' sendmail'; /usr/sbin/sendmail $sendmail_flags 3591.60Stlsfi 3601.60Stls 3611.67Smycroftif [ "$rarpd_flags" != NO ] && [ -r /etc/ethers ]; then 3621.67Smycroft if [ "$rarpd_flags" = DEFAULT ]; then 3631.67Smycroft rarpd_flags="-a" 3641.67Smycroft fi 3651.63Smrg echo -n ' rarpd'; rarpd $rarpd_flags 3661.60Stlsfi 3671.60Stls 3681.67Smycroftif [ "$rbootd_flags" != NO ] && [ -r /etc/rbootd.conf ]; then 3691.67Smycroft if [ "$rbootd_flags" = DEFAULT ]; then 3701.67Smycroft rbootd_flags="" 3711.67Smycroft fi 3721.63Smrg echo -n ' rbootd'; rbootd $rbootd_flags 3731.72Scjsfi 3741.72Scjs 3751.72Scjsif [ "$mopd_flags" != NO ]; then 3761.72Scjs if [ "$mopd_flags" = DEFAULT ]; then 3771.72Scjs mopd_flags="-a" 3781.72Scjs fi 3791.72Scjs echo -n ' mopd'; mopd $mopd_flags 3801.52Sthorpejfi 3811.52Sthorpej 3821.67Smycroftif [ "$inetd_flags" != NO ] && [ -r /etc/inetd.conf ]; then 3831.67Smycroft if [ "$inetd_flags" = DEFAULT ]; then 3841.67Smycroft inetd_flags="" 3851.67Smycroft fi 3861.63Smrg echo -n ' inetd'; inetd $inetd_flags 3871.30Smycroftfi 3881.30Smycroft 3891.1Scgdecho '.' 3901.73Sperry 3911.73Sperry# Kerberos runs ONLY on the Kerberos server machine 3921.73Sperryif [ "$kerberos_server" = YES ]; then 3931.73Sperry echo -n 'starting kerberos daemons:' 3941.73Sperry echo -n ' kerberos'; kerberos >> /var/log/kerberos.log & 3951.73Sperry echo -n ' kadmind'; kadmind -n >> /var/log/kadmind.log & 3961.73Sperry echo '.' 3971.73Sperryfi 3981.1Scgd 3991.25Smycroft. /etc/rc.local 4001.1Scgd 4011.1Scgddate 4021.1Scgdexit 0 403