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

Annotation of src/etc/rc, Revision 1.9

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