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

Annotation of src/etc/rc, Revision 1.12

1.12    ! deraadt     1: #      $OpenBSD: rc,v 1.11 1996/05/26 10:25:27 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.
                     20: if [ -f /etc/ccd.conf ]
                     21: then
                     22:        ccdconfig -C
                     23: fi
                     24:
                     25: if [ -e /fastboot ]
                     26: then
                     27:        echo "Fast boot: skipping disk checks."
                     28: elif [ $1x = autobootx ]
                     29: then
                     30:        echo "Automatic boot in progress: starting file system checks."
                     31:        fsck -p
                     32:        case $? in
                     33:        0)
                     34:                ;;
                     35:        2)
                     36:                exit 1
                     37:                ;;
                     38:        4)
                     39:                echo "Rebooting..."
                     40:                reboot
                     41:                echo "Reboot failed; help!"
                     42:                exit 1
                     43:                ;;
                     44:        8)
                     45:                echo "Automatic file system check failed; help!"
                     46:                exit 1
                     47:                ;;
                     48:        12)
                     49:                echo "Boot interrupted."
                     50:                exit 1
                     51:                ;;
                     52:        130)
                     53:                # interrupt before catcher installed
                     54:                exit 1
                     55:                ;;
                     56:        *)
                     57:                echo "Unknown error; help!"
                     58:                exit 1
                     59:                ;;
                     60:        esac
                     61: fi
                     62:
                     63: trap "echo 'Boot interrupted.'; exit 1" 3
                     64:
                     65: swapon -a
                     66:
                     67: umount -a >/dev/null 2>&1
                     68: mount -a -t nonfs
                     69: rm -f /fastboot                # XXX (root now writeable)
                     70:
                     71: # set flags on ttys.  (do early, in case they use tty for SLIP in netstart)
                     72: echo 'setting tty flags'
                     73: ttyflags -a
                     74:
                     75: # set hostname, turn on network
                     76: echo 'starting network'
                     77: . /etc/netstart
                     78:
                     79: mount /usr >/dev/null 2>&1
                     80: mount /var >/dev/null 2>&1
                     81:
1.5       dm         82: if [ X"${ipfilter}" = X"YES" -a X"${ipmon_flags}" != X"NO" ]; then
                     83:        ipmon ${ipmon_flags} &
                     84: fi
                     85:
1.1       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:
                     92: echo -n 'starting rpc daemons:'
                     93: echo -n ' portmap';            portmap
                     94:
1.9       deraadt    95: if [ -d /var/yp/binding ]; then
1.8       deraadt    96:        echo -n ' ypbind';              ypbind
                     97:
                     98:        if [ -d /var/yp/`domainname` ]; then
                     99:                # yp server capabilities needed...
1.10      deraadt   100:                echo -n ' ypserv';              ypserv -d
                    101:                echo -n ' ypxfrd';              ypxfrd
1.8       deraadt   102:
                    103:                # if we are the master server, run rpc.yppasswdd
                    104:                _host1=`ypwhich -m passwd 2> /dev/null`
                    105:                _host2=`hostname`
                    106:                if grep '^lookup' /etc/resolv.conf | grep yp | wc; then
                    107:                        _host1=`ypmatch $_host1 hosts | cut -d' ' -f2`
                    108:                        _host2=`ypmatch $_host2 hosts | cut -d' ' -f2 | head -1`
                    109:                else
                    110:                        _host1=`nslookup $_host1 | grep '^Name: ' | \
                    111:                            sed -e 's/^Name:    //'`
                    112:                        _host2=`nslookup $_host2 | grep '^Name: ' | \
                    113:                            sed -e 's/^Name:    //'`
                    114:                fi
                    115:                if [ "$host2" = "$host1" ]; then
1.10      deraadt   116:                        echo -n ' rpc.yppasswdd'; rpc.yppasswdd
1.8       deraadt   117:                fi
1.7       deraadt   118:        fi
1.1       deraadt   119: fi
                    120:
                    121: # $nfs_server is imported from /etc/netstart;
                    122: # if $nfs_server == YES, the machine is setup for being an nfs server
                    123: if [ X${nfs_server} = X"YES" -a -r /etc/exports ]; then
                    124:        rm -f /var/db/mountdtab
                    125:        echo -n > /var/db/mountdtab
                    126:        echo -n ' mountd';              mountd
                    127:        echo -n ' nfsd';                nfsd -tun 4
                    128: fi
                    129:
                    130: # $nfs_client is imported from /etc/netstart;
                    131: # if $nfs_client == YES, the machine is setup for being an nfs client
                    132: if [ X${nfs_client} = X"YES" ]; then
                    133:        echo -n ' nfsiod';              nfsiod -n 4
                    134: fi
                    135:
                    136: if [ X${amd} = X"YES" -a -d ${amd_dir} -a -r ${amd_master} ]; then
                    137:        echo -n ' amd'
                    138:        amd -l syslog -x error,noinfo,nostats -p \
                    139:            -a ${amd_dir} `cat ${amd_master}` > /var/run/amd.pid
                    140: fi
                    141:
                    142: echo '.'
                    143: mount -a -t nfs
                    144:
                    145: echo -n 'starting system logger'
                    146: rm -f /dev/log
1.3       deraadt   147: syslogd                # use "-s" for greater security
1.1       deraadt   148:
                    149: # $timed_flags is imported from /etc/netstart;
                    150: # if $timed_flags == NO, timed isn't run.
                    151: if [ "X${timed_flags}" != X"NO" ]; then
                    152:        echo -n ', time daemon'; timed $timed_flags
                    153: fi
                    154: echo '.'
                    155:
                    156: # /var/crash should be a directory or a symbolic link
                    157: # to the crash directory if core dumps are to be saved.
                    158: if [ -d /var/crash ]; then
                    159:        echo checking for core dump...
                    160:        savecore /var/crash
                    161: fi
                    162:
                    163:                                echo -n 'checking quotas:'
                    164: quotacheck -a
                    165:                                echo ' done.'
                    166: quotaon -a
                    167:
                    168: # build ps databases
                    169: echo 'building databases...'
