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

Annotation of src/etc/rc, Revision 1.282

1.282   ! avsm        1: #      $OpenBSD: rc,v 1.281 2006/03/27 16:53:10 reyk 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:
1.131     millert     8: # Subroutines (have to come first).
                      9:
                     10: # Strip comments (and leading/trailing whitespace if IFS is set)
                     11: # from a file and spew to stdout
                     12: stripcom() {
                     13:        local _file="$1"
                     14:        local _line
                     15:
                     16:        {
                     17:                while read _line ; do
                     18:                        _line=${_line%%#*}              # strip comments
                     19:                        test -z "$_line" && continue
                     20:                        echo $_line
                     21:                done
                     22:        } < $_file
                     23: }
                     24:
1.265     millert    25: # Update resource limits when sysctl changes
                     26: # Usage: update_limit -X loginconf_name
                     27: update_limit() {
                     28:        local _fl="$1"  # ulimit flag
                     29:        local _lc="$2"  # login.conf name
                     30:        local _new _suf
                     31:
                     32:        for _suf in "" -cur -max; do
                     33:                _new=`getcap -f /etc/login.conf -s ${_lc}${_suf} daemon 2>/dev/null`
                     34:                if [ X"$_new" != X"" ]; then
                     35:                        if [ X"$_new" = X"infinity" ]; then
                     36:                                _new=unlimited
                     37:                        fi
                     38:                        case "$_suf" in
                     39:                        -cur)
                     40:                                ulimit -S $_fl $_new
                     41:                                ;;
                     42:                        -max)
                     43:                                ulimit -H $_fl $_new
                     44:                                ;;
                     45:                        *)
                     46:                                ulimit $_fl $_new
                     47:                                return
                     48:                                ;;
                     49:                        esac
                     50:                fi
                     51:        done
                     52: }
                     53:
                     54: sysctl_conf() {
1.267     millert    55:        test -s /etc/sysctl.conf || return
                     56:
1.265     millert    57:        # delete comments and blank lines
                     58:        set -- `stripcom /etc/sysctl.conf`
                     59:        while [ $# -ge 1 ] ; do
                     60:                sysctl $1
                     61:                # update limits if needed
                     62:                case $1 in
                     63:                kern.maxproc=*)
                     64:                        update_limit -p maxproc
                     65:                        ;;
                     66:                kern.maxfiles=*)
                     67:                        update_limit -n openfiles
                     68:                        ;;
                     69:                esac
                     70:                shift
                     71:        done
                     72: }
                     73:
                     74: mixerctl_conf()
                     75: {
1.267     millert    76:        test -s /etc/mixerctl.conf || return
                     77:
1.265     millert    78:        # delete comments and blank lines
                     79:        set -- `stripcom /etc/mixerctl.conf`
                     80:        while [ $# -ge 1 ] ; do
                     81:                mixerctl -q $1 > /dev/null 2>&1
                     82:                shift
                     83:        done
                     84: }
                     85:
1.267     millert    86: wsconsctl_conf()
                     87: {
                     88:        local save_IFS="$IFS"
                     89:
                     90:        test -x /sbin/wsconsctl -a -s /etc/wsconsctl.conf || return
                     91:        # delete comments and blank lines
                     92:        IFS="
                     93: "
                     94:        set -- `stripcom /etc/wsconsctl.conf`
                     95:        IFS="$save_IFS"
                     96:        while [ $# -ge 1 ] ; do
                     97:                eval /sbin/wsconsctl -w $1
                     98:                shift
                     99:        done
                    100: }
                    101:
1.131     millert   102: # End subroutines
                    103:
1.1       deraadt   104: stty status '^T'
                    105:
                    106: # Set shell to ignore SIGINT (2), but not children;
                    107: # shell catches SIGQUIT (3) and returns to single user after fsck.
                    108: trap : 2
                    109: trap : 3       # shouldn't be needed
                    110:
                    111: HOME=/; export HOME
                    112: PATH=/sbin:/bin:/usr/sbin:/usr/bin
                    113: export PATH
1.108     deraadt   114:
1.266     millert   115: if [ X"$1" = X"shutdown" ]; then
1.108     deraadt   116:        dd if=/dev/urandom of=/var/db/host.random bs=1024 count=64 >/dev/null 2>&1
                    117:        chmod 600 /var/db/host.random >/dev/null 2>&1
                    118:        if [ $? -eq 0 -a -f /etc/rc.shutdown ]; then
                    119:                echo /etc/rc.shutdown in progress...
                    120:                . /etc/rc.shutdown
                    121:                echo /etc/rc.shutdown complete.
1.240     mcbride   122:
                    123:                # bring carp interfaces down gracefully
                    124:                for hn in /etc/hostname.carp[0-9]*; do
                    125:                        # Strip off /etc/hostname. prefix
                    126:                        if=${hn#/etc/hostname.}
1.241     cedric    127:                        test "$if" = "carp[0-9]*" && continue
1.240     mcbride   128:
1.243     deraadt   129:                        ifconfig $if > /dev/null 2>&1
1.271     mcbride   130:                        if [ $? -eq 0 ]; then
1.243     deraadt   131:                                ifconfig $if down
                    132:                        fi
1.240     mcbride   133:                done
1.246     mcbride   134:
1.266     millert   135:                if [ X"${powerdown}" = X"YES" ]; then
1.246     mcbride   136:                        exit 2
                    137:                fi
                    138:
1.108     deraadt   139:        else
                    140:                echo single user: not running /etc/rc.shutdown
                    141:        fi
                    142:        exit 0
                    143: fi
1.1       deraadt   144:
                    145: # Configure ccd devices.
1.17      deraadt   146: if [ -f /etc/ccd.conf ]; then
1.1       deraadt   147:        ccdconfig -C
                    148: fi
1.98      jakob     149:
                    150: # Configure raid devices.
                    151: for dev in 0 1 2 3; do
                    152:        if [ -f /etc/raid$dev.conf ]; then
                    153:                raidctl -c /etc/raid$dev.conf raid$dev
                    154:        fi
                    155: done
1.190     tdeval    156:
                    157: # Check parity on raid devices.
1.191     deraadt   158: raidctl -P all
1.1       deraadt   159:
1.172     miod      160: swapctl -A -t blk
1.170     deraadt   161:
1.17      deraadt   162: if [ -e /fastboot ]; then
1.1       deraadt   163:        echo "Fast boot: skipping disk checks."
1.266     millert   164: elif [ X"$1" = X"autoboot" ]; then
1.1       deraadt   165:        echo "Automatic boot in progress: starting file system checks."
1.31      millert   166:        fsck -p
1.1       deraadt   167:        case $? in
                    168:        0)
                    169:                ;;
                    170:        2)
                    171:                exit 1
                    172:                ;;
                    173:        4)
                    174:                echo "Rebooting..."
                    175:                reboot
                    176:                echo "Reboot failed; help!"
                    177:                exit 1
                    178:                ;;
                    179:        8)
                    180:                echo "Automatic file system check failed; help!"
                    181:                exit 1
                    182:                ;;
                    183:        12)
                    184:                echo "Boot interrupted."
                    185:                exit 1
                    186:                ;;
                    187:        130)
                    188:                # interrupt before catcher installed
                    189:                exit 1
                    190:                ;;
                    191:        *)
                    192:                echo "Unknown error; help!"
                    193:                exit 1
                    194:                ;;
                    195:        esac
                    196: fi
                    197:
                    198: trap "echo 'Boot interrupted.'; exit 1" 3
                    199:
                    200: umount -a >/dev/null 2>&1
                    201: mount -a -t nonfs
