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