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

Annotation of src/etc/rc, Revision 1.477

1.477   ! ajacouto    1: #      $OpenBSD: rc,v 1.476 2016/04/27 09:17:53 rpe Exp $
1.1       deraadt     2:
1.450     rpe         3: # System startup script run by init on autoboot or after single-user.
                      4: # Output and error are redirected to console by init, and the console is the
                      5: # controlling terminal.
1.454     rpe         6:
                      7: # Turn off Strict Bourne shell.
                      8: set +o sh
1.1       deraadt     9:
1.131     millert    10: # Subroutines (have to come first).
                     11:
1.450     rpe        12:
1.456     rpe        13: # Strip in- and whole-line comments from a file.
                     14: # Strip leading and trailing whitespace if IFS is set.
                     15: # Usage: stripcom /path/to/file
1.131     millert    16: stripcom() {
1.456     rpe        17:        local _file=$1 _line
1.131     millert    18:
1.456     rpe        19:        [[ -s $_file ]] || return
                     20:
                     21:        while read _line ; do
                     22:                _line=${_line%%#*}
                     23:                [[ -n $_line ]] && print -r -- "$_line"
                     24:        done <$_file
1.131     millert    25: }
                     26:
1.456     rpe        27: # Update resource limits based on login.conf settings.
                     28: # Usage: update_limit -flag capability
1.265     millert    29: update_limit() {
1.456     rpe        30:        local _flag=$1          # ulimit flag
                     31:        local _cap=$2 _val      # login.conf capability and its value
                     32:        local _suffix
                     33:
                     34:        for _suffix in {,-cur,-max}; do
                     35:                _val=$(getcap -f /etc/login.conf -s ${_cap}${_suffix} daemon 2>/dev/null)
                     36:                [[ -n $_val ]] || continue
                     37:                [[ $_val == infinity ]] && _val=unlimited
                     38:
                     39:                case $_suffix in
                     40:                -cur)   ulimit -S $_flag $_val
                     41:                        ;;
                     42:                -max)   ulimit -H $_flag $_val
                     43:                        ;;
                     44:                *)      ulimit $_flag $_val
                     45:                        return
                     46:                        ;;
                     47:                esac
1.265     millert    48:        done
                     49: }
                     50:
1.457     rpe        51: # Apply sysctl.conf(5) settings.
1.265     millert    52: sysctl_conf() {
1.457     rpe        53:        stripcom /etc/sysctl.conf |
                     54:        while read _line; do
                     55:                sysctl "$_line"
1.267     millert    56:
1.457     rpe        57:                case $_line in
1.265     millert    58:                kern.maxproc=*)
1.457     rpe        59:                        update_limit -p maxproc;;
1.265     millert    60:                kern.maxfiles=*)
1.457     rpe        61:                        update_limit -n openfiles;;
1.265     millert    62:                esac
                     63:        done
                     64: }
                     65:
1.457     rpe        66: # Apply mixerctl.conf(5) settings.
1.452     rpe        67: mixerctl_conf() {
1.457     rpe        68:        stripcom /etc/mixerctl.conf |
                     69:        while read _line; do
                     70:                mixerctl -q "$_line" 2>/dev/null
1.265     millert    71:        done
                     72: }
                     73:
1.457     rpe        74: # Apply wsconsctl.conf(5) settings.
1.452     rpe        75: wsconsctl_conf() {
1.457     rpe        76:        [[ -x /sbin/wsconsctl ]] || return
1.267     millert    77:
1.457     rpe        78:        stripcom /etc/wsconsctl.conf |
                     79:        while read _line; do
1.458     rpe        80:                eval "wsconsctl $_line"
1.267     millert    81:        done
                     82: }
                     83:
1.452     rpe        84: random_seed() {
1.427     bluhm      85:        # push the old seed into the kernel
                     86:        dd if=/var/db/host.random of=/dev/random bs=65536 count=1 status=none
                     87:        chmod 600 /var/db/host.random
                     88:        # ... and create a future seed
                     89:        dd if=/dev/random of=/var/db/host.random bs=65536 count=1 status=none
                     90:        # and create a seed file for the boot-loader
                     91:        dd if=/dev/random of=/etc/random.seed bs=512 count=1 status=none
                     92:        chmod 600 /etc/random.seed
1.312     djm        93: }
                     94:
