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