rc revision 83871
1221828Sgrehan#!/bin/sh 2221828Sgrehan# 3221828Sgrehan# Copyright (c) 2000 The FreeBSD Project 4221828Sgrehan# All rights reserved. 5221828Sgrehan# 6221828Sgrehan# Redistribution and use in source and binary forms, with or without 7221828Sgrehan# modification, are permitted provided that the following conditions 8221828Sgrehan# are met: 9221828Sgrehan# 1. Redistributions of source code must retain the above copyright 10221828Sgrehan# notice, this list of conditions and the following disclaimer. 11221828Sgrehan# 2. Redistributions in binary form must reproduce the above copyright 12221828Sgrehan# notice, this list of conditions and the following disclaimer in the 13221828Sgrehan# documentation and/or other materials provided with the distribution. 14221828Sgrehan# 15221828Sgrehan# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 16221828Sgrehan# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17221828Sgrehan# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18221828Sgrehan# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 19221828Sgrehan# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20221828Sgrehan# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 21221828Sgrehan# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22221828Sgrehan# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23221828Sgrehan# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24221828Sgrehan# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25221828Sgrehan# SUCH DAMAGE. 26221828Sgrehan# 27221828Sgrehan# @(#)rc 5.27 (Berkeley) 6/5/91 28221828Sgrehan# $FreeBSD: head/etc/rc 83871 2001-09-24 03:03:51Z obrien $ 29221828Sgrehan# 30221828Sgrehan 31221828Sgrehan# System startup script run by init on autoboot 32221828Sgrehan# or after single-user. 33234695Sgrehan# Output and error are redirected to console by init, 34221828Sgrehan# and the console is the controlling terminal. 35221828Sgrehan 36221828Sgrehan# Note that almost all of the user-configurable behavior is no longer in 37221828Sgrehan# this file, but rather in /etc/defaults/rc.conf. Please check that file 38221828Sgrehan# first before contemplating any changes here. If you do need to change 39221828Sgrehan# this file for some reason, we would like to know about it. 40221828Sgrehan 41221828Sgrehanstty status '^T' 42256072Sneel 43221828Sgrehan# Set shell to ignore SIGINT (2), but not children; 44221828Sgrehan# shell catches SIGQUIT (3) and returns to single user after fsck. 45221828Sgrehan# 46221828Sgrehantrap : 2 47221828Sgrehantrap : 3 # shouldn't be needed 48256072Sneel 49256072Sneelbootmode=$1 50256072Sneel 51256072SneelHOME=/ 52256072SneelPATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin 53256072Sneelexport HOME PATH 54221828Sgrehan 55261275Sjhb# BOOTP diskless boot. We have to run the rc file early in order to 56221828Sgrehan# retarget various config files. 57221828Sgrehan# 58241489Sneelif [ -r /etc/rc.diskless1 ]; then 59262350Sjhb dlv=`/sbin/sysctl -n vfs.nfs.diskless_valid 2> /dev/null` 60221914Sjhb if [ ${dlv:=0} != 0 ]; then 61256072Sneel . /etc/rc.diskless1 62221828Sgrehan fi 63221828Sgrehanfi 64261088Sjhb 65261088Sjhb# If there is a global system configuration file, suck it in. 66256072Sneel# 67242275Sneelif [ -r /etc/defaults/rc.conf ]; then 68221828Sgrehan . /etc/defaults/rc.conf 69221828Sgrehan source_rc_confs 70261088Sjhbelif [ -r /etc/rc.conf ]; then 71261088Sjhb . /etc/rc.conf 72221828Sgrehanfi 73221828Sgrehan 74221828Sgrehanfeed_dev_random() { 75221828Sgrehan if [ -f "${1}" -a -r "${1}" -a -s "${1}" ]; then 76242065Sneel# echo "Using ${1} as an entropy file" 77221828Sgrehan cat "${1}" | dd of=/dev/random bs=8k 2>/dev/null 78221828Sgrehan fi 79221828Sgrehan} 80221828Sgrehan 81221828Sgrehanchkdepend() { 82221828Sgrehan svc=$1 83221828Sgrehan svc_var=$2 84221828Sgrehan dep=$3 85241489Sneel dep_var=$4 86241489Sneel 87221828Sgrehan eval svc_val=\${$svc_var} 88221828Sgrehan eval dep_val=\${$dep_var} 89221828Sgrehan 90221828Sgrehan case ${svc_val} in 91234695Sgrehan [Yy][Ee][Ss]) 92221828Sgrehan case ${dep_val} in 93240894Sneel [Yy][Ee][Ss]) 94240922Sneel ;; 95241982Sneel *) 96221828Sgrehan eval ${dep_var}="YES" 97221828Sgrehan echo "DEPENDENCY NOTE: ${dep} will be enabled" \ 98242065Sneel "to support ${svc}" 99242065Sneel ;; 100242065Sneel esac 101256072Sneel ;; 102241489Sneel esac 103256072Sneel} 104256072Sneel 105256072Sneelchkdepend amd amd_enable portmap portmap_enable 106256072Sneelchkdepend NFS nfs_server_enable portmap portmap_enable 107256072Sneelchkdepend NIS nis_server_enable portmap portmap_enable 108256072Sneelchkdepend NIS nis_client_enable portmap portmap_enable 109221828Sgrehan 110221828Sgrehan# Enable harvesting of entropy via devices. The sooner this happens the 111221828Sgrehan# better so that we can take advantage of the boot process. 112221828Sgrehan# 113221828Sgrehanecho -n 'Entropy harvesting:' 114261088Sjhb 115261088Sjhbcase ${harvest_interrupt} in 116256072Sneel[Nn][Oo]) 117221828Sgrehan ;; 118221828Sgrehan*) 119256072Sneel if [ -w /dev/random ]; then 120221828Sgrehan /sbin/sysctl -w kern.random.sys.harvest.interrupt=1 >/dev/null 121221828Sgrehan echo -n ' interrupts' 122221828Sgrehan fi 123223621Sgrehan ;; 124221828Sgrehanesac 125221828Sgrehan 126221828Sgrehancase ${harvest_ethernet} in 127266339Sjhb[Nn][Oo]) 128266339Sjhb ;; 129266339Sjhb*) 130266339Sjhb if [ -w /dev/random ]; then 131266339Sjhb /sbin/sysctl -w kern.random.sys.harvest.ethernet=1 >/dev/null 132266339Sjhb echo -n ' ethernet' 133266339Sjhb fi 134221828Sgrehan ;; 135221828Sgrehanesac 136249396Sneel 137249396Sneelcase ${harvest_p_to_p} in 138221828Sgrehan[Nn][Oo]) 139266339Sjhb ;; 140221828Sgrehan*) 141261275Sjhb if [ -w /dev/random ]; then 142221828Sgrehan /sbin/sysctl -w kern.random.sys.harvest.point_to_point=1 >/dev/null 143256072Sneel echo -n ' point_to_point' 144266339Sjhb fi 145266339Sjhb ;; 146221828Sgrehanesac 147256072Sneel 148256072Sneelecho '.' 149256072Sneel 150256072Sneel# First pass at reseeding /dev/random. 151221828Sgrehan# 152221828Sgrehancase ${entropy_file} in 153221828Sgrehan[Nn][Oo] | '') 154221828Sgrehan ;; 155221828Sgrehan*) 156221828Sgrehan if [ -w /dev/random ]; then 157221828Sgrehan feed_dev_random "${entropy_file}" 158221828Sgrehan fi 159221828Sgrehan ;; 160221828Sgrehanesac 161221828Sgrehan 162221828Sgrehan# XXX temporary until we can get the entropy 163221828Sgrehan# harvesting rate up 164221828Sgrehan# Entropy below is not great, 165266339Sjhb# but better than nothing. 166266339Sjhb( ps -efauxww; sysctl -a; date; df -ib; dmesg; ps -efauxww; ) \ 167266339Sjhb | dd of=/dev/random bs=8k 2>/dev/null 168266339Sjhbcat /bin/ls | dd of=/dev/random bs=8k 2>/dev/null 169221828Sgrehan 170245021Sneel# Configure ccd devices. 171245021Sneel# 172221828Sgrehanif [ -r /etc/ccd.conf ]; then 173221828Sgrehan ccdconfig -C 174221828Sgrehanfi 175221828Sgrehan 176221828Sgrehancase ${start_vinum} in 177248389Sneel[Yy][Ee][Ss]) 178221828Sgrehan vinum start 179266339Sjhb ;; 180266339Sjhbesac 181266339Sjhb 182266339Sjhbswapon -a 183266339Sjhb 184266339Sjhbcase ${bootmode} in 185266339Sjhbautoboot) 186266339Sjhb echo 'Automatic boot in progress...' 187221828Sgrehan case ${background_fsck} in 188266339Sjhb [Yy][Ee][Ss]) 189221828Sgrehan fsck -F -p 190266339Sjhb ;; 191266339Sjhb *) 192266339Sjhb fsck -p 193234695Sgrehan ;; 194234695Sgrehan esac 195221828Sgrehan case $? in 196221828Sgrehan 0) 197221828Sgrehan ;; 198221828Sgrehan 2) 199221828Sgrehan exit 1 200221828Sgrehan ;; 201221828Sgrehan 4) 202221828Sgrehan reboot 203221828Sgrehan echo 'Reboot failed... help!' 204241489Sneel exit 1 205241489Sneel ;; 206221828Sgrehan 8) 207266339Sjhb case ${fsck_y_enable} in 208240943Sneel [Yy][Ee][Ss]) 209234695Sgrehan echo 'File system preen failed, trying fsck -y . . .' 210234695Sgrehan fsck -y 211221828Sgrehan case $? in 212221828Sgrehan 0) 213221828Sgrehan ;; 214240894Sneel *) 215240894Sneel echo 'Automatic file system check failed . . . help!' 216240894Sneel exit 1 217240894Sneel ;; 218240894Sneel esac 219240894Sneel ;; 220240894Sneel *) 221240894Sneel echo 'Automatic file system check failed . . . help!' 222240894Sneel exit 1 223240894Sneel ;; 224240894Sneel esac 225240894Sneel ;; 226240894Sneel 12) 227261275Sjhb echo 'Reboot interrupted' 228261275Sjhb exit 1 229261275Sjhb ;; 230261275Sjhb 130) 231261275Sjhb # interrupt before catcher installed 232261275Sjhb exit 1 233221828Sgrehan ;; 234221828Sgrehan *) 235221828Sgrehan echo 'Unknown error in reboot' 236221828Sgrehan exit 1 237221828Sgrehan ;; 238242275Sneel esac 239221828Sgrehan ;; 240266339Sjhb*) 241266339Sjhb echo 'Skipping disk checks ...' 242266339Sjhb ;; 243266339Sjhbesac 244221828Sgrehan 245221828Sgrehanset -T 246221828Sgrehantrap "echo 'Reboot interrupted'; exit 1" 3 247221828Sgrehan 248221828Sgrehan# root normally must be read/write, but if this is a BOOTP NFS 249221828Sgrehan# diskless boot it does not have to be. 250221828Sgrehan# 251221828Sgrehancase ${root_rw_mount} in 252221828Sgrehan[Nn][Oo] | '') 253221828Sgrehan ;; 254221828Sgrehan*) 255221828Sgrehan if ! mount -u -o rw / ; then 256261275Sjhb echo 'Mounting root filesystem rw failed, startup aborted' 257221828Sgrehan exit 1 258266339Sjhb fi 259221828Sgrehan ;; 260221828Sgrehanesac 261221828Sgrehan 262221828Sgrehanumount -a >/dev/null 2>&1 263221828Sgrehan 264221828Sgrehan# Mount everything except nfs filesystems. 265221828Sgrehanmount -a -t nonfs 266221828Sgrehan 267221828Sgrehancase $? in 268221828Sgrehan0) 269267070Sjhb ;; 270267070Sjhb*) 271221828Sgrehan echo 'Mounting /etc/fstab filesystems failed, startup aborted' 272249396Sneel exit 1 273249396Sneel ;; 274221828Sgrehanesac 275221828Sgrehan 276241454Sneel# Run custom disk mounting function here 277241454Sneel# 278261275Sjhbif [ -n "${diskless_mount}" -a -r "${diskless_mount}" ]; then 279241454Sneel sh ${diskless_mount} 280266339Sjhbfi 281266339Sjhb 282241454Sneel# Reseed /dev/random with previously stored entropy. 283253854Sgrehancase ${entropy_dir} in 284253854Sgrehan[Nn][Oo]) 285253854Sgrehan ;; 286253854Sgrehan*) 287253854Sgrehan entropy_dir=${entropy_dir:-/var/db/entropy} 288253854Sgrehan if [ -d "${entropy_dir}" ]; then 289241454Sneel if [ -w /dev/random ]; then 290221828Sgrehan for seedfile in ${entropy_dir}/*; do 291221828Sgrehan feed_dev_random "${seedfile}" 292221828Sgrehan done 293221828Sgrehan fi 294221828Sgrehan fi 295221828Sgrehan ;; 296221828Sgrehanesac 297221828Sgrehan 298221828Sgrehancase ${entropy_file} in 299221828Sgrehan[Nn][Oo] | '') 300221828Sgrehan ;; 301221828Sgrehan*) 302221828Sgrehan if [ -w /dev/random ]; then 303221828Sgrehan feed_dev_random "${entropy_file}" 304221828Sgrehan fi 305245704Sneel ;; 306245704Sneelesac 307245704Sneel 308245704Sneeladjkerntz -i 309245704Sneel 310245704Sneelpurgedir() { 311245704Sneel local dir file 312221828Sgrehan 313245704Sneel if [ $# -eq 0 ]; then 314221828Sgrehan purgedir . 315221828Sgrehan else 316249396Sneel for dir 317249396Sneel do 318221828Sgrehan ( 319221828Sgrehan cd "$dir" && for file in .* * 320221828Sgrehan do 321256072Sneel [ ."$file" = .. -o ."$file" = ... ] && continue 322221828Sgrehan if [ -d "$file" -a ! -L "$file" ] 323221828Sgrehan then 324221828Sgrehan purgedir "$file" 325249396Sneel else 326249396Sneel rm -f -- "$file" 327249396Sneel fi 328249396Sneel done 329249396Sneel ) 330249396Sneel done 331249396Sneel fi 332221828Sgrehan} 333249396Sneel 334221828Sgrehanclean_var() { 335256072Sneel if [ ! -f /var/run/clean_var ]; then 336256072Sneel purgedir /var/run /var/spool/lock 337256072Sneel rm -rf /var/spool/uucp/.Temp/* 338256072Sneel # Keep a copy of the boot messages around 339221828Sgrehan dmesg >/var/run/dmesg.boot 340221828Sgrehan # And an initial utmp file 341266339Sjhb (cd /var/run && cp /dev/null utmp && chmod 644 utmp;) 342266339Sjhb >/var/run/clean_var 343256072Sneel fi 344261088Sjhb} 345261088Sjhb 346221828Sgrehanif [ -d /var/run -a -d /var/spool/lock -a -d /var/spool/uucp/.Temp ]; then 347221828Sgrehan # network_pass1() *may* end up writing stuff to /var - we don't want to 348221828Sgrehan # remove it immediately afterwards - *nor* to we want to fail to clean 349221828Sgrehan # an nfs-mounted /var. 350221828Sgrehan clean_var 351221828Sgrehanfi 352221828Sgrehan 353221828Sgrehan# Add additional swapfile, if configured. 354249396Sneel# 355249396Sneelcase ${swapfile} in 356221828Sgrehan[Nn][Oo] | '') 357221828Sgrehan ;; 358241178Sneel*) 359256072Sneel if [ -w "${swapfile}" -a -c /dev/mdctl ]; then 360241178Sneel echo "Adding ${swapfile} as additional swap" 361241178Sneel mdev=`mdconfig -a -t vnode -f ${swapfile}` && swapon /dev/${mdev} 362256072Sneel fi 363256072Sneel ;; 364241362Sneelesac 365256072Sneel 366241178Sneel# Set sysctl variables as early as we can 367241178Sneel# 368221828Sgrehanif [ -r /etc/rc.sysctl ]; then 369221828Sgrehan . /etc/rc.sysctl 370221828Sgrehanfi 371221828Sgrehan 372221828Sgrehan# Configure serial devices 373221828Sgrehan# 374221828Sgrehanif [ -r /etc/rc.serial ]; then 375256072Sneel . /etc/rc.serial 376256072Sneelfi 377256072Sneel 378261088Sjhb# Start up PC-card configuration 379261088Sjhb# 380261088Sjhbif [ -r /etc/rc.pccard ]; then 381221828Sgrehan . /etc/rc.pccard 382241178Sneelfi 383221828Sgrehan 384241178Sneel# Start up the initial network configuration. 385241178Sneel# 386221828Sgrehanif [ -r /etc/rc.network ]; then 387266339Sjhb . /etc/rc.network # We only need to do this once. 388221828Sgrehan network_pass1 389256072Sneelfi 390221828Sgrehan 391221828Sgrehancase ${ipv6_enable} in 392221828Sgrehan[Yy][Ee][Ss]) 393221828Sgrehan if [ -r /etc/rc.network6 ]; then 394221828Sgrehan . /etc/rc.network6 # We only need to do this once also. 395221828Sgrehan network6_pass1 396221828Sgrehan fi 397221828Sgrehan ;; 398221828Sgrehanesac 399221828Sgrehan 400221828Sgrehan# Mount NFS filesystems if present in /etc/fstab 401221828Sgrehancase "`mount -d -a -t nfs 2> /dev/null`" in 402221828Sgrehan*mount_nfs*) 403221828Sgrehan echo -n 'Mounting NFS file systems:' 404221828Sgrehan mount -a -t nfs 405256072Sneel echo '.' 406221828Sgrehan ;; 407256072Sneelesac 408256072Sneel 409256072Sneel# Whack the pty perms back into shape. 410256072Sneel# 411221828Sgrehanif ls /dev/tty[pqrsPQRS]* > /dev/null 2>&1; then 412221828Sgrehan chflags 0 /dev/tty[pqrsPQRS]* 413221828Sgrehan chmod 666 /dev/tty[pqrsPQRS]* 414221828Sgrehan chown root:wheel /dev/tty[pqrsPQRS]* 415221828Sgrehanfi 416221828Sgrehan 417256072Sneel# Clean up left-over files 418256072Sneel# 419221828Sgrehanclean_var # If it hasn't already been done 420221828Sgrehanrm /var/run/clean_var 421256072Sneel 422256072Sneel# Clearing /tmp at boot-time seems to have a long tradition. It doesn't 423241041Sneel# help in any way for long-living systems, and it might accidentally 424241041Sneel# clobber files you would rather like to have preserved after a crash 425241041Sneel# (if not using mfs /tmp anyway). 426241041Sneel# 427241041Sneel# See also the example of another cleanup policy in /etc/periodic/daily. 428241041Sneel# 429241041Sneelcase ${clear_tmp_enable} in 430241041Sneel[Yy][Ee][Ss]) 431256072Sneel echo -n 'Clearing /tmp:' 432241041Sneel # prune quickly with one rm, then use find to clean up /tmp/[lq]* 433241041Sneel # (not needed with mfs /tmp, but doesn't hurt there...) 434256072Sneel (cd /tmp && rm -rf [a-km-pr-zA-Z]* && 435256072Sneel find -d . ! -name . ! -name lost+found ! -name quota.user \ 436256072Sneel ! -name quota.group -exec rm -rf -- {} \;) 437256072Sneel echo '.' 438241041Sneel ;; 439241041Sneelesac 440221828Sgrehan 441241041Sneel# Remove X lock files, since they will prevent you from restarting X11 442221828Sgrehan# after a system crash. 443256072Sneel# 444256072Sneelrm -f /tmp/.X*-lock /tmp/.X11-unix/* 445256072Sneel 446256072Sneel# Snapshot any kernel -c changes back to disk here <someday>. 447221828Sgrehan# This has changed with ELF and /kernel.config. 448241041Sneel 449241041Sneelecho -n 'Additional daemons:' 450221828Sgrehan 451241041Sneel# Start system logging and name service. Named needs to start before syslogd 452241041Sneel# if you don't have a /etc/resolv.conf. 453241041Sneel# 454256072Sneelcase ${syslogd_enable} in 455256072Sneel[Yy][Ee][Ss]) 456256072Sneel # Transitional symlink (for the next couple of years :) until all 457241041Sneel # binaries have had a chance to move towards /var/run/log. 458241041Sneel if [ ! -L /dev/log ]; then 459241041Sneel # might complain for r/o root f/s 460241041Sneel ln -sf /var/run/log /dev/log 461241041Sneel fi 462221828Sgrehan 463241041Sneel rm -f /var/run/log 464241041Sneel echo -n ' syslogd'; 465221828Sgrehan ${syslogd_program:-/usr/sbin/syslogd} ${syslogd_flags} 466241041Sneel ;; 467241041Sneelesac 468221828Sgrehan 469241041Sneelecho '.' 470241041Sneel 471241041Sneel# Build device name databases if we are not using DEVFS 472241041Sneel# 473241041Sneelif sysctl vfs.devfs.generation > /dev/null 2>&1 ; then 474241041Sneel rm -f /var/run/dev.db 475241041Sneelelse 476221828Sgrehan dev_mkdb 477221828Sgrehanfi 478221828Sgrehan 479241178Sneel# Enable dumpdev so that savecore can see it. 480221828Sgrehan# /var/crash should be a directory or a symbolic link 481256072Sneel# to the crash directory if core dumps are to be saved. 482256072Sneel# 483256072Sneelcase ${dumpdev} in 484241178Sneel[Nn][Oo] | '') 485256072Sneel ;; 486256072Sneel*) 487256072Sneel if [ -e "${dumpdev}" -a -d /var/crash ]; then 488241178Sneel /sbin/dumpon -v ${dumpdev} 489256072Sneel echo -n 'Checking for core dump: ' 490256072Sneel /sbin/savecore ${savecore_flags} /var/crash 491256072Sneel fi 492256072Sneel ;; 493256072Sneelesac 494256072Sneel 495256072Sneelif [ -n "${network_pass1_done}" ]; then 496256072Sneel network_pass2 497256072Sneelfi 498256072Sneel 499256072Sneel# Enable/Check the quotas (must be after ypbind if using NIS) 500256072Sneel# 501256072Sneelcase ${enable_quotas} in 502256072Sneel[Yy][Ee][Ss]) 503256072Sneel case ${check_quotas} in 504256072Sneel [Yy][Ee][Ss]) 505256072Sneel echo -n 'Checking quotas:' 506256072Sneel quotacheck -a 507256072Sneel echo ' done.' 508256072Sneel ;; 509256072Sneel esac 510256072Sneel 511256072Sneel echo -n 'Enabling quotas:' 512256072Sneel quotaon -a 513256072Sneel echo ' done.' 514256072Sneel ;; 515256072Sneelesac 516256072Sneel 517256072Sneelif [ -n "${network_pass2_done}" ]; then 518256072Sneel network_pass3 519256072Sneelfi 520256072Sneel 521256072Sneel# Check the password temp/lock file 522256072Sneel# 523256072Sneelif [ -e /etc/ptmp ]; then 524256072Sneel logger -s -p auth.err \ 525256072Sneel "password file may be incorrect -- /etc/ptmp exists" 526256072Sneelfi 527256072Sneel 528256072Sneelcase ${accounting_enable} in 529256072Sneel[Yy][Ee][Ss]) 530256072Sneel if [ -d /var/account ]; then 531256072Sneel echo 'Turning on accounting:' 532241178Sneel if [ ! -e /var/account/acct ]; then 533241178Sneel touch /var/account/acct 534256072Sneel fi 535256072Sneel accton /var/account/acct 536256072Sneel fi 537256072Sneel ;; 538241362Sneelesac 539256072Sneel 540241362Sneel# Make shared lib searching a little faster. Leave /usr/lib first if you 541256072Sneel# add your own entries or you may come to grief. 542256072Sneel# 543256072Sneelldconfig="/sbin/ldconfig" 544241178Sneelcase ${ldconfig_insecure} in 545256072Sneel[Yy][Ee][Ss]) 546256072Sneel ldconfig="${ldconfig} -i" 547256072Sneel ;; 548256072Sneelesac 549256072Sneelif [ -x /sbin/ldconfig ]; then 550256072Sneel case `/usr/bin/objformat` in 551256072Sneel elf) 552256072Sneel _LDC=/usr/lib 553256072Sneel for i in ${ldconfig_paths}; do 554256072Sneel if [ -d "${i}" ]; then 555256072Sneel _LDC="${_LDC} ${i}" 556256072Sneel fi 557256072Sneel done 558256072Sneel echo 'ELF ldconfig path:' ${_LDC} 559256072Sneel ${ldconfig} -elf ${_LDC} 560256072Sneel ;; 561256072Sneel esac 562256072Sneel 563256072Sneel # Legacy aout support for i386 only 564256072Sneel case `sysctl -n hw.machine` in 565256072Sneel i386) 566256072Sneel # Default the a.out ldconfig path. 567256072Sneel : ${ldconfig_paths_aout=${ldconfig_paths}} 568256072Sneel _LDC=/usr/lib/aout 569256072Sneel for i in ${ldconfig_paths_aout}; do 570256072Sneel if [ -d "${i}" ]; then 571256072Sneel _LDC="${_LDC} ${i}" 572256072Sneel fi 573256072Sneel done 574256072Sneel echo 'a.out ldconfig path:' ${_LDC} 575256072Sneel ${ldconfig} -aout ${_LDC} 576256072Sneel ;; 577256072Sneel esac 578256072Sneelfi 579256072Sneel 580256072Sneel# Now start up miscellaneous daemons that don't belong anywhere else 581256072Sneel# 582256072Sneelecho -n 'Starting standard daemons:' 583256072Sneelcase ${inetd_enable} in 584241178Sneel[Nn][Oo]) 585241178Sneel ;; 586256072Sneel*) 587256072Sneel echo -n ' inetd'; ${inetd_program:-/usr/sbin/inetd} ${inetd_flags} 588256072Sneel ;; 589256072Sneelesac 590256072Sneel 591256072Sneelcase ${cron_enable} in 592256072Sneel[Nn][Oo]) 593256072Sneel ;; 594256072Sneel*) 595256072Sneel echo -n ' cron'; ${cron_program:-/usr/sbin/cron} ${cron_flags} 596256072Sneel ;; 597256072Sneelesac 598256072Sneel 599256072Sneelcase ${lpd_enable} in 600256072Sneel[Yy][Ee][Ss]) 601256072Sneel echo -n ' printer'; ${lpd_program:-/usr/sbin/lpd} ${lpd_flags} 602256072Sneel ;; 603256072Sneelesac 604256072Sneel 605256072Sneelcase ${sshd_enable} in 606221828Sgrehan[Yy][Ee][Ss]) 607256072Sneel if [ -x ${sshd_program:-/usr/sbin/sshd} ]; then 608267070Sjhb echo -n ' sshd'; 609256072Sneel ${sshd_program:-/usr/sbin/sshd} ${sshd_flags} 610256072Sneel fi 611221828Sgrehan ;; 612256072Sneelesac 613256072Sneel 614221828Sgrehancase ${usbd_enable} in 615256072Sneel[Yy][Ee][Ss]) 616256072Sneel echo -n ' usbd'; /usr/sbin/usbd ${usbd_flags} 617256072Sneel ;; 618256072Sneelesac 619256072Sneel 620256072Sneelif [ -r /etc/mail/sendmail.cf ]; then 621241362Sneel case ${sendmail_enable} in 622256072Sneel [Yy][Ee][Ss]) 623256072Sneel echo -n ' sendmail' 624256072Sneel /usr/sbin/sendmail ${sendmail_flags} 625256072Sneel ;; 626256072Sneel *) 627241362Sneel case ${sendmail_outbound_enable} in 628267070Sjhb [Yy][Ee][Ss]) 629256072Sneel echo -n ' sendmail' 630256072Sneel /usr/sbin/sendmail ${sendmail_outbound_flags} 631256072Sneel ;; 632256072Sneel esac 633241362Sneel ;; 634256072Sneel esac 635256072Sneelfi 636256072Sneel 637241041Sneelecho '.' 638256072Sneel 639256072Sneel# Recover vi editor files. 640256072Sneelfind /var/tmp/vi.recover ! -type f -a ! -type d -delete 641256072Sneelvibackup=`echo /var/tmp/vi.recover/vi.*` 642256072Sneelif [ "${vibackup}" != '/var/tmp/vi.recover/vi.*' ]; then 643221828Sgrehan echo -n 'Recovering vi editor sessions:' 644221828Sgrehan for i in /var/tmp/vi.recover/vi.*; do 645256072Sneel # Only test files that are readable. 646256072Sneel if [ ! -r "${i}" ]; then 647256072Sneel continue 648221828Sgrehan fi 649256072Sneel 650256072Sneel # Unmodified nvi editor backup files either have the 651221828Sgrehan # execute bit set or are zero length. Delete them. 652256072Sneel if [ -x "${i}" -o ! -s "${i}" ]; then 653256072Sneel rm -f "${i}" 654256072Sneel fi 655241148Sneel done 656256072Sneel 657256072Sneel # It is possible to get incomplete recovery files, if the editor 658256072Sneel # crashes at the right time. 659256072Sneel virecovery=`echo /var/tmp/vi.recover/recover.*` 660256072Sneel if [ "${virecovery}" != "/var/tmp/vi.recover/recover.*" ]; then 661256072Sneel for i in /var/tmp/vi.recover/recover.*; do 662256072Sneel # Only test files that are readable. 663256072Sneel if [ ! -r "${i}" ]; then 664256072Sneel continue 665256072Sneel fi 666221828Sgrehan 667221828Sgrehan # Delete any recovery files that are zero length, 668256072Sneel # corrupted, or that have no corresponding backup file. 669256072Sneel # Else send mail to the user. 670256072Sneel recfile=`awk '/^X-vi-recover-path:/{print $2}' < "${i}"` 671256072Sneel if [ -n "${recfile}" -a -s "${recfile}" ]; then 672256072Sneel sendmail -t < "${i}" 673256072Sneel else 674256072Sneel rm -f "${i}" 675256072Sneel fi 676256072Sneel done 677256072Sneel fi 678221828Sgrehan echo '.' 679221828Sgrehanfi 680221828Sgrehan 681221828Sgrehan# Make a bounds file for msgs(1) if there isn't one already 682221828Sgrehan# 683221828Sgrehanif [ -d /var/msgs -a ! -f /var/msgs/bounds -a ! -L /var/msgs/bounds ]; then 684221828Sgrehan echo 0 > /var/msgs/bounds 685221828Sgrehanfi 686256072Sneel 687256072Sneelcase ${update_motd} in 688256072Sneel[Nn][Oo] | '') 689221828Sgrehan ;; 690221828Sgrehan*) 691221828Sgrehan if T=`mktemp /tmp/_motd.XXXXXX`; then 692221828Sgrehan uname -v | sed -e 's,^\([^#]*\) #\(.* [1-2][0-9][0-9][0-9]\).*/\([^\]*\) $,\1 (\3) #\2,' > ${T} 693221828Sgrehan awk '{if (NR == 1) {if ($1 == "FreeBSD") {next} else {print "\n"$0}} else {print}}' < /etc/motd >> ${T} 694221828Sgrehan cmp -s ${T} /etc/motd || { 695221828Sgrehan cp ${T} /etc/motd 696256072Sneel chmod 644 /etc/motd 697256072Sneel } 698256072Sneel rm -f ${T} 699256072Sneel fi 700256072Sneel ;; 701256072Sneelesac 702256072Sneel 703256072Sneel# Configure implementation specific stuff 704256072Sneel# 705256072Sneelarch=`uname -m` 706256072Sneelif [ -r /etc/rc.${arch} ]; then 707256072Sneel . /etc/rc.${arch} 708256072Sneelfi 709256072Sneel 710256072Sneel# Configure the system console 711256072Sneel# 712256072Sneelif [ -r /etc/rc.syscons ]; then 713256072Sneel . /etc/rc.syscons 714256072Sneelfi 715256072Sneel 716256072Sneel# Run rc.devfs if readable to customize devfs 717256072Sneel# 718256072Sneelif [ -r /etc/rc.devfs ]; then 719256072Sneel sh /etc/rc.devfs 720256072Sneelfi 721256072Sneel 722256072Sneelecho -n 'Additional ABI support:' 723221828Sgrehan 724221828Sgrehan# Load the SysV IPC API if requested. 725221828Sgrehancase ${sysvipc_enable} in 726221828Sgrehan[Yy][Ee][Ss]) 727221828Sgrehan echo -n ' sysvipc' 728221828Sgrehan kldload sysvmsg >/dev/null 2>&1 729221828Sgrehan kldload sysvsem >/dev/null 2>&1 730221828Sgrehan kldload sysvshm >/dev/null 2>&1 731221828Sgrehan ;; 732221828Sgrehanesac 733221828Sgrehan 734221828Sgrehan# Start the Linux binary compatibility if requested. 735221828Sgrehan# 736221828Sgrehancase ${linux_enable} in 737221828Sgrehan[Yy][Ee][Ss]) 738221828Sgrehan echo -n ' linux' 739221828Sgrehan if ! kldstat -v | grep -E 'linux(aout|elf)' > /dev/null; then 740221828Sgrehan kldload linux > /dev/null 2>&1 741221828Sgrehan fi 742221828Sgrehan if [ -x /compat/linux/sbin/ldconfig ]; then 743221828Sgrehan /compat/linux/sbin/ldconfig 744221828Sgrehan fi 745221828Sgrehan ;; 746221828Sgrehanesac 747221828Sgrehan 748221828Sgrehan# Start the SysVR4 binary emulation if requested. 749221828Sgrehan# 750221828Sgrehancase ${svr4_enable} in 751221828Sgrehan[Yy][Ee][Ss]) 752221828Sgrehan echo -n ' svr4'; kldload svr4 > /dev/null 2>&1 753221828Sgrehan ;; 754221828Sgrehanesac 755221828Sgrehan 756221828Sgrehanecho '.' 757221828Sgrehan 758221828Sgrehan# Do traditional (but rather obsolete) rc.local file if it exists. If you 759221828Sgrehan# use this file and want to make it programmatic, source /etc/defaults/rc.conf 760221828Sgrehan# in /etc/rc.local and add your custom variables to /etc/rc.conf, as 761221828Sgrehan# shown below. Please do not put local extensions into /etc/rc itself. 762221828Sgrehan# Use /etc/rc.local 763221828Sgrehan# 764221828Sgrehan# ---- rc.local ---- 765221828Sgrehan# if [ -r /etc/defaults/rc.conf ]; then 766221828Sgrehan# . /etc/defaults/rc.conf 767221828Sgrehan# source_rc_confs 768221828Sgrehan# elif [ -r /etc/rc.conf ]; then 769221828Sgrehan# . /etc/rc.conf 770221828Sgrehan# fi 771221828Sgrehan# 772221828Sgrehan# ... additional startup conditionals ... 773221828Sgrehan# ---- rc.local ---- 774221828Sgrehan# 775221828Sgrehanif [ -r /etc/rc.local ]; then 776221828Sgrehan echo -n 'Starting local daemons:' 777221828Sgrehan sh /etc/rc.local 778221828Sgrehan echo '.' 779221828Sgrehanfi 780221828Sgrehan 781221828Sgrehan# For each valid dir in $local_startup, search for init scripts matching *.sh 782221828Sgrehan# 783221828Sgrehancase ${local_startup} in 784221828Sgrehan[Nn][Oo] | '') 785221828Sgrehan ;; 786221828Sgrehan*) 787221828Sgrehan echo -n 'Local package initialization:' 788221828Sgrehan slist="" 789221828Sgrehan for dir in ${local_startup}; do 790221828Sgrehan if [ -d "${dir}" ]; then 791221828Sgrehan for script in ${dir}/*.sh; do 792221828Sgrehan slist="${slist}${script_name_sep}${script}" 793221828Sgrehan done 794221828Sgrehan fi 795221828Sgrehan done 796221828Sgrehan script_save_sep="$IFS" 797221828Sgrehan IFS="${script_name_sep}" 798221828Sgrehan for script in ${slist}; do 799221828Sgrehan if [ -x "${script}" ]; then 800221828Sgrehan (set -T 801221828Sgrehan trap 'exit 1' 2 802221828Sgrehan sh ${script} start) 803221828Sgrehan fi 804221828Sgrehan done 805221828Sgrehan IFS="${script_save_sep}" 806221828Sgrehan echo '.' 807221828Sgrehan ;; 808221828Sgrehanesac 809221828Sgrehan 810221828Sgrehanif [ -n "${network_pass3_done}" ]; then 811234695Sgrehan network_pass4 812234695Sgrehanfi 813242122Sneel 814242122Sneel# Raise kernel security level. This should be done only after `fsck' has 815221828Sgrehan# repaired local file systems if you want the securelevel to be greater than 1. 816234695Sgrehan# 817242122Sneelcase ${kern_securelevel_enable} in 818242122Sneel[Yy][Ee][Ss]) 819242122Sneel if [ "${kern_securelevel}" -ge 0 ]; then 820242122Sneel echo 'Raising kernel security level: ' 821242122Sneel sysctl -w kern.securelevel=${kern_securelevel} 822242122Sneel fi 823221828Sgrehan ;; 824221828Sgrehanesac 825221828Sgrehan 826221828Sgrehan# Start background fsck checks if necessary 827221828Sgrehancase ${background_fsck} in 828221828Sgrehan[Yy][Ee][Ss]) 829242122Sneel echo 'Starting background filesystem checks' 830242122Sneel nice -4 fsck -B -p 2>&1 | logger -p daemon.notice & 831242122Sneel ;; 832242122Sneelesac 833242122Sneel 834234695Sgrehanecho '' 835221828Sgrehan 836221828Sgrehandate 837221828Sgrehan 838248389Sneelexit 0 839242065Sneel 840256072Sneel