[BACK]Return to rc CVS log [TXT][DIR] Up to [cvs.NetBSD.org] / src / etc

Annotation of src/etc/rc, Revision 1.95

1.95    ! drochner    1: #      $NetBSD: rc,v 1.94 1997/10/07 12:11:48 lukem Exp $
1.73      perry       2: #      originally from: @(#)rc 8.2 (Berkeley) 3/17/94
1.1       cgd         3:
                      4: # System startup script run by init on autoboot
                      5: # or after single-user.
                      6: # Output and error are redirected to console by init,
                      7: # and the console is the controlling terminal.
                      8:
                      9: stty status '^T'
                     10:
                     11: # Set shell to ignore SIGINT (2), but not children;
                     12: # shell catches SIGQUIT (3) and returns to single user after fsck.
                     13: trap : 2
                     14: trap : 3       # shouldn't be needed
                     15:
1.68      mycroft    16: export HOME=/
                     17: export PATH=/sbin:/bin:/usr/sbin:/usr/bin
1.50      thorpej    18:
                     19: # Configure ccd devices.
1.63      mrg        20: if [ -f /etc/ccd.conf ]; then
1.50      thorpej    21:        ccdconfig -C
                     22: fi
1.1       cgd        23:
1.79      thorpej    24: # Add all block-type swap devices; these might be necessary
                     25: # during disk checks.
                     26: swapctl -A -t blk
                     27:
1.63      mrg        28: if [ -e /fastboot ]; then
1.38      cgd        29:        echo "Fast boot: skipping disk checks."
1.68      mycroft    30: elif [ "$1" = autoboot ]; then
1.38      cgd        31:        echo "Automatic boot in progress: starting file system checks."
1.1       cgd        32:        fsck -p
                     33:        case $? in
                     34:        0)
                     35:                ;;
                     36:        2)
                     37:                exit 1
                     38:                ;;
                     39:        4)
1.35      cgd        40:                echo "Rebooting..."
1.1       cgd        41:                reboot
1.38      cgd        42:                echo "Reboot failed; help!"
1.1       cgd        43:                exit 1
                     44:                ;;
                     45:        8)
1.38      cgd        46:                echo "Automatic file system check failed; help!"
1.1       cgd        47:                exit 1
                     48:                ;;
                     49:        12)
1.38      cgd        50:                echo "Boot interrupted."
1.1       cgd        51:                exit 1
                     52:                ;;
                     53:        130)
                     54:                # interrupt before catcher installed
                     55:                exit 1
                     56:                ;;
                     57:        *)
1.38      cgd        58:                echo "Unknown error; help!"
1.1       cgd        59:                exit 1
                     60:                ;;
                     61:        esac
                     62: fi
                     63:
1.38      cgd        64: trap "echo 'Boot interrupted.'; exit 1" 3
1.1       cgd        65:
                     66: umount -a >/dev/null 2>&1
1.83      drochner   67: mount /
1.1       cgd        68: rm -f /fastboot                # XXX (root now writeable)
1.40      cgd        69:
1.90      veego      70: if [ -f /etc/rc.subr ]; then
                     71:        . /etc/rc.subr
1.89      cjs        72: else
1.90      veego      73:        echo "Can't read /etc/rc.subr; aborting."
1.89      cjs        74:        exit 1;
                     75: fi
                     76:
1.71      mycroft    77: if [ -f /etc/rc.conf ]; then
1.63      mrg        78:        . /etc/rc.conf
                     79: fi
                     80:
1.89      cjs        81: if [ "$rc_configured" != YES ]; then
                     82:        echo "/etc/rc.conf is not configured. Multiuser boot aborted."
                     83:        exit 1
                     84: fi
                     85:
1.40      cgd        86: # set flags on ttys.  (do early, in case they use tty for SLIP in netstart)
                     87: echo 'setting tty flags'
                     88: ttyflags -a
1.1       cgd        89:
1.83      drochner   90: # load kernel modules specified in /etc/lkm.conf if the /usr filesystem
                     91: # is already present with "/" or can be mounted now
