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