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

Annotation of src/etc/rc, Revision 1.124

1.124   ! cjs         1: #      $NetBSD: rc,v 1.123 1999/03/26 13:45:47 drochner 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=/
1.96      jonathan   17: export PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/X11R6/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.107     tron       23:
                     24: # Configure raid devices.
                     25: for dev in 0 1 2 3; do
                     26:        if [ -f /etc/raid$dev.conf ]; then
                     27:                raidctl -c /etc/raid$dev.conf raid$dev
                     28:        fi
                     29: done
1.1       cgd        30:
1.79      thorpej    31: # Add all block-type swap devices; these might be necessary
                     32: # during disk checks.
                     33: swapctl -A -t blk
                     34:
1.63      mrg        35: if [ -e /fastboot ]; then
1.38      cgd        36:        echo "Fast boot: skipping disk checks."
1.68      mycroft    37: elif [ "$1" = autoboot ]; then
1.38      cgd        38:        echo "Automatic boot in progress: starting file system checks."
1.1       cgd        39:        fsck -p
                     40:        case $? in
                     41:        0)
                     42:                ;;
                     43:        2)
                     44:                exit 1
                     45:                ;;
                     46:        4)
1.35      cgd        47:                echo "Rebooting..."
1.1       cgd        48:                reboot
1.38      cgd        49:                echo "Reboot failed; help!"
1.1       cgd        50:                exit 1
                     51:                ;;
                     52:        8)
1.38      cgd        53:                echo "Automatic file system check failed; help!"
1.1       cgd        54:                exit 1
                     55:                ;;
                     56:        12)
1.38      cgd        57:                echo "Boot interrupted."
1.1       cgd        58:                exit 1
                     59:                ;;
                     60:        130)
                     61:                # interrupt before catcher installed
                     62:                exit 1
                     63:                ;;
                     64:        *)
1.38      cgd        65:                echo "Unknown error; help!"
1.1       cgd        66:                exit 1
                     67:                ;;
                     68:        esac
                     69: fi
                     70:
1.38      cgd        71: trap "echo 'Boot interrupted.'; exit 1" 3
1.1       cgd        72:
                     73: umount -a >/dev/null 2>&1
1.83      drochner   74: mount /
1.1       cgd        75: rm -f /fastboot                # XXX (root now writeable)
1.40      cgd        76:
1.90      veego      77: if [ -f /etc/rc.subr ]; then
                     78:        . /etc/rc.subr
1.89      cjs        79: else
1.90      veego      80:        echo "Can't read /etc/rc.subr; aborting."
1.89      cjs        81:        exit 1;
                     82: fi
                     83:
1.71      mycroft    84: if [ -f /etc/rc.conf ]; then
1.63      mrg        85:        . /etc/rc.conf
                     86: fi
                     87:
1.89      cjs        88: if [ "$rc_configured" != YES ]; then
                     89:        echo "/etc/rc.conf is not configured. Multiuser boot aborted."
                     90:        exit 1
                     91: fi
                     92:
1.40      cgd        93: # set flags on ttys.  (do early, in case they use tty for SLIP in netstart)
                     94: echo 'setting tty flags'
                     95: ttyflags -a
1.1       cgd        96:
1.83      drochner   97: # load kernel modules specified in /etc/lkm.conf if the /usr filesystem
                     98: # is already present with "/" or can be mounted now
1.93      drochner   99: if checkyesno lkm && [ -f /etc/rc.lkm ]; then
1.83      drochner  100:        mount /usr >/dev/null 2>&1
                    101:        if [ -x /usr/bin/ld ]; then
                    102:                lkmstage=BEFORENET
                    103:                . /etc/rc.lkm
                    104:        fi
1.63      mrg       105: fi
                    106:
1.124   ! cjs       107: mount_critical_filesystems local
1.120     mellon    108:
1.1       cgd       109: # set hostname, turn on network
                    110: echo 'starting network'