1.93      drochner   92: if checkyesno lkm && [ -f /etc/rc.lkm ]; then
1.83      drochner   93:        mount /usr >/dev/null 2>&1
                     94:        if [ -x /usr/bin/ld ]; then
                     95:                lkmstage=BEFORENET
                     96:                . /etc/rc.lkm
                     97:        fi
1.63      mrg        98: fi
                     99:
1.1       cgd       100: # set hostname, turn on network
                    101: echo 'starting network'
1.76      scottr    102: sh /etc/netstart
                    103: if [ $? -ne 0 ]; then
                    104:        exit 1
                    105: fi
1.1       cgd       106:
1.95    ! drochner  107: for fs in /usr /var $critical_filesystems; do
        !           108:        mount | (
        !           109:                        ismounted=no
        !           110:                        while read what _on on _type type; do
        !           111:                                 if [ $on = $fs ]; then
        !           112:                                                ismounted=yes
        !           113:                                 fi
        !           114:                        done
        !           115:                        if [ $ismounted = no ]; then
        !           116:                        mount $fs >/dev/null 2>&1
        !           117:                fi
        !           118:        )
        !           119: done
1.79      thorpej   120:
                    121: # "Critical" file systems are now mounted.  Go ahead and swap
                    122: # to files now, since they will be residing in the critical file
                    123: # systems (or, at least, better).
                    124: swapctl -A -t noblk
