Annotation of src/etc/rc, Revision 1.517
1.517 ! rpe 1: # $OpenBSD: rc,v 1.516 2017/08/28 06:56:54 ajacoutot 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.508 tb 161: local _dkdev _liba _libas _mp _tmpdir _remount=false _error=false
1.498 tb 162:
163: [[ $library_aslr == NO ]] && return
164:
165: _dkdev=$(df /usr/lib | sed '1d;s/ .*//')
166: _mp=$(mount | grep "^$_dkdev")
1.481 rpe 167:
1.484 rpe 168: # Skip if /usr/lib is on a nfs mounted filesystem.
169: [[ $_mp == *' type nfs '* ]] && return
170:
1.481 rpe 171: echo -n 'reordering libraries:'
1.475 deraadt 172:
1.481 rpe 173: # Remount read-write, if /usr/lib is on a read-only ffs filesystem.
174: if [[ $_mp == *' type ffs '*'read-only'* ]]; then
175: if mount -u -w $_dkdev; then
176: _remount=true
177: else
178: echo ' failed.'
179: return
180: fi
181: fi
1.509 tb 182:
183: # Only choose the latest version of the libraries.
184: for _liba in /usr/lib/lib{c,crypto}; do
1.513 zhuk 185: _libas="$_libas $(ls $_liba.so.+([0-9.]).a | sort -rV | head -1)"
1.509 tb 186: done
187: _libas=${_libas# }
1.481 rpe 188:
1.517 ! rpe 189: for _liba in /usr/libdata/ld.so.a $_libas; do
! 190: _tmpdir=$(mktemp -dq /tmp/_librebuild.XXXXXXXXXXXX) &&
! 191: (
! 192: set -o errexit
! 193: _install='install -F -S -o root -g bin -m 0444'
! 194: _lib=${_liba##*/}
! 195: _lib=${_lib%.a}
! 196: cd $_tmpdir
! 197: ar x $_liba
! 198: if [[ $_lib == ld.so ]]; then
! 199: ld -g -x -e _dl_start \
! 200: --version-script=Symbols.map --shared -Bsymbolic \
! 201: --no-undefined -o ld.so.test $(ls *.o | sort -R)
! 202: chmod u+x test-ld.so
! 203: [[ $(./test-ld.so ok) == './test-ld.so: ok!' ]]
! 204: $_install /usr/libexec/ld.so /usr/libexec/ld.so.save
! 205: $_install ld.so.test /usr/libexec/ld.so
! 206: else
1.475 deraadt 207: cc -shared -o $_lib $(ls *.so | sort -R) $(cat .ldadd)
208: [[ -s $_lib ]] && file $_lib | fgrep -q 'shared object'
209: LD_BIND_NOW=1 LD_LIBRARY_PATH=$_tmpdir awk 'BEGIN {exit 0}'
1.500 deraadt 210: LD_BIND_NOW=1 LD_LIBRARY_PATH=$_tmpdir openssl \
211: x509 -in /etc/ssl/cert.pem -out /dev/null
1.517 ! rpe 212: $_install $_lib ${_liba%/*}/$_lib
! 213: fi
1.485 rpe 214: ) || { _error=true; break; }
1.475 deraadt 215: done
1.481 rpe 216:
1.485 rpe 217: rm -rf /tmp/_librebuild.*
218:
1.481 rpe 219: # Restore previous mount state if it was changed.
220: if $_remount; then
1.485 rpe 221: mount -u -r $_dkdev || _error=true
1.481 rpe 222: fi
1.482 deraadt 223:
1.485 rpe 224: if $_error; then
225: echo ' failed.'
226: else
227: echo ' done.'
228: fi
1.475 deraadt 229: }
230:
1.483 rpe 231: # Run rc.* script and email output to root.
232: # Usage: run_upgrade_script firsttime|sysmerge
1.477 ajacouto 233: run_upgrade_script() {
234: local _suffix=$1
1.491 rpe 235:
1.477 ajacouto 236: [[ -n $_suffix ]] || return 1
1.491 rpe 237:
1.477 ajacouto 238: if [[ -f /etc/rc.$_suffix ]]; then
1.516 ajacouto 239: echo "running rc.$_suffix"
1.477 ajacouto 240: mv /etc/rc.$_suffix /etc/rc.$_suffix.run
241: . /etc/rc.$_suffix.run 2>&1 | tee /dev/tty |
242: mail -Es "$(hostname) rc.$_suffix output" root >/dev/null
243: fi
244: rm -f /etc/rc.$_suffix.run
245: }
246:
1.462 rpe 247: # Check filesystems, optionally by using a fsck(8) flag.
248: # Usage: do_fsck [-flag]
1.452 rpe 249: do_fsck() {
1.462 rpe 250: fsck -p "$@"
1.429 claudio 251: case $? in
1.462 rpe 252: 0) ;;
253: 2) exit 1
1.429 claudio 254: ;;
1.462 rpe 255: 4) echo "Rebooting..."
1.429 claudio 256: reboot
257: echo "Reboot failed; help!"
258: exit 1
259: ;;
1.462 rpe 260: 8) echo "Automatic file system check failed; help!"
1.429 claudio 261: exit 1
262: ;;
1.462 rpe 263: 12) echo "Boot interrupted."
1.429 claudio 264: exit 1
265: ;;
1.462 rpe 266: 130) # Interrupt before catcher installed.
1.429 claudio 267: exit 1
268: ;;
1.462 rpe 269: *) echo "Unknown error; help!"
1.429 claudio 270: exit 1
271: ;;
272: esac
273: }
274:
1.450 rpe 275: # End subroutines.
1.131 millert 276:
1.1 deraadt 277: stty status '^T'
278:
1.450 rpe 279: # Set shell to ignore SIGINT (2), but not children; shell catches SIGQUIT (3)
280: # and returns to single user after fsck.
1.1 deraadt 281: trap : 2
1.450 rpe 282: trap : 3 # Shouldn't be needed.
1.1 deraadt 283:
1.463 rpe 284: export HOME=/
285: export INRC=1
286: export PATH=/sbin:/bin:/usr/sbin:/usr/bin
1.395 deraadt 287:
1.450 rpe 288: # Must set the domainname before rc.conf, so YP startup choices can be made.
1.463 rpe 289: if [[ -s /etc/defaultdomain ]]; then
290: domainname "$(stripcom /etc/defaultdomain)"
1.395 deraadt 291: fi
1.108 deraadt 292:
1.495 rpe 293: # Get local functions from rc.subr to load rc.conf into scope.
1.428 robert 294: FUNCS_ONLY=1 . /etc/rc.d/rc.subr
295: _rc_parse_conf
1.343 robert 296:
1.495 rpe 297: # If executed with the 'shutdown' parameter by the halt, reboot or shutdown:
298: # - update seed files
299: # - execute the rc.d scripts specified by $pkg_scripts in reverse order
300: # - bring carp interfaces down gracefully
1.463 rpe 301: if [[ $1 == shutdown ]]; then
1.437 bluhm 302: if echo 2>/dev/null >>/var/db/host.random || \
303: echo 2>/dev/null >>/etc/random.seed; then
304: random_seed
305: else
306: echo warning: cannot write random seed to disk
307: fi
1.416 rpe 308:
1.469 tim 309: # If we are in secure level 0, assume single user mode.
1.463 rpe 310: if (($(sysctl -n kern.securelevel) == 0)); then
311: echo 'single user: not running shutdown scripts'
312: else
1.514 rpe 313: set -A _d -- $pkg_scripts
314: _i=${#_d[*]}
315: if ((_i)); then
1.413 deraadt 316: echo -n 'stopping package daemons:'
1.514 rpe 317: while ((--_i >= 0)); do
318: [[ -x /etc/rc.d/${_d[_i]} ]] &&
319: /etc/rc.d/${_d[_i]} stop
1.413 deraadt 320: done
321: echo '.'
322: fi
323:
1.463 rpe 324: [[ -f /etc/rc.shutdown ]] && sh /etc/rc.shutdown
1.413 deraadt 325: fi
1.240 mcbride 326:
1.463 rpe 327: ifconfig | while read _if _junk; do
1.474 rpe 328: [[ $_if == carp+([0-9]): ]] && ifconfig ${_if%:} down
1.413 deraadt 329: done
1.246 mcbride 330:
1.108 deraadt 331: exit 0
1.1 deraadt 332: fi
1.98 jakob 333:
1.482 deraadt 334: # Add swap block-devices.
1.172 miod 335: swapctl -A -t blk
1.170 deraadt 336:
1.495 rpe 337: # Run filesystem check unless a /fastboot file exists.
1.463 rpe 338: if [[ -e /fastboot ]]; then
1.1 deraadt 339: echo "Fast boot: skipping disk checks."
1.463 rpe 340: elif [[ $1 == autoboot ]]; then
1.1 deraadt 341: echo "Automatic boot in progress: starting file system checks."
1.429 claudio 342: do_fsck
1.1 deraadt 343: fi
344:
1.495 rpe 345: # From now on, allow user to interrupt (^C) the boot process.
1.1 deraadt 346: trap "echo 'Boot interrupted.'; exit 1" 3
347:
1.495 rpe 348: # Unmount all filesystems except root.
1.1 deraadt 349: umount -a >/dev/null 2>&1
1.495 rpe 350:
351: # Mount all filesystems except those of type NFS and VND.
1.303 grunk 352: mount -a -t nonfs,vnd
1.177 deraadt 353:
1.495 rpe 354: # Re-mount the root filesystem read/writeable. (root on nfs requires this,
355: # others aren't hurt.)
356: mount -uw /
1.499 deraadt 357: chmod og-rwx /bsd
1.503 deraadt 358: ln -fh /bsd /bsd.booted
1.495 rpe 359:
360: rm -f /fastboot
361:
1.505 tedu 362: # Set flags on ttys.
1.1 deraadt 363: echo 'setting tty flags'
364: ttyflags -a
1.77 angelos 365:
1.464 rpe 366: # Set keyboard encoding.
367: if [[ -x /sbin/kbd && -s /etc/kbdtype ]]; then
368: kbd "$(cat /etc/kbdtype)"
1.252 mcbride 369: fi
370:
1.279 deraadt 371: wsconsctl_conf
372:
1.464 rpe 373: # Set initial temporary pf rule set.
374: if [[ $pf != NO ]]; then
1.511 rpe 375: RULES="
1.510 rpe 376: block all
377: pass on lo0
378: pass in proto tcp from any to any port ssh keep state
379: pass out proto { tcp, udp } from any to any port domain keep state
380: pass out inet proto icmp all icmp-type echoreq keep state
381: pass out inet proto udp from any port bootpc to any port bootps
1.511 rpe 382: pass in inet proto udp from any port bootps to any port bootpc"
1.510 rpe 383:
1.257 grange 384: if ifconfig lo0 inet6 >/dev/null 2>&1; then
1.510 rpe 385: RULES="$RULES
386: pass out inet6 proto icmp6 all icmp6-type neighbrsol
387: pass in inet6 proto icmp6 all icmp6-type neighbradv
388: pass out inet6 proto icmp6 all icmp6-type routersol
389: pass in inet6 proto icmp6 all icmp6-type routeradv
390: pass out inet6 proto udp from any port dhcpv6-client to any port dhcpv6-server
391: pass in inet6 proto udp from any port dhcpv6-server to any port dhcpv6-client"
1.257 grange 392: fi
1.510 rpe 393:
394: RULES="$RULES
395: pass in proto carp keep state (no-sync)
396: pass out proto carp !received-on any keep state (no-sync)"
397:
1.512 rpe 398: if (($(sysctl -n vfs.mounts.nfs 2>/dev/null) > 0)); then
1.511 rpe 399: # Don't kill NFS.
1.510 rpe 400: RULES="set reassemble yes no-df
401: $RULES
402: pass in proto { tcp, udp } from any port { sunrpc, nfsd } to any
403: pass out proto { tcp, udp } from any to any port { sunrpc, nfsd } !received-on any"
1.474 rpe 404: fi
1.511 rpe 405:
1.464 rpe 406: print -- "$RULES" | pfctl -f -
1.269 dhartmei 407: pfctl -e
1.176 kjell 408: fi
1.318 djm 409:
410: fill_baddynamic udp
411: fill_baddynamic tcp
1.176 kjell 412:
1.267 millert 413: sysctl_conf
1.260 jsg 414:
1.501 florian 415: start_daemon slaacd >/dev/null 2>&1
416:
1.1 deraadt 417: echo 'starting network'
1.464 rpe 418:
419: # Set carp interlock by increasing the demotion counter.
420: # Prevents carp from preempting until the system is booted.
1.289 henning 421: ifconfig -g carp carpdemote 128
1.464 rpe 422:
1.439 ajacouto 423: sh /etc/netstart
1.464 rpe 424:
1.495 rpe 425: # Any write triggers a rekey.
426: dmesg >/dev/random
1.176 kjell 427:
1.450 rpe 428: # Load pf rules and bring up pfsync interface.
1.464 rpe 429: if [[ $pf != NO ]]; then
430: if [[ -f /etc/pf.conf ]]; then
1.449 ajacouto 431: pfctl -f /etc/pf.conf
1.309 mpf 432: fi
1.464 rpe 433: if [[ -f /etc/hostname.pfsync0 ]]; then
1.435 deraadt 434: sh /etc/netstart pfsync0
1.367 deraadt 435: fi
1.176 kjell 436: fi
1.1 deraadt 437:
1.278 otto 438: mount -s /usr >/dev/null 2>&1
439: mount -s /var >/dev/null 2>&1
1.180 deraadt 440:
1.389 deraadt 441: random_seed
1.475 deraadt 442:
1.481 rpe 443: reorder_libs
1.29 deraadt 444:
1.450 rpe 445: # Clean up left-over files.
1.492 jca 446: rm -f /etc/nologin /var/spool/lock/LCK.*
1.247 henning 447: (cd /var/run && { rm -rf -- *; install -c -m 664 -g utmp /dev/null utmp; })
1.196 beck 448: (cd /var/authpf && rm -rf -- *)
1.96 alex 449:
1.495 rpe 450: # Save a copy of the boot messages.
451: dmesg >/var/run/dmesg.boot
1.55 deraadt 452:
1.373 deraadt 453: make_keys
454:
1.379 deraadt 455: echo -n 'starting early daemons:'
1.501 florian 456: start_daemon syslogd ldattach pflogd nsd rebound unbound ntpd
1.429 claudio 457: start_daemon iscsid isakmpd iked sasyncd ldapd npppd
1.353 robert 458: echo '.'
1.280 hshoexer 459:
1.450 rpe 460: # Load IPsec rules.
1.464 rpe 461: if [[ $ipsec != NO && -f /etc/ipsec.conf ]]; then
462: ipsecctl -f /etc/ipsec.conf
1.40 provos 463: fi
1.1 deraadt 464:
1.379 deraadt 465: echo -n 'starting RPC daemons:'
1.399 dlg 466: start_daemon portmap ypldap
1.466 deraadt 467: rm -f /var/run/ypbind.lock
1.464 rpe 468: if [[ -n $(domainname) ]]; then
1.470 deraadt 469: start_daemon ypserv ypbind
1.376 deraadt 470: fi
1.399 dlg 471: start_daemon mountd nfsd lockd statd amd
1.1 deraadt 472: echo '.'
1.58 deraadt 473:
1.464 rpe 474: # Check and mount remaining file systems and enable additional swap.
1.278 otto 475: mount -a
1.172 miod 476: swapctl -A -t noblk
1.429 claudio 477: do_fsck -N
478: mount -a -N
1.1 deraadt 479:
1.450 rpe 480: # /var/crash should be a directory or a symbolic link to the crash directory
481: # if core dumps are to be saved.
1.464 rpe 482: if [[ -d /var/crash ]]; then
483: savecore $savecore_flags /var/crash
1.487 rpe 484: fi
485:
486: # Store ACPI tables in /var/db/acpi to be used by sendbug(1).
487: if [[ -x /usr/sbin/acpidump ]]; then
488: acpidump -o /var/db/acpi/
1.90 art 489: fi
490:
1.464 rpe 491: if [[ $check_quotas == YES ]]; then
1.41 downsj 492: echo -n 'checking quotas:'
493: quotacheck -a
494: echo ' done.'
495: quotaon -a
496: fi
1.1 deraadt 497:
1.464 rpe 498: # Build kvm(3) and /dev databases.
499: kvm_mkdb
1.1 deraadt 500: dev_mkdb
1.464 rpe 501:
502: # Set proper permission for the tty device files.
1.101 deraadt 503: chmod 666 /dev/tty[pqrstuvwxyzPQRST]*
1.226 millert 504: chown root:wheel /dev/tty[pqrstuvwxyzPQRST]*
1.1 deraadt 505:
1.495 rpe 506: # Check for the password temp/lock file.
1.467 rpe 507: if [[ -f /etc/ptmp ]]; then
1.1 deraadt 508: logger -s -p auth.err \
1.376 deraadt 509: 'password file may be incorrect -- /etc/ptmp exists'
1.32 deraadt 510: fi
511:
1.49 millert 512: echo clearing /tmp
513:
1.450 rpe 514: # Prune quickly with one rm, then use find to clean up /tmp/[lqv]*
515: # (not needed with mfs /tmp, but doesn't hurt there...).
1.444 deraadt 516: (cd /tmp && rm -rf [a-km-pr-uw-zA-Z]*)
1.339 sthen 517: (cd /tmp &&
1.443 millert 518: find . -maxdepth 1 ! -name . ! -name lost+found ! -name quota.user \
1.444 deraadt 519: ! -name quota.group ! -name vi.recover -execdir rm -rf -- {} \;)
1.373 deraadt 520:
1.462 rpe 521: # Create Unix sockets directories for X if needed and make sure they have
522: # correct permissions.
523: [[ -d /usr/X11R6/lib ]] && mkdir -m 1777 /tmp/.{X11,ICE}-unix
1.203 hugh 524:
1.467 rpe 525: [[ -f /etc/rc.securelevel ]] && sh /etc/rc.securelevel
526:
1.450 rpe 527: # rc.securelevel did not specifically set -1 or 2, so select the default: 1.
1.467 rpe 528: (($(sysctl -n kern.securelevel) == 0)) && sysctl kern.securelevel=1
529:
1.1 deraadt 530:
1.450 rpe 531: # Patch /etc/motd.
1.467 rpe 532: if [[ ! -f /etc/motd ]]; then
1.34 deraadt 533: install -c -o root -g wheel -m 664 /dev/null /etc/motd
534: fi
1.467 rpe 535: if T=$(mktemp /tmp/_motd.XXXXXXXXXX); then
1.451 rpe 536: sysctl -n kern.version | sed 1q >$T
1.494 schwarze 537: sed -n '/^$/,$p' </etc/motd >>$T
1.102 millert 538: cmp -s $T /etc/motd || cp $T /etc/motd
539: rm -f $T
540: fi
1.34 deraadt 541:
1.467 rpe 542: if [[ $accounting == YES ]]; then
543: [[ ! -f /var/account/acct ]] && touch /var/account/acct
544: echo 'turning on accounting'
545: accton /var/account/acct
1.1 deraadt 546: fi
547:
1.467 rpe 548: if [[ -x /sbin/ldconfig ]]; then
1.115 deraadt 549: echo 'creating runtime link editor directory cache.'
1.471 rpe 550: [[ -d /usr/local/lib ]] && shlib_dirs="/usr/local/lib $shlib_dirs"
1.467 rpe 551: [[ -d /usr/X11R6/lib ]] && shlib_dirs="/usr/X11R6/lib $shlib_dirs"
1.115 deraadt 552: ldconfig $shlib_dirs
1.231 millert 553: fi
554:
1.451 rpe 555: echo 'preserving editor files.'; /usr/libexec/vi.recover
1.244 markus 556:
1.477 ajacouto 557: # If rc.sysmerge exists, run it just once, and make sure it is deleted.
558: run_upgrade_script sysmerge
559:
1.353 robert 560: echo -n 'starting network daemons:'
1.489 reyk 561: start_daemon ldomd sshd switchd snmpd ldpd ripd ospfd ospf6d bgpd ifstated
1.465 renato 562: start_daemon relayd dhcpd dhcrelay mrouted dvmrpd radiusd eigrpd
1.127 itojun 563:
564: if ifconfig lo0 inet6 >/dev/null 2>&1; then
1.467 rpe 565: if (($(sysctl -n net.inet6.ip6.forwarding) == 1)); then
1.376 deraadt 566: start_daemon route6d rtadvd
1.127 itojun 567: fi
1.281 reyk 568: fi
569:
1.442 matthieu 570: start_daemon hostapd lpd smtpd slowcgi httpd ftpd
1.461 sthen 571: start_daemon ftpproxy ftpproxy6 tftpd tftpproxy identd inetd rarpd bootparamd
1.488 reyk 572: start_daemon rbootd mopd vmd spamd spamlogd sndiod
1.377 robert 573: echo '.'
1.335 deraadt 574:
1.450 rpe 575: # If rc.firsttime exists, run it just once, and make sure it is deleted.
1.477 ajacouto 576: run_upgrade_script firsttime
1.352 ajacouto 577:
1.450 rpe 578: # Run rc.d(8) scripts from packages.
1.467 rpe 579: if [[ -n $pkg_scripts ]]; then
1.352 ajacouto 580: echo -n 'starting package daemons:'
1.467 rpe 581: for _daemon in $pkg_scripts; do
582: if [[ -x /etc/rc.d/$_daemon ]]; then
583: start_daemon $_daemon
1.410 espie 584: else
1.467 rpe 585: echo -n " ${_daemon}(absent)"
1.410 espie 586: fi
1.352 ajacouto 587: done
588: echo '.'
589: fi
1.17 deraadt 590:
1.467 rpe 591: [[ -f /etc/rc.local ]] && sh /etc/rc.local
1.73 millert 592:
1.495 rpe 593: # Disable carp interlock.
594: ifconfig -g carp -carpdemote 128
1.286 mcbride 595:
1.379 deraadt 596: mixerctl_conf
1.467 rpe 597:
1.379 deraadt 598: echo -n 'starting local daemons:'
1.493 matthieu 599: start_daemon apmd sensorsd hotplugd watchdogd cron wsmoused xenodm
1.73 millert 600: echo '.'
1.502 rpe 601:
1.515 rpe 602: # Re-link the kernel, placing the objects in a random order.
603: # Replace current with relinked kernel and inform root about it.
604: /usr/libexec/reorder_kernel &
1.1 deraadt 605:
606: date
607: exit 0