[BACK]Return to rc CVS log [TXT][DIR] Up to [local] / src / etc

Annotation of src/etc/rc, Revision 1.85

1.85    ! marc        1: #      $OpenBSD: rc,v 1.84 1998/08/18 23:11:15 marc Exp $
1.1       deraadt     2:
                      3: # System startup script run by init on autoboot
                      4: # or after single-user.
                      5: # Output and error are redirected to console by init,
                      6: # and the console is the controlling terminal.
                      7:
                      8: stty status '^T'
                      9:
                     10: # Set shell to ignore SIGINT (2), but not children;
                     11: # shell catches SIGQUIT (3) and returns to single user after fsck.
                     12: trap : 2
                     13: trap : 3       # shouldn't be needed
                     14:
                     15: HOME=/; export HOME
                     16: PATH=/sbin:/bin:/usr/sbin:/usr/bin
                     17: export PATH
                     18:
                     19: # Configure ccd devices.
1.17      deraadt    20: if [ -f /etc/ccd.conf ]; then
1.1       deraadt    21:        ccdconfig -C
                     22: fi
                     23:
1.17      deraadt    24: if [ -e /fastboot ]; then
1.1       deraadt    25:        echo "Fast boot: skipping disk checks."
1.17      deraadt    26: elif [ $1x = autobootx ]; then
1.1       deraadt    27:        echo "Automatic boot in progress: starting file system checks."
1.31      millert    28:        fsck -p
1.1       deraadt    29:        case $? in
                     30:        0)
                     31:                ;;
                     32:        2)
                     33:                exit 1
                     34:                ;;
                     35:        4)
                     36:                echo "Rebooting..."
                     37:                reboot
                     38:                echo "Reboot failed; help!"
                     39:                exit 1
                     40:                ;;
                     41:        8)
                     42:                echo "Automatic file system check failed; help!"
                     43:                exit 1
                     44:                ;;
                     45:        12)
                     46:                echo "Boot interrupted."
                     47:                exit 1
                     48:                ;;
                     49:        130)
                     50:                # interrupt before catcher installed
                     51:                exit 1
                     52:                ;;
                     53:        *)
                     54:                echo "Unknown error; help!"
                     55:                exit 1
                     56:                ;;
                     57:        esac
                     58: fi
                     59:
                     60: trap "echo 'Boot interrupted.'; exit 1" 3
                     61:
                     62: swapon -a
                     63:
                     64: umount -a >/dev/null 2>&1
                     65: mount -a -t nonfs
1.57      niklas     66: mount -uw /            # root on nfs requires this, others aren't hurt
1.1       deraadt    67: rm -f /fastboot                # XXX (root now writeable)
                     68:
                     69: # set flags on ttys.  (do early, in case they use tty for SLIP in netstart)
                     70: echo 'setting tty flags'
                     71: ttyflags -a
1.77      angelos    72:
                     73: # if there's no /etc/host.random, make one through /dev/urandom
                     74: if [ ! -f /etc/host.random ]; then
1.82      deraadt    75:        dd if=/dev/urandom of=/etc/host.random bs=1024 count=64 >/dev/null 2>&1
1.78      todd       76:        chmod 600 /etc/host.random
1.77      angelos    77: fi
1.1       deraadt    78:
                     79: # set hostname, turn on network
                     80: echo 'starting network'
                     81: . /etc/netstart
                     82:
                     83: mount /usr >/dev/null 2>&1
                     84: mount /var >/dev/null 2>&1
