rc revision 95485
1#!/bin/sh 2# 3# Copyright (c) 2000 The FreeBSD Project 4# All rights reserved. 5# 6# Redistribution and use in source and binary forms, with or without 7# modification, are permitted provided that the following conditions 8# are met: 9# 1. Redistributions of source code must retain the above copyright 10# notice, this list of conditions and the following disclaimer. 11# 2. Redistributions in binary form must reproduce the above copyright 12# notice, this list of conditions and the following disclaimer in the 13# documentation and/or other materials provided with the distribution. 14# 15# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 16# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 19# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 21# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25# SUCH DAMAGE. 26# 27# @(#)rc 5.27 (Berkeley) 6/5/91 28# $FreeBSD: head/etc/rc 95485 2002-04-26 07:31:04Z wes $ 29# 30 31# System startup script run by init on autoboot 32# or after single-user. 33# Output and error are redirected to console by init, 34# and the console is the controlling terminal. 35 36# Note that almost all of the user-configurable behavior is no longer in 37# this file, but rather in /etc/defaults/rc.conf. Please check that file 38# first before contemplating any changes here. If you do need to change 39# this file for some reason, we would like to know about it. 40 41stty status '^T' 42 43# Set shell to ignore SIGINT (2), but not children; 44# shell catches SIGQUIT (3) and returns to single user after fsck. 45# 46trap : 2 47trap : 3 # shouldn't be needed 48 49bootmode=$1 50 51HOME=/ 52PATH=/sbin:/bin:/usr/sbin:/usr/bin 53export HOME PATH 54 55# BOOTP diskless boot. We have to run the rc file early in order to 56# retarget various config files. 57# 58if [ -r /etc/rc.diskless1 ]; then 59 dlv=`/sbin/sysctl -n vfs.nfs.diskless_valid 2> /dev/null` 60 if [ ${dlv:=0} != 0 ]; then 61 . /etc/rc.diskless1 62 fi 63fi 64 65# If there is a global system configuration file, suck it in. 66# 67if [ -r /etc/defaults/rc.conf ]; then 68 . /etc/defaults/rc.conf 69 source_rc_confs 70elif [ -r /etc/rc.conf ]; then 71 . /etc/rc.conf 72fi 73 74feed_dev_random() { 75 if [ -f "${1}" -a -r "${1}" -a -s "${1}" ]; then 76# echo "Using ${1} as an entropy file" 77 cat "${1}" | dd of=/dev/random bs=8k 2>/dev/null 78 fi 79} 80 81chkdepend() { 82 svc=$1 83 svc_var=$2 84 dep=$3 85 dep_var=$4 86 87 eval svc_val=\${$svc_var} 88 eval dep_val=\${$dep_var} 89 90 case ${svc_val} in 91 [Yy][Ee][Ss]) 92 case ${dep_val} in 93 [Yy][Ee][Ss]) 94 ;; 95 *) 96 eval ${dep_var}="YES" 97 echo "DEPENDENCY NOTE: ${dep} will be enabled" \ 98 "to support ${svc}" 99 ;; 100 esac 101 ;; 102 esac 103} 104 105chkdepend amd amd_enable portmap portmap_enable 106chkdepend amd amd_enable NFS nfs_client_enable 107chkdepend NFS nfs_server_enable portmap portmap_enable 108chkdepend NIS nis_server_enable portmap portmap_enable 109chkdepend NIS nis_client_enable portmap portmap_enable 110 111# Enable dumpdev early so that a crash during the boot process can be caught. 112# 113case ${dumpdev} in 114[Nn][Oo] | '') 115 dumpdev='NO' 116 ;; 117*) 118 /sbin/dumpon -v ${dumpdev} 119 ;; 120esac 121 122# Enable harvesting of entropy via devices. The sooner this happens the 123# better so that we can take advantage of the boot process. 124# 125echo -n 'Entropy harvesting:' 126 127case ${harvest_interrupt} in 128[Nn][Oo]) 129 ;; 130*) 131 if [ -w /dev/random ]; then 132 /sbin/sysctl kern.random.sys.harvest.interrupt=1 >/dev/null 133 echo -n ' interrupts' 134 fi 135 ;; 136esac 137 138case ${harvest_ethernet} in 139[Nn][Oo]) 140 ;; 141*) 142 if [ -w /dev/random ]; then 143 /sbin/sysctl kern.random.sys.harvest.ethernet=1 >/dev/null 144 echo -n ' ethernet' 145 fi 146 ;; 147esac 148 149case ${harvest_p_to_p} in 150[Nn][Oo]) 151 ;; 152*) 153 if [ -w /dev/random ]; then 154 /sbin/sysctl kern.random.sys.harvest.point_to_point=1 >/dev/null 155 echo -n ' point_to_point' 156 fi 157 ;; 158esac 159 160echo '.' 161 162# First pass at reseeding /dev/random. 163# 164case ${entropy_file} in 165[Nn][Oo] | '') 166 ;; 167*) 168 if [ -w /dev/random ]; then 169 feed_dev_random "${entropy_file}" 170 fi 171 ;; 172esac 173 174# XXX temporary until we can get the entropy 175# harvesting rate up 176# Entropy below is not great, 177# but better than nothing. 178( ps -fauxww; sysctl -a; date; df -ib; dmesg; ps -fauxww; ) \ 179 | dd of=/dev/random bs=8k 2>/dev/null 180cat /bin/ls | dd of=/dev/random bs=8k 2>/dev/null 181 182# Configure ccd devices. 183# 184if [ -r /etc/ccd.conf ]; then 185 ccdconfig -C 186fi 187 188case ${start_vinum} in 189[Yy][Ee][Ss]) 190 vinum start 191 ;; 192esac 193 194swapon -a 195 196# Last chance to do things before potentially waiting for 197# operator to do fsck related tasks 198if [ -r /etc/rc.early ]; then 199 . /etc/rc.early 200fi 201 202case ${bootmode} in 203autoboot) 204 echo 'Automatic boot in progress...' 205 case ${background_fsck} in 206 [Yy][Ee][Ss]) 207 fsck -F -p 208 ;; 209 *) 210 fsck -p 211 ;; 212 esac 213 case $? in 214 0) 215 ;; 216 2) 217 exit 1 218 ;; 219 4) 220 reboot 221 echo 'Reboot failed... help!' 222 exit 1 223 ;; 224 8) 225 case ${fsck_y_enable} in 226 [Yy][Ee][Ss]) 227 echo 'File system preen failed, trying fsck -y . . .' 228 fsck -y 229 case $? in 230 0) 231 ;; 232 *) 233 echo 'Automatic file system check failed . . . help!' 234 exit 1 235 ;; 236 esac 237 ;; 238 *) 239 echo 'Automatic file system check failed . . . help!' 240 exit 1 241 ;; 242 esac 243 ;; 244 12) 245 echo 'Reboot interrupted' 246 exit 1 247 ;; 248 130) 249 # interrupt before catcher installed 250 exit 1 251 ;; 252 *) 253 echo 'Unknown error in reboot' 254 exit 1 255 ;; 256 esac 257 ;; 258*) 259 echo 'Skipping disk checks ...' 260 ;; 261esac 262 263set -T 264trap "echo 'Reboot interrupted'; exit 1" 3 265 266# root normally must be read/write, but if this is a BOOTP NFS 267# diskless boot it does not have to be. 268# 269case ${root_rw_mount} in 270[Nn][Oo] | '') 271 ;; 272*) 273 if ! mount -u -o rw / ; then 274 echo 'Mounting root filesystem rw failed, startup aborted' 275 exit 1 276 fi 277 ;; 278esac 279 280umount -a >/dev/null 2>&1 281 282# Set up the list of network filesystem types for which mounting should be 283# delayed until after network initialization. 284networkfs_types='nfs:NFS smbfs:SMB portalfs:PORTAL' 285case ${extra_netfs_types} in 286[Nn][Oo]) 287 ;; 288*) 289 networkfs_types="${networkfs_types} ${extra_netfs_types}" 290 ;; 291esac 292 293# Mount everything except nfs filesystems. 294mount_excludes='no' 295for i in ${networkfs_types}; do 296 fstype=${i%:*} 297 mount_excludes="${mount_excludes}${fstype}," 298done 299mount_excludes=${mount_excludes%,} 300mount -a -t ${mount_excludes} 301 302case $? in 3030) 304 ;; 305*) 306 echo 'Mounting /etc/fstab filesystems failed, startup aborted' 307 exit 1 308 ;; 309esac 310 311# Run custom disk mounting function here 312# 313if [ -n "${diskless_mount}" -a -r "${diskless_mount}" ]; then 314 sh ${diskless_mount} 315fi 316 317# If we booted a special kernel remove the record so we will boot 318# the default kernel next time 319rm -f /boot/nextkernel 320 321# Reseed /dev/random with previously stored entropy. 322case ${entropy_dir} in 323[Nn][Oo]) 324 ;; 325*) 326 entropy_dir=${entropy_dir:-/var/db/entropy} 327 if [ -d "${entropy_dir}" ]; then 328 if [ -w /dev/random ]; then 329 for seedfile in ${entropy_dir}/*; do 330 feed_dev_random "${seedfile}" 331 done 332 fi 333 fi 334 ;; 335esac 336 337case ${entropy_file} in 338[Nn][Oo] | '') 339 ;; 340*) 341 if [ -w /dev/random ]; then 342 feed_dev_random "${entropy_file}" 343 fi 344 ;; 345esac 346 347adjkerntz -i 348 349purgedir() { 350 local dir file 351 352 if [ $# -eq 0 ]; then 353 purgedir . 354 else 355 for dir 356 do 357 ( 358 cd "$dir" && for file in .* * 359 do 360 [ ."$file" = .. -o ."$file" = ... ] && continue 361 if [ -d "$file" -a ! -L "$file" ] 362 then 363 purgedir "$file" 364 else 365 rm -f -- "$file" 366 fi 367 done 368 ) 369 done 370 fi 371} 372 373clean_var() { 374 if [ -d /var/run -a ! -f /var/run/clean_var ]; then 375 purgedir /var/run 376 # Keep a copy of the boot messages around 377 dmesg >/var/run/dmesg.boot 378 # And an initial utmp file 379 (cd /var/run && cp /dev/null utmp && chmod 644 utmp;) 380 >/var/run/clean_var 381 fi 382 if [ -d /var/spool/lock -a ! -f /var/spool/lock/clean_var ]; then 383 purgedir /var/spool/lock 384 >/var/spool/lock/clean_var 385 fi 386 rm -rf /var/spool/uucp/.Temp/* 387} 388 389# network_pass1() *may* end up writing stuff to /var - we don't want to 390# remove it immediately afterwards - *nor* do we want to fail to clean 391# an NFS-mounted /var. 392rm -f /var/run/clean_var /var/spool/lock/clean_var 393clean_var 394 395# Add additional swapfile, if configured. 396# 397case ${swapfile} in 398[Nn][Oo] | '') 399 ;; 400*) 401 if [ -w "${swapfile}" -a -c /dev/mdctl ]; then 402 echo "Adding ${swapfile} as additional swap" 403 mdev=`mdconfig -a -t vnode -f ${swapfile}` && swapon /dev/${mdev} 404 fi 405 ;; 406esac 407 408# Early pass to set the variables we can 409# 410if [ -r /etc/rc.sysctl ]; then 411 sh /etc/rc.sysctl first 412fi 413 414# Configure serial devices 415# 416if [ -r /etc/rc.serial ]; then 417 . /etc/rc.serial 418fi 419 420# Start up PC-card configuration 421# 422if [ -r /etc/rc.pccard ]; then 423 . /etc/rc.pccard 424fi 425 426# Start up the initial network configuration. 427# 428if [ -r /etc/rc.network ]; then 429 . /etc/rc.network # We only need to do this once. 430 network_pass1 431fi 432 433case ${ipv6_enable} in 434[Yy][Ee][Ss]) 435 if [ -r /etc/rc.network6 ]; then 436 . /etc/rc.network6 # We only need to do this once also. 437 network6_pass1 438 fi 439 ;; 440esac 441 442# Mount NFS filesystems if present in /etc/fstab 443# 444# XXX When the vfsload() issues with nfsclient support and related sysctls 445# have been resolved, this block can be removed, and the condition that 446# skips nfs in the following block (for "other network filesystems") can 447# be removed. 448case "`mount -d -a -t nfs 2> /dev/null`" in 449*mount_nfs*) 450 # Handle absent nfs client support 451 nfsclient_in_kernel=0 452 if sysctl vfs.nfs >/dev/null 2>&1; then 453 nfsclient_in_kernel=1 454 else 455 kldload nfsclient && nfsclient_in_kernel=1 456 fi 457 458 case ${nfsclient_in_kernel} in 459 1) 460 echo -n 'Mounting NFS file systems:' 461 mount -a -t nfs 462 echo '.' 463 ;; 464 *) 465 echo 'Warning: nfs mount requested, but no nfs client in kernel' 466 ;; 467 esac 468 ;; 469esac 470 471# Mount other network filesystems if present in /etc/fstab 472for i in ${networkfs_types}; do 473 fstype=${i%:*} 474 fsdecr=${i#*:} 475 476 if [ "${fstype}" = "nfs" ]; then 477 continue 478 fi 479 case "`mount -d -a -t ${fstype}`" in 480 *mount_${fstype}*) 481 echo -n "Mounting ${fsdecr} file systems:" 482 mount -a -t ${fstype} 483 echo '.' 484 ;; 485 esac 486done 487 488# Whack the pty perms back into shape. 489# 490if ls /dev/tty[pqrsPQRS]* > /dev/null 2>&1; then 491 chflags 0 /dev/tty[pqrsPQRS]* 492 chmod 666 /dev/tty[pqrsPQRS]* 493 chown root:wheel /dev/tty[pqrsPQRS]* 494fi 495 496# Clean up left-over files 497# 498clean_var # If it hasn't already been done 499rm /var/run/clean_var /var/spool/lock/clean_var 500 501# Clearing /tmp at boot-time seems to have a long tradition. It doesn't 502# help in any way for long-living systems, and it might accidentally 503# clobber files you would rather like to have preserved after a crash 504# (if not using mfs /tmp anyway). 505# 506# See also the example of another cleanup policy in /etc/periodic/daily. 507# 508case ${clear_tmp_enable} in 509[Yy][Ee][Ss]) 510 echo -n 'Clearing /tmp:' 511 # prune quickly with one rm, then use find to clean up /tmp/[lq]* 512 # (not needed with mfs /tmp, but doesn't hurt there...) 513 (cd /tmp && rm -rf [a-km-pr-zA-Z]* && 514 find -d . ! -name . ! -name lost+found ! -name quota.user \ 515 ! -name quota.group -exec rm -rf -- {} \;) 516 echo '.' 517 ;; 518esac 519 520# Remove X lock files, since they will prevent you from restarting X11 521# after a system crash. 522# 523rm -f /tmp/.X*-lock /tmp/.X11-unix/* 524 525# Snapshot any kernel -c changes back to disk here <someday>. 526# This has changed with ELF and /kernel.config. 527 528# Load LOMAC(4) security if wanted. 529case ${lomac_enable} in 530[Yy][Ee][Ss]) 531 kldload lomac >/dev/null 2>&1 532 ;; 533esac 534 535echo -n 'Additional daemons:' 536 537# Start system logging and name service. Named needs to start before syslogd 538# if you don't have a /etc/resolv.conf. 539# 540case ${syslogd_enable} in 541[Yy][Ee][Ss]) 542 # Transitional symlink (for the next couple of years :) until all 543 # binaries have had a chance to move towards /var/run/log. 544 if [ ! -L /dev/log ]; then 545 # might complain for r/o root f/s 546 ln -sf /var/run/log /dev/log 547 fi 548 549 rm -f /var/run/log 550 echo -n ' syslogd'; 551 ${syslogd_program:-/usr/sbin/syslogd} ${syslogd_flags} 552 ;; 553esac 554 555echo '.' 556 557# Build device name databases if we are not using DEVFS 558# 559if sysctl vfs.devfs.generation > /dev/null 2>&1 ; then 560 rm -f /var/run/dev.db 561else 562 dev_mkdb 563fi 564 565# $dumpdir should be a directory or a symbolic link 566# to the crash directory if core dumps are to be saved. 567# 568if [ "${dumpdev}" != 'NO' ]; then 569 case ${dumpdir} in 570 '') 571 dumpdir='/var/crash' 572 ;; 573 [Nn][Oo]) 574 dumpdir='NO' 575 ;; 576 esac 577 578 if [ "${dumpdir}" != 'NO' ]; then 579 echo -n 'Checking for core dump: ' 580 /sbin/savecore ${savecore_flags} "${dumpdir}" 581 fi 582fi 583 584if [ -n "${network_pass1_done}" ]; then 585 network_pass2 586fi 587 588# Enable/Check the quotas (must be after ypbind if using NIS) 589# 590case ${enable_quotas} in 591[Yy][Ee][Ss]) 592 case ${check_quotas} in 593 [Yy][Ee][Ss]) 594 echo -n 'Checking quotas:' 595 quotacheck -a 596 echo ' done.' 597 ;; 598 esac 599 600 echo -n 'Enabling quotas:' 601 quotaon -a 602 echo ' done.' 603 ;; 604esac 605 606if [ -n "${network_pass2_done}" ]; then 607 network_pass3 608fi 609 610# Check the password temp/lock file 611# 612if [ -e /etc/ptmp ]; then 613 logger -s -p auth.err \ 614 "password file may be incorrect -- /etc/ptmp exists" 615fi 616 617case ${accounting_enable} in 618[Yy][Ee][Ss]) 619 if [ -d /var/account ]; then 620 echo 'Turning on accounting:' 621 if [ ! -e /var/account/acct ]; then 622 touch /var/account/acct 623 fi 624 accton /var/account/acct 625 fi 626 ;; 627esac 628 629# Make shared lib searching a little faster. Leave /usr/lib first if you 630# add your own entries or you may come to grief. 631# 632ldconfig="/sbin/ldconfig" 633case ${ldconfig_insecure} in 634[Yy][Ee][Ss]) 635 ldconfig="${ldconfig} -i" 636 ;; 637esac 638if [ -x /sbin/ldconfig ]; then 639 case `/usr/bin/objformat` in 640 elf) 641 _LDC=/usr/lib 642 for i in ${ldconfig_paths}; do 643 if [ -d "${i}" ]; then 644 _LDC="${_LDC} ${i}" 645 fi 646 done 647 echo 'ELF ldconfig path:' ${_LDC} 648 ${ldconfig} -elf ${_LDC} 649 ;; 650 esac 651 652 # Legacy aout support for i386 only 653 case `sysctl -n hw.machine_arch` in 654 i386) 655 # Default the a.out ldconfig path. 656 : ${ldconfig_paths_aout=${ldconfig_paths}} 657 _LDC=/usr/lib/aout 658 for i in ${ldconfig_paths_aout}; do 659 if [ -d "${i}" ]; then 660 _LDC="${_LDC} ${i}" 661 fi 662 done 663 echo 'a.out ldconfig path:' ${_LDC} 664 ${ldconfig} -aout ${_LDC} 665 ;; 666 esac 667fi 668 669# Now start up miscellaneous daemons that don't belong anywhere else 670# 671echo -n 'Starting standard daemons:' 672case ${inetd_enable} in 673[Nn][Oo]) 674 ;; 675*) 676 echo -n ' inetd'; ${inetd_program:-/usr/sbin/inetd} ${inetd_flags} 677 ;; 678esac 679 680case ${cron_enable} in 681[Nn][Oo]) 682 ;; 683*) 684 echo -n ' cron'; ${cron_program:-/usr/sbin/cron} ${cron_flags} 685 ;; 686esac 687 688case ${lpd_enable} in 689[Yy][Ee][Ss]) 690 echo -n ' printer'; ${lpd_program:-/usr/sbin/lpd} ${lpd_flags} 691 ;; 692esac 693 694case ${sshd_enable} in 695[Yy][Ee][Ss]) 696 if [ -x ${sshd_program:-/usr/sbin/sshd} ]; then 697 echo -n ' sshd'; 698 ${sshd_program:-/usr/sbin/sshd} ${sshd_flags} 699 fi 700 ;; 701esac 702 703case ${usbd_enable} in 704[Yy][Ee][Ss]) 705 echo -n ' usbd'; /usr/sbin/usbd ${usbd_flags} 706 ;; 707esac 708 709case ${mta_start_script} in 710/*) 711 if [ -r ${mta_start_script} ]; then 712 sh ${mta_start_script} 713 fi 714 ;; 715esac 716 717echo '.' 718 719# Recover vi editor files. 720find /var/tmp/vi.recover ! -type f -a ! -type d -delete 721vibackup=`echo /var/tmp/vi.recover/vi.*` 722if [ "${vibackup}" != '/var/tmp/vi.recover/vi.*' ]; then 723 echo -n 'Recovering vi editor sessions:' 724 for i in /var/tmp/vi.recover/vi.*; do 725 # Only test files that are readable. 726 if [ ! -r "${i}" ]; then 727 continue 728 fi 729 730 # Unmodified nvi editor backup files either have the 731 # execute bit set or are zero length. Delete them. 732 if [ -x "${i}" -o ! -s "${i}" ]; then 733 rm -f "${i}" 734 fi 735 done 736 737 # It is possible to get incomplete recovery files, if the editor 738 # crashes at the right time. 739 virecovery=`echo /var/tmp/vi.recover/recover.*` 740 if [ "${virecovery}" != "/var/tmp/vi.recover/recover.*" ]; then 741 for i in /var/tmp/vi.recover/recover.*; do 742 # Only test files that are readable. 743 if [ ! -r "${i}" ]; then 744 continue 745 fi 746 747 # Delete any recovery files that are zero length, 748 # corrupted, or that have no corresponding backup file. 749 # Else send mail to the user. 750 recfile=`awk '/^X-vi-recover-path:/{print $2}' < "${i}"` 751 if [ -n "${recfile}" -a -s "${recfile}" ]; then 752 sendmail -t < "${i}" 753 else 754 rm -f "${i}" 755 fi 756 done 757 fi 758 echo '.' 759fi 760 761# Make a bounds file for msgs(1) if there isn't one already 762# 763if [ -d /var/msgs -a ! -f /var/msgs/bounds -a ! -L /var/msgs/bounds ]; then 764 echo 0 > /var/msgs/bounds 765fi 766 767case ${update_motd} in 768[Nn][Oo] | '') 769 ;; 770*) 771 if T=`mktemp /tmp/_motd.XXXXXX`; then 772 uname -v | sed -e 's,^\([^#]*\) #\(.* [1-2][0-9][0-9][0-9]\).*/\([^\]*\) $,\1 (\3) #\2,' > ${T} 773 awk '{if (NR == 1) {if ($1 == "FreeBSD") {next} else {print "\n"$0}} else {print}}' < /etc/motd >> ${T} 774 cmp -s ${T} /etc/motd || { 775 cp ${T} /etc/motd 776 chmod 644 /etc/motd 777 } 778 rm -f ${T} 779 fi 780 ;; 781esac 782 783# Run rc.devfs if readable to customize devfs 784# 785if [ -r /etc/rc.devfs ]; then 786 sh /etc/rc.devfs 787fi 788 789# Configure implementation specific stuff 790# 791arch=`uname -p` 792if [ -r /etc/rc.${arch} ]; then 793 . /etc/rc.${arch} 794fi 795 796# Configure the system console 797# 798if [ -r /etc/rc.syscons ]; then 799 . /etc/rc.syscons 800fi 801 802echo -n 'Additional ABI support:' 803 804# Load the SysV IPC API if requested. 805case ${sysvipc_enable} in 806[Yy][Ee][Ss]) 807 echo -n ' sysvipc' 808 kldload sysvmsg >/dev/null 2>&1 809 kldload sysvsem >/dev/null 2>&1 810 kldload sysvshm >/dev/null 2>&1 811 ;; 812esac 813 814# Start the Linux binary compatibility if requested. 815# 816case ${linux_enable} in 817[Yy][Ee][Ss]) 818 echo -n ' linux' 819 if ! kldstat -v | grep -E 'linux(aout|elf)' > /dev/null; then 820 kldload linux > /dev/null 2>&1 821 fi 822 if [ -x /compat/linux/sbin/ldconfig ]; then 823 /compat/linux/sbin/ldconfig 824 fi 825 ;; 826esac 827 828# Start the SysVR4 binary emulation if requested. 829# 830case ${svr4_enable} in 831[Yy][Ee][Ss]) 832 echo -n ' svr4'; kldload svr4 > /dev/null 2>&1 833 ;; 834esac 835 836echo '.' 837 838# Do traditional (but rather obsolete) rc.local file if it exists. If you 839# use this file and want to make it programmatic, source /etc/defaults/rc.conf 840# in /etc/rc.local and add your custom variables to /etc/rc.conf, as 841# shown below. Please do not put local extensions into /etc/rc itself. 842# Use /etc/rc.local 843# 844# ---- rc.local ---- 845# if [ -r /etc/defaults/rc.conf ]; then 846# . /etc/defaults/rc.conf 847# source_rc_confs 848# elif [ -r /etc/rc.conf ]; then 849# . /etc/rc.conf 850# fi 851# 852# ... additional startup conditionals ... 853# ---- rc.local ---- 854# 855if [ -r /etc/rc.local ]; then 856 echo -n 'Starting local daemons:' 857 sh /etc/rc.local 858 echo '.' 859fi 860 861# For each valid dir in $local_startup, search for init scripts matching *.sh 862# 863case ${local_startup} in 864[Nn][Oo] | '') 865 ;; 866*) 867 echo -n 'Local package initialization:' 868 slist="" 869 if [ -z "${script_name_sep}" ]; then 870 script_name_sep=" " 871 fi 872 for dir in ${local_startup}; do 873 if [ -d "${dir}" ]; then 874 for script in ${dir}/*.sh; do 875 slist="${slist}${script_name_sep}${script}" 876 done 877 fi 878 done 879 script_save_sep="$IFS" 880 IFS="${script_name_sep}" 881 for script in ${slist}; do 882 if [ -x "${script}" ]; then 883 (set -T 884 trap 'exit 1' 2 885 ${script} start) 886 elif [ -f "${script}" -o -L "${script}" ]; then 887 echo -n " (skipping ${script##*/}, not executable)" 888 fi 889 done 890 IFS="${script_save_sep}" 891 echo '.' 892 ;; 893esac 894 895if [ -n "${network_pass3_done}" ]; then 896 network_pass4 897fi 898 899# Late pass to set variables we missed the first time 900# 901if [ -r /etc/rc.sysctl ]; then 902 sh /etc/rc.sysctl last 903fi 904 905# Raise kernel security level. This should be done only after `fsck' has 906# repaired local file systems if you want the securelevel to be greater than 1. 907# 908case ${kern_securelevel_enable} in 909[Yy][Ee][Ss]) 910 if [ "${kern_securelevel}" -ge 0 ]; then 911 echo 'Raising kernel security level: ' 912 sysctl kern.securelevel=${kern_securelevel} 913 fi 914 ;; 915esac 916 917# Start background fsck checks if necessary 918case ${background_fsck} in 919[Yy][Ee][Ss]) 920 echo 'Starting background filesystem checks' 921 nice -4 fsck -B -p 2>&1 | logger -p daemon.notice & 922 ;; 923esac 924 925echo '' 926 927date 928 929exit 0 930 931