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

Annotation of src/etc/rc, Revision 1.50

1.50    ! millert     1: #      $OpenBSD: rc,v 1.49 1997/09/26 18:43:45 millert 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
                     66: rm -f /fastboot                # XXX (root now writeable)
                     67:
                     68: # set flags on ttys.  (do early, in case they use tty for SLIP in netstart)
                     69: echo 'setting tty flags'
                     70: ttyflags -a
                     71:
                     72: # set hostname, turn on network
                     73: echo 'starting network'
                     74: . /etc/netstart
                     75:
                     76: mount /usr >/dev/null 2>&1
                     77: mount /var >/dev/null 2>&1
1.29      deraadt    78:
                     79: # /etc/ifaliases, if it exists, contains the names of additional IP
                     80: # addresses for each interface. It is formatted as a series of lines
                     81: # that contain
                     82: #      interface address netmask
                     83: if [ -f /etc/ifaliases ]; then
                     84: (
                     85:        # delete comments and blank lines
                     86:        set -- `sed -e 's/#.*$//' /etc/ifaliases | grep -v '^$'`
                     87:        while [ $# -ge 3 ] ; do
                     88:                ifconfig $1 inet alias $2 netmask $3
1.44      millert    89:                route add -host $2 localhost
1.29      deraadt    90:                shift 3
                     91:        done
                     92: )
                     93: fi
1.1       deraadt    94:
1.5       dm         95: if [ X"${ipfilter}" = X"YES" -a X"${ipmon_flags}" != X"NO" ]; then
1.43      mickey     96:        echo 'starting ipmon';          ipmon ${ipmon_flags}
1.25      deraadt    97: fi
                     98:
                     99: if [ X"${rfc1323}" = X"NO" ]; then
                    100:        echo 'disabling rfc1323';       sysctl -w net.inet.tcp.rfc1323=0
1.5       dm        101: fi
                    102:
1.40      provos    103: # $photurisd_flags is imported from /etc/netstart;
1.45      kstailey  104: # If $photurisd_flags == NO or /etc/photuris/photuris.conf doesn't exist, then
1.40      provos    105: # photurisd isn't run.
1.45      kstailey  106: if [ "X${photurisd_flags}" != X"NO" -a -e /etc/photuris/photuris.conf ]; then
1.40      provos    107:        echo 'starting photurisd';      photurisd ${photurisd_flags}
                    108: fi
                    109:
1.1       deraadt   110: # clean up left-over files
                    111: rm -f /etc/nologin
                    112: rm -f /var/spool/lock/LCK.*
                    113: rm -f /var/spool/uucp/STST/*
                    114: (cd /var/run && { rm -rf -- *; install -c -m 664 -g utmp /dev/null utmp; })
                    115:
                    116: echo -n 'starting rpc daemons:'
1.24      millert   117:
                    118: # $portmap is imported from /etc/netstart;
                    119: # if $portmap == YES, the portmapper is started.
                    120: if [ X"${portmap}" = X"YES" ]; then
1.23      deraadt   121:        echo -n ' portmap';             portmap
                    122: fi
1.1       deraadt   123:
1.9       deraadt   124: if [ -d /var/yp/binding ]; then
1.8       deraadt   125:        if [ -d /var/yp/`domainname` ]; then
                    126:                # yp server capabilities needed...
1.36      niklas    127:                echo -n ' ypserv';              ypserv ${ypserv_flags}
1.16      deraadt   128:                #echo -n ' ypxfrd';             ypxfrd
1.21      deraadt   129:        fi
                    130:
                    131:        echo -n ' ypbind';              ypbind
1.8       deraadt   132:
1.21      deraadt   133:        if [ -d /var/yp/`domainname` ]; then
1.8       deraadt   134:                # if we are the master server, run rpc.yppasswdd
                    135:                _host1=`ypwhich -m passwd 2> /dev/null`
                    136:                _host2=`hostname`
1.15      deraadt   137:                if [ `grep '^lookup' /etc/resolv.conf | grep yp | wc -c` -ne 0 ]; then
1.8       deraadt   138:                        _host1=`ypmatch $_host1 hosts | cut -d' ' -f2`
                    139:                        _host2=`ypmatch $_host2 hosts | cut -d' ' -f2 | head -1`
                    140:                else
                    141:                        _host1=`nslookup $_host1 | grep '^Name: ' | \
                    142:                            sed -e 's/^Name:    //'`
                    143:                        _host2=`nslookup $_host2 | grep '^Name: ' | \
                    144:                            sed -e 's/^Name:    //'`
                    145:                fi
1.13      deraadt   146:                if [ "$_host2" = "$_host1" ]; then
1.35      niklas    147:                        echo -n ' rpc.yppasswdd'
                    148:                        rpc.yppasswdd ${yppasswdd_flags}
1.8       deraadt   149:                fi
1.7       deraadt   150:        fi
1.1       deraadt   151: fi
                    152:
                    153: # $nfs_server is imported from /etc/netstart;
                    154: # if $nfs_server == YES, the machine is setup for being an nfs server
1.46      deraadt   155: if [ X${nfs_server} = X"YES" -a -r /etc/exports -a \
1.47      deraadt   156:     `cat /etc/exports | sed -e '/^#/d' | wc -l` -ne 0 ]; then
1.1       deraadt   157:        rm -f /var/db/mountdtab
                    158:        echo -n > /var/db/mountdtab
                    159:        echo -n ' mountd';              mountd
1.42      niklas    160:        echo -n ' nfsd';                nfsd ${nfsd_flags}
                    161:        if [ X${lockd} = X"YES" ]; then
                    162:                echo -n ' rpc.lockd';   rpc.lockd
                    163:        fi
1.1       deraadt   164: fi
                    165:
                    166: # $nfs_client is imported from /etc/netstart;
                    167: # if $nfs_client == YES, the machine is setup for being an nfs client
                    168: if [ X${nfs_client} = X"YES" ]; then
                    169:        echo -n ' nfsiod';              nfsiod -n 4
                    170: fi
                    171:
                    172: if [ X${amd} = X"YES" -a -d ${amd_dir} -a -r ${amd_master} ]; then
                    173:        echo -n ' amd'
                    174:        amd -l syslog -x error,noinfo,nostats -p \
                    175:            -a ${amd_dir} `cat ${amd_master}` > /var/run/amd.pid
                    176: fi
                    177:
                    178: echo '.'
                    179: mount -a -t nfs
                    180:
                    181: echo -n 'starting system logger'
                    182: rm -f /dev/log
1.22      deraadt   183: syslogd
1.1       deraadt   184:
                    185: # $timed_flags is imported from /etc/netstart;
                    186: # if $timed_flags == NO, timed isn't run.
                    187: if [ "X${timed_flags}" != X"NO" ]; then
                    188:        echo -n ', time daemon'; timed $timed_flags
                    189: fi
                    190: echo '.'
                    191:
                    192: # /var/crash should be a directory or a symbolic link
                    193: # to the crash directory if core dumps are to be saved.
                    194: if [ -d /var/crash ]; then
                    195:        echo checking for core dump...
                    196:        savecore /var/crash
                    197: fi
                    198:
1.41      downsj    199: if [ "X${check_quotas}" = X"YES" ]; then
                    200:        echo -n 'checking quotas:'
                    201:        quotacheck -a
                    202:        echo ' done.'
                    203:        quotaon -a
                    204: fi
1.1       deraadt   205:
                    206: # build ps databases
                    207: echo 'building databases...'
1.2       deraadt   208: kvm_mkdb /bsd
1.1       deraadt   209: dev_mkdb
                    210:
                    211: chmod 666 /dev/tty[pqrs]*
                    212:
                    213: # check the password temp/lock file
1.17      deraadt   214: if [ -f /etc/ptmp ]; then
1.1       deraadt   215:        logger -s -p auth.err \
                    216:        'password file may be incorrect -- /etc/ptmp exists'
1.32      deraadt   217: fi
                    218:
1.49      millert   219: echo clearing /tmp
                    220:
                    221: # prune quickly with one rm, then use find to clean up /tmp/[lq]*
                    222: # (not needed with mfs /tmp, but doesn't hurt there...)
                    223: (cd /tmp && rm -rf [a-km-pr-zA-Z]* &&
                    224:     find . ! -name . ! -name lost+found ! -name quota.user \
                    225:        ! -name quota.group -exec rm -rf -- {} \; -type d -prune)
                    226:
1.33      millert   227: test -f /etc/rc.securelevel && . /etc/rc.securelevel
1.32      deraadt   228: if [ X${securelevel} != X"" ]; then
1.33      millert   229:        echo -n 'setting kernel security level: '
1.32      deraadt   230:        sysctl -w kern.securelevel=${securelevel}
1.1       deraadt   231: fi
                    232:
1.34      deraadt   233: # patch /etc/motd
                    234: if [ ! -f /etc/motd ]; then
                    235:        install -c -o root -g wheel -m 664 /dev/null /etc/motd
                    236: fi
                    237: T=/tmp/_motd
                    238: rm -f $T
                    239: sysctl -n kern.version | sed 1q > $T
                    240: echo "" >> $T
                    241: sed '1,/^$/d' < /etc/motd >> $T
                    242: cmp -s $T /etc/motd || cp $T /etc/motd
                    243: rm -f $T
                    244:
1.50    ! millert   245: if [ ! -d /var/tmp/vi.recover ]; then
        !           246:        if [ -e /var/tmp/vi.recover ]; then
        !           247:                echo "Warning!  /var/tmp/vi.recover is not a directory!"
        !           248:        else
        !           249:                mkdir /var/tmp/vi.recover
        !           250:                chmod 1777 /var/tmp/vi.recover
        !           251:        fi
        !           252: fi
1.1       deraadt   253: virecovery=/var/tmp/vi.recover/recover.*
                    254: if [ "$virecovery" != "/var/tmp/vi.recover/recover.*" ]; then
                    255:        echo preserving editor files
                    256:        for i in $virecovery; do
                    257:                sendmail -t < $i
                    258:        done
                    259: fi
                    260:
                    261: if [ -f /var/account/acct ]; then
                    262:        echo 'turning on accounting';   accton /var/account/acct
                    263: fi
                    264:
                    265: echo -n standard daemons:
                    266: echo -n ' cron';               cron
                    267: echo '.'
                    268:
                    269: echo -n starting network daemons:
                    270:
                    271: # $gated and $routed_flags are imported from /etc/netstart.
                    272: # If $gated == YES, gated is used; otherwise routed.
                    273: # If $routed_flags == NO, routed isn't run.
                    274: if [ X${gated} = X"YES" -a -r /etc/gated.conf ]; then
                    275:        echo -n ' gated';               gated $gated_flags
                    276: elif [ "X${routed_flags}" != X"NO" ]; then
                    277:        echo -n ' routed';              routed $routed_flags
                    278: fi
                    279:
1.4       deraadt   280: # $mrouted_flags is imported from /etc/netstart;
                    281: # If $mrouted_flags == NO, then mrouted isn't run.
                    282: if [ "X${mrouted_flags}" != X"NO" ]; then
                    283:        echo -n ' mrouted';             mrouted $mrouted_flags
                    284: fi
                    285:
                    286: # $named_flags is imported from /etc/netstart;
1.1       deraadt   287: # if $named_flags != NO, named is run.
                    288: if [ "X${named_flags}" != X"NO" ]; then
                    289:        echo -n ' named';               named $named_flags
                    290: fi
1.48      deraadt   291: mount -a -t nfs                # do again, in case DNS hostnames are used..
1.1       deraadt   292:
                    293: # $rwhod is imported from /etc/netstart;
                    294: # if $rwhod == YES, rwhod is run.
                    295: if [ X${rwhod} = X"YES" ]; then
                    296:        echo -n ' rwhod';               rwhod
                    297: fi
                    298:
1.23      deraadt   299:
                    300: if [ X${lpd} = X"YES" ]; then
                    301:        echo -n ' printer';             lpd
                    302: fi
1.1       deraadt   303:
                    304: # $sendmail_flags is imported from /etc/netstart;
                    305: # If $sendmail_flags == NO or /etc/sendmail.cf doesn't exist, then
1.6       deraadt   306: # sendmail isn't run.  We call sendmail with a full path so that
                    307: # SIGHUP works.
1.1       deraadt   308: if [ "X${sendmail_flags}" != X"NO" -a -r /etc/sendmail.cf ]; then
1.6       deraadt   309:        echo -n ' sendmail';            /usr/sbin/sendmail ${sendmail_flags}
1.1       deraadt   310: fi
                    311:
1.23      deraadt   312: if [ X${inetd} = X"YES" ]; then
                    313:        echo -n ' inetd';               inetd
                    314: fi
1.1       deraadt   315:
                    316: # $rarpd_flags is imported from /etc/netstart;
                    317: # If $rarpd_flags == NO or /etc/ethers doesn't exist, then
                    318: # rarpd isn't run.
                    319: if [ "X${rarpd_flags}" != X"NO" -a -r /etc/ethers ]; then
                    320:        echo -n ' rarpd';               rarpd ${rarpd_flags}
                    321: fi
                    322:
                    323: # $bootparamd_flags is imported from /etc/netstart;
                    324: # If $bootparamd_flags == NO or /etc/bootparams doesn't exist, then
                    325: # bootparamd isn't run.
                    326: if [ "X${bootparamd_flags}" != X"NO" -a -r /etc/bootparams ]; then
                    327:        echo -n ' rpc.bootparamd';      rpc.bootparamd ${bootparamd_flags}
                    328: fi
                    329:
                    330: # $rbootd_flags is imported from /etc/netstart;
                    331: # If $rbootd_flags == NO or /etc/rbootd.conf doesn't exist, then
                    332: # rbootd isn't run.
                    333: if [ "X${rbootd_flags}" != X"NO" -a -r /etc/rbootd.conf ]; then
                    334:        echo -n ' rbootd';              rbootd ${rbootd_flags}
1.37      deraadt   335: fi
                    336:
                    337: if [ -x /usr/sbin/screenblank ]; then
                    338:        echo -n ' screenblank'; /usr/sbin/screenblank
1.1       deraadt   339: fi
                    340:
                    341: echo '.'
                    342:
1.12      deraadt   343: if [ -f /sbin/kbd -a -f /etc/kbdtype ]; then
                    344:        kbd `cat /etc/kbdtype`
                    345: fi
1.17      deraadt   346:
                    347: if [ -f /sbin/ldconfig ]; then
                    348:        echo 'creating runtime link editor directory cache.'
1.26      deraadt   349:        _LIBS=
                    350:        if [ -d /usr/local/lib ]; then
                    351:                _LIBS="$_LIBS /usr/local/lib"
                    352:        fi
                    353:        if [ -d /usr/X11R6/lib ]; then
                    354:                _LIBS="$_LIBS /usr/X11R6/lib"
                    355:        fi
                    356:        ldconfig $_LIBS
1.17      deraadt   357: fi
                    358:
                    359: # Kerberos runs ONLY on the Kerberos server machine
                    360: if [ X${kerberos_server} = X"YES" ]; then
1.30      tholo     361:        echo 'kerberos server'
                    362:        kerberos >> /var/log/kerberos.log &
                    363:        kadmind -n >> /var/log/kadmind.log &
1.17      deraadt   364: fi
                    365:
                    366: . /etc/rc.local
1.1       deraadt   367:
                    368: date
                    369: exit 0