1.450     rpe        95: # Populate net.inet.(tcp|udp).baddynamic with the contents of /etc/services so
                     96: # as to avoid randomly allocating source ports that correspond to well-known
1.451     rpe        97: # services.
1.459     rpe        98: # Usage: fill_baddynamic tcp|udp
1.452     rpe        99: fill_baddynamic() {
1.390     halex     100:        local _service=$1
1.318     djm       101:        local _sysctl="net.inet.${_service}.baddynamic"
1.459     rpe       102:
1.390     halex     103:        stripcom /etc/services |
                    104:        {
1.459     rpe       105:                _ban=
1.390     halex     106:                while IFS="     /" read _name _port _srv _junk; do
1.459     rpe       107:                        [[ $_srv == $_service ]] || continue
                    108:
                    109:                        _ban="${_ban:+$_ban,}+$_port"
                    110:
1.390     halex     111:                        # Flush before argv gets too long
1.459     rpe       112:                        if ((${#_ban} > 1024)); then
                    113:                                sysctl -q "$_sysctl=$_ban"
                    114:                                _ban=
1.390     halex     115:                        fi
                    116:                done
1.459     rpe       117:                [[ -n $_ban ]] && sysctl -q "$_sysctl=$_ban"
1.390     halex     118:        }
1.318     djm       119: }
                    120:
1.450     rpe       121: # Start daemon using the rc.d daemon control scripts.
1.451     rpe       122: # Usage: start_daemon daemon1 daemon2 daemon3
1.452     rpe       123: start_daemon() {
1.460     rpe       124:        local _daemon
                    125:
                    126:        for _daemon; do
                    127:                eval "_do=\${${_daemon}_flags}"
                    128:                [[ $_do != NO ]] && /etc/rc.d/${_daemon} start
1.353     robert    129:        done
                    130: }
                    131:
1.469     tim       132: # Generate keys for isakmpd, iked and sshd if they don't exist yet.
1.452     rpe       133: make_keys() {
1.460     rpe       134:        local _isakmpd_key=/etc/isakmpd/private/local.key
                    135:        local _isakmpd_pub=/etc/isakmpd/local.pub
                    136:        local _iked_key=/etc/iked/private/local.key
                    137:        local _iked_pub=/etc/iked/local.pub
                    138:
                    139:        if [[ ! -f $_isakmpd_key ]]; then
                    140:                echo -n "openssl: generating isakmpd/iked RSA keys... "
                    141:                if openssl genrsa -out $_isakmpd_key 2048 >/dev/null 2>&1 &&
                    142:                        chmod 600 $_isakmpd_key &&
                    143:                        openssl rsa -out $_isakmpd_pub -in $_isakmpd_key \
                    144:                            -pubout >/dev/null 2>&1; then
1.373     deraadt   145:                        echo done.
                    146:                else
                    147:                        echo failed.
                    148:                fi
                    149:        fi
                    150:
1.460     rpe       151:        if [[ ! -f $_iked_key ]]; then
1.373     deraadt   152:                # Just copy the generated isakmpd key
1.460     rpe       153:                cp $_isakmpd_key $_iked_key
                    154:                chmod 600 $_iked_key
                    155:                cp $_isakmpd_pub $_iked_pub
1.373     deraadt   156:        fi
                    157:
                    158:        ssh-keygen -A
                    159: }
                    160:
1.475     deraadt   161: rebuildlibs() {
                    162:        local _l _liba _libas _tmpdir
                    163:
                    164:        # Only choose newest
                    165:        for _liba in /usr/lib/libc.so.*.a; do
1.476     rpe       166:                _liba=$(ls ${_liba%%.[0-9]*}*.a | sort -V | tail -1)
1.475     deraadt   167:                for _l in $_libas; do
                    168:                        [[ $_l == $_liba ]] && continue 2
                    169:                done
                    170:                _libas="$_libas $_liba"
                    171:        done
                    172:
                    173:        for _liba in $_libas; do
                    174:                _tmpdir=$(mktemp -dq /tmp/_librebuild.XXXXXXXXXXXX) || return
                    175:                (
                    176:                        set -o errexit
                    177:                        _lib=${_liba#/usr/lib/}
                    178:                        _lib=${_lib%.a}
                    179:                        cd $_tmpdir
                    180:                        ar x ${_liba}
                    181:                        cc -shared -o $_lib $(ls *.so | sort -R) $(cat .ldadd)
                    182:                        [[ -s $_lib ]] && file $_lib | fgrep -q 'shared object'
                    183:                        LD_BIND_NOW=1 LD_LIBRARY_PATH=$_tmpdir awk 'BEGIN {exit 0}'
                    184:                        install -S -o root -g bin -m 0444 $_lib /usr/lib/$_lib
                    185:                )
                    186:                rm -rf /tmp/_librebuild.${_tmpdir#*.}
                    187:        done
                    188: }
                    189:
1.477   ! ajacouto  190: run_upgrade_script() {
        !           191:        local _suffix=$1
        !           192:        [[ -n $_suffix ]] || return 1
        !           193:        if [[ -f /etc/rc.$_suffix ]]; then
        !           194:                mv /etc/rc.$_suffix /etc/rc.$_suffix.run
        !           195:                . /etc/rc.$_suffix.run 2>&1 | tee /dev/tty |
        !           196:                        mail -Es "$(hostname) rc.$_suffix output" root >/dev/null
        !           197:        fi
        !           198:        rm -f /etc/rc.$_suffix.run
        !           199: }
        !           200:
1.462     rpe       201: # Check filesystems, optionally by using a fsck(8) flag.
                    202: # Usage: do_fsck [-flag]
1.452     rpe       203: do_fsck() {
1.462     rpe       204:        fsck -p "$@"
1.429     claudio   205:        case $? in
1.462     rpe       206:        0)      ;;
                    207:        2)      exit 1
1.429     claudio   208:                ;;
1.462     rpe       209:        4)      echo "Rebooting..."
1.429     claudio   210:                reboot
                    211:                echo "Reboot failed; help!"
                    212:                exit 1
                    213:                ;;
1.462     rpe       214:        8)      echo "Automatic file system check failed; help!"
1.429     claudio   215:                exit 1
                    216:                ;;
1.462     rpe       217:        12)     echo "Boot interrupted."
1.429     claudio   218:                exit 1
                    219:                ;;
1.462     rpe       220:        130)    # Interrupt before catcher installed.
1.429     claudio   221:                exit 1
                    222:                ;;