1.57      niklas    202: mount -uw /            # root on nfs requires this, others aren't hurt
1.1       deraadt   203: rm -f /fastboot                # XXX (root now writeable)
1.177     deraadt   204:
                    205: # pick up option configuration
                    206: . /etc/rc.conf
1.1       deraadt   207:
1.255     henning   208: # set flags on ttys.  (do early, in case they use tty for SLIP in netstart)
1.1       deraadt   209: echo 'setting tty flags'
                    210: ttyflags -a
1.77      angelos   211:
1.252     mcbride   212: if [ -f /sbin/kbd -a -f /etc/kbdtype ]; then
                    213:        kbd `cat /etc/kbdtype`
                    214: fi
                    215:
1.279     deraadt   216: wsconsctl_conf
                    217:
1.266     millert   218: if [ X"${pf}" != X"NO" ]; then
1.211     mcbride   219:        RULES="block all"
1.228     henning   220:        RULES="$RULES\npass on lo0"
1.195     dhartmei  221:        RULES="$RULES\npass in proto tcp from any to any port 22 keep state"
1.208     camield   222:        RULES="$RULES\npass out proto { tcp, udp } from any to any port 53 keep state"
1.215     camield   223:        RULES="$RULES\npass out inet proto icmp all icmp-type echoreq keep state"
1.257     grange    224:        if ifconfig lo0 inet6 >/dev/null 2>&1; then
1.258     itojun    225:                RULES="$RULES\npass out inet6 proto icmp6 all icmp6-type neighbrsol"
                    226:                RULES="$RULES\npass in inet6 proto icmp6 all icmp6-type neighbradv"
1.257     grange    227:                RULES="$RULES\npass out inet6 proto icmp6 all icmp6-type routersol"
                    228:                RULES="$RULES\npass in inet6 proto icmp6 all icmp6-type routeradv"
                    229:        fi
1.240     mcbride   230:        RULES="$RULES\npass proto { pfsync, carp }"
1.193     deraadt   231:        case `sysctl vfs.mounts.nfs 2>/dev/null` in
1.184     deraadt   232:        *[1-9]*)
                    233:                # don't kill NFS
1.218     cedric    234:                RULES="scrub in all no-df\n$RULES"
1.184     deraadt   235:                RULES="$RULES\npass in proto udp from any port { 111, 2049 } to any"
                    236:                RULES="$RULES\npass out proto udp from any to any port { 111, 2049 }"
                    237:                ;;
                    238:        esac
1.269     dhartmei  239:        echo $RULES | pfctl -f -
                    240:        pfctl -e
