rc revision 76946
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# 2750472Speter# $FreeBSD: head/etc/rc 76946 2001-05-22 00:05:48Z dd $ 28709Swollman# From: @(#)rc 5.27 (Berkeley) 6/5/91 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 7671014Sdougb 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 18468985Sdougbcase ${bootmode} in 18551231Ssheldonhautoboot) 18670109Sdougb echo 'Automatic boot in progress...' 18776946Sdd case ${background_fsck} in 18876946Sdd [Yy][Ee][Ss]) 18976946Sdd fsck -F -p 19076946Sdd ;; 19176946Sdd *) 19276946Sdd fsck -p 19376946Sdd ;; 19476946Sdd esac 19537Srgrimes case $? in 19637Srgrimes 0) 19737Srgrimes ;; 19837Srgrimes 2) 19937Srgrimes exit 1 20037Srgrimes ;; 20137Srgrimes 4) 20237Srgrimes reboot 20370109Sdougb echo 'Reboot failed... help!' 20437Srgrimes exit 1 20537Srgrimes ;; 20637Srgrimes 8) 20772031Sdougb case ${fsck_y_enable} in 20872031Sdougb [Yy][Ee][Ss]) 20972031Sdougb echo 'File system preen failed, trying fsck -y . . .' 21072031Sdougb fsck -y 21172031Sdougb case $? in 21272031Sdougb 0) 21372031Sdougb ;; 21472031Sdougb *) 21572031Sdougb echo 'Automatic file system check failed . . . help!' 21672031Sdougb exit 1 21772031Sdougb ;; 21872031Sdougb esac 21972031Sdougb ;; 22072031Sdougb *) 22172031Sdougb echo 'Automatic file system check failed . . . help!' 22272031Sdougb exit 1 22372031Sdougb ;; 22472031Sdougb esac 22537Srgrimes ;; 22637Srgrimes 12) 22770109Sdougb echo 'Reboot interrupted' 22837Srgrimes exit 1 22937Srgrimes ;; 23037Srgrimes 130) 23137Srgrimes # interrupt before catcher installed 23237Srgrimes exit 1 23337Srgrimes ;; 23437Srgrimes *) 23570109Sdougb echo 'Unknown error in reboot' 23637Srgrimes exit 1 23737Srgrimes ;; 23837Srgrimes esac 23951231Ssheldonh ;; 24051231Ssheldonh*) 24170109Sdougb echo 'Skipping disk checks ...' 24251231Ssheldonh ;; 24351231Ssheldonhesac 24437Srgrimes 24545222Scracauerset -T 24637Srgrimestrap "echo 'Reboot interrupted'; exit 1" 3 24737Srgrimes 24843197Sdillon# root normally must be read/write, but if this is a BOOTP NFS 24943197Sdillon# diskless boot it does not have to be. 25043197Sdillon# 25151231Ssheldonhcase ${root_rw_mount} in 25251231Ssheldonh[Nn][Oo] | '') 25351231Ssheldonh ;; 25451231Ssheldonh*) 25551231Ssheldonh if ! mount -u -o rw / ; then 25670109Sdougb echo 'Mounting root filesystem rw failed, startup aborted' 25751231Ssheldonh exit 1 25851231Ssheldonh fi 25951231Ssheldonh ;; 26051231Ssheldonhesac 2611692Sphk 26243803Sdillonumount -a >/dev/null 2>&1 26343197Sdillon 26456038Sgreen# Mount everything except nfs filesystems. 26556038Sgreenmount -a -t nonfs 26651231Ssheldonh 26751231Ssheldonhcase $? in 26851231Ssheldonh0) 26951231Ssheldonh ;; 27051231Ssheldonh*) 27170109Sdougb echo 'Mounting /etc/fstab filesystems failed, startup aborted' 27243803Sdillon exit 1 27351231Ssheldonh ;; 27451231Ssheldonhesac 27537Srgrimes 27643197Sdillon# Run custom disk mounting function here 27743197Sdillon# 27851231Ssheldonhif [ -n "${diskless_mount}" -a -r "${diskless_mount}" ]; then 27950357Ssheldonh sh ${diskless_mount} 28043197Sdillonfi 28143197Sdillon 28271014Sdougb# Reseed /dev/random with previously stored entropy. 28371014Sdougbcase ${entropy_dir} in 28471014Sdougb[Nn][Oo]) 28567179Sjwd ;; 28667179Sjwd*) 28771014Sdougb entropy_dir=${entropy_dir:-/var/db/entropy} 28871014Sdougb if [ -d "${entropy_dir}" ]; then 28967179Sjwd if [ -w /dev/random ]; then 29071014Sdougb for seedfile in ${entropy_dir}/*; do 29171014Sdougb feed_dev_random "${seedfile}" 29271014Sdougb done 29367179Sjwd fi 29471014Sdougb fi 29567179Sjwd ;; 29667179Sjwdesac 29767179Sjwd 29871014Sdougbcase ${entropy_file} in 29971014Sdougb[Nn][Oo] | '') 30071014Sdougb ;; 30171014Sdougb*) 30271014Sdougb if [ -w /dev/random ]; then 30371014Sdougb feed_dev_random "${entropy_file}" 30471014Sdougb fi 30571014Sdougb ;; 30671014Sdougbesac 30767179Sjwd 3084091Sacheadjkerntz -i 309872Sache 31064400Sbrianpurgedir() { 31164400Sbrian local dir file 31264400Sbrian 31364400Sbrian if [ $# -eq 0 ]; then 31464400Sbrian purgedir . 31564400Sbrian else 31664400Sbrian for dir 31764400Sbrian do 31864400Sbrian ( 31964449Sbrian cd "$dir" && for file in .* * 32064400Sbrian do 32164449Sbrian [ ."$file" = .. -o ."$file" = ... ] && continue 32276430Sbrian if [ -d "$file" -a ! -L "$file" ] 32376430Sbrian then 32464449Sbrian purgedir "$file" 32576430Sbrian else 32676430Sbrian rm -f -- "$file" 32776430Sbrian fi 32864400Sbrian done 32964400Sbrian ) 33064400Sbrian done 33164400Sbrian fi 33264400Sbrian} 33364400Sbrian 33438237Sbrianclean_var() { 33539384Sbrian if [ ! -f /var/run/clean_var ]; then 33671830Sbrian purgedir /var/run /var/spool/lock 33739384Sbrian rm -rf /var/spool/uucp/.Temp/* 33839384Sbrian # Keep a copy of the boot messages around 33939384Sbrian dmesg >/var/run/dmesg.boot 34039384Sbrian # And an initial utmp file 34151231Ssheldonh (cd /var/run && cp /dev/null utmp && chmod 644 utmp;) 34239384Sbrian >/var/run/clean_var 34339384Sbrian fi 34438237Sbrian} 34526450Sache 34638237Sbrianif [ -d /var/run -a -d /var/spool/lock -a -d /var/spool/uucp/.Temp ]; then 34739384Sbrian # network_pass1() *may* end up writing stuff to /var - we don't want to 34839384Sbrian # remove it immediately afterwards - *nor* to we want to fail to clean 34939384Sbrian # an nfs-mounted /var. 35039384Sbrian clean_var 35138237Sbrianfi 35221197Sphk 35317767Sjkh# Add additional swapfile, if configured. 35451231Ssheldonh# 35551231Ssheldonhcase ${swapfile} in 35651231Ssheldonh[Nn][Oo] | '') 35751231Ssheldonh ;; 35851231Ssheldonh*) 35975384Sru if [ -w "${swapfile}" -a -c /dev/mdctl ]; then 36070109Sdougb echo "Adding ${swapfile} as additional swap" 36175384Sru mdev=`mdconfig -a -t vnode -f ${swapfile}` && swapon /dev/${mdev} 36251231Ssheldonh fi 36351231Ssheldonh ;; 36451231Ssheldonhesac 36517767Sjkh 36651231Ssheldonh# Set sysctl variables as early as we can 36751231Ssheldonh# 36851231Ssheldonhif [ -r /etc/rc.sysctl ]; then 36945096Simp . /etc/rc.sysctl 37045096Simpfi 37145096Simp 37251231Ssheldonh# Configure serial devices 37351231Ssheldonh# 37451231Ssheldonhif [ -r /etc/rc.serial ]; then 3757293Sjkh . /etc/rc.serial 3761675Sachefi 3771675Sache 37851231Ssheldonh# Start up PC-card configuration 37951231Ssheldonh# 38051231Ssheldonhif [ -r /etc/rc.pccard ]; then 38114624Snate . /etc/rc.pccard 38214596Snatefi 38314596Snate 38451231Ssheldonh# Start up the initial network configuration. 38551231Ssheldonh# 38651231Ssheldonhif [ -r /etc/rc.network ]; then 38725184Sjkh . /etc/rc.network # We only need to do this once. 38825184Sjkh network_pass1 3897460Sjkhfi 3907460Sjkh 39157398Sshincase ${ipv6_enable} in 39257398Sshin[Yy][Ee][Ss]) 39357398Sshin if [ -r /etc/rc.network6 ]; then 39457398Sshin . /etc/rc.network6 # We only need to do this once also. 39557398Sshin network6_pass1 39657398Sshin fi 39757398Sshin ;; 39857398Sshinesac 39957398Sshin 40058566Sdan# Mount NFS filesystems if present in /etc/fstab 40161065Sasmodaicase "`mount -d -a -t nfs`" in 40261065Sasmodai*mount_nfs*) 40370109Sdougb echo -n 'Mounting NFS file systems:' 40458566Sdan mount -a -t nfs 40570109Sdougb echo '.' 40661065Sasmodai ;; 40761065Sasmodaiesac 4087487Srgrimes 4097487Srgrimes# Whack the pty perms back into shape. 41051231Ssheldonh# 41164893Ssheldonhif ls /dev/tty[pqrsPQRS]* > /dev/null 2>&1; then 41264893Ssheldonh chflags 0 /dev/tty[pqrsPQRS]* 41364893Ssheldonh chmod 666 /dev/tty[pqrsPQRS]* 41464893Ssheldonh chown root:wheel /dev/tty[pqrsPQRS]* 41564893Ssheldonhfi 4167487Srgrimes 41751231Ssheldonh# Clean up left-over files 41851231Ssheldonh# 41938237Sbrianclean_var # If it hasn't already been done 42038237Sbrianrm /var/run/clean_var 42138237Sbrian 42231192Ssteve# Clearing /tmp at boot-time seems to have a long tradition. It doesn't 42331192Ssteve# help in any way for long-living systems, and it might accidentally 42431192Ssteve# clobber files you would rather like to have preserved after a crash 42531192Ssteve# (if not using mfs /tmp anyway). 42631192Ssteve# 42731192Ssteve# See also the example of another cleanup policy in /etc/periodic/daily. 42831192Ssteve# 42951231Ssheldonhcase ${clear_tmp_enable} in 43051231Ssheldonh[Yy][Ee][Ss]) 43170109Sdougb echo -n 'Clearing /tmp:' 43231192Ssteve # prune quickly with one rm, then use find to clean up /tmp/[lq]* 43331192Ssteve # (not needed with mfs /tmp, but doesn't hurt there...) 43431192Ssteve (cd /tmp && rm -rf [a-km-pr-zA-Z]* && 43551231Ssheldonh find -d . ! -name . ! -name lost+found ! -name quota.user \ 43651231Ssheldonh ! -name quota.group -exec rm -rf -- {} \;) 43770109Sdougb echo '.' 43851231Ssheldonh ;; 43951231Ssheldonhesac 44031192Ssteve 44151231Ssheldonh# Remove X lock files, since they will prevent you from restarting X11 44238915Scracauer# after a system crash. 44351231Ssheldonh# 44438915Scracauerrm -f /tmp/.X*-lock /tmp/.X11-unix/* 44538915Scracauer 44651231Ssheldonh# Snapshot any kernel -c changes back to disk here <someday>. 44751231Ssheldonh# This has changed with ELF and /kernel.config. 4487487Srgrimes 44970109Sdougbecho -n 'Additional daemons:' 45051231Ssheldonh 45151231Ssheldonh# Start system logging and name service. Named needs to start before syslogd 45251231Ssheldonh# if you don't have a /etc/resolv.conf. 4537259Sjkh# 45451231Ssheldonhcase ${syslogd_enable} in 45551231Ssheldonh[Yy][Ee][Ss]) 45624463Spst # Transitional symlink (for the next couple of years :) until all 45751231Ssheldonh # binaries have had a chance to move towards /var/run/log. 45875525Sphk if [ ! -L /dev/log ]; then 45924463Spst # might complain for r/o root f/s 46024463Spst ln -sf /var/run/log /dev/log 46124463Spst fi 46224463Spst 46324463Spst rm -f /var/run/log 46451231Ssheldonh echo -n ' syslogd'; syslogd ${syslogd_flags} 46551231Ssheldonh ;; 46651231Ssheldonhesac 46751231Ssheldonh 46825339Sjkhecho '.' 46925339Sjkh 47067445Sphk# Build device name databases if we are not using DEVFS 47167040Sache# 47267445Sphkif sysctl vfs.devfs.generation > /dev/null 2>&1 ; then 47370109Sdougb rm -f /var/run/dev.db 47467445Sphkelse 47567445Sphk dev_mkdb 47667445Sphkfi 47767040Sache 47851231Ssheldonh# Enable dumpdev so that savecore can see it. 47932340Sjoerg# /var/crash should be a directory or a symbolic link 48032340Sjoerg# to the crash directory if core dumps are to be saved. 48151231Ssheldonh# 48251231Ssheldonhcase ${dumpdev} in 48351231Ssheldonh[Nn][Oo] | '') 48451231Ssheldonh ;; 48551231Ssheldonh*) 48651231Ssheldonh if [ -e "${dumpdev}" -a -d /var/crash ]; then 48774140Sdougb /sbin/dumpon -v ${dumpdev} 48870109Sdougb echo -n 'Checking for core dump: ' 48974140Sdougb /sbin/savecore ${savecore_flags} /var/crash 49051231Ssheldonh fi 49151231Ssheldonh ;; 49251231Ssheldonhesac 49332340Sjoerg 49450357Ssheldonhif [ -n "${network_pass1_done}" ]; then 49539384Sbrian network_pass2 496857Sdgfi 49737Srgrimes 49844818Sbillf# Enable/Check the quotas (must be after ypbind if using NIS) 49951231Ssheldonh# 50051231Ssheldonhcase ${enable_quotas} in 50151231Ssheldonh[Yy][Ee][Ss]) 50251231Ssheldonh case ${check_quotas} in 50351231Ssheldonh [Yy][Ee][Ss]) 50470109Sdougb echo -n 'Checking quotas:' 50551231Ssheldonh quotacheck -a 50651231Ssheldonh echo ' done.' 50751231Ssheldonh ;; 50851231Ssheldonh esac 50944818Sbillf 51070109Sdougb echo -n 'Enabling quotas:' 51151231Ssheldonh quotaon -a 51251231Ssheldonh echo ' done.' 51351231Ssheldonh ;; 51451231Ssheldonhesac 51544818Sbillf 51650357Ssheldonhif [ -n "${network_pass2_done}" ]; then 51739384Sbrian network_pass3 5187477Sachefi 5197477Sache 52051231Ssheldonh# Check the password temp/lock file 52151231Ssheldonh# 52251231Ssheldonhif [ -e /etc/ptmp ]; then 5237487Srgrimes logger -s -p auth.err \ 5247487Srgrimes "password file may be incorrect -- /etc/ptmp exists" 5257238Sachefi 5267238Sache 52751231Ssheldonhcase ${accounting_enable} in 52851231Ssheldonh[Yy][Ee][Ss]) 52951231Ssheldonh if [ -d /var/account ]; then 53070109Sdougb echo 'Turning on accounting:' 53151231Ssheldonh if [ ! -e /var/account/acct ]; then 53251231Ssheldonh touch /var/account/acct 53351231Ssheldonh fi 53451231Ssheldonh accton /var/account/acct 53511992Sache fi 53651231Ssheldonh ;; 53751231Ssheldonhesac 5387238Sache 53927365Sjkh# Make shared lib searching a little faster. Leave /usr/lib first if you 54027365Sjkh# add your own entries or you may come to grief. 54151231Ssheldonh# 54264520Sjdpldconfig="/sbin/ldconfig" 54364520Sjdpcase ${ldconfig_insecure} in 54464520Sjdp[Yy][Ee][Ss]) 54564520Sjdp ldconfig="${ldconfig} -i" 54664520Sjdp ;; 54764520Sjdpesac 54838512Sgpalmerif [ -x /sbin/ldconfig ]; then 54951231Ssheldonh case `/usr/bin/objformat` in 55051231Ssheldonh elf) 55139329Sjdp _LDC=/usr/lib 55250357Ssheldonh for i in ${ldconfig_paths}; do 55351231Ssheldonh if [ -d "${i}" ]; then 55450357Ssheldonh _LDC="${_LDC} ${i}" 55539329Sjdp fi 55639329Sjdp done 55770109Sdougb echo 'ELF ldconfig path:' ${_LDC} 55864520Sjdp ${ldconfig} -elf ${_LDC} 55951231Ssheldonh ;; 56051231Ssheldonh esac 56139329Sjdp 56241648Sjb # Legacy aout support for i386 only 56351231Ssheldonh case `sysctl -n hw.machine` in 56451231Ssheldonh i386) 56543951Sjkh # Default the a.out ldconfig path. 56641648Sjb : ${ldconfig_paths_aout=${ldconfig_paths}} 56741648Sjb _LDC=/usr/lib/aout 56850357Ssheldonh for i in ${ldconfig_paths_aout}; do 56951231Ssheldonh if [ -d "${i}" ]; then 57050357Ssheldonh _LDC="${_LDC} ${i}" 57141648Sjb fi 57241648Sjb done 57370109Sdougb echo 'a.out ldconfig path:' ${_LDC} 57464520Sjdp ${ldconfig} -aout ${_LDC} 57551231Ssheldonh ;; 57651231Ssheldonh esac 57738512Sgpalmerfi 5787296Sjkh 57917210Spst# Now start up miscellaneous daemons that don't belong anywhere else 58017210Spst# 58170109Sdougbecho -n 'Starting standard daemons:' 58251231Ssheldonhcase ${inetd_enable} in 58351231Ssheldonh[Nn][Oo]) 58451231Ssheldonh ;; 58551231Ssheldonh*) 58626727Spst echo -n ' inetd'; inetd ${inetd_flags} 58751231Ssheldonh ;; 58851231Ssheldonhesac 58917210Spst 59051231Ssheldonhcase ${cron_enable} in 59151231Ssheldonh[Nn][Oo]) 59251231Ssheldonh ;; 59351231Ssheldonh*) 59471340Sdougb echo -n ' cron'; ${cron_program:-/usr/sbin/cron} ${cron_flags} 59551231Ssheldonh ;; 59651231Ssheldonhesac 59726727Spst 59851231Ssheldonhcase ${lpd_enable} in 59951231Ssheldonh[Yy][Ee][Ss]) 60051231Ssheldonh echo -n ' printer'; ${lpd_program:-/usr/sbin/lpd} ${lpd_flags} 60151231Ssheldonh ;; 60251231Ssheldonhesac 60317210Spst 60457572Smarkmcase ${sshd_enable} in 60557572Smarkm[Yy][Ee][Ss]) 60657572Smarkm if [ -x ${sshd_program:-/usr/sbin/sshd} ]; then 60757572Smarkm echo -n ' sshd'; 60857572Smarkm ${sshd_program:-/usr/sbin/sshd} ${sshd_flags} 60957572Smarkm fi 61057572Smarkm ;; 61157572Smarkmesac 61257572Smarkm 61351231Ssheldonhcase ${usbd_enable} in 61451231Ssheldonh[Yy][Ee][Ss]) 61542498Sn_hibma echo -n ' usbd'; /usr/sbin/usbd ${usbd_flags} 61651231Ssheldonh ;; 61751231Ssheldonhesac 61842498Sn_hibma 61974198Speterif [ -r /etc/mail/sendmail.cf ]; then 62074198Speter case ${sendmail_enable} in 62174198Speter [Yy][Ee][Ss]) 62274198Speter echo -n ' sendmail' 62374198Speter /usr/sbin/sendmail ${sendmail_flags} 62474198Speter ;; 62574198Speter *) 62674198Speter case ${sendmail_outbound_enable} in 62774198Speter [Yy][Ee][Ss]) 62874198Speter echo -n ' sendmail' 62974198Speter /usr/sbin/sendmail ${sendmail_outbound_flags} 63074198Speter ;; 63174198Speter esac 63274198Speter ;; 63374198Speter esac 63474198Speterfi 63574198Speter 63617161Spstecho '.' 63717161Spst 63816671Spst# Recover vi editor files. 63950612Simpfind /var/tmp/vi.recover ! -type f -a ! -type d -delete 64019314Spetervibackup=`echo /var/tmp/vi.recover/vi.*` 64150357Ssheldonhif [ "${vibackup}" != '/var/tmp/vi.recover/vi.*' ]; then 64270109Sdougb echo -n 'Recovering vi editor sessions:' 64355511Speter for i in /var/tmp/vi.recover/vi.*; do 64419314Speter # Only test files that are readable. 64551231Ssheldonh if [ ! -r "${i}" ]; then 64619314Speter continue 64719314Speter fi 64819314Speter 64919314Speter # Unmodified nvi editor backup files either have the 65019314Speter # execute bit set or are zero length. Delete them. 65151231Ssheldonh if [ -x "${i}" -o ! -s "${i}" ]; then 65255451Speter rm -f "${i}" 65319314Speter fi 65416671Spst done 65519314Speter 65619314Speter # It is possible to get incomplete recovery files, if the editor 65719314Speter # crashes at the right time. 65819314Speter virecovery=`echo /var/tmp/vi.recover/recover.*` 65950357Ssheldonh if [ "${virecovery}" != "/var/tmp/vi.recover/recover.*" ]; then 66055511Speter for i in /var/tmp/vi.recover/recover.*; do 66119314Speter # Only test files that are readable. 66251231Ssheldonh if [ ! -r "${i}" ]; then 66319314Speter continue 66419314Speter fi 66519314Speter 66619314Speter # Delete any recovery files that are zero length, 66719314Speter # corrupted, or that have no corresponding backup file. 66819314Speter # Else send mail to the user. 66955453Speter recfile=`awk '/^X-vi-recover-path:/{print $2}' < "${i}"` 67051231Ssheldonh if [ -n "${recfile}" -a -s "${recfile}" ]; then 67155451Speter sendmail -t < "${i}" 67219314Speter else 67355451Speter rm -f "${i}" 67419314Speter fi 67519314Speter done 67619314Speter fi 67770109Sdougb echo '.' 67816671Spstfi 67916671Spst 68051231Ssheldonh# Make a bounds file for msgs(1) if there isn't one already 68151231Ssheldonh# 68270109Sdougbif [ -d /var/msgs -a ! -f /var/msgs/bounds -a ! -L /var/msgs/bounds ]; then 68337899Snectar echo 0 > /var/msgs/bounds 68437899Snectarfi 68537899Snectar 68651231Ssheldonhcase ${update_motd} in 68751231Ssheldonh[Nn][Oo] | '') 68851231Ssheldonh ;; 68951231Ssheldonh*) 69051231Ssheldonh if T=`mktemp /tmp/_motd.XXXXXX`; then 69150357Ssheldonh uname -v | sed -e 's,^\([^#]*\) #\(.* [1-2][0-9][0-9][0-9]\).*/\([^\]*\) $,\1 (\3) #\2,' > ${T} 69250357Ssheldonh awk '{if (NR == 1) {if ($1 == "FreeBSD") {next} else {print "\n"$0}} else {print}}' < /etc/motd >> ${T} 69350357Ssheldonh cmp -s ${T} /etc/motd || { 69450357Ssheldonh cp ${T} /etc/motd 69549451Speter chmod 644 /etc/motd 69649451Speter } 69750357Ssheldonh rm -f ${T} 69849451Speter fi 69951231Ssheldonh ;; 70051231Ssheldonhesac 70151231Ssheldonh 70251617Snsayer# Configure implementation specific stuff 70351617Snsayer# 70451617Snsayerarch=`uname -m` 70551617Snsayerif [ -r /etc/rc.${arch} ]; then 70651617Snsayer . /etc/rc.${arch} 70751617Snsayerfi 70851617Snsayer 70970856Sjhb# Configure the system console 71070856Sjhb# 71170856Sjhbif [ -r /etc/rc.syscons ]; then 71270856Sjhb . /etc/rc.syscons 71370856Sjhbfi 71470856Sjhb 71551231Ssheldonh# Run rc.devfs if readable to customize devfs 71651231Ssheldonh# 71751231Ssheldonhif [ -r /etc/rc.devfs ]; then 71851231Ssheldonh sh /etc/rc.devfs 71941704Sdillonfi 72041704Sdillon 72170109Sdougbecho -n 'Additional ABI support:' 72264684Sobrien 72371121Sdes# Load the SysV IPC API if requested. 72471121Sdescase ${sysvipc_enable} in 72571121Sdes[Yy][Ee][Ss]) 72671121Sdes echo -n ' sysvipc' 72771121Sdes kldload sysvmsg >/dev/null 2>&1 72871121Sdes kldload sysvsem >/dev/null 2>&1 72971121Sdes kldload sysvshm >/dev/null 2>&1 73071121Sdes ;; 73171121Sdesesac 73271121Sdes 73364684Sobrien# Start the Linux binary compatibility if requested. 73464684Sobrien# 73564684Sobriencase ${linux_enable} in 73664684Sobrien[Yy][Ee][Ss]) 73764809Ssheldonh echo -n ' linux' 73864809Ssheldonh if ! kldstat -v | grep -E 'linux(aout|elf)' > /dev/null; then 73964809Ssheldonh kldload linux > /dev/null 2>&1 74064809Ssheldonh fi 74164809Ssheldonh if [ -x /compat/linux/sbin/ldconfig ]; then 74264809Ssheldonh /compat/linux/sbin/ldconfig 74364809Ssheldonh fi 74464684Sobrien ;; 74564684Sobrienesac 74664684Sobrien 74764684Sobrien# Start the SysVR4 binary emulation if requested. 74864684Sobrien# 74964684Sobriencase ${svr4_enable} in 75064684Sobrien[Yy][Ee][Ss]) 75176553Speter echo -n ' svr4'; kldload svr4 > /dev/null 2>&1 75264684Sobrien ;; 75364684Sobrienesac 75464684Sobrien 75570109Sdougbecho '.' 75664810Ssheldonh 75741704Sdillon# Do traditional (but rather obsolete) rc.local file if it exists. If you 75843951Sjkh# use this file and want to make it programmatic, source /etc/defaults/rc.conf 75943951Sjkh# in /etc/rc.local and add your custom variables to /etc/rc.conf, as 76043951Sjkh# shown below. Please do not put local extensions into /etc/rc itself. 76141704Sdillon# Use /etc/rc.local 76241704Sdillon# 76351231Ssheldonh# ---- rc.local ---- 76451231Ssheldonh# if [ -r /etc/defaults/rc.conf ]; then 76551231Ssheldonh# . /etc/defaults/rc.conf 76659674Ssheldonh# source_rc_confs 76759674Ssheldonh# elif [ -r /etc/rc.conf ]; then 76859674Ssheldonh# . /etc/rc.conf 76951231Ssheldonh# fi 77051231Ssheldonh# 77151231Ssheldonh# ... additional startup conditionals ... 77251231Ssheldonh# ---- rc.local ---- 77351231Ssheldonh# 77451231Ssheldonhif [ -r /etc/rc.local ]; then 77570109Sdougb echo -n 'Starting local daemons:' 77651231Ssheldonh sh /etc/rc.local 77743197Sdillon echo '.' 77841704Sdillonfi 77941704Sdillon 78051617Snsayer# For each valid dir in $local_startup, search for init scripts matching *.sh 78151617Snsayer# 78251617Snsayercase ${local_startup} in 78351617Snsayer[Nn][Oo] | '') 78451617Snsayer ;; 78551617Snsayer*) 78651617Snsayer echo -n 'Local package initialization:' 78751617Snsayer for dir in ${local_startup}; do 78851617Snsayer if [ -d "${dir}" ]; then 78951617Snsayer for script in ${dir}/*.sh; do 79051617Snsayer if [ -x "${script}" ]; then 79151617Snsayer (set -T 79251617Snsayer trap 'exit 1' 2 79351617Snsayer ${script} start) 79451617Snsayer fi 79551617Snsayer done 79651617Snsayer fi 79751617Snsayer done 79870109Sdougb echo '.' 79951617Snsayer ;; 80051617Snsayeresac 80151617Snsayer 80253314Sacheif [ -n "${network_pass3_done}" ]; then 80353314Sache network_pass4 80453314Sachefi 80553314Sache 80637106Sjkoshy# Raise kernel security level. This should be done only after `fsck' has 80737106Sjkoshy# repaired local file systems if you want the securelevel to be greater than 1. 80851231Ssheldonh# 80951231Ssheldonhcase ${kern_securelevel_enable} in 81051231Ssheldonh[Yy][Ee][Ss]) 81151231Ssheldonh if [ "${kern_securelevel}" -ge 0 ]; then 81270109Sdougb echo 'Raising kernel security level: ' 81351231Ssheldonh sysctl -w kern.securelevel=${kern_securelevel} 81451231Ssheldonh fi 81551231Ssheldonh ;; 81651231Ssheldonhesac 81737106Sjkoshy 81876946Sdd# Start background fsck checks if necessary 81976946Sddcase ${background_fsck} in 82076946Sdd[Yy][Ee][Ss]) 82176946Sdd echo 'Starting background filesystem checks' 82276946Sdd nice -4 fsck -B -p 2>&1 | logger -p daemon.notice & 82376946Sdd ;; 82476946Sddesac 82576460Smckusick 82670109Sdougbecho '' 82770109Sdougb 82837Srgrimesdate 82970109Sdougb 83037Srgrimesexit 0 83170109Sdougb 832