1.462     rpe       223:        *)      echo "Unknown error; help!"
1.429     claudio   224:                exit 1
                    225:                ;;
                    226:        esac
                    227: }
                    228:
1.450     rpe       229: # End subroutines.
1.131     millert   230:
1.1       deraadt   231: stty status '^T'
                    232:
1.450     rpe       233: # Set shell to ignore SIGINT (2), but not children; shell catches SIGQUIT (3)
                    234: # and returns to single user after fsck.
1.1       deraadt   235: trap : 2
1.450     rpe       236: trap : 3       # Shouldn't be needed.
1.1       deraadt   237:
1.463     rpe       238: export HOME=/
                    239: export INRC=1
                    240: export PATH=/sbin:/bin:/usr/sbin:/usr/bin
1.395     deraadt   241:
1.450     rpe       242: # Must set the domainname before rc.conf, so YP startup choices can be made.
1.463     rpe       243: if [[ -s /etc/defaultdomain ]]; then
                    244:        domainname "$(stripcom /etc/defaultdomain)"
1.395     deraadt   245: fi
1.108     deraadt   246:
1.450     rpe       247: # Need to get local functions from rc.subr.
1.428     robert    248: FUNCS_ONLY=1 . /etc/rc.d/rc.subr
                    249:
1.450     rpe       250: # Load rc.conf into scope.
1.428     robert    251: _rc_parse_conf
1.343     robert    252:
1.463     rpe       253: if [[ $1 == shutdown ]]; then
1.437     bluhm     254:        if echo 2>/dev/null >>/var/db/host.random || \
                    255:            echo 2>/dev/null >>/etc/random.seed; then
                    256:                random_seed
                    257:        else
                    258:                echo warning: cannot write random seed to disk
                    259:        fi