1.176     kjell     241: fi
                    242:
1.267     millert   243: sysctl_conf
1.260     jsg       244:
1.1       deraadt   245: # set hostname, turn on network
                    246: echo 'starting network'
1.264     deraadt   247: if [ -f /etc/resolv.conf.save ]; then
                    248:        mv /etc/resolv.conf.save /etc/resolv.conf
                    249:        touch /etc/resolv.conf
                    250: fi
1.1       deraadt   251: . /etc/netstart
1.176     kjell     252:
1.266     millert   253: if [ X"${pf}" != X"NO" ]; then
1.176     kjell     254:        if [ -f ${pf_rules} ]; then
1.198     dhartmei  255:                pfctl -f ${pf_rules}
1.176     kjell     256:        fi
                    257: fi
1.1       deraadt   258:
1.278     otto      259: mount -s /usr >/dev/null 2>&1
                    260: mount -s /var >/dev/null 2>&1
1.180     deraadt   261:
1.149     deraadt   262: # if there's no /var/db/host.random, make one through /dev/urandom
                    263: if [ ! -f /var/db/host.random ]; then
                    264:        dd if=/dev/urandom of=/var/db/host.random bs=1024 count=64 \
                    265:                >/dev/null 2>&1
                    266:        chmod 600 /var/db/host.random >/dev/null 2>&1
                    267: else
                    268:        dd if=/var/db/host.random of=/dev/urandom bs=1024 count=64 \
                    269:            > /dev/null 2>&1
                    270:        dd if=/var/db/host.random of=/dev/arandom bs=1024 count=64 \
                    271:            > /dev/null 2>&1
                    272: fi
1.157     deraadt   273:
                    274: # reset seed file, so that if a shutdown-less reboot occurs,
                    275: # the next seed is not a repeat
                    276: dd if=/dev/urandom of=/var/db/host.random bs=1024 count=64 \
                    277:     > /dev/null 2>&1
