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