1.29      deraadt    85:
1.55      deraadt    86: # clean up left-over files
                     87: rm -f /etc/nologin
                     88: rm -f /var/spool/lock/LCK.*
                     89: rm -f /var/spool/uucp/STST/*
                     90: (cd /var/run && { rm -rf -- *; install -c -m 664 -g utmp /dev/null utmp; })
                     91:
1.58      deraadt    92: echo 'starting system logger'
                     93: rm -f /dev/log
1.76      millert    94: if [ "X${named_flags}" != X"NO" -a "X${named_chroot}" != "X" ]; then
1.74      millert    95:        rm -f ${named_chroot}/dev/log
                     96:        syslogd_flags="${syslogd_flags} -a ${named_chroot}/dev/log"
                     97: fi
1.65      marc       98: syslogd ${syslogd_flags}
1.58      deraadt    99:
1.74      millert   100: # $named_flags, $named_user, and $named_chroot are imported from /etc/rc.conf;
1.54      deraadt   101: # if $named_flags != NO, named is run.
                    102: if [ "X${named_flags}" != X"NO" ]; then
1.74      millert   103:        if [ "X${named_user}" != "X" -a "X${named_user}" != X"root" ]; then
                    104:                named_flags="-u ${named_user} ${named_flags}"
                    105:        fi
1.75      millert   106:        if [ "X${named_chroot}" != "X" ]; then
1.81      millert   107:                if [ ! -c "${named_chroot}/dev/null" ]; then
                    108:                        ( cd /dev ; pax -rw -pe null ${named_chroot}/dev )
1.83      millert   109:                fi
                    110:                if [ -f /etc/localtime -a -d "${named_chroot}/etc" ]; then
                    111:                        cmp -s /etc/localtime "${named_chroot}/etc/localtime" \
                    112:                        || cp -p /etc/localtime "${named_chroot}/etc/localtime"
1.81      millert   113:                fi
1.74      millert   114:                named_flags="-t ${named_chroot} ${named_flags}"
                    115:        fi
1.58      deraadt   116:        echo 'starting named';          named $named_flags
1.54      deraadt   117: fi
                    118:
1.29      deraadt   119: # /etc/ifaliases, if it exists, contains the names of additional IP
                    120: # addresses for each interface. It is formatted as a series of lines
                    121: # that contain
                    122: #      interface address netmask
                    123: if [ -f /etc/ifaliases ]; then
                    124: (
                    125:        # delete comments and blank lines
                    126:        set -- `sed -e 's/#.*$//' /etc/ifaliases | grep -v '^$'`
                    127:        while [ $# -ge 3 ] ; do
                    128:                ifconfig $1 inet alias $2 netmask $3
1.80      deraadt   129:                route -n add -host $2 localhost
1.29      deraadt   130:                shift 3
                    131:        done
                    132: )
                    133: fi
1.1       deraadt   134:
1.5       dm        135: if [ X"${ipfilter}" = X"YES" -a X"${ipmon_flags}" != X"NO" ]; then
1.43      mickey    136:        echo 'starting ipmon';          ipmon ${ipmon_flags}
1.25      deraadt   137: fi
                    138:
1.52      deraadt   139: # $photurisd_flags is imported from /etc/rc.conf;
1.45      kstailey  140: # If $photurisd_flags == NO or /etc/photuris/photuris.conf doesn't exist, then
1.40      provos    141: # photurisd isn't run.
1.45      kstailey  142: if [ "X${photurisd_flags}" != X"NO" -a -e /etc/photuris/photuris.conf ]; then
1.40      provos    143:        echo 'starting photurisd';      photurisd ${photurisd_flags}
                    144: fi
1.1       deraadt   145:
                    146: echo -n 'starting rpc daemons:'
1.24      millert   147:
1.52      deraadt   148: # $portmap is imported from /etc/rc.conf;
1.24      millert   149: # if $portmap == YES, the portmapper is started.
                    150: if [ X"${portmap}" = X"YES" ]; then
1.23      deraadt   151:        echo -n ' portmap';             portmap
                    152: fi
1.1       deraadt   153:
1.9       deraadt   154: if [ -d /var/yp/binding ]; then
1.8       deraadt   155:        if [ -d /var/yp/`domainname` ]; then
                    156:                # yp server capabilities needed...
1.36      niklas    157:                echo -n ' ypserv';              ypserv ${ypserv_flags}
1.16      deraadt   158:                #echo -n ' ypxfrd';             ypxfrd
1.21      deraadt   159:        fi
                    160:
                    161:        echo -n ' ypbind';              ypbind
1.8       deraadt   162:
1.21      deraadt   163:        if [ -d /var/yp/`domainname` ]; then
1.8       deraadt   164:                # if we are the master server, run rpc.yppasswdd
                    165:                _host1=`ypwhich -m passwd 2> /dev/null`
                    166:                _host2=`hostname`
1.15      deraadt   167:                if [ `grep '^lookup' /etc/resolv.conf | grep yp | wc -c` -ne 0 ]; then
1.8       deraadt   168:                        _host1=`ypmatch $_host1 hosts | cut -d' ' -f2`
                    169:                        _host2=`ypmatch $_host2 hosts | cut -d' ' -f2 | head -1`
                    170:                else
                    171:                        _host1=`nslookup $_host1 | grep '^Name: ' | \
                    172:                            sed -e 's/^Name:    //'`
                    173:                        _host2=`nslookup $_host2 | grep '^Name: ' | \
                    174:                            sed -e 's/^Name:    //'`
                    175:                fi
1.13      deraadt   176:                if [ "$_host2" = "$_host1" ]; then
1.35      niklas    177:                        echo -n ' rpc.yppasswdd'
                    178:                        rpc.yppasswdd ${yppasswdd_flags}
1.8       deraadt   179:                fi
1.7       deraadt   180:        fi
1.1       deraadt   181: fi
                    182:
1.52      deraadt   183: # $nfs_server is imported from /etc/rc.conf;
1.1       deraadt   184: # if $nfs_server == YES, the machine is setup for being an nfs server
1.67      millert   185: if [ X${nfs_server} = X"YES" -a -s /etc/exports -a \
1.47      deraadt   186:     `cat /etc/exports | sed -e '/^#/d' | wc -l` -ne 0 ]; then
1.68      millert   187:        rm -f /var/db/mountdtab
1.1       deraadt   188:        echo -n > /var/db/mountdtab
                    189:        echo -n ' mountd';              mountd
1.42      niklas    190:        echo -n ' nfsd';                nfsd ${nfsd_flags}
                    191:        if [ X${lockd} = X"YES" ]; then
                    192:                echo -n ' rpc.lockd';   rpc.lockd
                    193:        fi
1.1       deraadt   194: fi
                    195:
1.52      deraadt   196: # $nfs_client is imported from /etc/rc.conf;
1.1       deraadt   197: # if $nfs_client == YES, the machine is setup for being an nfs client
                    198: if [ X${nfs_client} = X"YES" ]; then
1.59      downsj    199:        echo -n ' nfsiod';              nfsiod ${nfsiod_flags}
1.1       deraadt   200: fi
                    201:
1.67      millert   202: if [ X${amd} = X"YES" -a -d ${amd_dir} -a -e ${amd_master} ]; then
1.1       deraadt   203:        echo -n ' amd'
                    204:        amd -l syslog -x error,noinfo,nostats -p \
                    205:            -a ${amd_dir} `cat ${amd_master}` > /var/run/amd.pid
                    206: fi
                    207:
1.52      deraadt   208: # $timed_flags is imported from /etc/rc.conf;
1.1       deraadt   209: # if $timed_flags == NO, timed isn't run.
                    210: if [ "X${timed_flags}" != X"NO" ]; then
1.58      deraadt   211:        echo -n ' timed'; timed $timed_flags
1.1       deraadt   212: fi
                    213: echo '.'
1.58      deraadt   214:
                    215: mount -a -t nfs
1.1       deraadt   216:
                    217: # /var/crash should be a directory or a symbolic link
                    218: # to the crash directory if core dumps are to be saved.
                    219: if [ -d /var/crash ]; then
                    220:        savecore /var/crash
                    221: fi
                    222:
1.41      downsj    223: if [ "X${check_quotas}" = X"YES" ]; then
                    224:        echo -n 'checking quotas:'
                    225:        quotacheck -a
                    226:        echo ' done.'
                    227:        quotaon -a
                    228: fi
1.1       deraadt   229:
                    230: # build ps databases
                    231: echo 'building databases...'
1.2       deraadt   232: kvm_mkdb /bsd
1.1       deraadt   233: dev_mkdb
                    234:
                    235: chmod 666 /dev/tty[pqrs]*
                    236:
                    237: # check the password temp/lock file
1.17      deraadt   238: if [ -f /etc/ptmp ]; then
1.1       deraadt   239:        logger -s -p auth.err \
                    240:        'password file may be incorrect -- /etc/ptmp exists'
1.32      deraadt   241: fi
                    242:
1.49      millert   243: echo clearing /tmp
                    244:
                    245: # prune quickly with one rm, then use find to clean up /tmp/[lq]*
                    246: # (not needed with mfs /tmp, but doesn't hurt there...)
                    247: (cd /tmp && rm -rf [a-km-pr-zA-Z]* &&
                    248:     find . ! -name . ! -name lost+found ! -name quota.user \
                    249:        ! -name quota.group -exec rm -rf -- {} \; -type d -prune)
1.61      deraadt   250:
                    251: if [ -f /etc/sysctl.conf ]; then
1.62      deraadt   252: (
1.61      deraadt   253:        # delete comments and blank lines
                    254:        set -- `sed -e 's/#.*$//' /etc/sysctl.conf | grep -v '^$'`
                    255:        while [ $# -ge 1 ] ; do
                    256:                sysctl -w $1
                    257:                shift 1
                    258:        done
1.68      millert   259: )
1.61      deraadt   260: fi
1.49      millert   261:
1.72      deraadt   262: [ -f /etc/rc.securelevel ] && . /etc/rc.securelevel
1.32      deraadt   263: if [ X${securelevel} != X"" ]; then
1.33      millert   264:        echo -n 'setting kernel security level: '
1.32      deraadt   265:        sysctl -w kern.securelevel=${securelevel}
1.1       deraadt   266: fi
                    267:
1.34      deraadt   268: # patch /etc/motd
                    269: if [ ! -f /etc/motd ]; then
                    270:        install -c -o root -g wheel -m 664 /dev/null /etc/motd
                    271: fi
                    272: T=/tmp/_motd
                    273: rm -f $T
                    274: sysctl -n kern.version | sed 1q > $T
                    275: echo "" >> $T
                    276: sed '1,/^$/d' < /etc/motd >> $T
                    277: cmp -s $T /etc/motd || cp $T /etc/motd
                    278: rm -f $T
                    279:
1.51      millert   280: # nvi file recovery
1.50      millert   281: if [ ! -d /var/tmp/vi.recover ]; then
                    282:        if [ -e /var/tmp/vi.recover ]; then
                    283:                echo "Warning!  /var/tmp/vi.recover is not a directory!"
                    284:        else
                    285:                mkdir /var/tmp/vi.recover
                    286:                chmod 1777 /var/tmp/vi.recover
                    287:        fi
                    288: fi
1.51      millert   289: vibackup=/var/tmp/vi.recover/vi.*
                    290: if [ "$vibackup" != "/var/tmp/vi.recover/vi.*" ]; then
                    291:        for i in $vibackup; do
                    292:                # Unmodified nvi editor backup files either have the
                    293:                # execute bit set or are zero length.  Delete them.
1.72      deraadt   294:                if [ -x $i -o ! -s $i ]; then
1.51      millert   295:                        rm $i
                    296:                fi
                    297:        done
                    298: fi
1.1       deraadt   299: virecovery=/var/tmp/vi.recover/recover.*
                    300: if [ "$virecovery" != "/var/tmp/vi.recover/recover.*" ]; then
                    301:        echo preserving editor files
                    302:        for i in $virecovery; do
1.51      millert   303:                # Delete any recovery files that are zero length, corrupted,
                    304:                # or that have no corresponding backup file.  Else send mail
                    305:                # to the user.
                    306:                recfile=`awk '/^X-vi-recover-path:/{print $2}' < $i`
1.72      deraadt   307:                if [ -n "$recfile" -a -s "$recfile" ]; then
1.51      millert   308:                        sendmail -t < $i
                    309:                else
                    310:                        rm $i
                    311:                fi
1.1       deraadt   312:        done
                    313: fi
                    314:
                    315: if [ -f /var/account/acct ]; then
                    316:        echo 'turning on accounting';   accton /var/account/acct
                    317: fi
                    318:
                    319: echo -n starting network daemons:
                    320:
1.52      deraadt   321: # $gated and $routed_flags are imported from /etc/rc.conf.
1.1       deraadt   322: # If $gated == YES, gated is used; otherwise routed.
                    323: # If $routed_flags == NO, routed isn't run.
1.67      millert   324: if [ X${gated} = X"YES" -a -e /etc/gated.conf ]; then
1.1       deraadt   325:        echo -n ' gated';               gated $gated_flags
                    326: elif [ "X${routed_flags}" != X"NO" ]; then
                    327:        echo -n ' routed';              routed $routed_flags
                    328: fi
                    329:
1.52      deraadt   330: # $mrouted_flags is imported from /etc/rc.conf;
1.4       deraadt   331: # If $mrouted_flags == NO, then mrouted isn't run.
                    332: if [ "X${mrouted_flags}" != X"NO" ]; then
                    333:        echo -n ' mrouted';             mrouted $mrouted_flags
                    334: fi
1.1       deraadt   335:
1.52      deraadt   336: # $rwhod is imported from /etc/rc.conf;
1.1       deraadt   337: # if $rwhod == YES, rwhod is run.
                    338: if [ X${rwhod} = X"YES" ]; then
                    339:        echo -n ' rwhod';               rwhod
                    340: fi
                    341:
1.23      deraadt   342:
                    343: if [ X${lpd} = X"YES" ]; then
                    344:        echo -n ' printer';             lpd
                    345: fi
1.1       deraadt   346:
1.52      deraadt   347: # $sendmail_flags is imported from /etc/rc.conf;
1.1       deraadt   348: # If $sendmail_flags == NO or /etc/sendmail.cf doesn't exist, then
1.6       deraadt   349: # sendmail isn't run.  We call sendmail with a full path so that
                    350: # SIGHUP works.
1.67      millert   351: if [ "X${sendmail_flags}" != X"NO" -a -s /etc/sendmail.cf ]; then
1.6       deraadt   352:        echo -n ' sendmail';            /usr/sbin/sendmail ${sendmail_flags}
1.69      deraadt   353: fi
                    354:
                    355: if [ "X${httpd_flags}" != X"NO"  ]; then
                    356:        echo -n ' httpd';               /usr/sbin/httpd ${httpd_flags}
1.1       deraadt   357: fi
1.63      beck      358:
                    359: # $smtpfwdd_flags is imported from /etc/rc.conf;
                    360: # If $smtpfwdd_flags == NO, smtpfwdd isn't run.
                    361: if [ "X${smtpfwdd_flags}" != X"NO" ]; then
                    362:        echo -n ' smtpfwdd';    /usr/libexec/smtpfwdd ${smtpfwdd_flags}
                    363: fi
                    364:
1.1       deraadt   365:
1.23      deraadt   366: if [ X${inetd} = X"YES" ]; then
                    367:        echo -n ' inetd';               inetd
                    368: fi
1.1       deraadt   369:
1.52      deraadt   370: # $rarpd_flags is imported from /etc/rc.conf;
1.1       deraadt   371: # If $rarpd_flags == NO or /etc/ethers doesn't exist, then
                    372: # rarpd isn't run.
1.67      millert   373: if [ "X${rarpd_flags}" != X"NO" -a -s /etc/ethers ]; then
1.1       deraadt   374:        echo -n ' rarpd';               rarpd ${rarpd_flags}
                    375: fi
                    376:
1.52      deraadt   377: # $bootparamd_flags is imported from /etc/rc.conf;
1.1       deraadt   378: # If $bootparamd_flags == NO or /etc/bootparams doesn't exist, then
                    379: # bootparamd isn't run.
1.67      millert   380: if [ "X${bootparamd_flags}" != X"NO" -a -s /etc/bootparams ]; then
1.1       deraadt   381:        echo -n ' rpc.bootparamd';      rpc.bootparamd ${bootparamd_flags}
                    382: fi
                    383:
1.52      deraadt   384: # $rbootd_flags is imported from /etc/rc.conf;
1.1       deraadt   385: # If $rbootd_flags == NO or /etc/rbootd.conf doesn't exist, then
                    386: # rbootd isn't run.
1.67      millert   387: if [ "X${rbootd_flags}" != X"NO" -a -s /etc/rbootd.conf ]; then
1.1       deraadt   388:        echo -n ' rbootd';              rbootd ${rbootd_flags}
1.56      maja      389: fi
                    390:
                    391: # $mopd_flags is imported from /etc/rc.conf;
                    392: # If $mopd_flags == NO or /tftpboot/mop doesn't exist, then
                    393: # mopd isn't run.
                    394: if [ "X${mopd_flags}" != X"NO" -a -d /tftpboot/mop ]; then
                    395:        echo -n ' mopd';                mopd ${mopd_flags}
1.37      deraadt   396: fi
                    397:
                    398: if [ -x /usr/sbin/screenblank ]; then
                    399:        echo -n ' screenblank'; /usr/sbin/screenblank
1.1       deraadt   400: fi
                    401:
                    402: echo '.'
                    403:
1.12      deraadt   404: if [ -f /sbin/kbd -a -f /etc/kbdtype ]; then
                    405:        kbd `cat /etc/kbdtype`
                    406: fi
1.17      deraadt   407:
                    408: if [ -f /sbin/ldconfig ]; then
                    409:        echo 'creating runtime link editor directory cache.'
1.26      deraadt   410:        _LIBS=
                    411:        if [ -d /usr/local/lib ]; then
                    412:                _LIBS="$_LIBS /usr/local/lib"
                    413:        fi
                    414:        if [ -d /usr/X11R6/lib ]; then
                    415:                _LIBS="$_LIBS /usr/X11R6/lib"
                    416:        fi
                    417:        ldconfig $_LIBS
1.53      deraadt   418: fi
1.17      deraadt   419:
1.66      art       420: # Kerberos runs ONLY on the Kerberos servers
                    421: # Kadmin is runs only on the main server
1.17      deraadt   422: if [ X${kerberos_server} = X"YES" ]; then
1.30      tholo     423:        echo 'kerberos server'
1.60      art       424:        /usr/libexec/kerberos >> /var/log/kerberos.log &
                    425:        /usr/libexec/kadmind -n >> /var/log/kadmind.log &
1.66      art       426: fi
                    427:
                    428: # Kpropd runs only on Kerberos slave servers
                    429: if [ X${kerberos_slave} = X"YES" ]; then
                    430:        echo 'kerberos slave server'
                    431:        /usr/libexec/kerberos -s >> /var/log/kerberos.log &
                    432:        /usr/libexec/kpropd -i &
1.17      deraadt   433: fi
                    434:
1.72      deraadt   435: [ -f /etc/rc.local ] && . /etc/rc.local
1.73      millert   436:
                    437: echo -n standard daemons:
1.84      marc      438:
1.85    ! marc      439: # $apmd_flags is imported from /etc/rc.conf;
        !           440: # don't run daemon if $apmd_flags == NO or /usr/sbin/apmd doesn't exist
        !           441: if [ "X${apmd_flags}" != X"NO" -a -x /usr/sbin/apmd ]; then
        !           442:         echo -n ' apmd';        /usr/sbin/apmd ${apmd_flags}
1.84      marc      443: fi
                    444:
1.73      millert   445: echo -n ' cron';               cron
1.84      marc      446:
1.73      millert   447: echo '.'
1.1       deraadt   448:
                    449: date
1.71      deraadt   450:
                    451: # Alternatively, on some architectures, xdm may be started in /etc/ttys.
                    452: if [ "X${xdm_flags}" != X"NO" ]; then
                    453:        echo 'starting xdm...';         /usr/X11R6/bin/xdm
                    454: fi
                    455:
1.1       deraadt   456: exit 0