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

Annotation of src/etc/rc, Revision 1.24

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