1.76      scottr    111: sh /etc/netstart
                    112: if [ $? -ne 0 ]; then
                    113:        exit 1
                    114: fi
1.1       cgd       115:
1.124   ! cjs       116: mount_critical_filesystems network
1.99      veego     117:
                    118: # Network Address Translation...
1.100     lukem     119: if checkyesno ipnat && [ -f /etc/ipnat.conf ]; then
1.99      veego     120:        echo 'installing NAT rules ... '
1.100     lukem     121:        if ! checkyesno ipfilter || [ ! -f /etc/ipf.conf ]; then
1.99      veego     122:                ipf -E -Fa
                    123:        fi
                    124:        ipnat -F -f /etc/ipnat.conf
                    125: fi
1.79      thorpej   126:
                    127: # "Critical" file systems are now mounted.  Go ahead and swap
                    128: # to files now, since they will be residing in the critical file
                    129: # systems (or, at least, better).
                    130: swapctl -A -t noblk
1.97      mrg       131:
                    132: # Check for no swap, and warn about it unless that is desired.
1.100     lukem     133: if ! checkyesno no_swap; then
1.97      mrg       134:        swapctl -s | grep 'no swap devices configured' > /dev/null && \
                    135:                echo "WARNING:  no swap space configured!"
                    136: fi
