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

Annotation of src/etc/rc, Revision 1.57

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