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

Annotation of src/etc/rc, Revision 1.249

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