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

Annotation of src/etc/rc, Revision 1.266

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