rc revision 77662
1193323Sed#!/bin/sh 2193323Sed# 3193323Sed# Copyright (c) 2000 The FreeBSD Project 4193323Sed# All rights reserved. 5193323Sed# 6193323Sed# Redistribution and use in source and binary forms, with or without 7193323Sed# modification, are permitted provided that the following conditions 8193323Sed# are met: 9193323Sed# 1. Redistributions of source code must retain the above copyright 10193323Sed# notice, this list of conditions and the following disclaimer. 11193323Sed# 2. Redistributions in binary form must reproduce the above copyright 12193323Sed# notice, this list of conditions and the following disclaimer in the 13193323Sed# documentation and/or other materials provided with the distribution. 14193323Sed# 15193323Sed# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 16193323Sed# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17193323Sed# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18193323Sed# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 19218893Sdim# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20218893Sdim# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 21218893Sdim# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22218893Sdim# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23218893Sdim# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24193323Sed# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25218893Sdim# SUCH DAMAGE. 26218893Sdim# 27218893Sdim# $FreeBSD: head/etc/rc 77662 2001-06-03 20:15:13Z phk $ 28218893Sdim# From: @(#)rc 5.27 (Berkeley) 6/5/91 29218893Sdim# 30218893Sdim 31218893Sdim# System startup script run by init on autoboot 32218893Sdim# or after single-user. 33218893Sdim# Output and error are redirected to console by init, 34218893Sdim# and the console is the controlling terminal. 35193323Sed 36193323Sed# Note that almost all of the user-configurable behavior is no longer in 37193323Sed# this file, but rather in /etc/defaults/rc.conf. Please check that file 38193323Sed# first before contemplating any changes here. If you do need to change 39193323Sed# this file for some reason, we would like to know about it. 40193323Sed 41223017Sdimstty status '^T' 42193323Sed 43193323Sed# Set shell to ignore SIGINT (2), but not children; 44193323Sed# shell catches SIGQUIT (3) and returns to single user after fsck. 45193323Sed# 46193323Sedtrap : 2 47193323Sedtrap : 3 # shouldn't be needed 48193323Sed 49193323Sedbootmode=$1 50193323Sed 51218893SdimHOME=/ 52218893SdimPATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin 53193323Sedexport HOME PATH 54193323Sed 55193323Sed# BOOTP diskless boot. We have to run the rc file early in order to 56193323Sed# retarget various config files. 57212904Sdim# 58212904Sdimif [ -r /etc/rc.diskless1 ]; then 59193323Sed dlv=`/sbin/sysctl -n vfs.nfs.diskless_valid 2> /dev/null` 60193323Sed if [ ${dlv:=0} != 0 ]; then 61212904Sdim . /etc/rc.diskless1 62193323Sed fi 63193323Sedfi 64193323Sed 65193323Sed# If there is a global system configuration file, suck it in. 66193323Sed# 67193323Sedif [ -r /etc/defaults/rc.conf ]; then 68193323Sed . /etc/defaults/rc.conf 69193323Sed source_rc_confs 70198090Srdivackyelif [ -r /etc/rc.conf ]; then 71193323Sed . /etc/rc.conf 72193323Sedfi 73193323Sed 74193323Sedfeed_dev_random() { 75193323Sed if [ -f "${1}" -a -r "${1}" -a -s "${1}" ]; then 76193323Sed echo "Using ${1} as an entropy file" 77193323Sed cat "${1}" | dd of=/dev/random bs=8k 2>/dev/null 78212904Sdim fi 79212904Sdim} 80212904Sdim 81218893Sdimchkdepend() { 82212904Sdim svc=$1 83198090Srdivacky svc_var=$2 84198090Srdivacky dep=$3 85193323Sed dep_var=$4 86198090Srdivacky 87193323Sed eval svc_val=\${$svc_var} 88198090Srdivacky eval dep_val=\${$dep_var} 89198090Srdivacky 90198090Srdivacky case ${svc_val} in 91226890Sdim [Yy][Ee][Ss]) 92198090Srdivacky case ${dep_val} in 93193323Sed [Yy][Ee][Ss]) 94193323Sed ;; 95193323Sed *) 96193323Sed eval ${dep_var}="YES" 97218893Sdim echo "DEPENDENCY NOTE: ${dep} will be enabled" \ 98218893Sdim "to support ${svc}" 99218893Sdim ;; 100218893Sdim esac 101218893Sdim ;; 102218893Sdim esac 103218893Sdim} 104218893Sdim 105218893Sdimchkdepend amd amd_enable portmap portmap_enable 106218893Sdimchkdepend NFS nfs_server_enable portmap portmap_enable 107218893Sdimchkdepend NIS nis_server_enable portmap portmap_enable 108218893Sdimchkdepend NIS nis_client_enable portmap portmap_enable 109218893Sdim 110218893Sdim# Enable harvesting of entropy via devices. The sooner this happens the 111218893Sdim# better so that we can take advantage of the boot process. 112218893Sdim# 113218893Sdimecho -n 'Entropy harvesting:' 114218893Sdim 115218893Sdimcase ${harvest_interrupt} in 116218893Sdim[Nn][Oo]) 117218893Sdim ;; 118218893Sdim*) 119218893Sdim if [ -w /dev/random ]; then 120218893Sdim /sbin/sysctl -w kern.random.sys.harvest.interrupt=1 >/dev/null 121218893Sdim echo -n ' interrupts' 122218893Sdim fi 123218893Sdim ;; 124218893Sdimesac 125218893Sdim 126218893Sdimcase ${harvest_ethernet} in 127218893Sdim[Nn][Oo]) 128218893Sdim ;; 129218893Sdim*) 130218893Sdim if [ -w /dev/random ]; then 131218893Sdim /sbin/sysctl -w kern.random.sys.harvest.ethernet=1 >/dev/null 132218893Sdim echo -n ' ethernet' 133218893Sdim fi 134218893Sdim ;; 135218893Sdimesac 136218893Sdim 137218893Sdimcase ${harvest_p_to_p} in 138218893Sdim[Nn][Oo]) 139226890Sdim ;; 140226890Sdim*) 141218893Sdim if [ -w /dev/random ]; then 142218893Sdim /sbin/sysctl -w kern.random.sys.harvest.point_to_point=1 >/dev/null 143218893Sdim echo -n ' point_to_point' 144193323Sed fi 145193323Sed ;; 146193323Sedesac 147193323Sed 148193323Sedecho '.' 149193323Sed 150212904Sdim# First pass at reseeding /dev/random. 151212904Sdim# 152212904Sdimcase ${entropy_file} in 153218893Sdim[Nn][Oo] | '') 154218893Sdim ;; 155218893Sdim*) 156218893Sdim if [ -w /dev/random ]; then 157218893Sdim feed_dev_random "${entropy_file}" 158218893Sdim fi 159193323Sed ;; 160193323Sedesac 161218893Sdim 162218893Sdim# XXX temporary until we can get the entropy 163218893Sdim# harvesting rate up 164218893Sdim# Entropy below is not great, 165193323Sed# but better than nothing. 166218893Sdim( ps -efauxww; sysctl -a; date; df -ib; dmesg; ps -efauxww; ) \ 167218893Sdim | dd of=/dev/random bs=8k 2>/dev/null 168218893Sdimcat /bin/ls | dd of=/dev/random bs=8k 2>/dev/null 169218893Sdim 170218893Sdim# Configure ccd devices. 171218893Sdim# 172218893Sdimif [ -r /etc/ccd.conf ]; then 173212904Sdim ccdconfig -C 174212904Sdimfi 175212904Sdim 176212904Sdimcase ${start_vinum} in 177199989Srdivacky[Yy][Ee][Ss]) 178199989Srdivacky vinum start 179218893Sdim ;; 180218893Sdimesac 181199989Srdivacky 182193323Sedswapon -a 183218893Sdim 184218893Sdimcase ${bootmode} in 185218893Sdimautoboot) 186218893Sdim echo 'Automatic boot in progress...' 187218893Sdim case ${background_fsck} in 188218893Sdim [Yy][Ee][Ss]) 189218893Sdim fsck -F -p 190218893Sdim ;; 191218893Sdim *) 192218893Sdim fsck -p 193193323Sed ;; 194218893Sdim esac 195218893Sdim case $? in 196218893Sdim 0) 197218893Sdim ;; 198218893Sdim 2) 199218893Sdim exit 1 200218893Sdim ;; 201218893Sdim 4) 202218893Sdim reboot 203218893Sdim echo 'Reboot failed... help!' 204218893Sdim exit 1 205218893Sdim ;; 206218893Sdim 8) 207218893Sdim case ${fsck_y_enable} in 208218893Sdim [Yy][Ee][Ss]) 209218893Sdim echo 'File system preen failed, trying fsck -y . . .' 210218893Sdim fsck -y 211193323Sed case $? in 212193323Sed 0) 213193323Sed ;; 214193323Sed *) 215193323Sed echo 'Automatic file system check failed . . . help!' 216193323Sed exit 1 217193323Sed ;; 218193323Sed esac 219193323Sed ;; 220218893Sdim *) 221218893Sdim echo 'Automatic file system check failed . . . help!' 222218893Sdim exit 1 223193323Sed ;; 224193323Sed esac 225193323Sed ;; 226193323Sed 12) 227193323Sed echo 'Reboot interrupted' 228193323Sed exit 1 229218893Sdim ;; 230218893Sdim 130) 231218893Sdim # interrupt before catcher installed 232218893Sdim exit 1 233218893Sdim ;; 234218893Sdim *) 235218893Sdim echo 'Unknown error in reboot' 236193323Sed exit 1 237218893Sdim ;; 238218893Sdim esac 239218893Sdim ;; 240218893Sdim*) 241218893Sdim echo 'Skipping disk checks ...' 242218893Sdim ;; 243193323Sedesac 244218893Sdim 245218893Sdimset -T 246218893Sdimtrap "echo 'Reboot interrupted'; exit 1" 3 247218893Sdim 248218893Sdim# root normally must be read/write, but if this is a BOOTP NFS 249218893Sdim# diskless boot it does not have to be. 250193323Sed# 251218893Sdimcase ${root_rw_mount} in 252218893Sdim[Nn][Oo] | '') 253218893Sdim ;; 254218893Sdim*) 255218893Sdim if ! mount -u -o rw / ; then 256218893Sdim echo 'Mounting root filesystem rw failed, startup aborted' 257218893Sdim exit 1 258193323Sed fi 259218893Sdim ;; 260218893Sdimesac 261218893Sdim 262193323Sedumount -a >/dev/null 2>&1 263193323Sed 264193323Sed# Mount everything except nfs filesystems. 265212904Sdimmount -a -t nonfs 266193323Sed 267193323Sedcase $? in 268193323Sed0) 269212904Sdim ;; 270193323Sed*) 271193323Sed echo 'Mounting /etc/fstab filesystems failed, startup aborted' 272193323Sed exit 1 273193323Sed ;; 274193323Sedesac 275193323Sed 276193323Sed# Run custom disk mounting function here 277193323Sed# 278193323Sedif [ -n "${diskless_mount}" -a -r "${diskless_mount}" ]; then 279193323Sed sh ${diskless_mount} 280193323Sedfi 281193323Sed 282212904Sdim# Reseed /dev/random with previously stored entropy. 283193323Sedcase ${entropy_dir} in 284193323Sed[Nn][Oo]) 285193323Sed ;; 286193323Sed*) 287193323Sed entropy_dir=${entropy_dir:-/var/db/entropy} 288193323Sed if [ -d "${entropy_dir}" ]; then 289212904Sdim if [ -w /dev/random ]; then 290193323Sed for seedfile in ${entropy_dir}/*; do 291193323Sed feed_dev_random "${seedfile}" 292193323Sed done 293193323Sed fi 294193323Sed fi 295193323Sed ;; 296193323Sedesac 297193323Sed 298193323Sedcase ${entropy_file} in 299193323Sed[Nn][Oo] | '') 300193323Sed ;; 301193323Sed*) 302212904Sdim if [ -w /dev/random ]; then 303218893Sdim feed_dev_random "${entropy_file}" 304193323Sed fi 305193323Sed ;; 306193323Sedesac 307193323Sed 308193323Sedadjkerntz -i 309193323Sed 310212904Sdimpurgedir() { 311218893Sdim local dir file 312193323Sed 313193323Sed if [ $# -eq 0 ]; then 314218893Sdim purgedir . 315218893Sdim else 316218893Sdim for dir 317218893Sdim do 318218893Sdim ( 319218893Sdim cd "$dir" && for file in .* * 320193323Sed do 321218893Sdim [ ."$file" = .. -o ."$file" = ... ] && continue 322218893Sdim if [ -d "$file" -a ! -L "$file" ] 323218893Sdim then 324218893Sdim purgedir "$file" 325218893Sdim else 326218893Sdim rm -f -- "$file" 327218893Sdim fi 328218893Sdim done 329218893Sdim ) 330218893Sdim done 331218893Sdim fi 332218893Sdim} 333218893Sdim 334218893Sdimclean_var() { 335218893Sdim if [ ! -f /var/run/clean_var ]; then 336218893Sdim purgedir /var/run /var/spool/lock 337193323Sed rm -rf /var/spool/uucp/.Temp/* 338218893Sdim # Keep a copy of the boot messages around 339193323Sed dmesg >/var/run/dmesg.boot 340218893Sdim # And an initial utmp file 341218893Sdim (cd /var/run && cp /dev/null utmp && chmod 644 utmp;) 342218893Sdim >/var/run/clean_var 343218893Sdim fi 344218893Sdim} 345218893Sdim 346226890Sdimif [ -d /var/run -a -d /var/spool/lock -a -d /var/spool/uucp/.Temp ]; then 347226890Sdim # network_pass1() *may* end up writing stuff to /var - we don't want to 348226890Sdim # remove it immediately afterwards - *nor* to we want to fail to clean 349226890Sdim # an nfs-mounted /var. 350226890Sdim clean_var 351218893Sdimfi 352218893Sdim 353218893Sdim# Add additional swapfile, if configured. 354218893Sdim# 355218893Sdimcase ${swapfile} in 356193323Sed[Nn][Oo] | '') 357218893Sdim ;; 358218893Sdim*) 359218893Sdim if [ -w "${swapfile}" -a -c /dev/mdctl ]; then 360218893Sdim echo "Adding ${swapfile} as additional swap" 361218893Sdim mdev=`mdconfig -a -t vnode -f ${swapfile}` && swapon /dev/${mdev} 362218893Sdim fi 363193323Sed ;; 364218893Sdimesac 365212904Sdim 366218893Sdim# Set sysctl variables as early as we can 367193323Sed# 368218893Sdimif [ -r /etc/rc.sysctl ]; then 369218893Sdim . /etc/rc.sysctl 370218893Sdimfi 371218893Sdim 372218893Sdim# Configure serial devices 373218893Sdim# 374218893Sdimif [ -r /etc/rc.serial ]; then 375218893Sdim . /etc/rc.serial 376218893Sdimfi 377218893Sdim 378218893Sdim# Start up PC-card configuration 379218893Sdim# 380218893Sdimif [ -r /etc/rc.pccard ]; then 381218893Sdim . /etc/rc.pccard 382218893Sdimfi 383218893Sdim 384218893Sdim# Start up the initial network configuration. 385218893Sdim# 386218893Sdimif [ -r /etc/rc.network ]; then 387218893Sdim . /etc/rc.network # We only need to do this once. 388218893Sdim network_pass1 389218893Sdimfi 390218893Sdim 391218893Sdimcase ${ipv6_enable} in 392218893Sdim[Yy][Ee][Ss]) 393218893Sdim if [ -r /etc/rc.network6 ]; then 394218893Sdim . /etc/rc.network6 # We only need to do this once also. 395218893Sdim network6_pass1 396218893Sdim fi 397218893Sdim ;; 398218893Sdimesac 399218893Sdim 400218893Sdim# Mount NFS filesystems if present in /etc/fstab 401218893Sdimcase "`mount -d -a -t nfs 2> /dev/null`" in 402218893Sdim*mount_nfs*) 403218893Sdim echo -n 'Mounting NFS file systems:' 404218893Sdim mount -a -t nfs 405218893Sdim echo '.' 406218893Sdim ;; 407218893Sdimesac 408218893Sdim 409218893Sdim# Whack the pty perms back into shape. 410218893Sdim# 411218893Sdimif ls /dev/tty[pqrsPQRS]* > /dev/null 2>&1; then 412218893Sdim chflags 0 /dev/tty[pqrsPQRS]* 413218893Sdim chmod 666 /dev/tty[pqrsPQRS]* 414218893Sdim chown root:wheel /dev/tty[pqrsPQRS]* 415218893Sdimfi 416226890Sdim 417226890Sdim# Clean up left-over files 418226890Sdim# 419226890Sdimclean_var # If it hasn't already been done 420226890Sdimrm /var/run/clean_var 421226890Sdim 422226890Sdim# Clearing /tmp at boot-time seems to have a long tradition. It doesn't 423226890Sdim# help in any way for long-living systems, and it might accidentally 424226890Sdim# clobber files you would rather like to have preserved after a crash 425226890Sdim# (if not using mfs /tmp anyway). 426226890Sdim# 427226890Sdim# See also the example of another cleanup policy in /etc/periodic/daily. 428226890Sdim# 429226890Sdimcase ${clear_tmp_enable} in 430226890Sdim[Yy][Ee][Ss]) 431226890Sdim echo -n 'Clearing /tmp:' 432226890Sdim # prune quickly with one rm, then use find to clean up /tmp/[lq]* 433226890Sdim # (not needed with mfs /tmp, but doesn't hurt there...) 434226890Sdim (cd /tmp && rm -rf [a-km-pr-zA-Z]* && 435226890Sdim find -d . ! -name . ! -name lost+found ! -name quota.user \ 436226890Sdim ! -name quota.group -exec rm -rf -- {} \;) 437226890Sdim echo '.' 438226890Sdim ;; 439226890Sdimesac 440226890Sdim 441226890Sdim# Remove X lock files, since they will prevent you from restarting X11 442226890Sdim# after a system crash. 443226890Sdim# 444226890Sdimrm -f /tmp/.X*-lock /tmp/.X11-unix/* 445226890Sdim 446226890Sdim# Snapshot any kernel -c changes back to disk here <someday>. 447226890Sdim# This has changed with ELF and /kernel.config. 448226890Sdim 449218893Sdimecho -n 'Additional daemons:' 450218893Sdim 451218893Sdim# Start system logging and name service. Named needs to start before syslogd 452218893Sdim# if you don't have a /etc/resolv.conf. 453218893Sdim# 454218893Sdimcase ${syslogd_enable} in 455218893Sdim[Yy][Ee][Ss]) 456218893Sdim # Transitional symlink (for the next couple of years :) until all 457218893Sdim # binaries have had a chance to move towards /var/run/log. 458193323Sed if [ ! -L /dev/log ]; then 459212904Sdim # might complain for r/o root f/s 460212904Sdim ln -sf /var/run/log /dev/log 461212904Sdim fi 462212904Sdim 463212904Sdim rm -f /var/run/log 464193323Sed echo -n ' syslogd'; syslogd ${syslogd_flags} 465193323Sed ;; 466193323Sedesac 467193323Sed 468193323Sed# Start disk checking daemon if required. 469193323Sed# 470193323Sedcase ${diskcheckd_enable} in 471218893Sdim[Yy][Ee][Ss]) 472193323Sed echo -n ' diskcheckd'; diskcheckd ${diskcheckd_flags} 473218893Sdim ;; 474218893Sdimesac 475218893Sdim 476218893Sdimecho '.' 477218893Sdim 478193323Sed# Build device name databases if we are not using DEVFS 479193323Sed# 480193323Sedif sysctl vfs.devfs.generation > /dev/null 2>&1 ; then 481193323Sed rm -f /var/run/dev.db 482193323Sedelse 483218893Sdim dev_mkdb 484193323Sedfi 485218893Sdim 486218893Sdim# Enable dumpdev so that savecore can see it. 487218893Sdim# /var/crash should be a directory or a symbolic link 488218893Sdim# to the crash directory if core dumps are to be saved. 489218893Sdim# 490218893Sdimcase ${dumpdev} in 491193323Sed[Nn][Oo] | '') 492193323Sed ;; 493193323Sed*) 494193323Sed if [ -e "${dumpdev}" -a -d /var/crash ]; then 495193323Sed /sbin/dumpon -v ${dumpdev} 496193323Sed echo -n 'Checking for core dump: ' 497193323Sed /sbin/savecore ${savecore_flags} /var/crash 498193323Sed fi 499193323Sed ;; 500193323Sedesac 501193323Sed 502193323Sedif [ -n "${network_pass1_done}" ]; then 503193323Sed network_pass2 504193323Sedfi 505193323Sed 506193323Sed# Enable/Check the quotas (must be after ypbind if using NIS) 507193323Sed# 508193323Sedcase ${enable_quotas} in 509193323Sed[Yy][Ee][Ss]) 510193323Sed case ${check_quotas} in 511193323Sed [Yy][Ee][Ss]) 512218893Sdim echo -n 'Checking quotas:' 513218893Sdim quotacheck -a 514218893Sdim echo ' done.' 515218893Sdim ;; 516218893Sdim esac 517218893Sdim 518218893Sdim echo -n 'Enabling quotas:' 519218893Sdim quotaon -a 520218893Sdim echo ' done.' 521218893Sdim ;; 522218893Sdimesac 523193323Sed 524193323Sedif [ -n "${network_pass2_done}" ]; then 525193323Sed network_pass3 526193323Sedfi 527193323Sed 528193323Sed# Check the password temp/lock file 529193323Sed# 530193323Sedif [ -e /etc/ptmp ]; then 531193323Sed logger -s -p auth.err \ 532223017Sdim "password file may be incorrect -- /etc/ptmp exists" 533223017Sdimfi 534223017Sdim 535223017Sdimcase ${accounting_enable} in 536223017Sdim[Yy][Ee][Ss]) 537223017Sdim if [ -d /var/account ]; then 538223017Sdim echo 'Turning on accounting:' 539223017Sdim if [ ! -e /var/account/acct ]; then 540223017Sdim touch /var/account/acct 541223017Sdim fi 542223017Sdim accton /var/account/acct 543223017Sdim fi 544223017Sdim ;; 545223017Sdimesac 546223017Sdim 547223017Sdim# Make shared lib searching a little faster. Leave /usr/lib first if you 548223017Sdim# add your own entries or you may come to grief. 549223017Sdim# 550223017Sdimldconfig="/sbin/ldconfig" 551223017Sdimcase ${ldconfig_insecure} in 552223017Sdim[Yy][Ee][Ss]) 553223017Sdim ldconfig="${ldconfig} -i" 554223017Sdim ;; 555223017Sdimesac 556223017Sdimif [ -x /sbin/ldconfig ]; then 557223017Sdim case `/usr/bin/objformat` in 558193323Sed elf) 559193323Sed _LDC=/usr/lib 560193323Sed for i in ${ldconfig_paths}; do 561193323Sed if [ -d "${i}" ]; then 562193323Sed _LDC="${_LDC} ${i}" 563193323Sed fi 564198090Srdivacky done 565193323Sed echo 'ELF ldconfig path:' ${_LDC} 566193323Sed ${ldconfig} -elf ${_LDC} 567193323Sed ;; 568193323Sed esac 569193323Sed 570193323Sed # Legacy aout support for i386 only 571193323Sed case `sysctl -n hw.machine` in 572193323Sed i386) 573193323Sed # Default the a.out ldconfig path. 574 : ${ldconfig_paths_aout=${ldconfig_paths}} 575 _LDC=/usr/lib/aout 576 for i in ${ldconfig_paths_aout}; do 577 if [ -d "${i}" ]; then 578 _LDC="${_LDC} ${i}" 579 fi 580 done 581 echo 'a.out ldconfig path:' ${_LDC} 582 ${ldconfig} -aout ${_LDC} 583 ;; 584 esac 585fi 586 587# Now start up miscellaneous daemons that don't belong anywhere else 588# 589echo -n 'Starting standard daemons:' 590case ${inetd_enable} in 591[Nn][Oo]) 592 ;; 593*) 594 echo -n ' inetd'; inetd ${inetd_flags} 595 ;; 596esac 597 598case ${cron_enable} in 599[Nn][Oo]) 600 ;; 601*) 602 echo -n ' cron'; ${cron_program:-/usr/sbin/cron} ${cron_flags} 603 ;; 604esac 605 606case ${lpd_enable} in 607[Yy][Ee][Ss]) 608 echo -n ' printer'; ${lpd_program:-/usr/sbin/lpd} ${lpd_flags} 609 ;; 610esac 611 612case ${sshd_enable} in 613[Yy][Ee][Ss]) 614 if [ -x ${sshd_program:-/usr/sbin/sshd} ]; then 615 echo -n ' sshd'; 616 ${sshd_program:-/usr/sbin/sshd} ${sshd_flags} 617 fi 618 ;; 619esac 620 621case ${usbd_enable} in 622[Yy][Ee][Ss]) 623 echo -n ' usbd'; /usr/sbin/usbd ${usbd_flags} 624 ;; 625esac 626 627if [ -r /etc/mail/sendmail.cf ]; then 628 case ${sendmail_enable} in 629 [Yy][Ee][Ss]) 630 echo -n ' sendmail' 631 /usr/sbin/sendmail ${sendmail_flags} 632 ;; 633 *) 634 case ${sendmail_outbound_enable} in 635 [Yy][Ee][Ss]) 636 echo -n ' sendmail' 637 /usr/sbin/sendmail ${sendmail_outbound_flags} 638 ;; 639 esac 640 ;; 641 esac 642fi 643 644echo '.' 645 646# Recover vi editor files. 647find /var/tmp/vi.recover ! -type f -a ! -type d -delete 648vibackup=`echo /var/tmp/vi.recover/vi.*` 649if [ "${vibackup}" != '/var/tmp/vi.recover/vi.*' ]; then 650 echo -n 'Recovering vi editor sessions:' 651 for i in /var/tmp/vi.recover/vi.*; do 652 # Only test files that are readable. 653 if [ ! -r "${i}" ]; then 654 continue 655 fi 656 657 # Unmodified nvi editor backup files either have the 658 # execute bit set or are zero length. Delete them. 659 if [ -x "${i}" -o ! -s "${i}" ]; then 660 rm -f "${i}" 661 fi 662 done 663 664 # It is possible to get incomplete recovery files, if the editor 665 # crashes at the right time. 666 virecovery=`echo /var/tmp/vi.recover/recover.*` 667 if [ "${virecovery}" != "/var/tmp/vi.recover/recover.*" ]; then 668 for i in /var/tmp/vi.recover/recover.*; do 669 # Only test files that are readable. 670 if [ ! -r "${i}" ]; then 671 continue 672 fi 673 674 # Delete any recovery files that are zero length, 675 # corrupted, or that have no corresponding backup file. 676 # Else send mail to the user. 677 recfile=`awk '/^X-vi-recover-path:/{print $2}' < "${i}"` 678 if [ -n "${recfile}" -a -s "${recfile}" ]; then 679 sendmail -t < "${i}" 680 else 681 rm -f "${i}" 682 fi 683 done 684 fi 685 echo '.' 686fi 687 688# Make a bounds file for msgs(1) if there isn't one already 689# 690if [ -d /var/msgs -a ! -f /var/msgs/bounds -a ! -L /var/msgs/bounds ]; then 691 echo 0 > /var/msgs/bounds 692fi 693 694case ${update_motd} in 695[Nn][Oo] | '') 696 ;; 697*) 698 if T=`mktemp /tmp/_motd.XXXXXX`; then 699 uname -v | sed -e 's,^\([^#]*\) #\(.* [1-2][0-9][0-9][0-9]\).*/\([^\]*\) $,\1 (\3) #\2,' > ${T} 700 awk '{if (NR == 1) {if ($1 == "FreeBSD") {next} else {print "\n"$0}} else {print}}' < /etc/motd >> ${T} 701 cmp -s ${T} /etc/motd || { 702 cp ${T} /etc/motd 703 chmod 644 /etc/motd 704 } 705 rm -f ${T} 706 fi 707 ;; 708esac 709 710# Configure implementation specific stuff 711# 712arch=`uname -m` 713if [ -r /etc/rc.${arch} ]; then 714 . /etc/rc.${arch} 715fi 716 717# Configure the system console 718# 719if [ -r /etc/rc.syscons ]; then 720 . /etc/rc.syscons 721fi 722 723# Run rc.devfs if readable to customize devfs 724# 725if [ -r /etc/rc.devfs ]; then 726 sh /etc/rc.devfs 727fi 728 729echo -n 'Additional ABI support:' 730 731# Load the SysV IPC API if requested. 732case ${sysvipc_enable} in 733[Yy][Ee][Ss]) 734 echo -n ' sysvipc' 735 kldload sysvmsg >/dev/null 2>&1 736 kldload sysvsem >/dev/null 2>&1 737 kldload sysvshm >/dev/null 2>&1 738 ;; 739esac 740 741# Start the Linux binary compatibility if requested. 742# 743case ${linux_enable} in 744[Yy][Ee][Ss]) 745 echo -n ' linux' 746 if ! kldstat -v | grep -E 'linux(aout|elf)' > /dev/null; then 747 kldload linux > /dev/null 2>&1 748 fi 749 if [ -x /compat/linux/sbin/ldconfig ]; then 750 /compat/linux/sbin/ldconfig 751 fi 752 ;; 753esac 754 755# Start the SysVR4 binary emulation if requested. 756# 757case ${svr4_enable} in 758[Yy][Ee][Ss]) 759 echo -n ' svr4'; kldload svr4 > /dev/null 2>&1 760 ;; 761esac 762 763echo '.' 764 765# Do traditional (but rather obsolete) rc.local file if it exists. If you 766# use this file and want to make it programmatic, source /etc/defaults/rc.conf 767# in /etc/rc.local and add your custom variables to /etc/rc.conf, as 768# shown below. Please do not put local extensions into /etc/rc itself. 769# Use /etc/rc.local 770# 771# ---- rc.local ---- 772# if [ -r /etc/defaults/rc.conf ]; then 773# . /etc/defaults/rc.conf 774# source_rc_confs 775# elif [ -r /etc/rc.conf ]; then 776# . /etc/rc.conf 777# fi 778# 779# ... additional startup conditionals ... 780# ---- rc.local ---- 781# 782if [ -r /etc/rc.local ]; then 783 echo -n 'Starting local daemons:' 784 sh /etc/rc.local 785 echo '.' 786fi 787 788# For each valid dir in $local_startup, search for init scripts matching *.sh 789# 790case ${local_startup} in 791[Nn][Oo] | '') 792 ;; 793*) 794 echo -n 'Local package initialization:' 795 for dir in ${local_startup}; do 796 if [ -d "${dir}" ]; then 797 for script in ${dir}/*.sh; do 798 if [ -x "${script}" ]; then 799 (set -T 800 trap 'exit 1' 2 801 ${script} start) 802 fi 803 done 804 fi 805 done 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