1.2       deraadt   170: kvm_mkdb /bsd
1.1       deraadt   171: dev_mkdb
                    172:
                    173: chmod 666 /dev/tty[pqrs]*
                    174:
                    175: # check the password temp/lock file
                    176: if [ -f /etc/ptmp ]
                    177: then
                    178:        logger -s -p auth.err \
                    179:        'password file may be incorrect -- /etc/ptmp exists'
                    180: fi
                    181:
                    182: virecovery=/var/tmp/vi.recover/recover.*
                    183: if [ "$virecovery" != "/var/tmp/vi.recover/recover.*" ]; then
                    184:        echo preserving editor files
                    185:        for i in $virecovery; do
                    186:                sendmail -t < $i
                    187:        done
                    188: fi
                    189:
                    190: echo clearing /tmp
                    191:
                    192: # prune quickly with one rm, then use find to clean up /tmp/[lq]*
                    193: # (not needed with mfs /tmp, but doesn't hurt there...)
                    194: (cd /tmp && rm -rf [a-km-pr-zA-Z]* &&
                    195:     find . ! -name . ! -name lost+found ! -name quota.user \
                    196:        ! -name quota.group -exec rm -rf -- {} \; -type d -prune)
                    197:
                    198: if [ -f /var/account/acct ]; then
                    199:        echo 'turning on accounting';   accton /var/account/acct
                    200: fi
                    201:
                    202: echo -n standard daemons:
                    203: echo -n ' update';             update
                    204: echo -n ' cron';               cron
                    205: echo '.'
                    206:
                    207: echo -n starting network daemons:
                    208:
                    209: # $gated and $routed_flags are imported from /etc/netstart.
                    210: # If $gated == YES, gated is used; otherwise routed.
                    211: # If $routed_flags == NO, routed isn't run.
                    212: if [ X${gated} = X"YES" -a -r /etc/gated.conf ]; then
                    213:        echo -n ' gated';               gated $gated_flags
                    214: elif [ "X${routed_flags}" != X"NO" ]; then
                    215:        echo -n ' routed';              routed $routed_flags
                    216: fi
                    217:
1.4       deraadt   218: # $mrouted_flags is imported from /etc/netstart;
                    219: # If $mrouted_flags == NO, then mrouted isn't run.
                    220: if [ "X${mrouted_flags}" != X"NO" ]; then
                    221:        echo -n ' mrouted';             mrouted $mrouted_flags
                    222: fi
                    223:
                    224: # $named_flags is imported from /etc/netstart;
1.1       deraadt   225: # if $named_flags != NO, named is run.
                    226: if [ "X${named_flags}" != X"NO" ]; then
                    227:        echo -n ' named';               named $named_flags
                    228: fi
                    229:
                    230: # $rwhod is imported from /etc/netstart;
                    231: # if $rwhod == YES, rwhod is run.
                    232: if [ X${rwhod} = X"YES" ]; then
                    233:        echo -n ' rwhod';               rwhod
                    234: fi
                    235:
                    236: echo -n ' printer';            lpd
                    237:
                    238: # $sendmail_flags is imported from /etc/netstart;
                    239: # If $sendmail_flags == NO or /etc/sendmail.cf doesn't exist, then
1.6       deraadt   240: # sendmail isn't run.  We call sendmail with a full path so that
                    241: # SIGHUP works.
1.1       deraadt   242: if [ "X${sendmail_flags}" != X"NO" -a -r /etc/sendmail.cf ]; then
1.6       deraadt   243:        echo -n ' sendmail';            /usr/sbin/sendmail ${sendmail_flags}
1.1       deraadt   244: fi
                    245:
                    246: echo -n ' inetd';              inetd
                    247:
                    248: # $rarpd_flags is imported from /etc/netstart;
                    249: # If $rarpd_flags == NO or /etc/ethers doesn't exist, then
                    250: # rarpd isn't run.
                    251: if [ "X${rarpd_flags}" != X"NO" -a -r /etc/ethers ]; then
                    252:        echo -n ' rarpd';               rarpd ${rarpd_flags}
                    253: fi
                    254:
                    255: # $bootparamd_flags is imported from /etc/netstart;
                    256: # If $bootparamd_flags == NO or /etc/bootparams doesn't exist, then
                    257: # bootparamd isn't run.
                    258: if [ "X${bootparamd_flags}" != X"NO" -a -r /etc/bootparams ]; then
                    259:        echo -n ' rpc.bootparamd';      rpc.bootparamd ${bootparamd_flags}
                    260: fi
                    261:
                    262: # $rbootd_flags is imported from /etc/netstart;
                    263: # If $rbootd_flags == NO or /etc/rbootd.conf doesn't exist, then
                    264: # rbootd isn't run.
                    265: if [ "X${rbootd_flags}" != X"NO" -a -r /etc/rbootd.conf ]; then
                    266:        echo -n ' rbootd';              rbootd ${rbootd_flags}
                    267: fi
                    268:
                    269: echo '.'
                    270:
                    271: . /etc/rc.local
1.12    ! deraadt   272:
        !           273: if [ -f /sbin/kbd -a -f /etc/kbdtype ]; then
        !           274:        kbd `cat /etc/kbdtype`
        !           275: fi
1.1       deraadt   276:
                    277: date
                    278: exit 0