rc revision 83957
140123Sdes#!/bin/sh 266830Sobrien# 366830Sobrien# Copyright (c) 2000 The FreeBSD Project 466830Sobrien# All rights reserved. 566830Sobrien# 666830Sobrien# Redistribution and use in source and binary forms, with or without 766830Sobrien# modification, are permitted provided that the following conditions 866830Sobrien# are met: 966830Sobrien# 1. Redistributions of source code must retain the above copyright 1066830Sobrien# notice, this list of conditions and the following disclaimer. 1166830Sobrien# 2. Redistributions in binary form must reproduce the above copyright 1266830Sobrien# notice, this list of conditions and the following disclaimer in the 1366830Sobrien# documentation and/or other materials provided with the distribution. 1466830Sobrien# 1566830Sobrien# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 1666830Sobrien# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 1766830Sobrien# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 1866830Sobrien# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 1966830Sobrien# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2066830Sobrien# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2166830Sobrien# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2266830Sobrien# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2366830Sobrien# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2466830Sobrien# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 2566830Sobrien# SUCH DAMAGE. 2666830Sobrien# 2783871Sobrien# @(#)rc 5.27 (Berkeley) 6/5/91 2850472Speter# $FreeBSD: head/etc/rc 83957 2001-09-26 06:17:25Z phk $ 2966830Sobrien# 3037Srgrimes 3137Srgrimes# System startup script run by init on autoboot 3237Srgrimes# or after single-user. 3337Srgrimes# Output and error are redirected to console by init, 3437Srgrimes# and the console is the controlling terminal. 3537Srgrimes 3651231Ssheldonh# Note that almost all of the user-configurable behavior is no longer in 3751231Ssheldonh# this file, but rather in /etc/defaults/rc.conf. Please check that file 3851231Ssheldonh# first before contemplating any changes here. If you do need to change 3951231Ssheldonh# this file for some reason, we would like to know about it. 408460Sjkh 4137Srgrimesstty status '^T' 4237Srgrimes 4337Srgrimes# Set shell to ignore SIGINT (2), but not children; 4437Srgrimes# shell catches SIGQUIT (3) and returns to single user after fsck. 4551231Ssheldonh# 4637Srgrimestrap : 2 4737Srgrimestrap : 3 # shouldn't be needed 4837Srgrimes 4968985Sdougbbootmode=$1 5068985Sdougb 5151231SsheldonhHOME=/ 5220684SjoergPATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin 5351231Ssheldonhexport HOME PATH 5437Srgrimes 5543179Sdillon# BOOTP diskless boot. We have to run the rc file early in order to 5643803Sdillon# retarget various config files. 5743179Sdillon# 5851231Ssheldonhif [ -r /etc/rc.diskless1 ]; then 5943375Sdillon dlv=`/sbin/sysctl -n vfs.nfs.diskless_valid 2> /dev/null` 6043375Sdillon if [ ${dlv:=0} != 0 ]; then 6143803Sdillon . /etc/rc.diskless1 6243179Sdillon fi 6343179Sdillonfi 6443179Sdillon 6543219Speter# If there is a global system configuration file, suck it in. 6643219Speter# 6751231Ssheldonhif [ -r /etc/defaults/rc.conf ]; then 6843849Sjkh . /etc/defaults/rc.conf 6959674Ssheldonh source_rc_confs 7051231Ssheldonhelif [ -r /etc/rc.conf ]; then 7143219Speter . /etc/rc.conf 7243219Speterfi 7343219Speter 7471014Sdougbfeed_dev_random() { 7571014Sdougb if [ -f "${1}" -a -r "${1}" -a -s "${1}" ]; then 7678918Srwatson# echo "Using ${1} as an entropy file" 7771014Sdougb cat "${1}" | dd of=/dev/random bs=8k 2>/dev/null 7871014Sdougb fi 7971014Sdougb} 8071014Sdougb 8169988Sbsdchkdepend() { 8269988Sbsd svc=$1 8369988Sbsd svc_var=$2 8469988Sbsd dep=$3 8569988Sbsd dep_var=$4 8669988Sbsd 8769988Sbsd eval svc_val=\${$svc_var} 8869988Sbsd eval dep_val=\${$dep_var} 8969988Sbsd 9069988Sbsd case ${svc_val} in 9169876Sobrien [Yy][Ee][Ss]) 9269988Sbsd case ${dep_val} in 9369949Sbsd [Yy][Ee][Ss]) 9469988Sbsd ;; 9569949Sbsd *) 9669988Sbsd eval ${dep_var}="YES" 9769988Sbsd echo "DEPENDENCY NOTE: ${dep} will be enabled" \ 9869988Sbsd "to support ${svc}" 9969988Sbsd ;; 10069949Sbsd esac 10169876Sobrien ;; 10269876Sobrien esac 10369988Sbsd} 10467179Sjwd 10569988Sbsdchkdepend amd amd_enable portmap portmap_enable 10669988Sbsdchkdepend NFS nfs_server_enable portmap portmap_enable 10770916Sbsdchkdepend NIS nis_server_enable portmap portmap_enable 10870916Sbsdchkdepend NIS nis_client_enable portmap portmap_enable 10969876Sobrien 11073277Sdougb# Enable harvesting of entropy via devices. The sooner this happens the 11173277Sdougb# better so that we can take advantage of the boot process. 11273277Sdougb# 11373277Sdougbecho -n 'Entropy harvesting:' 11473277Sdougb 11573277Sdougbcase ${harvest_interrupt} in 11673277Sdougb[Nn][Oo]) 11773277Sdougb ;; 11873277Sdougb*) 11973277Sdougb if [ -w /dev/random ]; then 12074075Smarkm /sbin/sysctl -w kern.random.sys.harvest.interrupt=1 >/dev/null 12173277Sdougb echo -n ' interrupts' 12273277Sdougb fi 12373277Sdougb ;; 12473277Sdougbesac 12573277Sdougb 12673277Sdougbcase ${harvest_ethernet} in 12773277Sdougb[Nn][Oo]) 12873277Sdougb ;; 12973277Sdougb*) 13074063Sdougb if [ -w /dev/random ]; then 13174075Smarkm /sbin/sysctl -w kern.random.sys.harvest.ethernet=1 >/dev/null 13273277Sdougb echo -n ' ethernet' 13373277Sdougb fi 13473277Sdougb ;; 13573277Sdougbesac 13673277Sdougb 13773277Sdougbcase ${harvest_p_to_p} in 13873277Sdougb[Nn][Oo]) 13973277Sdougb ;; 14073277Sdougb*) 14174063Sdougb if [ -w /dev/random ]; then 14274075Smarkm /sbin/sysctl -w kern.random.sys.harvest.point_to_point=1 >/dev/null 14373277Sdougb echo -n ' point_to_point' 14473277Sdougb fi 14573277Sdougb ;; 14673277Sdougbesac 14773277Sdougb 14873277Sdougbecho '.' 14973277Sdougb 15071014Sdougb# First pass at reseeding /dev/random. 15167113Smarkm# 15267113Smarkmcase ${entropy_file} in 15367113Smarkm[Nn][Oo] | '') 15467113Smarkm ;; 15567113Smarkm*) 15667113Smarkm if [ -w /dev/random ]; then 15770922Sdougb feed_dev_random "${entropy_file}" 15870922Sdougb fi 15970922Sdougb ;; 16070922Sdougbesac 16170922Sdougb 16274063Sdougb# XXX temporary until we can get the entropy 16374063Sdougb# harvesting rate up 16474063Sdougb# Entropy below is not great, 16574063Sdougb# but better than nothing. 16674063Sdougb( ps -efauxww; sysctl -a; date; df -ib; dmesg; ps -efauxww; ) \ 16774063Sdougb | dd of=/dev/random bs=8k 2>/dev/null 16874063Sdougbcat /bin/ls | dd of=/dev/random bs=8k 2>/dev/null 16974063Sdougb 17015568Sasami# Configure ccd devices. 17151231Ssheldonh# 17251231Ssheldonhif [ -r /etc/ccd.conf ]; then 17315568Sasami ccdconfig -C 17415568Sasamifi 17515568Sasami 17651231Ssheldonhcase ${start_vinum} in 17751231Ssheldonh[Yy][Ee][Ss]) 17845239Sgrog vinum start 17951231Ssheldonh ;; 18051231Ssheldonhesac 18142741Sgrog 18243803Sdillonswapon -a 1833843Sdg 18483957Sphk# Last chance to do things before potentially waiting for 18583957Sphk# operator to do fsck related tasks 18683957Sphkif [ -r /etc/rc.early ]; then 18783957Sphk . /etc/rc.early 18883957Sphkfi 18983957Sphk 19068985Sdougbcase ${bootmode} in 19151231Ssheldonhautoboot) 19270109Sdougb echo 'Automatic boot in progress...' 19376946Sdd case ${background_fsck} in 19476946Sdd [Yy][Ee][Ss]) 19576946Sdd fsck -F -p 19676946Sdd ;; 19776946Sdd *) 19876946Sdd fsck -p 19976946Sdd ;; 20076946Sdd esac 20137Srgrimes case $? in 20237Srgrimes 0) 20337Srgrimes ;; 20437Srgrimes 2) 20537Srgrimes exit 1 20637Srgrimes ;; 20737Srgrimes 4) 20837Srgrimes reboot 20970109Sdougb echo 'Reboot failed... help!' 21037Srgrimes exit 1 21137Srgrimes ;; 21237Srgrimes 8) 21372031Sdougb case ${fsck_y_enable} in 21472031Sdougb [Yy][Ee][Ss]) 21572031Sdougb echo 'File system preen failed, trying fsck -y . . .' 21672031Sdougb fsck -y 21772031Sdougb case $? in 21872031Sdougb 0) 21972031Sdougb ;; 22072031Sdougb *) 22172031Sdougb echo 'Automatic file system check failed . . . help!' 22272031Sdougb exit 1 22372031Sdougb ;; 22472031Sdougb esac 22572031Sdougb ;; 22672031Sdougb *) 22772031Sdougb echo 'Automatic file system check failed . . . help!' 22872031Sdougb exit 1 22972031Sdougb ;; 23072031Sdougb esac 23137Srgrimes ;; 23237Srgrimes 12) 23370109Sdougb echo 'Reboot interrupted' 23437Srgrimes exit 1 23537Srgrimes ;; 23637Srgrimes 130) 23737Srgrimes # interrupt before catcher installed 23837Srgrimes exit 1 23937Srgrimes ;; 24037Srgrimes *) 24170109Sdougb echo 'Unknown error in reboot' 24237Srgrimes exit 1 24337Srgrimes ;; 24437Srgrimes esac 24551231Ssheldonh ;; 24651231Ssheldonh*) 24770109Sdougb echo 'Skipping disk checks ...' 24851231Ssheldonh ;; 24951231Ssheldonhesac 25037Srgrimes 25145222Scracauerset -T 25237Srgrimestrap "echo 'Reboot interrupted'; exit 1" 3 25337Srgrimes 25443197Sdillon# root normally must be read/write, but if this is a BOOTP NFS 25543197Sdillon# diskless boot it does not have to be. 25643197Sdillon# 25751231Ssheldonhcase ${root_rw_mount} in 25851231Ssheldonh[Nn][Oo] | '') 25951231Ssheldonh ;; 26051231Ssheldonh*) 26151231Ssheldonh if ! mount -u -o rw / ; then 26270109Sdougb echo 'Mounting root filesystem rw failed, startup aborted' 26351231Ssheldonh exit 1 26451231Ssheldonh fi 26551231Ssheldonh ;; 26651231Ssheldonhesac 2671692Sphk 26843803Sdillonumount -a >/dev/null 2>&1 26943197Sdillon 27077974Ssheldonh# Mount everything except nfs filesystems. 27177974Ssheldonhmount -a -t nonfs 27251231Ssheldonh 27351231Ssheldonhcase $? in 27451231Ssheldonh0) 27551231Ssheldonh ;; 27651231Ssheldonh*) 27770109Sdougb echo 'Mounting /etc/fstab filesystems failed, startup aborted' 27843803Sdillon exit 1 27951231Ssheldonh ;; 28051231Ssheldonhesac 28137Srgrimes 28243197Sdillon# Run custom disk mounting function here 28343197Sdillon# 28451231Ssheldonhif [ -n "${diskless_mount}" -a -r "${diskless_mount}" ]; then 28550357Ssheldonh sh ${diskless_mount} 28643197Sdillonfi 28743197Sdillon 28871014Sdougb# Reseed /dev/random with previously stored entropy. 28971014Sdougbcase ${entropy_dir} in 29071014Sdougb[Nn][Oo]) 29167179Sjwd ;; 29267179Sjwd*) 29371014Sdougb entropy_dir=${entropy_dir:-/var/db/entropy} 29471014Sdougb if [ -d "${entropy_dir}" ]; then 29567179Sjwd if [ -w /dev/random ]; then 29671014Sdougb for seedfile in ${entropy_dir}/*; do 29771014Sdougb feed_dev_random "${seedfile}" 29871014Sdougb done 29967179Sjwd fi 30071014Sdougb fi 30167179Sjwd ;; 30267179Sjwdesac 30367179Sjwd 30471014Sdougbcase ${entropy_file} in 30571014Sdougb[Nn][Oo] | '') 30671014Sdougb ;; 30771014Sdougb*) 30871014Sdougb if [ -w /dev/random ]; then 30971014Sdougb feed_dev_random "${entropy_file}" 31071014Sdougb fi 31171014Sdougb ;; 31271014Sdougbesac 31367179Sjwd 3144091Sacheadjkerntz -i 315872Sache 31664400Sbrianpurgedir() { 31764400Sbrian local dir file 31864400Sbrian 31964400Sbrian if [ $# -eq 0 ]; then 32064400Sbrian purgedir . 32164400Sbrian else 32264400Sbrian for dir 32364400Sbrian do 32464400Sbrian ( 32564449Sbrian cd "$dir" && for file in .* * 32664400Sbrian do 32764449Sbrian [ ."$file" = .. -o ."$file" = ... ] && continue 32876430Sbrian if [ -d "$file" -a ! -L "$file" ] 32976430Sbrian then 33064449Sbrian purgedir "$file" 33176430Sbrian else 33276430Sbrian rm -f -- "$file" 33376430Sbrian fi 33464400Sbrian done 33564400Sbrian ) 33664400Sbrian done 33764400Sbrian fi 33864400Sbrian} 33964400Sbrian 34038237Sbrianclean_var() { 34139384Sbrian if [ ! -f /var/run/clean_var ]; then 34271830Sbrian purgedir /var/run /var/spool/lock 34339384Sbrian rm -rf /var/spool/uucp/.Temp/* 34439384Sbrian # Keep a copy of the boot messages around 34539384Sbrian dmesg >/var/run/dmesg.boot 34639384Sbrian # And an initial utmp file 34751231Ssheldonh (cd /var/run && cp /dev/null utmp && chmod 644 utmp;) 34839384Sbrian >/var/run/clean_var 34939384Sbrian fi 35038237Sbrian} 35126450Sache 35238237Sbrianif [ -d /var/run -a -d /var/spool/lock -a -d /var/spool/uucp/.Temp ]; then 35339384Sbrian # network_pass1() *may* end up writing stuff to /var - we don't want to 35439384Sbrian # remove it immediately afterwards - *nor* to we want to fail to clean 35539384Sbrian # an nfs-mounted /var. 35639384Sbrian clean_var 35738237Sbrianfi 35821197Sphk 35917767Sjkh# Add additional swapfile, if configured. 36051231Ssheldonh# 36151231Ssheldonhcase ${swapfile} in 36251231Ssheldonh[Nn][Oo] | '') 36351231Ssheldonh ;; 36451231Ssheldonh*) 36575384Sru if [ -w "${swapfile}" -a -c /dev/mdctl ]; then 36670109Sdougb echo "Adding ${swapfile} as additional swap" 36775384Sru mdev=`mdconfig -a -t vnode -f ${swapfile}` && swapon /dev/${mdev} 36851231Ssheldonh fi 36951231Ssheldonh ;; 37051231Ssheldonhesac 37117767Sjkh 37251231Ssheldonh# Set sysctl variables as early as we can 37351231Ssheldonh# 37451231Ssheldonhif [ -r /etc/rc.sysctl ]; then 37545096Simp . /etc/rc.sysctl 37645096Simpfi 37745096Simp 37851231Ssheldonh# Configure serial devices 37951231Ssheldonh# 38051231Ssheldonhif [ -r /etc/rc.serial ]; then 3817293Sjkh . /etc/rc.serial 3821675Sachefi 3831675Sache 38451231Ssheldonh# Start up PC-card configuration 38551231Ssheldonh# 38651231Ssheldonhif [ -r /etc/rc.pccard ]; then 38714624Snate . /etc/rc.pccard 38814596Snatefi 38914596Snate 39051231Ssheldonh# Start up the initial network configuration. 39151231Ssheldonh# 39251231Ssheldonhif [ -r /etc/rc.network ]; then 39325184Sjkh . /etc/rc.network # We only need to do this once. 39425184Sjkh network_pass1 3957460Sjkhfi 3967460Sjkh 39757398Sshincase ${ipv6_enable} in 39857398Sshin[Yy][Ee][Ss]) 39957398Sshin if [ -r /etc/rc.network6 ]; then 40057398Sshin . /etc/rc.network6 # We only need to do this once also. 40157398Sshin network6_pass1 40257398Sshin fi 40357398Sshin ;; 40457398Sshinesac 40557398Sshin 40677974Ssheldonh# Mount NFS filesystems if present in /etc/fstab 40777974Ssheldonhcase "`mount -d -a -t nfs 2> /dev/null`" in 40877974Ssheldonh*mount_nfs*) 40977974Ssheldonh echo -n 'Mounting NFS file systems:' 41077974Ssheldonh mount -a -t nfs 41177974Ssheldonh echo '.' 41277974Ssheldonh ;; 41377974Ssheldonhesac 4147487Srgrimes 4157487Srgrimes# Whack the pty perms back into shape. 41651231Ssheldonh# 41764893Ssheldonhif ls /dev/tty[pqrsPQRS]* > /dev/null 2>&1; then 41864893Ssheldonh chflags 0 /dev/tty[pqrsPQRS]* 41964893Ssheldonh chmod 666 /dev/tty[pqrsPQRS]* 42064893Ssheldonh chown root:wheel /dev/tty[pqrsPQRS]* 42164893Ssheldonhfi 4227487Srgrimes 42351231Ssheldonh# Clean up left-over files 42451231Ssheldonh# 42538237Sbrianclean_var # If it hasn't already been done 42638237Sbrianrm /var/run/clean_var 42738237Sbrian 42831192Ssteve# Clearing /tmp at boot-time seems to have a long tradition. It doesn't 42931192Ssteve# help in any way for long-living systems, and it might accidentally 43031192Ssteve# clobber files you would rather like to have preserved after a crash 43131192Ssteve# (if not using mfs /tmp anyway). 43231192Ssteve# 43331192Ssteve# See also the example of another cleanup policy in /etc/periodic/daily. 43431192Ssteve# 43551231Ssheldonhcase ${clear_tmp_enable} in 43651231Ssheldonh[Yy][Ee][Ss]) 43770109Sdougb echo -n 'Clearing /tmp:' 43831192Ssteve # prune quickly with one rm, then use find to clean up /tmp/[lq]* 43931192Ssteve # (not needed with mfs /tmp, but doesn't hurt there...) 44031192Ssteve (cd /tmp && rm -rf [a-km-pr-zA-Z]* && 44151231Ssheldonh find -d . ! -name . ! -name lost+found ! -name quota.user \ 44251231Ssheldonh ! -name quota.group -exec rm -rf -- {} \;) 44370109Sdougb echo '.' 44451231Ssheldonh ;; 44551231Ssheldonhesac 44631192Ssteve 44751231Ssheldonh# Remove X lock files, since they will prevent you from restarting X11 44838915Scracauer# after a system crash. 44951231Ssheldonh# 45038915Scracauerrm -f /tmp/.X*-lock /tmp/.X11-unix/* 45138915Scracauer 45251231Ssheldonh# Snapshot any kernel -c changes back to disk here <someday>. 45351231Ssheldonh# This has changed with ELF and /kernel.config. 4547487Srgrimes 45570109Sdougbecho -n 'Additional daemons:' 45651231Ssheldonh 45751231Ssheldonh# Start system logging and name service. Named needs to start before syslogd 45851231Ssheldonh# if you don't have a /etc/resolv.conf. 4597259Sjkh# 46051231Ssheldonhcase ${syslogd_enable} in 46151231Ssheldonh[Yy][Ee][Ss]) 46224463Spst # Transitional symlink (for the next couple of years :) until all 46351231Ssheldonh # binaries have had a chance to move towards /var/run/log. 46475525Sphk if [ ! -L /dev/log ]; then 46524463Spst # might complain for r/o root f/s 46624463Spst ln -sf /var/run/log /dev/log 46724463Spst fi 46824463Spst 46924463Spst rm -f /var/run/log 47078905Sdd echo -n ' syslogd'; 47178905Sdd ${syslogd_program:-/usr/sbin/syslogd} ${syslogd_flags} 47251231Ssheldonh ;; 47351231Ssheldonhesac 47451231Ssheldonh 47525339Sjkhecho '.' 47625339Sjkh 47767445Sphk# Build device name databases if we are not using DEVFS 47867040Sache# 47967445Sphkif sysctl vfs.devfs.generation > /dev/null 2>&1 ; then 48070109Sdougb rm -f /var/run/dev.db 48167445Sphkelse 48267445Sphk dev_mkdb 48367445Sphkfi 48467040Sache 48551231Ssheldonh# Enable dumpdev so that savecore can see it. 48632340Sjoerg# /var/crash should be a directory or a symbolic link 48732340Sjoerg# to the crash directory if core dumps are to be saved. 48851231Ssheldonh# 48951231Ssheldonhcase ${dumpdev} in 49051231Ssheldonh[Nn][Oo] | '') 49151231Ssheldonh ;; 49251231Ssheldonh*) 49351231Ssheldonh if [ -e "${dumpdev}" -a -d /var/crash ]; then 49474140Sdougb /sbin/dumpon -v ${dumpdev} 49570109Sdougb echo -n 'Checking for core dump: ' 49674140Sdougb /sbin/savecore ${savecore_flags} /var/crash 49751231Ssheldonh fi 49851231Ssheldonh ;; 49951231Ssheldonhesac 50032340Sjoerg 50150357Ssheldonhif [ -n "${network_pass1_done}" ]; then 50239384Sbrian network_pass2 503857Sdgfi 50437Srgrimes 50544818Sbillf# Enable/Check the quotas (must be after ypbind if using NIS) 50651231Ssheldonh# 50751231Ssheldonhcase ${enable_quotas} in 50851231Ssheldonh[Yy][Ee][Ss]) 50951231Ssheldonh case ${check_quotas} in 51051231Ssheldonh [Yy][Ee][Ss]) 51170109Sdougb echo -n 'Checking quotas:' 51251231Ssheldonh quotacheck -a 51351231Ssheldonh echo ' done.' 51451231Ssheldonh ;; 51551231Ssheldonh esac 51644818Sbillf 51770109Sdougb echo -n 'Enabling quotas:' 51851231Ssheldonh quotaon -a 51951231Ssheldonh echo ' done.' 52051231Ssheldonh ;; 52151231Ssheldonhesac 52244818Sbillf 52350357Ssheldonhif [ -n "${network_pass2_done}" ]; then 52439384Sbrian network_pass3 5257477Sachefi 5267477Sache 52751231Ssheldonh# Check the password temp/lock file 52851231Ssheldonh# 52951231Ssheldonhif [ -e /etc/ptmp ]; then 5307487Srgrimes logger -s -p auth.err \ 5317487Srgrimes "password file may be incorrect -- /etc/ptmp exists" 5327238Sachefi 5337238Sache 53451231Ssheldonhcase ${accounting_enable} in 53551231Ssheldonh[Yy][Ee][Ss]) 53651231Ssheldonh if [ -d /var/account ]; then 53770109Sdougb echo 'Turning on accounting:' 53851231Ssheldonh if [ ! -e /var/account/acct ]; then 53951231Ssheldonh touch /var/account/acct 54051231Ssheldonh fi 54151231Ssheldonh accton /var/account/acct 54211992Sache fi 54351231Ssheldonh ;; 54451231Ssheldonhesac 5457238Sache 54627365Sjkh# Make shared lib searching a little faster. Leave /usr/lib first if you 54727365Sjkh# add your own entries or you may come to grief. 54851231Ssheldonh# 54964520Sjdpldconfig="/sbin/ldconfig" 55064520Sjdpcase ${ldconfig_insecure} in 55164520Sjdp[Yy][Ee][Ss]) 55264520Sjdp ldconfig="${ldconfig} -i" 55364520Sjdp ;; 55464520Sjdpesac 55538512Sgpalmerif [ -x /sbin/ldconfig ]; then 55651231Ssheldonh case `/usr/bin/objformat` in 55751231Ssheldonh elf) 55839329Sjdp _LDC=/usr/lib 55950357Ssheldonh for i in ${ldconfig_paths}; do 56051231Ssheldonh if [ -d "${i}" ]; then 56150357Ssheldonh _LDC="${_LDC} ${i}" 56239329Sjdp fi 56339329Sjdp done 56470109Sdougb echo 'ELF ldconfig path:' ${_LDC} 56564520Sjdp ${ldconfig} -elf ${_LDC} 56651231Ssheldonh ;; 56751231Ssheldonh esac 56839329Sjdp 56941648Sjb # Legacy aout support for i386 only 57051231Ssheldonh case `sysctl -n hw.machine` in 57151231Ssheldonh i386) 57243951Sjkh # Default the a.out ldconfig path. 57341648Sjb : ${ldconfig_paths_aout=${ldconfig_paths}} 57441648Sjb _LDC=/usr/lib/aout 57550357Ssheldonh for i in ${ldconfig_paths_aout}; do 57651231Ssheldonh if [ -d "${i}" ]; then 57750357Ssheldonh _LDC="${_LDC} ${i}" 57841648Sjb fi 57941648Sjb done 58070109Sdougb echo 'a.out ldconfig path:' ${_LDC} 58164520Sjdp ${ldconfig} -aout ${_LDC} 58251231Ssheldonh ;; 58351231Ssheldonh esac 58438512Sgpalmerfi 5857296Sjkh 58617210Spst# Now start up miscellaneous daemons that don't belong anywhere else 58717210Spst# 58870109Sdougbecho -n 'Starting standard daemons:' 58951231Ssheldonhcase ${inetd_enable} in 59051231Ssheldonh[Nn][Oo]) 59151231Ssheldonh ;; 59251231Ssheldonh*) 59378905Sdd echo -n ' inetd'; ${inetd_program:-/usr/sbin/inetd} ${inetd_flags} 59451231Ssheldonh ;; 59551231Ssheldonhesac 59617210Spst 59751231Ssheldonhcase ${cron_enable} in 59851231Ssheldonh[Nn][Oo]) 59951231Ssheldonh ;; 60051231Ssheldonh*) 60171340Sdougb echo -n ' cron'; ${cron_program:-/usr/sbin/cron} ${cron_flags} 60251231Ssheldonh ;; 60351231Ssheldonhesac 60426727Spst 60551231Ssheldonhcase ${lpd_enable} in 60651231Ssheldonh[Yy][Ee][Ss]) 60751231Ssheldonh echo -n ' printer'; ${lpd_program:-/usr/sbin/lpd} ${lpd_flags} 60851231Ssheldonh ;; 60951231Ssheldonhesac 61017210Spst 61157572Smarkmcase ${sshd_enable} in 61257572Smarkm[Yy][Ee][Ss]) 61357572Smarkm if [ -x ${sshd_program:-/usr/sbin/sshd} ]; then 61457572Smarkm echo -n ' sshd'; 61557572Smarkm ${sshd_program:-/usr/sbin/sshd} ${sshd_flags} 61657572Smarkm fi 61757572Smarkm ;; 61857572Smarkmesac 61957572Smarkm 62051231Ssheldonhcase ${usbd_enable} in 62151231Ssheldonh[Yy][Ee][Ss]) 62242498Sn_hibma echo -n ' usbd'; /usr/sbin/usbd ${usbd_flags} 62351231Ssheldonh ;; 62451231Ssheldonhesac 62542498Sn_hibma 62674198Speterif [ -r /etc/mail/sendmail.cf ]; then 62774198Speter case ${sendmail_enable} in 62874198Speter [Yy][Ee][Ss]) 62974198Speter echo -n ' sendmail' 63074198Speter /usr/sbin/sendmail ${sendmail_flags} 63174198Speter ;; 63274198Speter *) 63374198Speter case ${sendmail_outbound_enable} in 63474198Speter [Yy][Ee][Ss]) 63574198Speter echo -n ' sendmail' 63674198Speter /usr/sbin/sendmail ${sendmail_outbound_flags} 63774198Speter ;; 63874198Speter esac 63974198Speter ;; 64074198Speter esac 64174198Speterfi 64274198Speter 64317161Spstecho '.' 64417161Spst 64516671Spst# Recover vi editor files. 64650612Simpfind /var/tmp/vi.recover ! -type f -a ! -type d -delete 64719314Spetervibackup=`echo /var/tmp/vi.recover/vi.*` 64850357Ssheldonhif [ "${vibackup}" != '/var/tmp/vi.recover/vi.*' ]; then 64970109Sdougb echo -n 'Recovering vi editor sessions:' 65055511Speter for i in /var/tmp/vi.recover/vi.*; do 65119314Speter # Only test files that are readable. 65251231Ssheldonh if [ ! -r "${i}" ]; then 65319314Speter continue 65419314Speter fi 65519314Speter 65619314Speter # Unmodified nvi editor backup files either have the 65719314Speter # execute bit set or are zero length. Delete them. 65851231Ssheldonh if [ -x "${i}" -o ! -s "${i}" ]; then 65955451Speter rm -f "${i}" 66019314Speter fi 66116671Spst done 66219314Speter 66319314Speter # It is possible to get incomplete recovery files, if the editor 66419314Speter # crashes at the right time. 66519314Speter virecovery=`echo /var/tmp/vi.recover/recover.*` 66650357Ssheldonh if [ "${virecovery}" != "/var/tmp/vi.recover/recover.*" ]; then 66755511Speter for i in /var/tmp/vi.recover/recover.*; do 66819314Speter # Only test files that are readable. 66951231Ssheldonh if [ ! -r "${i}" ]; then 67019314Speter continue 67119314Speter fi 67219314Speter 67319314Speter # Delete any recovery files that are zero length, 67419314Speter # corrupted, or that have no corresponding backup file. 67519314Speter # Else send mail to the user. 67655453Speter recfile=`awk '/^X-vi-recover-path:/{print $2}' < "${i}"` 67751231Ssheldonh if [ -n "${recfile}" -a -s "${recfile}" ]; then 67855451Speter sendmail -t < "${i}" 67919314Speter else 68055451Speter rm -f "${i}" 68119314Speter fi 68219314Speter done 68319314Speter fi 68470109Sdougb echo '.' 68516671Spstfi 68616671Spst 68751231Ssheldonh# Make a bounds file for msgs(1) if there isn't one already 68851231Ssheldonh# 68970109Sdougbif [ -d /var/msgs -a ! -f /var/msgs/bounds -a ! -L /var/msgs/bounds ]; then 69037899Snectar echo 0 > /var/msgs/bounds 69137899Snectarfi 69237899Snectar 69351231Ssheldonhcase ${update_motd} in 69451231Ssheldonh[Nn][Oo] | '') 69551231Ssheldonh ;; 69651231Ssheldonh*) 69751231Ssheldonh if T=`mktemp /tmp/_motd.XXXXXX`; then 69850357Ssheldonh uname -v | sed -e 's,^\([^#]*\) #\(.* [1-2][0-9][0-9][0-9]\).*/\([^\]*\) $,\1 (\3) #\2,' > ${T} 69950357Ssheldonh awk '{if (NR == 1) {if ($1 == "FreeBSD") {next} else {print "\n"$0}} else {print}}' < /etc/motd >> ${T} 70050357Ssheldonh cmp -s ${T} /etc/motd || { 70150357Ssheldonh cp ${T} /etc/motd 70249451Speter chmod 644 /etc/motd 70349451Speter } 70450357Ssheldonh rm -f ${T} 70549451Speter fi 70651231Ssheldonh ;; 70751231Ssheldonhesac 70851231Ssheldonh 70983956Sobrien# Run rc.devfs if readable to customize devfs 71083956Sobrien# 71183956Sobrienif [ -r /etc/rc.devfs ]; then 71283956Sobrien sh /etc/rc.devfs 71383956Sobrienfi 71483956Sobrien 71551617Snsayer# Configure implementation specific stuff 71651617Snsayer# 71751617Snsayerarch=`uname -m` 71851617Snsayerif [ -r /etc/rc.${arch} ]; then 71951617Snsayer . /etc/rc.${arch} 72051617Snsayerfi 72151617Snsayer 72270856Sjhb# Configure the system console 72370856Sjhb# 72470856Sjhbif [ -r /etc/rc.syscons ]; then 72570856Sjhb . /etc/rc.syscons 72670856Sjhbfi 72770856Sjhb 72870109Sdougbecho -n 'Additional ABI support:' 72964684Sobrien 73071121Sdes# Load the SysV IPC API if requested. 73171121Sdescase ${sysvipc_enable} in 73271121Sdes[Yy][Ee][Ss]) 73371121Sdes echo -n ' sysvipc' 73471121Sdes kldload sysvmsg >/dev/null 2>&1 73571121Sdes kldload sysvsem >/dev/null 2>&1 73671121Sdes kldload sysvshm >/dev/null 2>&1 73771121Sdes ;; 73871121Sdesesac 73971121Sdes 74064684Sobrien# Start the Linux binary compatibility if requested. 74164684Sobrien# 74264684Sobriencase ${linux_enable} in 74364684Sobrien[Yy][Ee][Ss]) 74464809Ssheldonh echo -n ' linux' 74564809Ssheldonh if ! kldstat -v | grep -E 'linux(aout|elf)' > /dev/null; then 74664809Ssheldonh kldload linux > /dev/null 2>&1 74764809Ssheldonh fi 74864809Ssheldonh if [ -x /compat/linux/sbin/ldconfig ]; then 74964809Ssheldonh /compat/linux/sbin/ldconfig 75064809Ssheldonh fi 75164684Sobrien ;; 75264684Sobrienesac 75364684Sobrien 75464684Sobrien# Start the SysVR4 binary emulation if requested. 75564684Sobrien# 75664684Sobriencase ${svr4_enable} in 75764684Sobrien[Yy][Ee][Ss]) 75876553Speter echo -n ' svr4'; kldload svr4 > /dev/null 2>&1 75964684Sobrien ;; 76064684Sobrienesac 76164684Sobrien 76270109Sdougbecho '.' 76364810Ssheldonh 76441704Sdillon# Do traditional (but rather obsolete) rc.local file if it exists. If you 76543951Sjkh# use this file and want to make it programmatic, source /etc/defaults/rc.conf 76643951Sjkh# in /etc/rc.local and add your custom variables to /etc/rc.conf, as 76743951Sjkh# shown below. Please do not put local extensions into /etc/rc itself. 76841704Sdillon# Use /etc/rc.local 76941704Sdillon# 77051231Ssheldonh# ---- rc.local ---- 77151231Ssheldonh# if [ -r /etc/defaults/rc.conf ]; then 77251231Ssheldonh# . /etc/defaults/rc.conf 77359674Ssheldonh# source_rc_confs 77459674Ssheldonh# elif [ -r /etc/rc.conf ]; then 77559674Ssheldonh# . /etc/rc.conf 77651231Ssheldonh# fi 77751231Ssheldonh# 77851231Ssheldonh# ... additional startup conditionals ... 77951231Ssheldonh# ---- rc.local ---- 78051231Ssheldonh# 78151231Ssheldonhif [ -r /etc/rc.local ]; then 78270109Sdougb echo -n 'Starting local daemons:' 78351231Ssheldonh sh /etc/rc.local 78443197Sdillon echo '.' 78541704Sdillonfi 78641704Sdillon 78751617Snsayer# For each valid dir in $local_startup, search for init scripts matching *.sh 78851617Snsayer# 78951617Snsayercase ${local_startup} in 79051617Snsayer[Nn][Oo] | '') 79151617Snsayer ;; 79251617Snsayer*) 79351617Snsayer echo -n 'Local package initialization:' 79479825Sroam slist="" 79551617Snsayer for dir in ${local_startup}; do 79651617Snsayer if [ -d "${dir}" ]; then 79751617Snsayer for script in ${dir}/*.sh; do 79879825Sroam slist="${slist}${script_name_sep}${script}" 79951617Snsayer done 80051617Snsayer fi 80151617Snsayer done 80279825Sroam script_save_sep="$IFS" 80379825Sroam IFS="${script_name_sep}" 80479825Sroam for script in ${slist}; do 80579825Sroam if [ -x "${script}" ]; then 80679825Sroam (set -T 80779825Sroam trap 'exit 1' 2 80883897Sobrien ${script} start) 80983916Sobrien else 81083916Sobrien echo "Skipping ${script}, not executable" 81179825Sroam fi 81279825Sroam done 81379825Sroam IFS="${script_save_sep}" 81470109Sdougb echo '.' 81551617Snsayer ;; 81651617Snsayeresac 81751617Snsayer 81853314Sacheif [ -n "${network_pass3_done}" ]; then 81953314Sache network_pass4 82053314Sachefi 82153314Sache 82237106Sjkoshy# Raise kernel security level. This should be done only after `fsck' has 82337106Sjkoshy# repaired local file systems if you want the securelevel to be greater than 1. 82451231Ssheldonh# 82551231Ssheldonhcase ${kern_securelevel_enable} in 82651231Ssheldonh[Yy][Ee][Ss]) 82751231Ssheldonh if [ "${kern_securelevel}" -ge 0 ]; then 82870109Sdougb echo 'Raising kernel security level: ' 82951231Ssheldonh sysctl -w kern.securelevel=${kern_securelevel} 83051231Ssheldonh fi 83151231Ssheldonh ;; 83251231Ssheldonhesac 83337106Sjkoshy 83476946Sdd# Start background fsck checks if necessary 83576946Sddcase ${background_fsck} in 83676946Sdd[Yy][Ee][Ss]) 83776946Sdd echo 'Starting background filesystem checks' 83876946Sdd nice -4 fsck -B -p 2>&1 | logger -p daemon.notice & 83976946Sdd ;; 84076946Sddesac 84176460Smckusick 84270109Sdougbecho '' 84370109Sdougb 84437Srgrimesdate 84570109Sdougb 84637Srgrimesexit 0 84770109Sdougb 848