1.416     rpe       260:
1.469     tim       261:        # If we are in secure level 0, assume single user mode.
1.463     rpe       262:        if (($(sysctl -n kern.securelevel) == 0)); then
                    263:                echo 'single user: not running shutdown scripts'
                    264:        else
1.421     schwarze  265:                pkg_scripts=${pkg_scripts%%*( )}
1.463     rpe       266:                if [[ -n $pkg_scripts ]]; then
1.413     deraadt   267:                        echo -n 'stopping package daemons:'
1.463     rpe       268:                        while [[ -n $pkg_scripts ]]; do
                    269:                                _d=${pkg_scripts##* }
                    270:                                pkg_scripts=${pkg_scripts%%*( )$_d}
                    271:                                [[ -x /etc/rc.d/$_d ]] && /etc/rc.d/$_d stop
1.413     deraadt   272:                        done
                    273:                        echo '.'
                    274:                fi
                    275:
1.463     rpe       276:                [[ -f /etc/rc.shutdown ]] && sh /etc/rc.shutdown
1.413     deraadt   277:        fi
1.240     mcbride   278:
1.450     rpe       279:        # Bring carp interfaces down gracefully.
1.463     rpe       280:        ifconfig | while read _if _junk; do
1.474     rpe       281:                [[ $_if == carp+([0-9]): ]] && ifconfig ${_if%:} down
1.413     deraadt   282:        done
1.246     mcbride   283:
1.108     deraadt   284:        exit 0
1.1       deraadt   285: fi
1.98      jakob     286:
1.463     rpe       287: # Add swap block-devices.
1.172     miod      288: swapctl -A -t blk
1.170     deraadt   289:
1.463     rpe       290: if [[ -e /fastboot ]]; then
1.1       deraadt   291:        echo "Fast boot: skipping disk checks."
1.463     rpe       292: elif [[ $1 == autoboot ]]; then
1.1       deraadt   293:        echo "Automatic boot in progress: starting file system checks."
1.429     claudio   294:        do_fsck
1.1       deraadt   295: fi
                    296:
                    297: trap "echo 'Boot interrupted.'; exit 1" 3
                    298:
                    299: umount -a >/dev/null 2>&1
1.303     grunk     300: mount -a -t nonfs,vnd
1.450     rpe       301: mount -uw /            # root on nfs requires this, others aren't hurt.
1.1       deraadt   302: rm -f /fastboot                # XXX (root now writeable)
1.177     deraadt   303:
1.450     rpe       304: # Set flags on ttys.  (Do early, in case they use tty for SLIP in netstart.)
1.1       deraadt   305: echo 'setting tty flags'
                    306: ttyflags -a
1.77      angelos   307:
1.464     rpe       308: # Set keyboard encoding.
                    309: if [[ -x /sbin/kbd && -s /etc/kbdtype ]]; then
                    310:        kbd "$(cat /etc/kbdtype)"
1.252     mcbride   311: fi
                    312:
1.279     deraadt   313: wsconsctl_conf
                    314:
1.464     rpe       315: # Set initial temporary pf rule set.
                    316: if [[ $pf != NO ]]; then
1.211     mcbride   317:        RULES="block all"
1.228     henning   318:        RULES="$RULES\npass on lo0"
1.447     krw       319:        RULES="$RULES\npass in proto tcp from any to any port ssh keep state"
                    320:        RULES="$RULES\npass out proto { tcp, udp } from any to any port domain keep state"
1.215     camield   321:        RULES="$RULES\npass out inet proto icmp all icmp-type echoreq keep state"
1.420     claudio   322:        RULES="$RULES\npass out inet proto udp from any port bootpc to any port bootps"
                    323:        RULES="$RULES\npass in inet proto udp from any port bootps to any port bootpc"
1.257     grange    324:        if ifconfig lo0 inet6 >/dev/null 2>&1; then
1.258     itojun    325:                RULES="$RULES\npass out inet6 proto icmp6 all icmp6-type neighbrsol"
                    326:                RULES="$RULES\npass in inet6 proto icmp6 all icmp6-type neighbradv"
1.257     grange    327:                RULES="$RULES\npass out inet6 proto icmp6 all icmp6-type routersol"
                    328:                RULES="$RULES\npass in inet6 proto icmp6 all icmp6-type routeradv"
1.420     claudio   329:                RULES="$RULES\npass out inet6 proto udp from any port dhcpv6-client to any port dhcpv6-server"
                    330:                RULES="$RULES\npass in inet6 proto udp from any port dhcpv6-server to any port dhcpv6-client"
1.257     grange    331:        fi
1.424     henning   332:        RULES="$RULES\npass in proto carp keep state (no-sync)"
                    333:        RULES="$RULES\npass out proto carp !received-on any keep state (no-sync)"
1.474     rpe       334:        if [[ $(sysctl vfs.mounts.nfs 2>/dev/null) == *[1-9]* ]]; then
1.450     rpe       335:                # Don't kill NFS.
1.324     henning   336:                RULES="set reassemble yes no-df\n$RULES"
1.447     krw       337:                RULES="$RULES\npass in proto { tcp, udp } from any port { sunrpc, nfsd } to any"
                    338:                RULES="$RULES\npass out proto { tcp, udp } from any to any port { sunrpc, nfsd } !received-on any"
1.474     rpe       339:        fi
1.464     rpe       340:        print -- "$RULES" | pfctl -f -
1.269     dhartmei  341:        pfctl -e
1.176     kjell     342: fi
1.318     djm       343:
1.450     rpe       344: # Fill net.inet.(tcp|udp).baddynamic lists from /etc/services.
1.318     djm       345: fill_baddynamic udp
                    346: fill_baddynamic tcp
1.176     kjell     347:
1.267     millert   348: sysctl_conf
1.260     jsg       349:
1.1       deraadt   350: echo 'starting network'
1.464     rpe       351:
                    352: # Set carp interlock by increasing the demotion counter.
                    353: # Prevents carp from preempting until the system is booted.
1.289     henning   354: ifconfig -g carp carpdemote 128
1.464     rpe       355:
                    356: # Recover resolv.conf in case dhclient died hard.
                    357: if [[ -f /etc/resolv.conf.save ]]; then
1.334     deraadt   358:        mv -f /etc/resolv.conf.save /etc/resolv.conf
1.264     deraadt   359:        touch /etc/resolv.conf
                    360: fi
1.464     rpe       361:
1.439     ajacouto  362: sh /etc/netstart
1.464     rpe       363:
1.451     rpe       364: dmesg >/dev/random     # Any write triggers a rekey.
1.176     kjell     365:
1.450     rpe       366: # Load pf rules and bring up pfsync interface.
1.464     rpe       367: if [[ $pf != NO ]]; then
                    368:        if [[ -f /etc/pf.conf ]]; then
1.449     ajacouto  369:                pfctl -f /etc/pf.conf
1.309     mpf       370:        fi
1.464     rpe       371:        if [[ -f /etc/hostname.pfsync0 ]]; then
1.435     deraadt   372:                sh /etc/netstart pfsync0
1.367     deraadt   373:        fi
1.176     kjell     374: fi
1.1       deraadt   375:
1.278     otto      376: mount -s /usr >/dev/null 2>&1
                    377: mount -s /var >/dev/null 2>&1
1.180     deraadt   378:
1.389     deraadt   379: random_seed
1.475     deraadt   380:
                    381: rebuildlibs
1.29      deraadt   382:
1.450     rpe       383: # Clean up left-over files.
1.376     deraadt   384: rm -f /etc/nologin /var/spool/lock/LCK.* /var/spool/uucp/STST/*
1.247     henning   385: (cd /var/run && { rm -rf -- *; install -c -m 664 -g utmp /dev/null utmp; })
1.196     beck      386: (cd /var/authpf && rm -rf -- *)
1.96      alex      387:
1.464     rpe       388: dmesg >/var/run/dmesg.boot     # Save a copy of the boot messages.
1.55      deraadt   389:
1.373     deraadt   390: make_keys
                    391:
1.379     deraadt   392: echo -n 'starting early daemons:'
1.473     rpe       393: start_daemon syslogd ldattach pflogd nsd rebound unbound ntpd
1.429     claudio   394: start_daemon iscsid isakmpd iked sasyncd ldapd npppd
1.353     robert    395: echo '.'
1.280     hshoexer  396:
1.450     rpe       397: # Load IPsec rules.
1.464     rpe       398: if [[ $ipsec != NO && -f /etc/ipsec.conf ]]; then
                    399:        ipsecctl -f /etc/ipsec.conf
1.40      provos    400: fi
1.1       deraadt   401:
1.379     deraadt   402: echo -n 'starting RPC daemons:'
1.399     dlg       403: start_daemon portmap ypldap
1.466     deraadt   404: rm -f /var/run/ypbind.lock
1.464     rpe       405: if [[ -n $(domainname) ]]; then
1.470     deraadt   406:        start_daemon ypserv ypbind
1.376     deraadt   407: fi
1.399     dlg       408: start_daemon mountd nfsd lockd statd amd
1.1       deraadt   409: echo '.'
1.58      deraadt   410:
1.464     rpe       411: # Check and mount remaining file systems and enable additional swap.
1.278     otto      412: mount -a
1.172     miod      413: swapctl -A -t noblk
1.429     claudio   414: do_fsck -N
                    415: mount -a -N
1.1       deraadt   416:
1.450     rpe       417: # /var/crash should be a directory or a symbolic link to the crash directory
                    418: # if core dumps are to be saved.
1.464     rpe       419: if [[ -d /var/crash ]]; then
                    420:        savecore $savecore_flags /var/crash
1.90      art       421: fi
                    422:
1.464     rpe       423: if [[ $check_quotas == YES ]]; then
1.41      downsj    424:        echo -n 'checking quotas:'
                    425:        quotacheck -a
                    426:        echo ' done.'
                    427:        quotaon -a
                    428: fi
1.1       deraadt   429:
1.464     rpe       430: # Build kvm(3) and /dev databases.
                    431: kvm_mkdb
1.1       deraadt   432: dev_mkdb
1.464     rpe       433:
                    434: # Set proper permission for the tty device files.
1.101     deraadt   435: chmod 666 /dev/tty[pqrstuvwxyzPQRST]*
1.226     millert   436: chown root:wheel /dev/tty[pqrstuvwxyzPQRST]*
1.1       deraadt   437:
1.450     rpe       438: # Check the password temp/lock file.
1.467     rpe       439: if [[ -f /etc/ptmp ]]; then
1.1       deraadt   440:        logger -s -p auth.err \
1.376     deraadt   441:            'password file may be incorrect -- /etc/ptmp exists'
1.32      deraadt   442: fi
                    443:
1.49      millert   444: echo clearing /tmp
                    445:
1.450     rpe       446: # Prune quickly with one rm, then use find to clean up /tmp/[lqv]*
                    447: # (not needed with mfs /tmp, but doesn't hurt there...).
1.444     deraadt   448: (cd /tmp && rm -rf [a-km-pr-uw-zA-Z]*)
1.339     sthen     449: (cd /tmp &&
1.443     millert   450:     find . -maxdepth 1 ! -name . ! -name lost+found ! -name quota.user \
1.444     deraadt   451:        ! -name quota.group ! -name vi.recover -execdir rm -rf -- {} \;)
1.373     deraadt   452:
1.462     rpe       453: # Create Unix sockets directories for X if needed and make sure they have
                    454: # correct permissions.
                    455: [[ -d /usr/X11R6/lib ]] && mkdir -m 1777 /tmp/.{X11,ICE}-unix
1.203     hugh      456:
1.467     rpe       457: [[ -f /etc/rc.securelevel ]] && sh /etc/rc.securelevel
                    458:
1.450     rpe       459: # rc.securelevel did not specifically set -1 or 2, so select the default: 1.
1.467     rpe       460: (($(sysctl -n kern.securelevel) == 0)) && sysctl kern.securelevel=1
                    461:
1.1       deraadt   462:
1.450     rpe       463: # Patch /etc/motd.
1.467     rpe       464: if [[ ! -f /etc/motd ]]; then
1.34      deraadt   465:        install -c -o root -g wheel -m 664 /dev/null /etc/motd
                    466: fi
1.467     rpe       467: if T=$(mktemp /tmp/_motd.XXXXXXXXXX); then
1.451     rpe       468:        sysctl -n kern.version | sed 1q >$T
                    469:        echo "" >>$T
                    470:        sed '1,/^$/d' </etc/motd >>$T
1.102     millert   471:        cmp -s $T /etc/motd || cp $T /etc/motd
                    472:        rm -f $T
                    473: fi
1.34      deraadt   474:
1.467     rpe       475: if [[ $accounting == YES ]]; then
                    476:        [[ ! -f /var/account/acct ]] && touch /var/account/acct
                    477:        echo 'turning on accounting'
                    478:        accton /var/account/acct
1.1       deraadt   479: fi
                    480:
1.467     rpe       481: if [[ -x /sbin/ldconfig ]]; then
1.115     deraadt   482:        echo 'creating runtime link editor directory cache.'
1.471     rpe       483:        [[ -d /usr/local/lib ]] && shlib_dirs="/usr/local/lib $shlib_dirs"
1.467     rpe       484:        [[ -d /usr/X11R6/lib ]] && shlib_dirs="/usr/X11R6/lib $shlib_dirs"
1.115     deraadt   485:        ldconfig $shlib_dirs
1.231     millert   486: fi
                    487:
1.451     rpe       488: echo 'preserving editor files.'; /usr/libexec/vi.recover
1.244     markus    489:
1.477   ! ajacouto  490: # If rc.sysmerge exists, run it just once, and make sure it is deleted.
        !           491: run_upgrade_script sysmerge
        !           492:
1.353     robert    493: echo -n 'starting network daemons:'
1.472     jasper    494: start_daemon ldomd vmd sshd snmpd ldpd ripd ospfd ospf6d bgpd ifstated
1.465     renato    495: start_daemon relayd dhcpd dhcrelay mrouted dvmrpd radiusd eigrpd
1.127     itojun    496:
                    497: if ifconfig lo0 inet6 >/dev/null 2>&1; then
1.467     rpe       498:        if (($(sysctl -n net.inet6.ip6.forwarding) == 1)); then
1.376     deraadt   499:                start_daemon route6d rtadvd
1.127     itojun    500:        fi
1.281     reyk      501: fi
                    502:
1.442     matthieu  503: start_daemon hostapd lpd smtpd slowcgi httpd ftpd
1.461     sthen     504: start_daemon ftpproxy ftpproxy6 tftpd tftpproxy identd inetd rarpd bootparamd
1.425     ajacouto  505: start_daemon rbootd mopd spamd spamlogd sndiod
1.377     robert    506: echo '.'
1.335     deraadt   507:
1.450     rpe       508: # If rc.firsttime exists, run it just once, and make sure it is deleted.
1.477   ! ajacouto  509: run_upgrade_script firsttime
1.352     ajacouto  510:
1.450     rpe       511: # Run rc.d(8) scripts from packages.
1.467     rpe       512: if [[ -n $pkg_scripts ]]; then
1.352     ajacouto  513:        echo -n 'starting package daemons:'
1.467     rpe       514:        for _daemon in $pkg_scripts; do
                    515:                if [[ -x /etc/rc.d/$_daemon ]]; then
                    516:                        start_daemon $_daemon
1.410     espie     517:                else
1.467     rpe       518:                        echo -n " ${_daemon}(absent)"
1.410     espie     519:                fi
1.352     ajacouto  520:        done
                    521:        echo '.'
                    522: fi
1.17      deraadt   523:
1.467     rpe       524: [[ -f /etc/rc.local ]] && sh /etc/rc.local
1.73      millert   525:
1.467     rpe       526: ifconfig -g carp -carpdemote 128       # Disable carp interlock.
1.286     mcbride   527:
1.379     deraadt   528: mixerctl_conf
1.467     rpe       529:
1.379     deraadt   530: echo -n 'starting local daemons:'
1.386     deraadt   531: start_daemon apmd sensorsd hotplugd watchdogd cron wsmoused xdm
1.73      millert   532: echo '.'
1.1       deraadt   533:
                    534: date
                    535: exit 0