rc revision 104334
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 104334 2002-10-02 00:59:14Z dd $ 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 # Local FreeBSD hack to reload the rc.conf on 92 # a return status of 2 93 if [ $? -eq 2 ]; then 94 unset _rc_conf_loaded 95 load_rc_config 'XXX' 96 echo "Reloading rc.conf" 97 fi 98 done 99 100 echo '' 101 date 102 exit 0 103 ;; 104*) 105 # fall-through to the old rc scripts 106 ;; 107esac 108 109bootmode=$1 110 111# BOOTP diskless boot. We have to run the rc file early in order to 112# retarget various config files. 113# 114if [ -r /etc/rc.diskless1 ]; then 115 dlv=`/sbin/sysctl -n vfs.nfs.diskless_valid 2> /dev/null` 116 if [ ${dlv:=0} != 0 ]; then 117 . /etc/rc.diskless1 118 fi 119fi 120 121# If there is a global system configuration file, suck it in. 122# 123if [ -r /etc/defaults/rc.conf ]; then 124 . /etc/defaults/rc.conf 125 source_rc_confs 126elif [ -r /etc/rc.conf ]; then 127 . /etc/rc.conf 128fi 129 130# XXX - Deprecated variable name support 131# for rpcbind and ntpd 132# 133[ -n "$portmap_enable" ] && rpcbind_enable="$portmap_enable" 134[ -n "$portmap_program" ] && rpcbind_program="$portmap_program" 135[ -n "$portmap_flags" ] && rpcbind_flags="$portmap_flags" 136[ -n "$single_mountd_enable" ] && mountd_enable="$single_mountd_enable" 137[ -n "$xntpd_enable" ] && ntpd_enable="$xntpd_enable" 138[ -n "$xntpd_program" ] && ntpd_program="$xntpd_program" 139[ -n "$xntpd_flags" ] && ntpd_flags="$xntpd_flags" 140 141feed_dev_random() { 142 if [ -f "${1}" -a -r "${1}" -a -s "${1}" ]; then 143# echo "Using ${1} as an entropy file" 144 cat "${1}" | dd of=/dev/random bs=8k 2>/dev/null 145 fi 146} 147 148chkdepend() { 149 svc=$1 150 svc_var=$2 151 dep=$3 152 dep_var=$4 153 154 eval svc_val=\${$svc_var} 155 eval dep_val=\${$dep_var} 156 157 case ${svc_val} in 158 [Yy][Ee][Ss]) 159 case ${dep_val} in 160 [Yy][Ee][Ss]) 161 ;; 162 *) 163 eval ${dep_var}="YES" 164 echo "DEPENDENCY NOTE: ${dep} will be enabled" \ 165 "to support ${svc}" 166 ;; 167 esac 168 ;; 169 esac 170} 171 172chkdepend amd amd_enable rpcbind rpcbind_enable 173chkdepend amd amd_enable NFS nfs_client_enable 174chkdepend NFS nfs_server_enable rpcbind rpcbind_enable 175chkdepend NIS nis_server_enable rpcbind rpcbind_enable 176chkdepend NIS nis_client_enable rpcbind rpcbind_enable 177 178# Enable dumpdev early so that a crash during the boot process can be caught. 179# 180case ${dumpdev} in 181[Nn][Oo] | '') 182 dumpdev='NO' 183 ;; 184*) 185 /sbin/dumpon -v ${dumpdev} 186 ;; 187esac 188 189# Enable harvesting of entropy via devices. The sooner this happens the 190# better so that we can take advantage of the boot process. 191# 192echo -n 'Entropy harvesting:' 193 194case ${harvest_interrupt} in 195[Nn][Oo]) 196 ;; 197*) 198 if [ -w /dev/random ]; then 199 /sbin/sysctl kern.random.sys.harvest.interrupt=1 >/dev/null 200 echo -n ' interrupts' 201 fi 202 ;; 203esac 204 205case ${harvest_ethernet} in 206[Nn][Oo]) 207 ;; 208*) 209 if [ -w /dev/random ]; then 210 /sbin/sysctl kern.random.sys.harvest.ethernet=1 >/dev/null 211 echo -n ' ethernet' 212 fi 213 ;; 214esac 215 216case ${harvest_p_to_p} in 217[Nn][Oo]) 218 ;; 219*) 220 if [ -w /dev/random ]; then 221 /sbin/sysctl kern.random.sys.harvest.point_to_point=1 >/dev/null 222 echo -n ' point_to_point' 223 fi 224 ;; 225esac 226 227echo '.' 228 229# First pass at reseeding /dev/random. 230# 231case ${entropy_file} in 232[Nn][Oo] | '') 233 ;; 234*) 235 if [ -w /dev/random ]; then 236 feed_dev_random "${entropy_file}" 237 fi 238 ;; 239esac 240 241# XXX temporary until we can get the entropy 242# harvesting rate up 243# Entropy below is not great, 244# but better than nothing. 245( ps -fauxww; sysctl -a; date; df -ib; dmesg; ps -fauxww; ) \ 246 | dd of=/dev/random bs=8k 2>/dev/null 247cat /bin/ls | dd of=/dev/random bs=8k 2>/dev/null 248 249# Configure ccd devices. 250# 251if [ -r /etc/ccd.conf ]; then 252 ccdconfig -C 253fi 254 255case ${start_vinum} in 256[Yy][Ee][Ss]) 257 vinum start 258 ;; 259esac 260 261swapon -a 262 263# Last chance to do things before potentially waiting for 264# operator to do fsck related tasks 265if [ -r /etc/rc.early ]; then 266 . /etc/rc.early 267fi 268 269case ${bootmode} in 270autoboot) 271 echo 'Automatic boot in progress...' 272 case ${background_fsck} in 273 [Yy][Ee][Ss]) 274 fsck -F -p 275 ;; 276 *) 277 fsck -p 278 ;; 279 esac 280 case $? in 281 0) 282 ;; 283 2) 284 exit 1 285 ;; 286 4) 287 reboot 288 echo 'Reboot failed... help!' 289 exit 1 290 ;; 291 8) 292 case ${fsck_y_enable} in 293 [Yy][Ee][Ss]) 294 echo 'File system preen failed, trying fsck -y . . .' 295 fsck -y 296 case $? in 297 0) 298 ;; 299 *) 300 echo 'Automatic filesystem check failed . . . help!' 301 exit 1 302 ;; 303 esac 304 ;; 305 *) 306 echo 'Automatic filesystem check failed . . . help!' 307 exit 1 308 ;; 309 esac 310 ;; 311 12) 312 echo 'Reboot interrupted' 313 exit 1 314 ;; 315 130) 316 # interrupt before catcher installed 317 exit 1 318 ;; 319 *) 320 echo 'Unknown error in reboot' 321 exit 1 322 ;; 323 esac 324 ;; 325*) 326 echo 'Skipping disk checks ...' 327 ;; 328esac 329 330set -T 331trap "echo 'Reboot interrupted'; exit 1" 3 332 333# root normally must be read/write, but if this is a BOOTP NFS 334# diskless boot it does not have to be. 335# 336case ${root_rw_mount} in 337[Nn][Oo] | '') 338 ;; 339*) 340 if ! mount -u -o rw / ; then 341 echo 'Mounting root filesystem rw failed, startup aborted' 342 exit 1 343 fi 344 ;; 345esac 346 347umount -a >/dev/null 2>&1 348 349# Set up the list of network filesystem types for which mounting should be 350# delayed until after network initialization. 351networkfs_types='nfs:NFS smbfs:SMB portalfs:PORTAL' 352case ${extra_netfs_types} in 353[Nn][Oo]) 354 ;; 355*) 356 networkfs_types="${networkfs_types} ${extra_netfs_types}" 357 ;; 358esac 359 360# Mount everything except nfs filesystems. 361mount_excludes='no' 362for i in ${networkfs_types}; do 363 fstype=${i%:*} 364 mount_excludes="${mount_excludes}${fstype}," 365done 366mount_excludes=${mount_excludes%,} 367mount -a -t ${mount_excludes} 368 369case $? in 3700) 371 ;; 372*) 373 echo 'Mounting /etc/fstab filesystems failed, startup aborted' 374 exit 1 375 ;; 376esac 377 378# Run custom disk mounting function here 379# 380if [ -n "${diskless_mount}" -a -r "${diskless_mount}" ]; then 381 sh ${diskless_mount} 382fi 383 384# If we booted a special kernel remove the record so we will boot 385# the default kernel next time 386rm -f /boot/nextboot.conf 387 388# Reseed /dev/random with previously stored entropy. 389case ${entropy_dir} in 390[Nn][Oo]) 391 ;; 392*) 393 entropy_dir=${entropy_dir:-/var/db/entropy} 394 if [ -d "${entropy_dir}" ]; then 395 if [ -w /dev/random ]; then 396 for seedfile in ${entropy_dir}/*; do 397 feed_dev_random "${seedfile}" 398 done 399 fi 400 fi 401 ;; 402esac 403 404case ${entropy_file} in 405[Nn][Oo] | '') 406 ;; 407*) 408 if [ -w /dev/random ]; then 409 feed_dev_random "${entropy_file}" 410 fi 411 ;; 412esac 413 414adjkerntz -i 415 416purgedir() { 417 local dir file 418 419 if [ $# -eq 0 ]; then 420 purgedir . 421 else 422 for dir 423 do 424 ( 425 cd "$dir" && for file in .* * 426 do 427 [ ."$file" = .. -o ."$file" = ... ] && continue 428 if [ -d "$file" -a ! -L "$file" ] 429 then 430 purgedir "$file" 431 else 432 rm -f -- "$file" 433 fi 434 done 435 ) 436 done 437 fi 438} 439 440clean_var() { 441 if [ -d /var/run -a ! -f /var/run/clean_var ]; then 442 purgedir /var/run 443 # Keep a copy of the boot messages around 444 dmesg >/var/run/dmesg.boot 445 # And an initial utmp file 446 (cd /var/run && cp /dev/null utmp && chmod 644 utmp;) 447 >/var/run/clean_var 448 fi 449 if [ -d /var/spool/lock -a ! -f /var/spool/lock/clean_var ]; then 450 purgedir /var/spool/lock 451 >/var/spool/lock/clean_var 452 fi 453 rm -rf /var/spool/uucp/.Temp/* 454} 455 456# network_pass1() *may* end up writing stuff to /var - we don't want to 457# remove it immediately afterwards - *nor* do we want to fail to clean 458# an NFS-mounted /var. 459rm -f /var/run/clean_var /var/spool/lock/clean_var 460clean_var 461 462# Add additional swapfile, if configured. 463# 464case ${swapfile} in 465[Nn][Oo] | '') 466 ;; 467*) 468 if [ -w "${swapfile}" -a -c /dev/mdctl ]; then 469 echo "Adding ${swapfile} as additional swap" 470 mdev=`mdconfig -a -t vnode -f ${swapfile}` && swapon /dev/${mdev} 471 fi 472 ;; 473esac 474 475# Early pass to set the variables we can 476# 477if [ -r /etc/rc.sysctl ]; then 478 sh /etc/rc.sysctl first 479fi 480 481# Configure serial devices 482# 483if [ -r /etc/rc.serial ]; then 484 . /etc/rc.serial 485fi 486 487# Start up PC-card configuration 488# 489if [ -r /etc/rc.pccard ]; then 490 . /etc/rc.pccard 491fi 492 493# Start up the initial network configuration. 494# 495if [ -r /etc/rc.network ]; then 496 . /etc/rc.network # We only need to do this once. 497 network_pass1 498fi 499 500case ${ipv6_enable} in 501[Yy][Ee][Ss]) 502 if [ -r /etc/rc.network6 ]; then 503 . /etc/rc.network6 # We only need to do this once also. 504 network6_pass1 505 fi 506 ;; 507esac 508 509# Mount NFS filesystems if present in /etc/fstab 510# 511# XXX When the vfsload() issues with nfsclient support and related sysctls 512# have been resolved, this block can be removed, and the condition that 513# skips nfs in the following block (for "other network filesystems") can 514# be removed. 515case "`mount -d -a -t nfs 2> /dev/null`" in 516*mount_nfs*) 517 # Handle absent nfs client support 518 nfsclient_in_kernel=0 519 if sysctl vfs.nfs >/dev/null 2>&1; then 520 nfsclient_in_kernel=1 521 else 522 kldload nfsclient && nfsclient_in_kernel=1 523 fi 524 525 case ${nfsclient_in_kernel} in 526 1) 527 echo -n 'Mounting NFS filesystem:' 528 mount -a -t nfs 529 echo '.' 530 ;; 531 *) 532 echo 'Warning: nfs mount requested, but no nfs client in kernel' 533 ;; 534 esac 535 ;; 536esac 537 538# Mount other network filesystems if present in /etc/fstab 539for i in ${networkfs_types}; do 540 fstype=${i%:*} 541 fsdecr=${i#*:} 542 543 if [ "${fstype}" = "nfs" ]; then 544 continue 545 fi 546 case "`mount -d -a -t ${fstype}`" in 547 *mount_${fstype}*) 548 echo -n "Mounting ${fsdecr} filesystems:" 549 mount -a -t ${fstype} 550 echo '.' 551 ;; 552 esac 553done 554 555# Whack the pty perms back into shape. 556# 557if ls /dev/tty[pqrsPQRS]* > /dev/null 2>&1; then 558 chflags 0 /dev/tty[pqrsPQRS]* 559 chmod 666 /dev/tty[pqrsPQRS]* 560 chown root:wheel /dev/tty[pqrsPQRS]* 561fi 562 563# Clean up left-over files 564# 565clean_var # If it hasn't already been done 566rm /var/run/clean_var /var/spool/lock/clean_var 567 568# Clearing /tmp at boot-time seems to have a long tradition. It doesn't 569# help in any way for long-living systems, and it might accidentally 570# clobber files you would rather like to have preserved after a crash 571# (if not using mfs /tmp anyway). 572# 573# See also the example of another cleanup policy in /etc/periodic/daily. 574# 575case ${clear_tmp_enable} in 576[Yy][Ee][Ss]) 577 echo -n 'Clearing /tmp:' 578 # prune quickly with one rm, then use find to clean up /tmp/[lq]* 579 # (not needed with mfs /tmp, but doesn't hurt there...) 580 (cd /tmp && rm -rf [a-km-pr-zA-Z]* && 581 find -d . ! -name . ! -name lost+found ! -name quota.user \ 582 ! -name quota.group -exec rm -rf -- {} \;) 583 echo '.' 584 ;; 585esac 586 587# Remove X lock files, since they will prevent you from restarting X11 588# after a system crash. 589# 590rm -f /tmp/.X*-lock 591rm -fr /tmp/.X11-unix 592mkdir -m 1777 /tmp/.X11-unix 593 594# Snapshot any kernel -c changes back to disk here <someday>. 595# This has changed with ELF and /kernel.config. 596 597# Load LOMAC(4) security if wanted. 598case ${lomac_enable} in 599[Yy][Ee][Ss]) 600 kldload lomac >/dev/null 2>&1 601 ;; 602esac 603 604echo -n 'Additional daemons:' 605 606# Start system logging and name service. Named needs to start before syslogd 607# if you don't have a /etc/resolv.conf. 608# 609case ${syslogd_enable} in 610[Yy][Ee][Ss]) 611 # Transitional symlink (for the next couple of years :) until all 612 # binaries have had a chance to move towards /var/run/log. 613 if [ ! -L /dev/log ]; then 614 # might complain for r/o root f/s 615 ln -sf /var/run/log /dev/log 616 fi 617 618 rm -f /var/run/log 619 echo -n ' syslogd'; 620 ${syslogd_program:-/usr/sbin/syslogd} ${syslogd_flags} 621 ;; 622esac 623 624echo '.' 625 626# Build device name databases if we are not using DEVFS 627# 628if sysctl vfs.devfs.generation > /dev/null 2>&1 ; then 629 rm -f /var/run/dev.db 630else 631 dev_mkdb 632fi 633 634# $dumpdir should be a directory or a symbolic link 635# to the crash directory if core dumps are to be saved. 636# 637if [ "${dumpdev}" != 'NO' ]; then 638 case ${dumpdir} in 639 '') 640 dumpdir='/var/crash' 641 ;; 642 [Nn][Oo]) 643 dumpdir='NO' 644 ;; 645 esac 646 647 if [ "${dumpdir}" != 'NO' ]; then 648 echo -n 'Checking for core dump: ' 649 /sbin/savecore ${savecore_flags} "${dumpdir}" 650 fi 651fi 652 653if [ -n "${network_pass1_done}" ]; then 654 network_pass2 655fi 656 657# Enable/Check the quotas (must be after ypbind if using NIS) 658# 659case ${enable_quotas} in 660[Yy][Ee][Ss]) 661 case ${check_quotas} in 662 [Yy][Ee][Ss]) 663 echo -n 'Checking quotas:' 664 quotacheck -a 665 echo ' done.' 666 ;; 667 esac 668 669 echo -n 'Enabling quotas:' 670 quotaon -a 671 echo ' done.' 672 ;; 673esac 674 675if [ -n "${network_pass2_done}" ]; then 676 network_pass3 677fi 678 679# Check the password temp/lock file 680# 681if [ -e /etc/ptmp ]; then 682 logger -s -p auth.err \ 683 "password file may be incorrect -- /etc/ptmp exists" 684fi 685 686case ${accounting_enable} in 687[Yy][Ee][Ss]) 688 if [ -d /var/account ]; then 689 echo 'Turning on accounting:' 690 if [ ! -e /var/account/acct ]; then 691 touch /var/account/acct 692 fi 693 accton /var/account/acct 694 fi 695 ;; 696esac 697 698# Make shared lib searching a little faster. Leave /usr/lib first if you 699# add your own entries or you may come to grief. 700# 701ldconfig="/sbin/ldconfig" 702case ${ldconfig_insecure} in 703[Yy][Ee][Ss]) 704 ldconfig="${ldconfig} -i" 705 ;; 706esac 707if [ -x /sbin/ldconfig ]; then 708 _LDC=/usr/lib 709 for i in ${ldconfig_paths}; do 710 if [ -d "${i}" ]; then 711 _LDC="${_LDC} ${i}" 712 fi 713 done 714 echo 'ELF ldconfig path:' ${_LDC} 715 ${ldconfig} ${_LDC} 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