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