rc revision 83897
1219820Sjeff#!/bin/sh 2219820Sjeff# 3219820Sjeff# Copyright (c) 2000 The FreeBSD Project 4219820Sjeff# All rights reserved. 5219820Sjeff# 6219820Sjeff# Redistribution and use in source and binary forms, with or without 7219820Sjeff# modification, are permitted provided that the following conditions 8219820Sjeff# are met: 9219820Sjeff# 1. Redistributions of source code must retain the above copyright 10219820Sjeff# notice, this list of conditions and the following disclaimer. 11219820Sjeff# 2. Redistributions in binary form must reproduce the above copyright 12219820Sjeff# notice, this list of conditions and the following disclaimer in the 13219820Sjeff# documentation and/or other materials provided with the distribution. 14219820Sjeff# 15219820Sjeff# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 16219820Sjeff# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17219820Sjeff# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18219820Sjeff# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 19219820Sjeff# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20219820Sjeff# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 21219820Sjeff# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22219820Sjeff# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23219820Sjeff# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24219820Sjeff# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25219820Sjeff# SUCH DAMAGE. 26219820Sjeff# 27219820Sjeff# @(#)rc 5.27 (Berkeley) 6/5/91 28219820Sjeff# $FreeBSD: head/etc/rc 83897 2001-09-24 18:17:11Z obrien $ 29219820Sjeff# 30219820Sjeff 31219820Sjeff# System startup script run by init on autoboot 32219820Sjeff# or after single-user. 33219820Sjeff# Output and error are redirected to console by init, 34219820Sjeff# and the console is the controlling terminal. 35219820Sjeff 36219820Sjeff# Note that almost all of the user-configurable behavior is no longer in 37219820Sjeff# this file, but rather in /etc/defaults/rc.conf. Please check that file 38219820Sjeff# first before contemplating any changes here. If you do need to change 39219820Sjeff# this file for some reason, we would like to know about it. 40219820Sjeff 41219820Sjeffstty status '^T' 42219820Sjeff 43219820Sjeff# Set shell to ignore SIGINT (2), but not children; 44219820Sjeff# shell catches SIGQUIT (3) and returns to single user after fsck. 45219820Sjeff# 46219820Sjefftrap : 2 47219820Sjefftrap : 3 # shouldn't be needed 48219820Sjeff 49219820Sjeffbootmode=$1 50219820Sjeff 51219820SjeffHOME=/ 52219820SjeffPATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin 53219820Sjeffexport HOME PATH 54219820Sjeff 55219820Sjeff# BOOTP diskless boot. We have to run the rc file early in order to 56219820Sjeff# retarget various config files. 57219820Sjeff# 58219820Sjeffif [ -r /etc/rc.diskless1 ]; then 59219820Sjeff dlv=`/sbin/sysctl -n vfs.nfs.diskless_valid 2> /dev/null` 60219820Sjeff if [ ${dlv:=0} != 0 ]; then 61219820Sjeff . /etc/rc.diskless1 62219820Sjeff fi 63219820Sjefffi 64219820Sjeff 65219820Sjeff# If there is a global system configuration file, suck it in. 66219820Sjeff# 67219820Sjeffif [ -r /etc/defaults/rc.conf ]; then 68219820Sjeff . /etc/defaults/rc.conf 69219820Sjeff source_rc_confs 70219820Sjeffelif [ -r /etc/rc.conf ]; then 71219820Sjeff . /etc/rc.conf 72219820Sjefffi 73219820Sjeff 74219820Sjefffeed_dev_random() { 75219820Sjeff if [ -f "${1}" -a -r "${1}" -a -s "${1}" ]; then 76219820Sjeff# echo "Using ${1} as an entropy file" 77219820Sjeff cat "${1}" | dd of=/dev/random bs=8k 2>/dev/null 78219820Sjeff fi 79219820Sjeff} 80219820Sjeff 81219820Sjeffchkdepend() { 82219820Sjeff svc=$1 83219820Sjeff svc_var=$2 84219820Sjeff dep=$3 85219820Sjeff dep_var=$4 86219820Sjeff 87219820Sjeff eval svc_val=\${$svc_var} 88219820Sjeff eval dep_val=\${$dep_var} 89219820Sjeff 90219820Sjeff case ${svc_val} in 91219820Sjeff [Yy][Ee][Ss]) 92219820Sjeff case ${dep_val} in 93219820Sjeff [Yy][Ee][Ss]) 94219820Sjeff ;; 95219820Sjeff *) 96219820Sjeff eval ${dep_var}="YES" 97219820Sjeff echo "DEPENDENCY NOTE: ${dep} will be enabled" \ 98219820Sjeff "to support ${svc}" 99219820Sjeff ;; 100219820Sjeff esac 101219820Sjeff ;; 102219820Sjeff esac 103219820Sjeff} 104219820Sjeff 105219820Sjeffchkdepend amd amd_enable portmap portmap_enable 106219820Sjeffchkdepend NFS nfs_server_enable portmap portmap_enable 107219820Sjeffchkdepend NIS nis_server_enable portmap portmap_enable 108219820Sjeffchkdepend NIS nis_client_enable portmap portmap_enable 109219820Sjeff 110219820Sjeff# Enable harvesting of entropy via devices. The sooner this happens the 111219820Sjeff# better so that we can take advantage of the boot process. 112219820Sjeff# 113219820Sjeffecho -n 'Entropy harvesting:' 114219820Sjeff 115219820Sjeffcase ${harvest_interrupt} in 116219820Sjeff[Nn][Oo]) 117219820Sjeff ;; 118219820Sjeff*) 119219820Sjeff if [ -w /dev/random ]; then 120219820Sjeff /sbin/sysctl -w kern.random.sys.harvest.interrupt=1 >/dev/null 121219820Sjeff echo -n ' interrupts' 122219820Sjeff fi 123219820Sjeff ;; 124219820Sjeffesac 125219820Sjeff 126219820Sjeffcase ${harvest_ethernet} in 127219820Sjeff[Nn][Oo]) 128219820Sjeff ;; 129219820Sjeff*) 130219820Sjeff if [ -w /dev/random ]; then 131219820Sjeff /sbin/sysctl -w kern.random.sys.harvest.ethernet=1 >/dev/null 132219820Sjeff echo -n ' ethernet' 133219820Sjeff fi 134219820Sjeff ;; 135219820Sjeffesac 136219820Sjeff 137219820Sjeffcase ${harvest_p_to_p} in 138219820Sjeff[Nn][Oo]) 139219820Sjeff ;; 140219820Sjeff*) 141219820Sjeff if [ -w /dev/random ]; then 142219820Sjeff /sbin/sysctl -w kern.random.sys.harvest.point_to_point=1 >/dev/null 143219820Sjeff echo -n ' point_to_point' 144219820Sjeff fi 145219820Sjeff ;; 146219820Sjeffesac 147219820Sjeff 148219820Sjeffecho '.' 149219820Sjeff 150219820Sjeff# First pass at reseeding /dev/random. 151219820Sjeff# 152219820Sjeffcase ${entropy_file} in 153219820Sjeff[Nn][Oo] | '') 154219820Sjeff ;; 155219820Sjeff*) 156219820Sjeff if [ -w /dev/random ]; then 157219820Sjeff feed_dev_random "${entropy_file}" 158219820Sjeff fi 159219820Sjeff ;; 160219820Sjeffesac 161219820Sjeff 162219820Sjeff# XXX temporary until we can get the entropy 163219820Sjeff# harvesting rate up 164219820Sjeff# Entropy below is not great, 165219820Sjeff# but better than nothing. 166219820Sjeff( ps -efauxww; sysctl -a; date; df -ib; dmesg; ps -efauxww; ) \ 167219820Sjeff | dd of=/dev/random bs=8k 2>/dev/null 168219820Sjeffcat /bin/ls | dd of=/dev/random bs=8k 2>/dev/null 169219820Sjeff 170219820Sjeff# Configure ccd devices. 171219820Sjeff# 172219820Sjeffif [ -r /etc/ccd.conf ]; then 173219820Sjeff ccdconfig -C 174219820Sjefffi 175219820Sjeff 176219820Sjeffcase ${start_vinum} in 177219820Sjeff[Yy][Ee][Ss]) 178219820Sjeff vinum start 179219820Sjeff ;; 180219820Sjeffesac 181219820Sjeff 182219820Sjeffswapon -a 183219820Sjeff 184219820Sjeffcase ${bootmode} in 185219820Sjeffautoboot) 186219820Sjeff echo 'Automatic boot in progress...' 187219820Sjeff case ${background_fsck} in 188219820Sjeff [Yy][Ee][Ss]) 189219820Sjeff fsck -F -p 190219820Sjeff ;; 191219820Sjeff *) 192219820Sjeff fsck -p 193219820Sjeff ;; 194219820Sjeff esac 195219820Sjeff case $? in 196219820Sjeff 0) 197219820Sjeff ;; 198219820Sjeff 2) 199219820Sjeff exit 1 200219820Sjeff ;; 201219820Sjeff 4) 202219820Sjeff reboot 203219820Sjeff echo 'Reboot failed... help!' 204219820Sjeff exit 1 205219820Sjeff ;; 206219820Sjeff 8) 207219820Sjeff case ${fsck_y_enable} in 208219820Sjeff [Yy][Ee][Ss]) 209219820Sjeff echo 'File system preen failed, trying fsck -y . . .' 210219820Sjeff fsck -y 211219820Sjeff case $? in 212219820Sjeff 0) 213219820Sjeff ;; 214219820Sjeff *) 215219820Sjeff echo 'Automatic file system check failed . . . help!' 216219820Sjeff exit 1 217219820Sjeff ;; 218219820Sjeff esac 219219820Sjeff ;; 220219820Sjeff *) 221219820Sjeff echo 'Automatic file system check failed . . . help!' 222219820Sjeff exit 1 223219820Sjeff ;; 224219820Sjeff esac 225219820Sjeff ;; 226219820Sjeff 12) 227219820Sjeff echo 'Reboot interrupted' 228219820Sjeff exit 1 229219820Sjeff ;; 230219820Sjeff 130) 231219820Sjeff # interrupt before catcher installed 232219820Sjeff exit 1 233219820Sjeff ;; 234219820Sjeff *) 235219820Sjeff echo 'Unknown error in reboot' 236219820Sjeff exit 1 237219820Sjeff ;; 238219820Sjeff esac 239219820Sjeff ;; 240219820Sjeff*) 241219820Sjeff echo 'Skipping disk checks ...' 242219820Sjeff ;; 243219820Sjeffesac 244219820Sjeff 245219820Sjeffset -T 246219820Sjefftrap "echo 'Reboot interrupted'; exit 1" 3 247219820Sjeff 248219820Sjeff# root normally must be read/write, but if this is a BOOTP NFS 249219820Sjeff# diskless boot it does not have to be. 250219820Sjeff# 251219820Sjeffcase ${root_rw_mount} in 252219820Sjeff[Nn][Oo] | '') 253219820Sjeff ;; 254219820Sjeff*) 255219820Sjeff if ! mount -u -o rw / ; then 256219820Sjeff echo 'Mounting root filesystem rw failed, startup aborted' 257219820Sjeff exit 1 258219820Sjeff fi 259219820Sjeff ;; 260219820Sjeffesac 261219820Sjeff 262219820Sjeffumount -a >/dev/null 2>&1 263219820Sjeff 264219820Sjeff# Mount everything except nfs filesystems. 265219820Sjeffmount -a -t nonfs 266219820Sjeff 267219820Sjeffcase $? in 268219820Sjeff0) 269219820Sjeff ;; 270*) 271 echo 'Mounting /etc/fstab filesystems failed, startup aborted' 272 exit 1 273 ;; 274esac 275 276# Run custom disk mounting function here 277# 278if [ -n "${diskless_mount}" -a -r "${diskless_mount}" ]; then 279 sh ${diskless_mount} 280fi 281 282# Reseed /dev/random with previously stored entropy. 283case ${entropy_dir} in 284[Nn][Oo]) 285 ;; 286*) 287 entropy_dir=${entropy_dir:-/var/db/entropy} 288 if [ -d "${entropy_dir}" ]; then 289 if [ -w /dev/random ]; then 290 for seedfile in ${entropy_dir}/*; do 291 feed_dev_random "${seedfile}" 292 done 293 fi 294 fi 295 ;; 296esac 297 298case ${entropy_file} in 299[Nn][Oo] | '') 300 ;; 301*) 302 if [ -w /dev/random ]; then 303 feed_dev_random "${entropy_file}" 304 fi 305 ;; 306esac 307 308adjkerntz -i 309 310purgedir() { 311 local dir file 312 313 if [ $# -eq 0 ]; then 314 purgedir . 315 else 316 for dir 317 do 318 ( 319 cd "$dir" && for file in .* * 320 do 321 [ ."$file" = .. -o ."$file" = ... ] && continue 322 if [ -d "$file" -a ! -L "$file" ] 323 then 324 purgedir "$file" 325 else 326 rm -f -- "$file" 327 fi 328 done 329 ) 330 done 331 fi 332} 333 334clean_var() { 335 if [ ! -f /var/run/clean_var ]; then 336 purgedir /var/run /var/spool/lock 337 rm -rf /var/spool/uucp/.Temp/* 338 # Keep a copy of the boot messages around 339 dmesg >/var/run/dmesg.boot 340 # And an initial utmp file 341 (cd /var/run && cp /dev/null utmp && chmod 644 utmp;) 342 >/var/run/clean_var 343 fi 344} 345 346if [ -d /var/run -a -d /var/spool/lock -a -d /var/spool/uucp/.Temp ]; then 347 # network_pass1() *may* end up writing stuff to /var - we don't want to 348 # remove it immediately afterwards - *nor* to we want to fail to clean 349 # an nfs-mounted /var. 350 clean_var 351fi 352 353# Add additional swapfile, if configured. 354# 355case ${swapfile} in 356[Nn][Oo] | '') 357 ;; 358*) 359 if [ -w "${swapfile}" -a -c /dev/mdctl ]; then 360 echo "Adding ${swapfile} as additional swap" 361 mdev=`mdconfig -a -t vnode -f ${swapfile}` && swapon /dev/${mdev} 362 fi 363 ;; 364esac 365 366# Set sysctl variables as early as we can 367# 368if [ -r /etc/rc.sysctl ]; then 369 . /etc/rc.sysctl 370fi 371 372# Configure serial devices 373# 374if [ -r /etc/rc.serial ]; then 375 . /etc/rc.serial 376fi 377 378# Start up PC-card configuration 379# 380if [ -r /etc/rc.pccard ]; then 381 . /etc/rc.pccard 382fi 383 384# Start up the initial network configuration. 385# 386if [ -r /etc/rc.network ]; then 387 . /etc/rc.network # We only need to do this once. 388 network_pass1 389fi 390 391case ${ipv6_enable} in 392[Yy][Ee][Ss]) 393 if [ -r /etc/rc.network6 ]; then 394 . /etc/rc.network6 # We only need to do this once also. 395 network6_pass1 396 fi 397 ;; 398esac 399 400# Mount NFS filesystems if present in /etc/fstab 401case "`mount -d -a -t nfs 2> /dev/null`" in 402*mount_nfs*) 403 echo -n 'Mounting NFS file systems:' 404 mount -a -t nfs 405 echo '.' 406 ;; 407esac 408 409# Whack the pty perms back into shape. 410# 411if ls /dev/tty[pqrsPQRS]* > /dev/null 2>&1; then 412 chflags 0 /dev/tty[pqrsPQRS]* 413 chmod 666 /dev/tty[pqrsPQRS]* 414 chown root:wheel /dev/tty[pqrsPQRS]* 415fi 416 417# Clean up left-over files 418# 419clean_var # If it hasn't already been done 420rm /var/run/clean_var 421 422# Clearing /tmp at boot-time seems to have a long tradition. It doesn't 423# help in any way for long-living systems, and it might accidentally 424# clobber files you would rather like to have preserved after a crash 425# (if not using mfs /tmp anyway). 426# 427# See also the example of another cleanup policy in /etc/periodic/daily. 428# 429case ${clear_tmp_enable} in 430[Yy][Ee][Ss]) 431 echo -n 'Clearing /tmp:' 432 # prune quickly with one rm, then use find to clean up /tmp/[lq]* 433 # (not needed with mfs /tmp, but doesn't hurt there...) 434 (cd /tmp && rm -rf [a-km-pr-zA-Z]* && 435 find -d . ! -name . ! -name lost+found ! -name quota.user \ 436 ! -name quota.group -exec rm -rf -- {} \;) 437 echo '.' 438 ;; 439esac 440 441# Remove X lock files, since they will prevent you from restarting X11 442# after a system crash. 443# 444rm -f /tmp/.X*-lock /tmp/.X11-unix/* 445 446# Snapshot any kernel -c changes back to disk here <someday>. 447# This has changed with ELF and /kernel.config. 448 449echo -n 'Additional daemons:' 450 451# Start system logging and name service. Named needs to start before syslogd 452# if you don't have a /etc/resolv.conf. 453# 454case ${syslogd_enable} in 455[Yy][Ee][Ss]) 456 # Transitional symlink (for the next couple of years :) until all 457 # binaries have had a chance to move towards /var/run/log. 458 if [ ! -L /dev/log ]; then 459 # might complain for r/o root f/s 460 ln -sf /var/run/log /dev/log 461 fi 462 463 rm -f /var/run/log 464 echo -n ' syslogd'; 465 ${syslogd_program:-/usr/sbin/syslogd} ${syslogd_flags} 466 ;; 467esac 468 469echo '.' 470 471# Build device name databases if we are not using DEVFS 472# 473if sysctl vfs.devfs.generation > /dev/null 2>&1 ; then 474 rm -f /var/run/dev.db 475else 476 dev_mkdb 477fi 478 479# Enable dumpdev so that savecore can see it. 480# /var/crash should be a directory or a symbolic link 481# to the crash directory if core dumps are to be saved. 482# 483case ${dumpdev} in 484[Nn][Oo] | '') 485 ;; 486*) 487 if [ -e "${dumpdev}" -a -d /var/crash ]; then 488 /sbin/dumpon -v ${dumpdev} 489 echo -n 'Checking for core dump: ' 490 /sbin/savecore ${savecore_flags} /var/crash 491 fi 492 ;; 493esac 494 495if [ -n "${network_pass1_done}" ]; then 496 network_pass2 497fi 498 499# Enable/Check the quotas (must be after ypbind if using NIS) 500# 501case ${enable_quotas} in 502[Yy][Ee][Ss]) 503 case ${check_quotas} in 504 [Yy][Ee][Ss]) 505 echo -n 'Checking quotas:' 506 quotacheck -a 507 echo ' done.' 508 ;; 509 esac 510 511 echo -n 'Enabling quotas:' 512 quotaon -a 513 echo ' done.' 514 ;; 515esac 516 517if [ -n "${network_pass2_done}" ]; then 518 network_pass3 519fi 520 521# Check the password temp/lock file 522# 523if [ -e /etc/ptmp ]; then 524 logger -s -p auth.err \ 525 "password file may be incorrect -- /etc/ptmp exists" 526fi 527 528case ${accounting_enable} in 529[Yy][Ee][Ss]) 530 if [ -d /var/account ]; then 531 echo 'Turning on accounting:' 532 if [ ! -e /var/account/acct ]; then 533 touch /var/account/acct 534 fi 535 accton /var/account/acct 536 fi 537 ;; 538esac 539 540# Make shared lib searching a little faster. Leave /usr/lib first if you 541# add your own entries or you may come to grief. 542# 543ldconfig="/sbin/ldconfig" 544case ${ldconfig_insecure} in 545[Yy][Ee][Ss]) 546 ldconfig="${ldconfig} -i" 547 ;; 548esac 549if [ -x /sbin/ldconfig ]; then 550 case `/usr/bin/objformat` in 551 elf) 552 _LDC=/usr/lib 553 for i in ${ldconfig_paths}; do 554 if [ -d "${i}" ]; then 555 _LDC="${_LDC} ${i}" 556 fi 557 done 558 echo 'ELF ldconfig path:' ${_LDC} 559 ${ldconfig} -elf ${_LDC} 560 ;; 561 esac 562 563 # Legacy aout support for i386 only 564 case `sysctl -n hw.machine` in 565 i386) 566 # Default the a.out ldconfig path. 567 : ${ldconfig_paths_aout=${ldconfig_paths}} 568 _LDC=/usr/lib/aout 569 for i in ${ldconfig_paths_aout}; do 570 if [ -d "${i}" ]; then 571 _LDC="${_LDC} ${i}" 572 fi 573 done 574 echo 'a.out ldconfig path:' ${_LDC} 575 ${ldconfig} -aout ${_LDC} 576 ;; 577 esac 578fi 579 580# Now start up miscellaneous daemons that don't belong anywhere else 581# 582echo -n 'Starting standard daemons:' 583case ${inetd_enable} in 584[Nn][Oo]) 585 ;; 586*) 587 echo -n ' inetd'; ${inetd_program:-/usr/sbin/inetd} ${inetd_flags} 588 ;; 589esac 590 591case ${cron_enable} in 592[Nn][Oo]) 593 ;; 594*) 595 echo -n ' cron'; ${cron_program:-/usr/sbin/cron} ${cron_flags} 596 ;; 597esac 598 599case ${lpd_enable} in 600[Yy][Ee][Ss]) 601 echo -n ' printer'; ${lpd_program:-/usr/sbin/lpd} ${lpd_flags} 602 ;; 603esac 604 605case ${sshd_enable} in 606[Yy][Ee][Ss]) 607 if [ -x ${sshd_program:-/usr/sbin/sshd} ]; then 608 echo -n ' sshd'; 609 ${sshd_program:-/usr/sbin/sshd} ${sshd_flags} 610 fi 611 ;; 612esac 613 614case ${usbd_enable} in 615[Yy][Ee][Ss]) 616 echo -n ' usbd'; /usr/sbin/usbd ${usbd_flags} 617 ;; 618esac 619 620if [ -r /etc/mail/sendmail.cf ]; then 621 case ${sendmail_enable} in 622 [Yy][Ee][Ss]) 623 echo -n ' sendmail' 624 /usr/sbin/sendmail ${sendmail_flags} 625 ;; 626 *) 627 case ${sendmail_outbound_enable} in 628 [Yy][Ee][Ss]) 629 echo -n ' sendmail' 630 /usr/sbin/sendmail ${sendmail_outbound_flags} 631 ;; 632 esac 633 ;; 634 esac 635fi 636 637echo '.' 638 639# Recover vi editor files. 640find /var/tmp/vi.recover ! -type f -a ! -type d -delete 641vibackup=`echo /var/tmp/vi.recover/vi.*` 642if [ "${vibackup}" != '/var/tmp/vi.recover/vi.*' ]; then 643 echo -n 'Recovering vi editor sessions:' 644 for i in /var/tmp/vi.recover/vi.*; do 645 # Only test files that are readable. 646 if [ ! -r "${i}" ]; then 647 continue 648 fi 649 650 # Unmodified nvi editor backup files either have the 651 # execute bit set or are zero length. Delete them. 652 if [ -x "${i}" -o ! -s "${i}" ]; then 653 rm -f "${i}" 654 fi 655 done 656 657 # It is possible to get incomplete recovery files, if the editor 658 # crashes at the right time. 659 virecovery=`echo /var/tmp/vi.recover/recover.*` 660 if [ "${virecovery}" != "/var/tmp/vi.recover/recover.*" ]; then 661 for i in /var/tmp/vi.recover/recover.*; do 662 # Only test files that are readable. 663 if [ ! -r "${i}" ]; then 664 continue 665 fi 666 667 # Delete any recovery files that are zero length, 668 # corrupted, or that have no corresponding backup file. 669 # Else send mail to the user. 670 recfile=`awk '/^X-vi-recover-path:/{print $2}' < "${i}"` 671 if [ -n "${recfile}" -a -s "${recfile}" ]; then 672 sendmail -t < "${i}" 673 else 674 rm -f "${i}" 675 fi 676 done 677 fi 678 echo '.' 679fi 680 681# Make a bounds file for msgs(1) if there isn't one already 682# 683if [ -d /var/msgs -a ! -f /var/msgs/bounds -a ! -L /var/msgs/bounds ]; then 684 echo 0 > /var/msgs/bounds 685fi 686 687case ${update_motd} in 688[Nn][Oo] | '') 689 ;; 690*) 691 if T=`mktemp /tmp/_motd.XXXXXX`; then 692 uname -v | sed -e 's,^\([^#]*\) #\(.* [1-2][0-9][0-9][0-9]\).*/\([^\]*\) $,\1 (\3) #\2,' > ${T} 693 awk '{if (NR == 1) {if ($1 == "FreeBSD") {next} else {print "\n"$0}} else {print}}' < /etc/motd >> ${T} 694 cmp -s ${T} /etc/motd || { 695 cp ${T} /etc/motd 696 chmod 644 /etc/motd 697 } 698 rm -f ${T} 699 fi 700 ;; 701esac 702 703# Configure implementation specific stuff 704# 705arch=`uname -m` 706if [ -r /etc/rc.${arch} ]; then 707 . /etc/rc.${arch} 708fi 709 710# Configure the system console 711# 712if [ -r /etc/rc.syscons ]; then 713 . /etc/rc.syscons 714fi 715 716# Run rc.devfs if readable to customize devfs 717# 718if [ -r /etc/rc.devfs ]; then 719 sh /etc/rc.devfs 720fi 721 722echo -n 'Additional ABI support:' 723 724# Load the SysV IPC API if requested. 725case ${sysvipc_enable} in 726[Yy][Ee][Ss]) 727 echo -n ' sysvipc' 728 kldload sysvmsg >/dev/null 2>&1 729 kldload sysvsem >/dev/null 2>&1 730 kldload sysvshm >/dev/null 2>&1 731 ;; 732esac 733 734# Start the Linux binary compatibility if requested. 735# 736case ${linux_enable} in 737[Yy][Ee][Ss]) 738 echo -n ' linux' 739 if ! kldstat -v | grep -E 'linux(aout|elf)' > /dev/null; then 740 kldload linux > /dev/null 2>&1 741 fi 742 if [ -x /compat/linux/sbin/ldconfig ]; then 743 /compat/linux/sbin/ldconfig 744 fi 745 ;; 746esac 747 748# Start the SysVR4 binary emulation if requested. 749# 750case ${svr4_enable} in 751[Yy][Ee][Ss]) 752 echo -n ' svr4'; kldload svr4 > /dev/null 2>&1 753 ;; 754esac 755 756echo '.' 757 758# Do traditional (but rather obsolete) rc.local file if it exists. If you 759# use this file and want to make it programmatic, source /etc/defaults/rc.conf 760# in /etc/rc.local and add your custom variables to /etc/rc.conf, as 761# shown below. Please do not put local extensions into /etc/rc itself. 762# Use /etc/rc.local 763# 764# ---- rc.local ---- 765# if [ -r /etc/defaults/rc.conf ]; then 766# . /etc/defaults/rc.conf 767# source_rc_confs 768# elif [ -r /etc/rc.conf ]; then 769# . /etc/rc.conf 770# fi 771# 772# ... additional startup conditionals ... 773# ---- rc.local ---- 774# 775if [ -r /etc/rc.local ]; then 776 echo -n 'Starting local daemons:' 777 sh /etc/rc.local 778 echo '.' 779fi 780 781# For each valid dir in $local_startup, search for init scripts matching *.sh 782# 783case ${local_startup} in 784[Nn][Oo] | '') 785 ;; 786*) 787 echo -n 'Local package initialization:' 788 slist="" 789 for dir in ${local_startup}; do 790 if [ -d "${dir}" ]; then 791 for script in ${dir}/*.sh; do 792 slist="${slist}${script_name_sep}${script}" 793 done 794 fi 795 done 796 script_save_sep="$IFS" 797 IFS="${script_name_sep}" 798 for script in ${slist}; do 799 if [ -x "${script}" ]; then 800 (set -T 801 trap 'exit 1' 2 802 ${script} start) 803 fi 804 done 805 IFS="${script_save_sep}" 806 echo '.' 807 ;; 808esac 809 810if [ -n "${network_pass3_done}" ]; then 811 network_pass4 812fi 813 814# Raise kernel security level. This should be done only after `fsck' has 815# repaired local file systems if you want the securelevel to be greater than 1. 816# 817case ${kern_securelevel_enable} in 818[Yy][Ee][Ss]) 819 if [ "${kern_securelevel}" -ge 0 ]; then 820 echo 'Raising kernel security level: ' 821 sysctl -w kern.securelevel=${kern_securelevel} 822 fi 823 ;; 824esac 825 826# Start background fsck checks if necessary 827case ${background_fsck} in 828[Yy][Ee][Ss]) 829 echo 'Starting background filesystem checks' 830 nice -4 fsck -B -p 2>&1 | logger -p daemon.notice & 831 ;; 832esac 833 834echo '' 835 836date 837 838exit 0 839 840