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

Annotation of src/etc/rc, Revision 1.26

1.26    ! deraadt     1: #      $OpenBSD: rc,v 1.25 1996/09/23 13:06:36 deraadt 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."
                     28:        fsck -p
                     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
                     78:
1.5       dm         79: if [ X"${ipfilter}" = X"YES" -a X"${ipmon_flags}" != X"NO" ]; then
                     80:        ipmon ${ipmon_flags} &
1.25      deraadt    81: fi
                     82:
                     83: if [ X"${rfc1323}" = X"NO" ]; then
                     84:        echo 'disabling rfc1323';       sysctl -w net.inet.tcp.rfc1323=0
1.5       dm         85: fi
                     86:
1.1       deraadt    87: # clean up left-over files
                     88: rm -f /etc/nologin
                     89: rm -f /var/spool/lock/LCK.*
                     90: rm -f /var/spool/uucp/STST/*
                     91: (cd /var/run && { rm -rf -- *; install -c -m 664 -g utmp /dev/null utmp; })
                     92:
                     93: echo -n 'starting rpc daemons:'
1.24      millert    94:
                     95: # $portmap is imported from /etc/netstart;
                     96: # if $portmap == YES, the portmapper is started.
                     97: if [ X"${portmap}" = X"YES" ]; then
1.23      deraadt    98:        echo -n ' portmap';             portmap
                     99: fi
1.1       deraadt   100:
1.9       deraadt   101: if [ -d /var/yp/binding ]; then
1.8       deraadt   102:        if [ -d /var/yp/`domainname` ]; then
                    103:                # yp server capabilities needed...
1.10      deraadt   104:                echo -n ' ypserv';              ypserv -d
1.16      deraadt   105:                #echo -n ' ypxfrd';             ypxfrd
1.21      deraadt   106:        fi
                    107:
                    108:        echo -n ' ypbind';              ypbind
1.8       deraadt   109:
1.21      deraadt   110:        if [ -d /var/yp/`domainname` ]; then
1.8       deraadt   111:                # if we are the master server, run rpc.yppasswdd
                    112:                _host1=`ypwhich -m passwd 2> /dev/null`
                    113:                _host2=`hostname`
1.15      deraadt   114:                if [ `grep '^lookup' /etc/resolv.conf | grep yp | wc -c` -ne 0 ]; then
1.8       deraadt   115:                        _host1=`ypmatch $_host1 hosts | cut -d' ' -f2`
                    116:                        _host2=`ypmatch $_host2 hosts | cut -d' ' -f2 | head -1`
                    117:                else
                    118:                        _host1=`nslookup $_host1 | grep '^Name: ' | \
                    119:                            sed -e 's/^Name:    //'`
                    120:                        _host2=`nslookup $_host2 | grep '^Name: ' | \
                    121:                            sed -e 's/^Name:    //'`
                    122:                fi
1.13      deraadt   123:                if [ "$_host2" = "$_host1" ]; then
1.10      deraadt   124:                        echo -n ' rpc.yppasswdd'; rpc.yppasswdd
1.8       deraadt   125:                fi
1.7       deraadt   126:        fi
1.1       deraadt   127: fi
                    128:
                    129: # $nfs_server is imported from /etc/netstart;
                    130: # if $nfs_server == YES, the machine is setup for being an nfs server
                    131: if [ X${nfs_server} = X"YES" -a -r /etc/exports ]; then
                    132:        rm -f /var/db/mountdtab
                    133:        echo -n > /var/db/mountdtab
                    134:        echo -n ' mountd';              mountd
                    135:        echo -n ' nfsd';                nfsd -tun 4
                    136: fi
                    137:
                    138: # $nfs_client is imported from /etc/netstart;
                    139: # if $nfs_client == YES, the machine is setup for being an nfs client
                    140: if [ X${nfs_client} = X"YES" ]; then
                    141:        echo -n ' nfsiod';              nfsiod -n 4
                    142: fi
                    143:
                    144: if [ X${amd} = X"YES" -a -d ${amd_dir} -a -r ${amd_master} ]; then
                    145:        echo -n ' amd'
                    146:        amd -l syslog -x error,noinfo,nostats -p \
                    147:            -a ${amd_dir} `cat ${amd_master}` > /var/run/amd.pid
                    148: fi
                    149:
                    150: echo '.'
                    151: mount -a -t nfs
                    152:
                    153: echo -n 'starting system logger'
                    154: rm -f /dev/log
1.22      deraadt   155: syslogd
1.1       deraadt   156:
                    157: # $timed_flags is imported from /etc/netstart;
                    158: # if $timed_flags == NO, timed isn't run.
                    159: if [ "X${timed_flags}" != X"NO" ]; then
                    160:        echo -n ', time daemon'; timed $timed_flags
                    161: fi
                    162: echo '.'
                    163:
                    164: # /var/crash should be a directory or a symbolic link
                    165: # to the crash directory if core dumps are to be saved.
                    166: if [ -d /var/crash ]; then
                    167:        echo checking for core dump...
                    168:        savecore /var/crash
                    169: fi
                    170:
                    171:                                echo -n 'checking quotas:'
                    172: quotacheck -a
                    173:                                echo ' done.'
                    174: quotaon -a
                    175:
                    176: # build ps databases
                    177: echo 'building databases...'
1.2       deraadt   178: kvm_mkdb /bsd
1.1       deraadt   179: dev_mkdb
                    180:
                    181: chmod 666 /dev/tty[pqrs]*
                    182:
                    183: # check the password temp/lock file
1.17      deraadt   184: if [ -f /etc/ptmp ]; then
1.1       deraadt   185:        logger -s -p auth.err \
                    186:        'password file may be incorrect -- /etc/ptmp exists'
                    187: fi
                    188:
                    189: virecovery=/var/tmp/vi.recover/recover.*
                    190: if [ "$virecovery" != "/var/tmp/vi.recover/recover.*" ]; then
                    191:        echo preserving editor files
                    192:        for i in $virecovery; do
                    193:                sendmail -t < $i
                    194:        done
                    195: fi
                    196:
                    197: echo clearing /tmp
                    198:
                    199: # prune quickly with one rm, then use find to clean up /tmp/[lq]*
                    200: # (not needed with mfs /tmp, but doesn't hurt there...)
                    201: (cd /tmp && rm -rf [a-km-pr-zA-Z]* &&
                    202:     find . ! -name . ! -name lost+found ! -name quota.user \
                    203:        ! -name quota.group -exec rm -rf -- {} \; -type d -prune)
                    204:
                    205: if [ -f /var/account/acct ]; then
                    206:        echo 'turning on accounting';   accton /var/account/acct
                    207: fi
                    208:
                    209: echo -n standard daemons:
                    210: echo -n ' cron';               cron
                    211: echo '.'
                    212:
                    213: echo -n starting network daemons:
                    214:
                    215: # $gated and $routed_flags are imported from /etc/netstart.
                    216: # If $gated == YES, gated is used; otherwise routed.
                    217: # If $routed_flags == NO, routed isn't run.
                    218: if [ X${gated} = X"YES" -a -r /etc/gated.conf ]; then
                    219:        echo -n ' gated';               gated $gated_flags
                    220: elif [ "X${routed_flags}" != X"NO" ]; then
                    221:        echo -n ' routed';              routed $routed_flags
                    222: fi
                    223:
1.4       deraadt   224: # $mrouted_flags is imported from /etc/netstart;
                    225: # If $mrouted_flags == NO, then mrouted isn't run.
                    226: if [ "X${mrouted_flags}" != X"NO" ]; then
                    227:        echo -n ' mrouted';             mrouted $mrouted_flags
                    228: fi
                    229:
                    230: # $named_flags is imported from /etc/netstart;
1.1       deraadt   231: # if $named_flags != NO, named is run.
                    232: if [ "X${named_flags}" != X"NO" ]; then
                    233:        echo -n ' named';               named $named_flags
                    234: fi
                    235:
                    236: # $rwhod is imported from /etc/netstart;
                    237: # if $rwhod == YES, rwhod is run.
                    238: if [ X${rwhod} = X"YES" ]; then
                    239:        echo -n ' rwhod';               rwhod
                    240: fi
                    241:
1.23      deraadt   242:
                    243: if [ X${lpd} = X"YES" ]; then
                    244:        echo -n ' printer';             lpd
                    245: fi
1.1       deraadt   246:
                    247: # $sendmail_flags is imported from /etc/netstart;
                    248: # If $sendmail_flags == NO or /etc/sendmail.cf doesn't exist, then
1.6       deraadt   249: # sendmail isn't run.  We call sendmail with a full path so that
                    250: # SIGHUP works.
1.1       deraadt   251: if [ "X${sendmail_flags}" != X"NO" -a -r /etc/sendmail.cf ]; then
1.6       deraadt   252:        echo -n ' sendmail';            /usr/sbin/sendmail ${sendmail_flags}
1.1       deraadt   253: fi
                    254:
1.23      deraadt   255: if [ X${inetd} = X"YES" ]; then
                    256:        echo -n ' inetd';               inetd
                    257: fi
1.1       deraadt   258:
                    259: # $rarpd_flags is imported from /etc/netstart;
                    260: # If $rarpd_flags == NO or /etc/ethers doesn't exist, then
                    261: # rarpd isn't run.
                    262: if [ "X${rarpd_flags}" != X"NO" -a -r /etc/ethers ]; then
                    263:        echo -n ' rarpd';               rarpd ${rarpd_flags}
                    264: fi
                    265:
                    266: # $bootparamd_flags is imported from /etc/netstart;
                    267: # If $bootparamd_flags == NO or /etc/bootparams doesn't exist, then
                    268: # bootparamd isn't run.
                    269: if [ "X${bootparamd_flags}" != X"NO" -a -r /etc/bootparams ]; then
                    270:        echo -n ' rpc.bootparamd';      rpc.bootparamd ${bootparamd_flags}
                    271: fi
                    272:
                    273: # $rbootd_flags is imported from /etc/netstart;
                    274: # If $rbootd_flags == NO or /etc/rbootd.conf doesn't exist, then
                    275: # rbootd isn't run.
                    276: if [ "X${rbootd_flags}" != X"NO" -a -r /etc/rbootd.conf ]; then
                    277:        echo -n ' rbootd';              rbootd ${rbootd_flags}
                    278: fi
                    279:
                    280: echo '.'
                    281:
1.12      deraadt   282: if [ -f /sbin/kbd -a -f /etc/kbdtype ]; then
                    283:        kbd `cat /etc/kbdtype`
                    284: fi
1.17      deraadt   285:
                    286: # patch /etc/motd
                    287: if [ ! -f /etc/motd ]; then
                    288:        install -c -o root -g wheel -m 664 /dev/null /etc/motd
                    289: fi
                    290: T=/tmp/_motd
                    291: rm -f $T
                    292: sysctl -n kern.version | sed 1q > $T
                    293: echo "" >> $T
                    294: sed '1,/^$/d' < /etc/motd >> $T
                    295: cmp -s $T /etc/motd || cp $T /etc/motd
                    296: rm -f $T
                    297:
                    298: if [ -f /sbin/ldconfig ]; then
                    299:        echo 'creating runtime link editor directory cache.'
1.26    ! deraadt   300:        _LIBS=
        !           301:        if [ -d /usr/local/lib ]; then
        !           302:                _LIBS="$_LIBS /usr/local/lib"
        !           303:        fi
        !           304:        if [ -d /usr/X11R6/lib ]; then
        !           305:                _LIBS="$_LIBS /usr/X11R6/lib"
        !           306:        fi
        !           307:        ldconfig $_LIBS
1.17      deraadt   308: fi
                    309:
                    310: # Kerberos runs ONLY on the Kerberos server machine
                    311: if [ X${kerberos_server} = X"YES" ]; then
                    312:        echo 'kerberos server'; kerberos >> /var/log/kerberos.log &
                    313: fi
                    314:
                    315: . /etc/rc.local
1.1       deraadt   316:
                    317: date
                    318: exit 0