1.26      deraadt   125:
1.41      jtc       126: # clean up left-over files
                    127: rm -f /etc/nologin
                    128: rm -f /var/spool/lock/LCK.*
                    129: rm -f /var/spool/uucp/STST/*
1.45      cgd       130: (cd /var/run && { rm -rf -- *; install -c -m 664 -g utmp /dev/null utmp; })
1.41      jtc       131:
1.84      veego     132: # start the system logger first, so that all messages from daemons
                    133: # are logged, then start savecore to get a dump on low memory systems
                    134: # and then start the name server.
1.63      mrg       135:
1.89      cjs       136: if checkyesno syslogd; then
1.63      mrg       137:        echo 'starting system logger'
                    138:        rm -f /dev/log
                    139:        syslogd $syslogd_flags
1.94      lukem     140: fi
                    141:
                    142: # Enable ipmon (only useful if ipfilter is running)
                    143: # NOTE: requires the IPFILTER_LOG kernel option.
                    144: if checkyesno ipmon; then
                    145:        echo 'starting ipmon'
                    146:        ipmon $ipmon_flags &
1.63      mrg       147: fi
                    148:
1.84      veego     149: # /var/crash should be a directory or a symbolic link
                    150: # to the crash directory if core dumps are to be saved.
1.89      cjs       151: if checkyesno savecore; then
                    152:        if [ -d /var/crash ]; then
                    153:                echo checking for core dump...
                    154:                savecore $savecore_flags /var/crash
                    155:        else
                    156:                logger -s "WARNING: no /var/crash directory; savecore not run."
1.84      veego     157:        fi
                    158: fi
                    159:
1.89      cjs       160: if checkyesno named; then
                    161:        echo 'starting name server';    named $named_flags
                    162: fi
                    163:
                    164: # set time, if requested
                    165: if checkyesno ntpdate; then
1.91      mikel     166:        if [ -z "$ntpdate_hosts" ]; then
1.89      cjs       167:                ntpdate_hosts=`awk '/^server/ {print $2}' </etc/ntp.conf`
                    168:        fi
                    169:        if [ -n "$ntpdate_hosts"  ]; then
                    170:                echo 'Setting date via ntp.'
                    171:                ntpdate -b $ntpdate_hosts
1.67      mycroft   172:        fi
1.63      mrg       173: fi
                    174:
1.84      veego     175: # now start the rpc servers, for YP server/client.
1.63      mrg       176: echo -n 'starting rpc daemons:'
                    177:
                    178: # note that portmap is generally required for all other rpc services.
1.89      cjs       179: if checkyesno portmap; then
1.63      mrg       180:        echo -n ' portmap';             portmap
                    181: fi
                    182:
1.89      cjs       183: if checkyesno ypserv; then
1.63      mrg       184:         echo -n ' ypserv';              ypserv $ypserv_flags
                    185: fi
                    186:
1.89      cjs       187: if checkyesno ypbind; then
1.63      mrg       188:         echo -n ' ypbind';              ypbind $ypbind_flags
                    189: fi
                    190:
1.89      cjs       191: if checkyesno yppasswdd; then
1.63      mrg       192:         echo -n ' rpc.yppasswdd';       rpc.yppasswdd $yppasswdd_flags
                    193: fi
                    194:
1.89      cjs       195: if checkyesno bootparamd; then
                    196:        if [ -r /etc/bootparams ]; then
                    197:                echo -n ' rpc.bootparamd'; rpc.bootparamd $bootparamd_flags
                    198:        else
                    199:                echo
                    200:                logger -s "WARNING: /etc/bootparams not found. " \
                    201:                    "bootparamd not started."
1.67      mycroft   202:        fi
1.63      mrg       203: fi
                    204:
1.84      veego     205: echo '.'
                    206:
                    207: # load kernel modules specified in /etc/lkm.conf
1.89      cjs       208: if checkyesno lkm; then
                    209:        if [ -r /etc/rc.lkm ]; then
                    210:                lkmstage=BEFOREMOUNT
                    211:                . /etc/rc.lkm
                    212:        else
                    213:                logger -s "WARNING: /etc/rc.lkm not found; LKMs not loaded."
                    214:        fi
1.84      veego     215: fi
                    216:
                    217: mount -a
                    218:
                    219: # now start the rpc servers, for NFS server/client.
1.90      veego     220: echo -n 'starting nfs daemons:'
1.84      veego     221:
1.67      mycroft   222: nfs_locking=NO
                    223:
1.89      cjs       224: if checkyesno nfs_server; then
                    225:        if [ -r /etc/exports ]; then
                    226:                rm -f /var/db/mountdtab
                    227:                echo -n > /var/db/mountdtab
                    228:                echo -n ' mountd';              mountd $mountd_flags
                    229:                echo -n ' nfsd';                nfsd $nfsd_flags
                    230:                nfs_locking=MAYBE
                    231:        else
                    232:                echo
                    233:                logger -s "WARNING: /etc/exports not readable; " \
                    234:                    "NFS server not started."
1.69      mycroft   235:        fi
1.1       cgd       236: fi
1.63      mrg       237:
1.89      cjs       238: if checkyesno nfs_client; then
1.63      mrg       239:         echo -n ' nfsiod';              nfsiod $nfsiod_flags
1.67      mycroft   240:        nfs_locking=MAYBE
1.66      scottr    241: fi
                    242:
1.67      mycroft   243: if [ "$nfs_locking" != NO ]; then
1.89      cjs       244:        if checkyesno statd; then
1.71      mycroft   245:                echo -n ' rpc.statd';           rpc.statd $statd_flags
1.66      scottr    246:        fi
1.89      cjs       247:        if checkyesno lockd; then
1.71      mycroft   248:                echo -n ' rpc.lockd';           rpc.lockd $lockd_flags
1.66      scottr    249:        fi
1.63      mrg       250: fi
                    251:
1.89      cjs       252: if checkyesno amd; then
                    253:        if [ -d "$amd_dir" ]; then
                    254:                if [ -r "$amd_master" ]; then
                    255:                        echo -n ' amd'
                    256:                        amd $amd_flags -p -a $amd_dir `cat $amd_master` \
                    257:                            > /var/run/amd.pid
                    258:                else
                    259:                        echo
                    260:                        logger -s "WARNING: \$amd_master ($amd_master)not " \
                    261:                            "readable; amd not started."
                    262:                fi
                    263:        else
                    264:                echo
                    265:                logger -s "WARNING: \$amd_dir ($amd_dir) not a directory; " \
                    266:                    "amd not started."
1.67      mycroft   267:        fi
1.63      mrg       268: fi
                    269:
1.1       cgd       270: echo '.'
1.83      drochner  271:
1.63      mrg       272: if [ -f /sbin/ldconfig ]; then
                    273:        echo 'creating runtime link editor directory cache.'
1.88      thorpej   274:        ldconfig
1.63      mrg       275: fi
1.83      drochner  276:
                    277: # load kernel modules specified in /etc/lkm.conf
1.89      cjs       278: if checkyesno lkm && [ -f /etc/rc.lkm ]; then
1.83      drochner  279:        lkmstage=AFTERMOUNT
                    280:        . /etc/rc.lkm
1.1       cgd       281: fi
                    282:
1.89      cjs       283: echo -n 'checking quotas:'; quotacheck -a; echo ' done.'
1.47      deraadt   284: quotaon -a
1.1       cgd       285:
                    286: # build ps databases
1.2       cgd       287: echo 'building databases...'
1.11      cgd       288: kvm_mkdb /netbsd
1.1       cgd       289: dev_mkdb
                    290:
                    291: chmod 666 /dev/tty[pqrs]*
                    292:
                    293: # check the password temp/lock file
                    294: if [ -f /etc/ptmp ]
                    295: then
                    296:        logger -s -p auth.err \
                    297:        'password file may be incorrect -- /etc/ptmp exists'
                    298: fi
                    299:
1.85      perry     300: virecovery=`echo /var/tmp/vi.recover/recover.*`
1.32      mycroft   301: if [ "$virecovery" != "/var/tmp/vi.recover/recover.*" ]; then
                    302:        echo preserving editor files
                    303:        for i in $virecovery; do
                    304:                sendmail -t < $i
                    305:        done
                    306: fi
1.1       cgd       307:
                    308: echo clearing /tmp
                    309:
1.65      mikel     310: # Prune quickly with one rm, then use find to clean up /tmp/[lq]* (this
                    311: # is not needed with mfs /tmp, but doesn't hurt anything).
1.1       cgd       312: (cd /tmp && rm -rf [a-km-pr-zA-Z]* &&
1.46      deraadt   313:     find . ! -name . ! -name lost+found ! -name quota.user \
                    314:        ! -name quota.group -exec rm -rf -- {} \; -type d -prune)
1.1       cgd       315:
1.74      perry     316: # Update kernel info in /etc/motd
                    317: # Must be done *before* interactive logins are possible to prevent
                    318: # possible race conditions.
1.89      cjs       319: if checkyesno update_motd; then
1.74      perry     320:        echo 'updating motd.'
                    321:        if [ ! -f /etc/motd ]; then
                    322:                install -c -o root -g wheel -m 664 /dev/null /etc/motd
                    323:        fi
                    324:        T=/tmp/_motd
                    325:        rm -f $T
                    326:        sysctl -n kern.version | sed 1q > $T
                    327:        echo "" >> $T
                    328:        sed '1,/^$/d' < /etc/motd >> $T
                    329:        cmp -s $T /etc/motd || cp $T /etc/motd
                    330:        rm -f $T
                    331: fi
                    332:
1.34      cgd       333: if [ -f /var/account/acct ]; then
                    334:        echo 'turning on accounting';   accton /var/account/acct
                    335: fi
1.1       cgd       336:
                    337: echo -n standard daemons:
1.89      cjs       338: if checkyesno update; then
1.70      mycroft   339:        echo -n ' update';              update $update_flags
                    340: fi
1.31      jtc       341: echo -n ' cron';               cron
1.1       cgd       342: echo '.'
                    343:
1.63      mrg       344: # now start all the other daemons
1.1       cgd       345: echo -n starting network daemons:
                    346:
1.89      cjs       347: if checkyesno gated && checkyesno routed; then
                    348:        echo
                    349:        logger -s "WARNING: gated and routed both requested to be run: " \
                    350:            "running only gated."
                    351:        routed=NO
                    352: fi
                    353:
                    354: if checkyesno gated; then
                    355:        if [ -r /etc/gated.conf ]; then
                    356:                echo -n ' gated';               gated $gated_flags
                    357:        else
                    358:                logger -s "WARNING: no /etc/gated.conf; gated not started."
1.67      mycroft   359:        fi
1.89      cjs       360: fi
                    361:
                    362: if checkyesno routed; then
1.48      mycroft   363:        echo -n ' routed';              routed $routed_flags
1.1       cgd       364: fi
                    365:
1.89      cjs       366: if checkyesno mrouted; then
1.55      thorpej   367:        echo -n ' mrouted';             mrouted $mrouted_flags
                    368: fi
                    369:
1.89      cjs       370: if checkyesno timed; then
1.67      mycroft   371:        echo -n ' timed';               timed $timed_flags
1.63      mrg       372: fi
                    373:
1.89      cjs       374: if checkyesno xntpd; then
1.67      mycroft   375:        echo -n ' xntpd';               xntpd $xntpd_flags
1.61      mrg       376: fi
                    377:
1.89      cjs       378: if checkyesno dhcpd; then
                    379:        if [ -r /etc/dhcpd.conf ]; then
                    380:                echo -n ' dhcpd';               dhcpd $dhcpd_flags
                    381:        else
                    382:                echo
                    383:                logger -s "WARNING: /etc/dhcpd.conf not readable; " \
                    384:                    "dhcpd not started."
1.67      mycroft   385:        fi
1.29      mycroft   386: fi
                    387:
1.89      cjs       388: if checkyesno rwhod; then
1.48      mycroft   389:        echo -n ' rwhod';               rwhod
1.1       cgd       390: fi
                    391:
1.89      cjs       392: if checkyesno lpd; then
                    393:        echo -n ' lpd';                 lpd $lpd_flags
1.60      tls       394: fi
                    395:
1.63      mrg       396: # We call sendmail with a full path so that SIGHUP works.
1.89      cjs       397: if checkyesno sendmail; then
                    398:        if [ -r /etc/sendmail.cf ]; then
                    399:                echo -n ' sendmail';    /usr/sbin/sendmail $sendmail_flags
                    400:        else
                    401:                echo
                    402:                logger -s "WARNING: /etc/sendmail.cf not readable; " \
                    403:                    "sendmail not started."
1.67      mycroft   404:        fi
1.60      tls       405: fi
                    406:
1.89      cjs       407: if checkyesno rarpd; then
                    408:        if [ -r /etc/ethers ]; then
                    409:                echo -n ' rarpd';       rarpd $rarpd_flags
                    410:        else
                    411:                echo
                    412:                logger -s "WARNING: /etc/ethers not readable; " \
                    413:                    "rarpd not started."
1.67      mycroft   414:        fi
1.60      tls       415: fi
                    416:
1.89      cjs       417: if checkyesno rbootd; then
                    418:        if [ -r /etc/rbootd.conf ]; then
                    419:                echo -n ' rbootd';      rbootd $rbootd_flags
                    420:        else
                    421:                echo
                    422:                logger -s "WARNING: /etc/rbootd.conf not readable; " \
                    423:                    "rarpd not started."
1.67      mycroft   424:        fi
1.72      cjs       425: fi
                    426:
1.89      cjs       427: if checkyesno mopd; then
1.72      cjs       428:        echo -n ' mopd';                mopd $mopd_flags
1.86      perry     429: fi
                    430:
1.89      cjs       431: if checkyesno apmd; then
1.86      perry     432:        echo -n ' apmd';                apmd $apmd_flags
1.52      thorpej   433: fi
                    434:
1.89      cjs       435: if checkyesno inetd; then
                    436:        if [ -r /etc/inetd.conf ]; then
                    437:                echo -n ' inetd';       inetd $inetd_flags
                    438:        else
                    439:                echo
                    440:                logger -s "WARNING: /etc/inetd.conf not readable; " \
                    441:                    "inetd not started."
1.67      mycroft   442:        fi
1.30      mycroft   443: fi
                    444:
1.1       cgd       445: echo '.'
1.73      perry     446:
                    447: # Kerberos runs ONLY on the Kerberos server machine
1.89      cjs       448: if checkyesno kerberos; then
1.73      perry     449:        echo -n 'starting kerberos daemons:'
                    450:        echo -n ' kerberos';    kerberos >> /var/log/kerberos.log &
                    451:        echo -n ' kadmind';     kadmind -n >> /var/log/kadmind.log &
                    452:        echo '.'
                    453: fi
1.1       cgd       454:
1.25      mycroft   455: . /etc/rc.local
1.1       cgd       456:
                    457: date
                    458: exit 0

CVSweb <webmaster@jp.NetBSD.org>