1.26      deraadt   137:
1.41      jtc       138: # clean up left-over files
                    139: rm -f /etc/nologin
                    140: rm -f /var/spool/lock/LCK.*
                    141: rm -f /var/spool/uucp/STST/*
1.45      cgd       142: (cd /var/run && { rm -rf -- *; install -c -m 664 -g utmp /dev/null utmp; })
1.108     abs       143:
1.111     mrg       144: # get the system dmesg output, hopefully containing the boot messages
                    145: # $dmesg_flags is imported from /etc/rc.conf
                    146: if checkyesno dmesg; then
                    147:        dmesg $dmesg_flags > /var/run/dmesg.boot
                    148: fi
1.41      jtc       149:
1.84      veego     150: # start the system logger first, so that all messages from daemons
                    151: # are logged, then start savecore to get a dump on low memory systems
                    152: # and then start the name server.
1.63      mrg       153:
1.89      cjs       154: if checkyesno syslogd; then
1.63      mrg       155:        echo 'starting system logger'
1.119     perry     156:        # Transitional symlink for old binaries
                    157:        if [ ! -h /dev/log ] ; then
                    158:                ln -sf /var/run/log /dev/log
                    159:        fi
                    160:        rm -f /var/run/log
1.63      mrg       161:        syslogd $syslogd_flags
1.94      lukem     162: fi
                    163:
                    164: # Enable ipmon (only useful if ipfilter is running)
                    165: # NOTE: requires the IPFILTER_LOG kernel option.
                    166: if checkyesno ipmon; then
                    167:        echo 'starting ipmon'
                    168:        ipmon $ipmon_flags &
1.63      mrg       169: fi
                    170:
1.84      veego     171: # /var/crash should be a directory or a symbolic link
                    172: # to the crash directory if core dumps are to be saved.
1.89      cjs       173: if checkyesno savecore; then
1.106     hubertf   174:        if [ -d /var/crash/. ]; then
1.89      cjs       175:                echo checking for core dump...
                    176:                savecore $savecore_flags /var/crash
                    177:        else
                    178:                logger -s "WARNING: no /var/crash directory; savecore not run."
1.84      veego     179:        fi
                    180: fi
                    181:
1.89      cjs       182: if checkyesno named; then
                    183:        echo 'starting name server';    named $named_flags
                    184: fi
                    185:
                    186: # set time, if requested
                    187: if checkyesno ntpdate; then
1.91      mikel     188:        if [ -z "$ntpdate_hosts" ]; then
1.101     lukem     189:                ntpdate_hosts=`awk '
                    190:                    /^server[ \t]*127.127/      {next}
1.115     bad       191:                    /^(server|peer)/                    {print $2}
1.101     lukem     192:                ' </etc/ntp.conf`
1.89      cjs       193:        fi
                    194:        if [ -n "$ntpdate_hosts"  ]; then
                    195:                echo 'Setting date via ntp.'
1.102     lukem     196:                ntpdate -b -s $ntpdate_hosts
1.67      mycroft   197:        fi
1.63      mrg       198: fi
                    199:
1.84      veego     200: # now start the rpc servers, for YP server/client.
1.63      mrg       201: echo -n 'starting rpc daemons:'
                    202:
                    203: # note that portmap is generally required for all other rpc services.
1.89      cjs       204: if checkyesno portmap; then
1.109     jwise     205:        echo -n ' portmap';             portmap $portmap_flags
1.63      mrg       206: fi
                    207:
1.89      cjs       208: if checkyesno ypserv; then
1.63      mrg       209:         echo -n ' ypserv';              ypserv $ypserv_flags
                    210: fi
                    211:
1.89      cjs       212: if checkyesno ypbind; then
1.63      mrg       213:         echo -n ' ypbind';              ypbind $ypbind_flags
                    214: fi
                    215:
1.89      cjs       216: if checkyesno yppasswdd; then
1.63      mrg       217:         echo -n ' rpc.yppasswdd';       rpc.yppasswdd $yppasswdd_flags
                    218: fi
                    219:
1.89      cjs       220: if checkyesno bootparamd; then
                    221:        if [ -r /etc/bootparams ]; then
                    222:                echo -n ' rpc.bootparamd'; rpc.bootparamd $bootparamd_flags
                    223:        else
                    224:                echo
                    225:                logger -s "WARNING: /etc/bootparams not found. " \
                    226:                    "bootparamd not started."
1.67      mycroft   227:        fi
1.63      mrg       228: fi
                    229:
1.84      veego     230: echo '.'
                    231:
                    232: # load kernel modules specified in /etc/lkm.conf
1.89      cjs       233: if checkyesno lkm; then
                    234:        if [ -r /etc/rc.lkm ]; then
                    235:                lkmstage=BEFOREMOUNT
                    236:                . /etc/rc.lkm
                    237:        else
                    238:                logger -s "WARNING: /etc/rc.lkm not found; LKMs not loaded."
                    239:        fi
1.84      veego     240: fi
                    241:
                    242: mount -a
                    243:
                    244: # now start the rpc servers, for NFS server/client.
1.90      veego     245: echo -n 'starting nfs daemons:'
1.84      veego     246:
1.67      mycroft   247: nfs_locking=NO
                    248:
1.89      cjs       249: if checkyesno nfs_server; then
                    250:        if [ -r /etc/exports ]; then
                    251:                rm -f /var/db/mountdtab
                    252:                echo -n > /var/db/mountdtab
                    253:                echo -n ' mountd';              mountd $mountd_flags
                    254:                echo -n ' nfsd';                nfsd $nfsd_flags
1.100     lukem     255:                nfs_locking=YES
1.89      cjs       256:        else
                    257:                echo
                    258:                logger -s "WARNING: /etc/exports not readable; " \
                    259:                    "NFS server not started."
1.69      mycroft   260:        fi
1.1       cgd       261: fi
1.63      mrg       262:
1.89      cjs       263: if checkyesno nfs_client; then
1.63      mrg       264:         echo -n ' nfsiod';              nfsiod $nfsiod_flags
1.100     lukem     265:        nfs_locking=YES
1.66      scottr    266: fi
                    267:
1.100     lukem     268: if checkyesno nfs_locking; then
1.89      cjs       269:        if checkyesno statd; then
1.71      mycroft   270:                echo -n ' rpc.statd';           rpc.statd $statd_flags
1.66      scottr    271:        fi
1.89      cjs       272:        if checkyesno lockd; then
1.71      mycroft   273:                echo -n ' rpc.lockd';           rpc.lockd $lockd_flags
1.66      scottr    274:        fi
1.63      mrg       275: fi
                    276:
1.89      cjs       277: if checkyesno amd; then
                    278:        if [ -d "$amd_dir" ]; then
                    279:                if [ -r "$amd_master" ]; then
                    280:                        echo -n ' amd'
1.104     tron      281:                        amd $amd_flags -p -a $amd_dir \
                    282:                        `sed s/#.*$// <$amd_master`  >/var/run/amd.pid
1.89      cjs       283:                else
                    284:                        echo
                    285:                        logger -s "WARNING: \$amd_master ($amd_master)not " \
                    286:                            "readable; amd not started."
                    287:                fi
                    288:        else
                    289:                echo
                    290:                logger -s "WARNING: \$amd_dir ($amd_dir) not a directory; " \
                    291:                    "amd not started."
1.67      mycroft   292:        fi
1.63      mrg       293: fi
                    294:
1.1       cgd       295: echo '.'
1.83      drochner  296:
1.63      mrg       297: if [ -f /sbin/ldconfig ]; then
                    298:        echo 'creating runtime link editor directory cache.'
1.88      thorpej   299:        ldconfig
1.63      mrg       300: fi
1.83      drochner  301:
                    302: # load kernel modules specified in /etc/lkm.conf
1.89      cjs       303: if checkyesno lkm && [ -f /etc/rc.lkm ]; then
1.83      drochner  304:        lkmstage=AFTERMOUNT
                    305:        . /etc/rc.lkm
1.1       cgd       306: fi
                    307:
1.112     mrg       308: # if $securelevel is set, change it here, else if it is 0, change
                    309: # it to 1 here, before we start login services.
1.113     mrg       310: if [ -n "$securelevel" ]; then
1.112     mrg       311:        echo -n 'setting securelevel: '
                    312:        sysctl -w kern.securelevel=$securelevel
                    313: else
1.116     frueauf   314:        securelevel=`sysctl -n kern.securelevel`
1.112     mrg       315:        if [ x"$securelevel" = x0 ]; then
                    316:                echo -n 'setting securelevel: '
                    317:                sysctl -w kern.securelevel=1
                    318:        fi
                    319: fi
                    320:
1.89      cjs       321: echo -n 'checking quotas:'; quotacheck -a; echo ' done.'
1.47      deraadt   322: quotaon -a
1.1       cgd       323:
                    324: # build ps databases
1.2       cgd       325: echo 'building databases...'
1.11      cgd       326: kvm_mkdb /netbsd
1.1       cgd       327: dev_mkdb
                    328:
                    329: chmod 666 /dev/tty[pqrs]*
                    330:
                    331: # check the password temp/lock file
                    332: if [ -f /etc/ptmp ]
                    333: then
                    334:        logger -s -p auth.err \
                    335:        'password file may be incorrect -- /etc/ptmp exists'
                    336: fi
                    337:
1.112     mrg       338: # XXX replace me with a script that works!
1.85      perry     339: virecovery=`echo /var/tmp/vi.recover/recover.*`
1.32      mycroft   340: if [ "$virecovery" != "/var/tmp/vi.recover/recover.*" ]; then
                    341:        echo preserving editor files
                    342:        for i in $virecovery; do
                    343:                sendmail -t < $i
                    344:        done
                    345: fi
1.1       cgd       346:
                    347: echo clearing /tmp
                    348:
1.65      mikel     349: # Prune quickly with one rm, then use find to clean up /tmp/[lq]* (this
                    350: # is not needed with mfs /tmp, but doesn't hurt anything).
1.1       cgd       351: (cd /tmp && rm -rf [a-km-pr-zA-Z]* &&
1.46      deraadt   352:     find . ! -name . ! -name lost+found ! -name quota.user \
                    353:        ! -name quota.group -exec rm -rf -- {} \; -type d -prune)
1.1       cgd       354:
1.74      perry     355: # Update kernel info in /etc/motd
                    356: # Must be done *before* interactive logins are possible to prevent
                    357: # possible race conditions.
1.89      cjs       358: if checkyesno update_motd; then
1.74      perry     359:        echo 'updating motd.'
                    360:        if [ ! -f /etc/motd ]; then
                    361:                install -c -o root -g wheel -m 664 /dev/null /etc/motd
                    362:        fi
                    363:        T=/tmp/_motd
                    364:        rm -f $T
                    365:        sysctl -n kern.version | sed 1q > $T
                    366:        echo "" >> $T
                    367:        sed '1,/^$/d' < /etc/motd >> $T
                    368:        cmp -s $T /etc/motd || cp $T /etc/motd
                    369:        rm -f $T
                    370: fi
                    371:
1.34      cgd       372: if [ -f /var/account/acct ]; then
                    373:        echo 'turning on accounting';   accton /var/account/acct
                    374: fi
1.1       cgd       375:
                    376: echo -n standard daemons:
1.89      cjs       377: if checkyesno update; then
1.70      mycroft   378:        echo -n ' update';              update $update_flags
                    379: fi
1.110     jwise     380: if checkyesno cron; then
                    381:        echo -n ' cron';                cron
                    382: fi
1.1       cgd       383: echo '.'
                    384:
1.63      mrg       385: # now start all the other daemons
1.1       cgd       386: echo -n starting network daemons:
                    387:
1.89      cjs       388: if checkyesno gated && checkyesno routed; then
                    389:        echo
                    390:        logger -s "WARNING: gated and routed both requested to be run: " \
                    391:            "running only gated."
                    392:        routed=NO
                    393: fi
                    394:
                    395: if checkyesno gated; then
                    396:        if [ -r /etc/gated.conf ]; then
                    397:                echo -n ' gated';               gated $gated_flags
                    398:        else
                    399:                logger -s "WARNING: no /etc/gated.conf; gated not started."
1.67      mycroft   400:        fi
1.89      cjs       401: fi
                    402:
                    403: if checkyesno routed; then
1.48      mycroft   404:        echo -n ' routed';              routed $routed_flags
1.1       cgd       405: fi
                    406:
1.89      cjs       407: if checkyesno mrouted; then
1.55      thorpej   408:        echo -n ' mrouted';             mrouted $mrouted_flags
                    409: fi
                    410:
1.89      cjs       411: if checkyesno timed; then
1.67      mycroft   412:        echo -n ' timed';               timed $timed_flags
1.63      mrg       413: fi
                    414:
1.89      cjs       415: if checkyesno xntpd; then
1.67      mycroft   416:        echo -n ' xntpd';               xntpd $xntpd_flags
1.61      mrg       417: fi
                    418:
1.89      cjs       419: if checkyesno dhcpd; then
                    420:        if [ -r /etc/dhcpd.conf ]; then
                    421:                echo -n ' dhcpd';               dhcpd $dhcpd_flags
                    422:        else
                    423:                echo
                    424:                logger -s "WARNING: /etc/dhcpd.conf not readable; " \
                    425:                    "dhcpd not started."
1.67      mycroft   426:        fi
1.122     sommerfe  427: elif checkyesno dhcrelay; then
                    428:        echo -n ' dhcrelay';            dhcrelay $dhcrelay_flags
1.29      mycroft   429: fi
                    430:
1.89      cjs       431: if checkyesno rwhod; then
1.48      mycroft   432:        echo -n ' rwhod';               rwhod
1.1       cgd       433: fi
                    434:
1.89      cjs       435: if checkyesno lpd; then
                    436:        echo -n ' lpd';                 lpd $lpd_flags
1.60      tls       437: fi
                    438:
1.63      mrg       439: # We call sendmail with a full path so that SIGHUP works.
1.89      cjs       440: if checkyesno sendmail; then
                    441:        if [ -r /etc/sendmail.cf ]; then
                    442:                echo -n ' sendmail';    /usr/sbin/sendmail $sendmail_flags
                    443:        else
                    444:                echo
                    445:                logger -s "WARNING: /etc/sendmail.cf not readable; " \
                    446:                    "sendmail not started."
1.67      mycroft   447:        fi
1.60      tls       448: fi
                    449:
1.96      jonathan  450: # Start xfs before boot daemons, so its ready before client xterminals.
                    451: if checkyesno xfs; then
                    452:        echo -n ' xfs';                 xfs $xfs_flags &
1.98      perry     453:        sleep 2
1.96      jonathan  454: fi
                    455:
1.89      cjs       456: if checkyesno rarpd; then
                    457:        if [ -r /etc/ethers ]; then
                    458:                echo -n ' rarpd';       rarpd $rarpd_flags
                    459:        else
                    460:                echo
                    461:                logger -s "WARNING: /etc/ethers not readable; " \
                    462:                    "rarpd not started."
1.67      mycroft   463:        fi
1.60      tls       464: fi
                    465:
1.89      cjs       466: if checkyesno rbootd; then
                    467:        if [ -r /etc/rbootd.conf ]; then
                    468:                echo -n ' rbootd';      rbootd $rbootd_flags
                    469:        else
                    470:                echo
                    471:                logger -s "WARNING: /etc/rbootd.conf not readable; " \
1.111     mrg       472:                    "rbootd not started."
1.67      mycroft   473:        fi
1.72      cjs       474: fi
                    475:
1.89      cjs       476: if checkyesno mopd; then
1.72      cjs       477:        echo -n ' mopd';                mopd $mopd_flags
1.86      perry     478: fi
                    479:
1.89      cjs       480: if checkyesno apmd; then
1.86      perry     481:        echo -n ' apmd';                apmd $apmd_flags
1.103     mrg       482: fi
                    483:
                    484: if checkyesno screenblank; then
                    485:        echo -n ' screenblank';         screenblank $screenblank_flags
1.52      thorpej   486: fi
                    487:
1.89      cjs       488: if checkyesno inetd; then
                    489:        if [ -r /etc/inetd.conf ]; then
                    490:                echo -n ' inetd';       inetd $inetd_flags
                    491:        else
                    492:                echo
                    493:                logger -s "WARNING: /etc/inetd.conf not readable; " \
                    494:                    "inetd not started."
1.67      mycroft   495:        fi
1.105     augustss  496: fi
                    497:
                    498: if checkyesno usbd; then
                    499:        echo -n ' usbd';                usbd $usbd_flags
1.96      jonathan  500: fi
                    501:
1.1       cgd       502: echo '.'
1.73      perry     503:
                    504: # Kerberos runs ONLY on the Kerberos server machine
1.89      cjs       505: if checkyesno kerberos; then
1.73      perry     506:        echo -n 'starting kerberos daemons:'
                    507:        echo -n ' kerberos';    kerberos >> /var/log/kerberos.log &
                    508:        echo -n ' kadmind';     kadmind -n >> /var/log/kadmind.log &
                    509:        echo '.'
1.117     drochner  510: fi
                    511:
                    512: if checkyesno wscons && [ -f /etc/rc.wscons ]; then
                    513:        echo 'configuring wscons'
1.118     drochner  514:        /bin/sh /etc/rc.wscons $wscons_flags
1.123     drochner  515: fi
                    516:
                    517: # xdm after wscons - need a virtual screen for X
                    518: if checkyesno xdm; then
                    519:        echo 'starting xdm'
                    520:        xdm $xdm_flags
1.73      perry     521: fi
1.1       cgd       522:
1.25      mycroft   523: . /etc/rc.local
1.1       cgd       524:
                    525: date
                    526: exit 0

CVSweb <webmaster@jp.NetBSD.org>