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

Annotation of src/etc/rc, Revision 1.21

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