1.29      deraadt   278:
1.55      deraadt   279: # clean up left-over files
                    280: rm -f /etc/nologin
                    281: rm -f /var/spool/lock/LCK.*
                    282: rm -f /var/spool/uucp/STST/*
1.247     henning   283: (cd /var/run && { rm -rf -- *; install -c -m 664 -g utmp /dev/null utmp; })
1.196     beck      284: (cd /var/authpf && rm -rf -- *)
1.96      alex      285:
                    286: # save a copy of the boot messages
                    287: dmesg >/var/run/dmesg.boot
1.55      deraadt   288:
1.58      deraadt   289: echo 'starting system logger'
                    290: rm -f /dev/log
1.266     millert   291: if [ X"${named_flags}" != X"NO" ]; then
1.220     jakob     292:        rm -f /var/named/dev/log
                    293:        syslogd_flags="${syslogd_flags} -a /var/named/dev/log"
1.216     millert   294: fi
                    295: if [ -d /var/empty ]; then
                    296:        rm -f /var/empty/dev/log
                    297:        mkdir -p -m 0555 /var/empty/dev
                    298:        syslogd_flags="${syslogd_flags} -a /var/empty/dev/log"
1.74      millert   299: fi
1.65      marc      300: syslogd ${syslogd_flags}
1.184     deraadt   301:
1.186     deraadt   302: if [ X"${pf}" != X"NO" -a X"${pflogd_flags}" != X"NO" ]; then
1.261     millert   303:        if ifconfig pflog0 >/dev/null 2>&1; then
                    304:                ifconfig pflog0 up
                    305:                pflogd ${pflogd_flags}
                    306:        fi
1.217     jakob     307: fi
                    308:
1.224     todd      309: # $named_flags is imported from /etc/rc.conf;
1.54      deraadt   310: # if $named_flags != NO, named is run.
1.266     millert   311: if [ X"${named_flags}" != X"NO" ]; then
1.221     jakob     312:        if ! cmp -s /etc/rndc.key /var/named/etc/rndc.key ; then
                    313:                echo -n "rndc-confgen: generating new shared secret... "
                    314:                if /usr/sbin/rndc-confgen -a -t /var/named >/dev/null 2>&1; then
                    315:                        chmod 0640 /var/named/etc/rndc.key >/dev/null 2>&1
                    316:                        echo done.
                    317:                else
                    318:                        echo failed.
                    319:                fi
                    320:        fi
                    321:
1.58      deraadt   322:        echo 'starting named';          named $named_flags
1.94      deraadt   323: fi
                    324:
                    325: # $isakmpd_flags is imported from /etc/rc.conf;
1.251     hshoexer  326: # If $isakmpd_flags == NO, isakmpd isn't run.
1.266     millert   327: if [ X"${isakmpd_flags}" != X"NO" ]; then
1.94      deraadt   328:        echo 'starting isakmpd';        isakmpd ${isakmpd_flags}
1.280     hshoexer  329: fi
                    330:
                    331: # $ipsec is imported from /etc/rc.conf;
                    332: # if $ipsec == NO or /etc/ipsec.conf doesn't exist, then
                    333: # ipsecctl isn't run.
                    334: if [ X"${ipsec}" != X"NO" ]; then
                    335:        if [ -f ${ipsec_rules} ]; then
                    336:                ipsecctl -f ${ipsec_rules}
                    337:        fi
1.40      provos    338: fi
1.1       deraadt   339:
1.276     tom       340: echo -n 'starting initial daemons:'
1.24      millert   341:
1.52      deraadt   342: # $portmap is imported from /etc/rc.conf;
1.24      millert   343: # if $portmap == YES, the portmapper is started.
                    344: if [ X"${portmap}" = X"YES" ]; then
1.23      deraadt   345:        echo -n ' portmap';             portmap
                    346: fi
1.1       deraadt   347:
1.273     deraadt   348: if [ X`domainname` != X ]; then
1.8       deraadt   349:        if [ -d /var/yp/`domainname` ]; then
1.273     deraadt   350:                # YP server capabilities needed...
1.36      niklas    351:                echo -n ' ypserv';              ypserv ${ypserv_flags}
1.16      deraadt   352:                #echo -n ' ypxfrd';             ypxfrd
1.21      deraadt   353:        fi
                    354:
1.273     deraadt   355:        if [ -d /var/yp/binding ]; then
                    356:                # YP client capabilities needed...
                    357:                echo -n ' ypbind';              ypbind
                    358:        fi
1.8       deraadt   359:
1.232     deraadt   360:        if [ X"${yppasswdd_flags}" != X"NO" -a -d /var/yp/`domainname` ]; then
1.8       deraadt   361:                # if we are the master server, run rpc.yppasswdd
                    362:                _host1=`ypwhich -m passwd 2> /dev/null`
                    363:                _host2=`hostname`
1.15      deraadt   364:                if [ `grep '^lookup' /etc/resolv.conf | grep yp | wc -c` -ne 0 ]; then
1.8       deraadt   365:                        _host1=`ypmatch $_host1 hosts | cut -d' ' -f2`
                    366:                        _host2=`ypmatch $_host2 hosts | cut -d' ' -f2 | head -1`
                    367:                else
1.263     deraadt   368:                        _host1=`echo $_host1 | nslookup | grep '^Name: ' | \
1.8       deraadt   369:                            sed -e 's/^Name:    //'`
1.263     deraadt   370:                        _host2=`echo $_host2 | nslookup | grep '^Name: ' | \
1.8       deraadt   371:                            sed -e 's/^Name:    //'`
                    372:                fi
1.13      deraadt   373:                if [ "$_host2" = "$_host1" ]; then
1.35      niklas    374:                        echo -n ' rpc.yppasswdd'
                    375:                        rpc.yppasswdd ${yppasswdd_flags}
1.8       deraadt   376:                fi
1.7       deraadt   377:        fi
1.1       deraadt   378: fi
                    379:
1.52      deraadt   380: # $nfs_server is imported from /etc/rc.conf;
1.1       deraadt   381: # if $nfs_server == YES, the machine is setup for being an nfs server
1.266     millert   382: if [ X"${nfs_server}" = X"YES" -a -s /etc/exports -a \
1.141     deraadt   383:     `sed -e '/^#/d' < /etc/exports | wc -l` -ne 0 ]; then
1.68      millert   384:        rm -f /var/db/mountdtab
1.1       deraadt   385:        echo -n > /var/db/mountdtab
1.282   ! avsm      386:        echo -n ' mountd';              mountd ${mountd_flags}
1.42      niklas    387:        echo -n ' nfsd';                nfsd ${nfsd_flags}
1.266     millert   388:        if [ X"${lockd}" = X"YES" ]; then
1.42      niklas    389:                echo -n ' rpc.lockd';   rpc.lockd
                    390:        fi
1.1       deraadt   391: fi
                    392:
1.266     millert   393: if [ X"${amd}" = X"YES" -a -e ${amd_master} ]; then
1.1       deraadt   394:        echo -n ' amd'
1.107     deraadt   395:        (cd /etc/amd; amd -l syslog -x error,noinfo,nostats -p \
                    396:            -a ${amd_dir} `cat ${amd_master}` > /var/run/amd.pid )
1.146     matt      397: fi
                    398:
1.255     henning   399: # run rdate before timed/ntpd
                    400: if [ X"${rdate_flags}" != X"NO" ]; then
                    401:        echo -n ' rdate';       rdate -s ${rdate_flags}
                    402: fi
                    403:
                    404: # $timed_flags is imported from /etc/rc.conf;
                    405: # if $timed_flags == NO, timed isn't run.
1.266     millert   406: if [ X"${timed_flags}" != X"NO" ]; then
1.255     henning   407:        echo -n ' timed'; timed $timed_flags
                    408: fi
                    409:
1.266     millert   410: if [ X"${ntpd_flags}" != X"NO" ]; then
1.270     deraadt   411:        echo -n ' ntpd'; ntpd $ntpd_flags
1.255     henning   412: fi
1.1       deraadt   413: echo '.'
1.58      deraadt   414:
1.278     otto      415: mount -a
1.172     miod      416:
                    417: swapctl -A -t noblk
1.1       deraadt   418:
                    419: # /var/crash should be a directory or a symbolic link
                    420: # to the crash directory if core dumps are to be saved.
                    421: if [ -d /var/crash ]; then
1.188     tholo     422:        savecore ${savecore_flags} /var/crash
1.1       deraadt   423: fi
                    424:
1.266     millert   425: if [ X"${afs}" = X"YES" -a -c /dev/xfs0 ]; then
1.90      art       426:        echo -n 'mounting afs:'
1.233     beck      427:        mkdir -p -m 0755 /afs
                    428:        mount -t xfs /dev/xfs0 /afs
1.245     deraadt   429:        /usr/libexec/afsd ${afsd_flags}
1.90      art       430:        echo ' done.'
                    431: fi
                    432:
1.266     millert   433: if [ X"${check_quotas}" = X"YES" ]; then
1.41      downsj    434:        echo -n 'checking quotas:'
                    435:        quotacheck -a
                    436:        echo ' done.'
                    437:        quotaon -a
                    438: fi
1.1       deraadt   439:
                    440: # build ps databases
1.95      deraadt   441: echo -n 'building ps databases:'
                    442: echo -n " kvm"
1.88      millert   443: kvm_mkdb
1.95      deraadt   444: echo -n " dev"
1.1       deraadt   445: dev_mkdb
1.95      deraadt   446: echo "."
1.1       deraadt   447:
1.101     deraadt   448: chmod 666 /dev/tty[pqrstuvwxyzPQRST]*
1.226     millert   449: chown root:wheel /dev/tty[pqrstuvwxyzPQRST]*
1.1       deraadt   450:
                    451: # check the password temp/lock file
1.17      deraadt   452: if [ -f /etc/ptmp ]; then
1.1       deraadt   453:        logger -s -p auth.err \
                    454:        'password file may be incorrect -- /etc/ptmp exists'
1.32      deraadt   455: fi
                    456:
1.49      millert   457: echo clearing /tmp
                    458:
                    459: # prune quickly with one rm, then use find to clean up /tmp/[lq]*
                    460: # (not needed with mfs /tmp, but doesn't hurt there...)
                    461: (cd /tmp && rm -rf [a-km-pr-zA-Z]* &&
                    462:     find . ! -name . ! -name lost+found ! -name quota.user \
1.103     millert   463:        ! -name quota.group -execdir rm -rf -- {} \; -type d -prune)
1.49      millert   464:
1.256     henning   465: # create Unix sockets directories for X if needed and make sure they have
1.203     hugh      466: # correct permissions
1.210     henning   467: if [ -d /usr/X11R6/lib ]; then
1.203     hugh      468:        for d in /tmp/.X11-unix /tmp/.ICE-unix ; do
1.210     henning   469:                if [ -d $d ]; then
1.203     hugh      470:                        if [ `ls -ld $d | cut -d' ' -f4` != root ]; then
                    471:                                chown root $d
                    472:                        fi
                    473:                        if [ `ls -ld $d | cut -d' ' -f1` != drwxrwxrwt ]; then
                    474:                                chmod 1777 $d
                    475:                        fi
                    476:                elif [ -e $d ]; then
                    477:                        echo "Error: $d exists and isn't a directory."
                    478:                else
                    479:                        mkdir -m 1777 $d
                    480:                fi
                    481:        done
                    482: fi
                    483:
1.72      deraadt   484: [ -f /etc/rc.securelevel ] && . /etc/rc.securelevel
1.266     millert   485: if [ X"${securelevel}" != X"" ]; then
1.33      millert   486:        echo -n 'setting kernel security level: '
1.234     jmc       487:        sysctl kern.securelevel=${securelevel}
1.1       deraadt   488: fi
                    489:
1.34      deraadt   490: # patch /etc/motd
                    491: if [ ! -f /etc/motd ]; then
                    492:        install -c -o root -g wheel -m 664 /dev/null /etc/motd
                    493: fi
1.131     millert   494: T=`mktemp /tmp/_motd.XXXXXXXXXX`
1.105     millert   495: if [ $? -eq 0 ]; then
1.102     millert   496:        sysctl -n kern.version | sed 1q > $T
                    497:        echo "" >> $T
                    498:        sed '1,/^$/d' < /etc/motd >> $T
                    499:        cmp -s $T /etc/motd || cp $T /etc/motd
                    500:        rm -f $T
                    501: fi
1.34      deraadt   502:
1.1       deraadt   503: if [ -f /var/account/acct ]; then
                    504:        echo 'turning on accounting';   accton /var/account/acct
                    505: fi
                    506:
1.115     deraadt   507: if [ -f /sbin/ldconfig ]; then
                    508:        echo 'creating runtime link editor directory cache.'
                    509:        if [ -d /usr/local/lib ]; then
1.183     todd      510:                shlib_dirs="/usr/local/lib $shlib_dirs"
1.115     deraadt   511:        fi
                    512:        if [ -d /usr/X11R6/lib ]; then
1.183     todd      513:                shlib_dirs="/usr/X11R6/lib $shlib_dirs"
1.115     deraadt   514:        fi
                    515:        ldconfig $shlib_dirs
1.231     millert   516: fi
                    517:
                    518: if [ -x /usr/libexec/vi.recover ]; then
                    519:        echo 'preserving editor files'; /usr/libexec/vi.recover
1.115     deraadt   520: fi
                    521:
1.189     deraadt   522: if [ ! -f /etc/ssh/ssh_host_dsa_key ]; then
1.133     deraadt   523:        echo -n "ssh-keygen: generating new DSA host key... "
1.189     deraadt   524:        if /usr/bin/ssh-keygen -q -t dsa -f /etc/ssh/ssh_host_dsa_key -N ''; then
1.163     deraadt   525:                echo done.
                    526:        else
                    527:                echo failed.
                    528:        fi
                    529: fi
1.189     deraadt   530: if [ ! -f /etc/ssh/ssh_host_rsa_key ]; then
1.163     deraadt   531:        echo -n "ssh-keygen: generating new RSA host key... "
1.189     deraadt   532:        if /usr/bin/ssh-keygen -q -t rsa -f /etc/ssh/ssh_host_rsa_key -N ''; then
1.133     deraadt   533:                echo done.
                    534:        else
                    535:                echo failed.
                    536:        fi
                    537: fi
1.189     deraadt   538: if [ ! -f /etc/ssh/ssh_host_key ]; then
1.187     markus    539:        echo -n "ssh-keygen: generating new RSA1 host key... "
1.189     deraadt   540:        if /usr/bin/ssh-keygen -q -t rsa1 -f /etc/ssh/ssh_host_key -N ''; then
1.244     markus    541:                echo done.
                    542:        else
                    543:                echo failed.
                    544:        fi
                    545: fi
                    546:
                    547: if [ ! -f /etc/isakmpd/private/local.key ]; then
                    548:        echo -n "openssl: generating new isakmpd RSA key... "
                    549:        if /usr/sbin/openssl genrsa -out /etc/isakmpd/private/local.key 1024 \
                    550:            > /dev/null 2>&1; then
                    551:                chmod 600 /etc/isakmpd/private/local.key
                    552:                openssl rsa -out /etc/isakmpd/private/local.pub \
                    553:                    -in /etc/isakmpd/private/local.key -pubout > /dev/null 2>&1
1.114     deraadt   554:                echo done.
                    555:        else
                    556:                echo failed.
                    557:        fi
                    558: fi
                    559:
1.1       deraadt   560: echo -n starting network daemons:
                    561:
1.227     ian       562: # $routed_flags are imported from /etc/rc.conf.
1.1       deraadt   563: # If $routed_flags == NO, routed isn't run.
1.266     millert   564: if [ X"${routed_flags}" != X"NO" ]; then
1.1       deraadt   565:        echo -n ' routed';              routed $routed_flags
                    566: fi
                    567:
1.52      deraadt   568: # $mrouted_flags is imported from /etc/rc.conf;
1.4       deraadt   569: # If $mrouted_flags == NO, then mrouted isn't run.
1.266     millert   570: if [ X"${mrouted_flags}" != X"NO" ]; then
1.4       deraadt   571:        echo -n ' mrouted';             mrouted $mrouted_flags
1.262     henning   572: fi
                    573:
1.266     millert   574: if [ X"${ospfd_flags}" != X"NO" ]; then
1.262     henning   575:        echo -n ' ospfd';               /usr/sbin/ospfd $ospfd_flags
1.239     henning   576: fi
                    577:
1.266     millert   578: if [ X"${bgpd_flags}" != X"NO" ]; then
1.239     henning   579:        echo -n ' bgpd';                /usr/sbin/bgpd $bgpd_flags
1.4       deraadt   580: fi
1.1       deraadt   581:
1.86      form      582: # $dhcpd_flags is imported from /etc/rc.conf
                    583: # If $dhcpd_flags == NO or /etc/dhcpd.conf doesn't exist, then dhcpd isn't run.
1.266     millert   584: if [ X"${dhcpd_flags}" != X"NO" -a -f /etc/dhcpd.conf ]; then
1.86      form      585:        touch /var/db/dhcpd.leases
                    586:        if [ -f /etc/dhcpd.interfaces ]; then
1.207     mpech     587:                dhcpd_ifs=`stripcom /etc/dhcpd.interfaces`
1.86      form      588:        fi
                    589:        echo -n ' dhcpd';       /usr/sbin/dhcpd ${dhcpd_flags} ${dhcpd_ifs}
1.127     itojun    590: fi
                    591:
                    592: if ifconfig lo0 inet6 >/dev/null 2>&1; then
                    593:        fw=`sysctl -n net.inet6.ip6.forwarding`
1.266     millert   594:        if [ X"${fw}" = X"0" ]; then
1.127     itojun    595:                # $rtsold_flags is imported from /etc/rc.conf;
                    596:                # If $rtsold_flags == NO, then rtsold isn't run.
1.266     millert   597:                if [ X"${rtsold_flags}" != X"NO" ]; then
1.127     itojun    598:                        echo -n ' rtsold'
                    599:                        /usr/sbin/rtsold ${rtsold_flags}
                    600:                fi
                    601:        else
                    602:                # $route6d_flags is imported from /etc/rc.conf;
                    603:                # If $route6d_flags == NO, then route6d isn't run.
1.266     millert   604:                if [ X"${route6d_flags}" != X"NO" ]; then
1.127     itojun    605:                        echo -n ' route6d'
                    606:                        /usr/sbin/route6d ${route6d_flags}
                    607:                fi
                    608:                # $rtadvd_flags is imported from /etc/rc.conf;
1.147     itojun    609:                # If $rtadvd_flags == NO, then rtadvd isn't run.
1.266     millert   610:                if [ X"${rtadvd_flags}" != X"NO" ]; then
1.127     itojun    611:                        echo -n ' rtadvd'
                    612:                        /usr/sbin/rtadvd ${rtadvd_flags}
                    613:                fi
                    614:        fi
1.281     reyk      615: fi
                    616:
                    617: if [ X"${hostapd_flags}" != X"NO" ]; then
                    618:        echo -n ' hostapd';             /usr/sbin/hostapd ${hostapd_flags};
1.86      form      619: fi
                    620:
1.52      deraadt   621: # $rwhod is imported from /etc/rc.conf;
1.1       deraadt   622: # if $rwhod == YES, rwhod is run.
1.266     millert   623: if [ X"${rwhod}" = X"YES" ]; then
1.1       deraadt   624:        echo -n ' rwhod';               rwhod
                    625: fi
                    626:
1.23      deraadt   627:
1.266     millert   628: if [ X"${lpd_flags}" != X"NO" ]; then
1.272     fgsch     629:        echo -n ' lpd';                 lpd ${lpd_flags}
1.23      deraadt   630: fi
1.1       deraadt   631:
1.52      deraadt   632: # $sendmail_flags is imported from /etc/rc.conf;
1.154     millert   633: # If $sendmail_flags == NO or /etc/mailer.conf doesn't exist, then
1.255     henning   634: # sendmail isn't run.  We call sendmail with a full path so that
                    635: # SIGHUP works.  Note that /usr/sbin/sendmail may actually call a
1.154     millert   636: # mailer other than sendmail, depending on /etc/mailer.conf.
1.266     millert   637: if [ X"${sendmail_flags}" != X"NO" -a -s /etc/mailer.conf ]; then
1.153     millert   638:        echo -n ' sendmail';            ( /usr/sbin/sendmail ${sendmail_flags} >/dev/null 2>&1 & )
1.212     deraadt   639: fi
                    640:
1.266     millert   641: if [ X"${httpd_flags}" != X"NO" ]; then
1.143     espie     642:        # Clean up left-over httpd locks
                    643:        rm -f /var/www/logs/{ssl_mutex,httpd.lock,accept.lock}.*
1.160     angelos   644:        echo -n ' httpd';               /usr/sbin/httpd ${httpd_flags}
1.93      downsj    645: fi
                    646:
1.266     millert   647: if [ X"${ftpd_flags}" != X"NO" ]; then
1.93      downsj    648:        echo -n ' ftpd';                /usr/libexec/ftpd ${ftpd_flags}
1.275     camield   649: fi
                    650:
                    651: if [ X"${ftpproxy_flags}" != X"NO" ]; then
                    652:        echo -n ' ftp-proxy';           /usr/sbin/ftp-proxy ${ftpproxy_flags}
1.124     fgsch     653: fi
                    654:
1.266     millert   655: if [ X"${identd_flags}" != X"NO" ]; then
1.124     fgsch     656:        echo -n ' identd';              /usr/libexec/identd ${identd_flags}
1.1       deraadt   657: fi
                    658:
1.266     millert   659: if [ X"${inetd}" = X"YES" -a -e /etc/inetd.conf ]; then
1.23      deraadt   660:        echo -n ' inetd';               inetd
1.237     deraadt   661: fi
                    662:
                    663: if [ X"${sshd_flags}" != X"NO" ]; then
                    664:        echo -n ' sshd';                /usr/sbin/sshd ${sshd_flags};
1.238     deraadt   665: fi
                    666:
1.266     millert   667: if [ X"${spamd_flags}" != X"NO" ]; then
                    668:        if [ X"${spamd_grey}" != X"NO" ]; then
1.238     deraadt   669:                spamd_flags="${spamd_flags} -g"
                    670:        fi
1.242     otto      671:        echo -n ' spamd';               eval /usr/libexec/spamd ${spamd_flags}
1.238     deraadt   672:        /usr/libexec/spamd-setup
1.266     millert   673:        if [ X"${spamd_grey}" != X"NO" ]; then
1.238     deraadt   674:                echo -n ' spamlogd'
1.259     henning   675:                /usr/libexec/spamlogd ${spamlogd_flags}
1.238     deraadt   676:        fi
1.23      deraadt   677: fi
1.1       deraadt   678:
1.52      deraadt   679: # $rarpd_flags is imported from /etc/rc.conf;
1.1       deraadt   680: # If $rarpd_flags == NO or /etc/ethers doesn't exist, then
                    681: # rarpd isn't run.
1.266     millert   682: if [ X"${rarpd_flags}" != X"NO" -a -s /etc/ethers ]; then
1.1       deraadt   683:        echo -n ' rarpd';               rarpd ${rarpd_flags}
                    684: fi
                    685:
1.52      deraadt   686: # $bootparamd_flags is imported from /etc/rc.conf;
1.1       deraadt   687: # If $bootparamd_flags == NO or /etc/bootparams doesn't exist, then
                    688: # bootparamd isn't run.
1.266     millert   689: if [ X"${bootparamd_flags}" != X"NO" -a -s /etc/bootparams ]; then
1.1       deraadt   690:        echo -n ' rpc.bootparamd';      rpc.bootparamd ${bootparamd_flags}
                    691: fi
                    692:
1.52      deraadt   693: # $rbootd_flags is imported from /etc/rc.conf;
1.1       deraadt   694: # If $rbootd_flags == NO or /etc/rbootd.conf doesn't exist, then
                    695: # rbootd isn't run.
1.266     millert   696: if [ X"${rbootd_flags}" != X"NO" -a -s /etc/rbootd.conf ]; then
1.1       deraadt   697:        echo -n ' rbootd';              rbootd ${rbootd_flags}
1.56      maja      698: fi
                    699:
                    700: # $mopd_flags is imported from /etc/rc.conf;
                    701: # If $mopd_flags == NO or /tftpboot/mop doesn't exist, then
                    702: # mopd isn't run.
1.266     millert   703: if [ X"${mopd_flags}" != X"NO" -a -d /tftpboot/mop ]; then
1.56      maja      704:        echo -n ' mopd';                mopd ${mopd_flags}
1.1       deraadt   705: fi
                    706:
                    707: echo '.'
1.277     deraadt   708:
                    709: mixerctl_conf
1.175     hin       710:
                    711: # KerberosV master KDC
1.266     millert   712: if [ X"${krb5_master_kdc}" = X"YES" ]; then
1.175     hin       713:        echo 'KerberosV master KDC'
                    714:        /usr/libexec/kdc &
                    715:        /usr/libexec/kadmind &
                    716:        /usr/libexec/kpasswdd &
                    717: fi
                    718:
                    719: # KerberosV slave KDC
1.266     millert   720: if [ X"${krb5_slave_kdc}" = X"YES" ]; then
1.175     hin       721:        echo 'KerberosV slave KDC'
                    722:        /usr/libexec/kdc &
                    723:        # Remember to enable hpropd in inetd.conf
1.17      deraadt   724: fi
                    725:
1.72      deraadt   726: [ -f /etc/rc.local ] && . /etc/rc.local
1.73      millert   727:
                    728: echo -n standard daemons:
1.87      marc      729:
                    730: # $apmd_flags is imported from /etc/rc.conf;
                    731: # don't run daemon if $apmd_flags == NO or /usr/sbin/apmd doesn't exist
1.266     millert   732: if [ X"${apmd_flags}" != X"NO" -a -x /usr/sbin/apmd ]; then
1.230     deraadt   733:        echo -n ' apmd';        /usr/sbin/apmd ${apmd_flags}
1.268     tholo     734: fi
                    735:
                    736: if [ X"${acpid_flags}" != X"NO" -a -x /usr/sbin/acpid ]; then
                    737:        echo -n ' acpid';       /usr/sbin/acpid ${acpid_flags}
1.229     henning   738: fi
                    739:
                    740: if [ X"${sensorsd_flags}" != X"NO" ]; then
                    741:        echo -n ' sensorsd';    /usr/sbin/sensorsd ${sensorsd_flags}
1.248     grange    742: fi
                    743:
                    744: if [ X"${hotplugd_flags}" != X"NO" -a -x /usr/sbin/hotplugd ]; then
                    745:        echo -n ' hotplugd';    /usr/sbin/hotplugd ${hotplugd_flags}
1.274     henning   746: fi
                    747:
                    748: if [ X"${watchdogd_flags}" != X"NO" -a -x /usr/sbin/watchdogd ]; then
                    749:        echo -n ' watchdogd';   /usr/sbin/watchdogd ${watchdogd_flags}
1.87      marc      750: fi
                    751:
1.73      millert   752: echo -n ' cron';               cron
1.87      marc      753:
1.73      millert   754: echo '.'
1.1       deraadt   755:
                    756: date
1.71      deraadt   757:
1.266     millert   758: if [ X"${wsmoused_flags}" != X"NO" -a -x /usr/sbin/wsmoused ]; then
1.169     deraadt   759:        echo 'starting wsmoused...';    /usr/sbin/wsmoused ${wsmoused_flags}
1.155     aaron     760: fi
                    761:
1.71      deraadt   762: # Alternatively, on some architectures, xdm may be started in /etc/ttys.
1.266     millert   763: if [ X"${xdm_flags}" != X"NO" ]; then
1.92      downsj    764:        echo 'starting xdm...';         /usr/X11R6/bin/xdm ${xdm_flags}
1.71      deraadt   765: fi
                    766:
1.1       deraadt   767: exit 0
1.90      art       768: