rc revision 66830
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 66830 2000-10-08 19:20:36Z obrien $ 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 4951231SsheldonhHOME=/ 5020684SjoergPATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin 5151231Ssheldonhexport HOME PATH 5237Srgrimes 5343179Sdillon# BOOTP diskless boot. We have to run the rc file early in order to 5443803Sdillon# retarget various config files. 5543179Sdillon# 5651231Ssheldonhif [ -r /etc/rc.diskless1 ]; then 5743375Sdillon dlv=`/sbin/sysctl -n vfs.nfs.diskless_valid 2> /dev/null` 5843375Sdillon if [ ${dlv:=0} != 0 ]; then 5943803Sdillon . /etc/rc.diskless1 6043179Sdillon fi 6143179Sdillonfi 6243179Sdillon 6343219Speter# If there is a global system configuration file, suck it in. 6443219Speter# 6551231Ssheldonhif [ -r /etc/defaults/rc.conf ]; then 6643849Sjkh . /etc/defaults/rc.conf 6759674Ssheldonh source_rc_confs 6851231Ssheldonhelif [ -r /etc/rc.conf ]; then 6943219Speter . /etc/rc.conf 7043219Speterfi 7143219Speter 7215568Sasami# Configure ccd devices. 7351231Ssheldonh# 7451231Ssheldonhif [ -r /etc/ccd.conf ]; then 7515568Sasami ccdconfig -C 7615568Sasamifi 7715568Sasami 7851231Ssheldonhcase ${start_vinum} in 7951231Ssheldonh[Yy][Ee][Ss]) 8045239Sgrog vinum start 8151231Ssheldonh ;; 8251231Ssheldonhesac 8342741Sgrog 8443803Sdillonswapon -a 853843Sdg 8651231Ssheldonhcase $1 in 8751231Ssheldonhautoboot) 8860350Sdavidn echo Automatic boot in progress... 8937Srgrimes fsck -p 9037Srgrimes case $? in 9137Srgrimes 0) 9237Srgrimes ;; 9337Srgrimes 2) 9437Srgrimes exit 1 9537Srgrimes ;; 9637Srgrimes 4) 9737Srgrimes reboot 9837Srgrimes echo "reboot failed... help!" 9937Srgrimes exit 1 10037Srgrimes ;; 10137Srgrimes 8) 10237Srgrimes echo "Automatic file system check failed... help!" 10337Srgrimes exit 1 10437Srgrimes ;; 10537Srgrimes 12) 10637Srgrimes echo "Reboot interrupted" 10737Srgrimes exit 1 10837Srgrimes ;; 10937Srgrimes 130) 11037Srgrimes # interrupt before catcher installed 11137Srgrimes exit 1 11237Srgrimes ;; 11337Srgrimes *) 11437Srgrimes echo "Unknown error in reboot" 11537Srgrimes exit 1 11637Srgrimes ;; 11737Srgrimes esac 11851231Ssheldonh ;; 11951231Ssheldonh*) 1202164Sdg echo Skipping disk checks ... 12151231Ssheldonh ;; 12251231Ssheldonhesac 12337Srgrimes 12445222Scracauerset -T 12537Srgrimestrap "echo 'Reboot interrupted'; exit 1" 3 12637Srgrimes 12743197Sdillon# root normally must be read/write, but if this is a BOOTP NFS 12843197Sdillon# diskless boot it does not have to be. 12943197Sdillon# 13051231Ssheldonhcase ${root_rw_mount} in 13151231Ssheldonh[Nn][Oo] | '') 13251231Ssheldonh ;; 13351231Ssheldonh*) 13451231Ssheldonh if ! mount -u -o rw / ; then 13551231Ssheldonh echo "Mounting root filesystem rw failed, startup aborted" 13651231Ssheldonh exit 1 13751231Ssheldonh fi 13851231Ssheldonh ;; 13951231Ssheldonhesac 1401692Sphk 14143803Sdillonumount -a >/dev/null 2>&1 14243197Sdillon 14356038Sgreen# Mount everything except nfs filesystems. 14456038Sgreenmount -a -t nonfs 14551231Ssheldonh 14651231Ssheldonhcase $? in 14751231Ssheldonh0) 14851231Ssheldonh ;; 14951231Ssheldonh*) 15051231Ssheldonh echo "Mounting /etc/fstab filesystems failed, startup aborted" 15143803Sdillon exit 1 15251231Ssheldonh ;; 15351231Ssheldonhesac 15437Srgrimes 15543197Sdillon# Run custom disk mounting function here 15643197Sdillon# 15751231Ssheldonhif [ -n "${diskless_mount}" -a -r "${diskless_mount}" ]; then 15850357Ssheldonh sh ${diskless_mount} 15943197Sdillonfi 16043197Sdillon 16163307Smarkm# Recover some entropy so the rebooting /dev/random can reseed 16263307Smarkm# 16363307Smarkmcase ${entropy_file} in 16463307Smarkm[Nn][Oo] | '') 16563307Smarkm ;; 16663307Smarkm*) 16763793Ssheldonh if [ -f ${entropy_file} -a -r ${entropy_file} -a -w /dev/random ]; then 16863311Ssheldonh echo "Reading entropy file" 16964892Ssheldonh cat ${entropy_file} > /dev/random 17063307Smarkm rm -f ${entropy_file} 17163307Smarkm fi 17263307Smarkm ;; 17363307Smarkmesac 17463307Smarkm 1754091Sacheadjkerntz -i 176872Sache 17764400Sbrianpurgedir() { 17864400Sbrian local dir file 17964400Sbrian 18064400Sbrian if [ $# -eq 0 ]; then 18164400Sbrian purgedir . 18264400Sbrian else 18364400Sbrian for dir 18464400Sbrian do 18564400Sbrian ( 18664449Sbrian cd "$dir" && for file in .* * 18764400Sbrian do 18864449Sbrian [ ."$file" = .. -o ."$file" = ... ] && continue 18964449Sbrian [ -d "$file" -a ! -L "$file" ] && 19064449Sbrian purgedir "$file" 19164449Sbrian [ -f "$file" ] && rm -f -- "$file" 19264400Sbrian done 19364400Sbrian ) 19464400Sbrian done 19564400Sbrian fi 19664400Sbrian} 19764400Sbrian 19838237Sbrianclean_var() { 19939384Sbrian if [ ! -f /var/run/clean_var ]; then 20039384Sbrian rm -rf /var/run/* 20164400Sbrian purgedir /var/spool/lock 20239384Sbrian rm -rf /var/spool/uucp/.Temp/* 20339384Sbrian # Keep a copy of the boot messages around 20439384Sbrian dmesg >/var/run/dmesg.boot 20539384Sbrian # And an initial utmp file 20651231Ssheldonh (cd /var/run && cp /dev/null utmp && chmod 644 utmp;) 20739384Sbrian >/var/run/clean_var 20839384Sbrian fi 20938237Sbrian} 21026450Sache 21138237Sbrianif [ -d /var/run -a -d /var/spool/lock -a -d /var/spool/uucp/.Temp ]; then 21239384Sbrian # network_pass1() *may* end up writing stuff to /var - we don't want to 21339384Sbrian # remove it immediately afterwards - *nor* to we want to fail to clean 21439384Sbrian # an nfs-mounted /var. 21539384Sbrian clean_var 21638237Sbrianfi 21721197Sphk 21817767Sjkh# Add additional swapfile, if configured. 21951231Ssheldonh# 22051231Ssheldonhcase ${swapfile} in 22151231Ssheldonh[Nn][Oo] | '') 22251231Ssheldonh ;; 22351231Ssheldonh*) 22456969Snsayer if [ -w "${swapfile}" -a -c /dev/vn0b ]; then 22551231Ssheldonh echo "Adding ${swapfile} as additional swap." 22651231Ssheldonh vnconfig /dev/vn0b ${swapfile} && swapon /dev/vn0b 22751231Ssheldonh fi 22851231Ssheldonh ;; 22951231Ssheldonhesac 23017767Sjkh 23151231Ssheldonh# Set sysctl variables as early as we can 23251231Ssheldonh# 23351231Ssheldonhif [ -r /etc/rc.sysctl ]; then 23445096Simp . /etc/rc.sysctl 23545096Simpfi 23645096Simp 23751231Ssheldonh# Configure serial devices 23851231Ssheldonh# 23951231Ssheldonhif [ -r /etc/rc.serial ]; then 2407293Sjkh . /etc/rc.serial 2411675Sachefi 2421675Sache 24351231Ssheldonh# Start up PC-card configuration 24451231Ssheldonh# 24551231Ssheldonhif [ -r /etc/rc.pccard ]; then 24614624Snate . /etc/rc.pccard 24714596Snatefi 24814596Snate 24951231Ssheldonh# Start up the initial network configuration. 25051231Ssheldonh# 25151231Ssheldonhif [ -r /etc/rc.network ]; then 25225184Sjkh . /etc/rc.network # We only need to do this once. 25325184Sjkh network_pass1 2547460Sjkhfi 2557460Sjkh 25657398Sshincase ${ipv6_enable} in 25757398Sshin[Yy][Ee][Ss]) 25857398Sshin if [ -r /etc/rc.network6 ]; then 25957398Sshin . /etc/rc.network6 # We only need to do this once also. 26057398Sshin network6_pass1 26157398Sshin fi 26257398Sshin ;; 26357398Sshinesac 26457398Sshin 26558566Sdan# Mount NFS filesystems if present in /etc/fstab 26661065Sasmodaicase "`mount -d -a -t nfs`" in 26761065Sasmodai*mount_nfs*) 26858566Sdan echo -n "Mounting NFS file systems" 26958566Sdan mount -a -t nfs 27058566Sdan echo . 27161065Sasmodai ;; 27261065Sasmodaiesac 2737487Srgrimes 2747487Srgrimes# Whack the pty perms back into shape. 27551231Ssheldonh# 27664893Ssheldonhif ls /dev/tty[pqrsPQRS]* > /dev/null 2>&1; then 27764893Ssheldonh chflags 0 /dev/tty[pqrsPQRS]* 27864893Ssheldonh chmod 666 /dev/tty[pqrsPQRS]* 27964893Ssheldonh chown root:wheel /dev/tty[pqrsPQRS]* 28064893Ssheldonhfi 2817487Srgrimes 28251231Ssheldonh# Clean up left-over files 28351231Ssheldonh# 28438237Sbrianclean_var # If it hasn't already been done 28538237Sbrianrm /var/run/clean_var 28638237Sbrian 28731192Ssteve# Clearing /tmp at boot-time seems to have a long tradition. It doesn't 28831192Ssteve# help in any way for long-living systems, and it might accidentally 28931192Ssteve# clobber files you would rather like to have preserved after a crash 29031192Ssteve# (if not using mfs /tmp anyway). 29131192Ssteve# 29231192Ssteve# See also the example of another cleanup policy in /etc/periodic/daily. 29331192Ssteve# 29451231Ssheldonhcase ${clear_tmp_enable} in 29551231Ssheldonh[Yy][Ee][Ss]) 29631192Ssteve echo clearing /tmp 29731192Ssteve # prune quickly with one rm, then use find to clean up /tmp/[lq]* 29831192Ssteve # (not needed with mfs /tmp, but doesn't hurt there...) 29931192Ssteve (cd /tmp && rm -rf [a-km-pr-zA-Z]* && 30051231Ssheldonh find -d . ! -name . ! -name lost+found ! -name quota.user \ 30151231Ssheldonh ! -name quota.group -exec rm -rf -- {} \;) 30251231Ssheldonh ;; 30351231Ssheldonhesac 30431192Ssteve 30551231Ssheldonh# Remove X lock files, since they will prevent you from restarting X11 30638915Scracauer# after a system crash. 30751231Ssheldonh# 30838915Scracauerrm -f /tmp/.X*-lock /tmp/.X11-unix/* 30938915Scracauer 31051231Ssheldonh# Snapshot any kernel -c changes back to disk here <someday>. 31151231Ssheldonh# This has changed with ELF and /kernel.config. 3127487Srgrimes 31325339Sjkhecho -n 'additional daemons:' 31451231Ssheldonh 31551231Ssheldonh# Start system logging and name service. Named needs to start before syslogd 31651231Ssheldonh# if you don't have a /etc/resolv.conf. 3177259Sjkh# 31851231Ssheldonhcase ${syslogd_enable} in 31951231Ssheldonh[Yy][Ee][Ss]) 32024463Spst # Transitional symlink (for the next couple of years :) until all 32151231Ssheldonh # binaries have had a chance to move towards /var/run/log. 32251231Ssheldonh if [ ! -h /dev/log ]; then 32324463Spst # might complain for r/o root f/s 32424463Spst ln -sf /var/run/log /dev/log 32524463Spst fi 32624463Spst 32724463Spst rm -f /var/run/log 32851231Ssheldonh echo -n ' syslogd'; syslogd ${syslogd_flags} 32951231Ssheldonh ;; 33051231Ssheldonhesac 33151231Ssheldonh 33225339Sjkhecho '.' 33325339Sjkh 33451231Ssheldonh# Enable dumpdev so that savecore can see it. 33532340Sjoerg# /var/crash should be a directory or a symbolic link 33632340Sjoerg# to the crash directory if core dumps are to be saved. 33751231Ssheldonh# 33851231Ssheldonhcase ${dumpdev} in 33951231Ssheldonh[Nn][Oo] | '') 34051231Ssheldonh ;; 34151231Ssheldonh*) 34251231Ssheldonh if [ -e "${dumpdev}" -a -d /var/crash ]; then 34351231Ssheldonh dumpon ${dumpdev} 34451231Ssheldonh echo -n checking for core dump... 34551231Ssheldonh savecore /var/crash 34651231Ssheldonh fi 34751231Ssheldonh ;; 34851231Ssheldonhesac 34932340Sjoerg 35050357Ssheldonhif [ -n "${network_pass1_done}" ]; then 35139384Sbrian network_pass2 352857Sdgfi 35337Srgrimes 35444818Sbillf# Enable/Check the quotas (must be after ypbind if using NIS) 35551231Ssheldonh# 35651231Ssheldonhcase ${enable_quotas} in 35751231Ssheldonh[Yy][Ee][Ss]) 35851231Ssheldonh case ${check_quotas} in 35951231Ssheldonh [Yy][Ee][Ss]) 36051231Ssheldonh echo -n 'checking quotas:' 36151231Ssheldonh quotacheck -a 36251231Ssheldonh echo ' done.' 36351231Ssheldonh ;; 36451231Ssheldonh esac 36544818Sbillf 36651231Ssheldonh echo -n 'enabling quotas:' 36751231Ssheldonh quotaon -a 36851231Ssheldonh echo ' done.' 36951231Ssheldonh ;; 37051231Ssheldonhesac 37144818Sbillf 37250357Ssheldonhif [ -n "${network_pass2_done}" ]; then 37339384Sbrian network_pass3 3747477Sachefi 3757477Sache 37651231Ssheldonh# Build ps databases 37751231Ssheldonh# 3787487Srgrimesdev_mkdb 3797487Srgrimes 38051231Ssheldonh# Check the password temp/lock file 38151231Ssheldonh# 38251231Ssheldonhif [ -e /etc/ptmp ]; then 3837487Srgrimes logger -s -p auth.err \ 3847487Srgrimes "password file may be incorrect -- /etc/ptmp exists" 3857238Sachefi 3867238Sache 38751231Ssheldonhcase ${accounting_enable} in 38851231Ssheldonh[Yy][Ee][Ss]) 38951231Ssheldonh if [ -d /var/account ]; then 39051231Ssheldonh echo 'turning on accounting' 39151231Ssheldonh if [ ! -e /var/account/acct ]; then 39251231Ssheldonh touch /var/account/acct 39351231Ssheldonh fi 39451231Ssheldonh accton /var/account/acct 39511992Sache fi 39651231Ssheldonh ;; 39751231Ssheldonhesac 3987238Sache 39927365Sjkh# Make shared lib searching a little faster. Leave /usr/lib first if you 40027365Sjkh# add your own entries or you may come to grief. 40151231Ssheldonh# 40264520Sjdpldconfig="/sbin/ldconfig" 40364520Sjdpcase ${ldconfig_insecure} in 40464520Sjdp[Yy][Ee][Ss]) 40564520Sjdp ldconfig="${ldconfig} -i" 40664520Sjdp ;; 40764520Sjdpesac 40838512Sgpalmerif [ -x /sbin/ldconfig ]; then 40951231Ssheldonh case `/usr/bin/objformat` in 41051231Ssheldonh elf) 41139329Sjdp _LDC=/usr/lib 41250357Ssheldonh for i in ${ldconfig_paths}; do 41351231Ssheldonh if [ -d "${i}" ]; then 41450357Ssheldonh _LDC="${_LDC} ${i}" 41539329Sjdp fi 41639329Sjdp done 41739329Sjdp echo 'setting ELF ldconfig path:' ${_LDC} 41864520Sjdp ${ldconfig} -elf ${_LDC} 41951231Ssheldonh ;; 42051231Ssheldonh esac 42139329Sjdp 42241648Sjb # Legacy aout support for i386 only 42351231Ssheldonh case `sysctl -n hw.machine` in 42451231Ssheldonh i386) 42543951Sjkh # Default the a.out ldconfig path. 42641648Sjb : ${ldconfig_paths_aout=${ldconfig_paths}} 42741648Sjb _LDC=/usr/lib/aout 42850357Ssheldonh for i in ${ldconfig_paths_aout}; do 42951231Ssheldonh if [ -d "${i}" ]; then 43050357Ssheldonh _LDC="${_LDC} ${i}" 43141648Sjb fi 43241648Sjb done 43341648Sjb echo 'setting a.out ldconfig path:' ${_LDC} 43464520Sjdp ${ldconfig} -aout ${_LDC} 43551231Ssheldonh ;; 43651231Ssheldonh esac 43738512Sgpalmerfi 4387296Sjkh 43917210Spst# Now start up miscellaneous daemons that don't belong anywhere else 44017210Spst# 44125339Sjkhecho -n starting standard daemons: 44251231Ssheldonhcase ${inetd_enable} in 44351231Ssheldonh[Nn][Oo]) 44451231Ssheldonh ;; 44551231Ssheldonh*) 44626727Spst echo -n ' inetd'; inetd ${inetd_flags} 44751231Ssheldonh ;; 44851231Ssheldonhesac 44917210Spst 45051231Ssheldonhcase ${cron_enable} in 45151231Ssheldonh[Nn][Oo]) 45251231Ssheldonh ;; 45351231Ssheldonh*) 45426727Spst echo -n ' cron'; cron 45551231Ssheldonh ;; 45651231Ssheldonhesac 45726727Spst 45851231Ssheldonhcase ${lpd_enable} in 45951231Ssheldonh[Yy][Ee][Ss]) 46051231Ssheldonh echo -n ' printer'; ${lpd_program:-/usr/sbin/lpd} ${lpd_flags} 46151231Ssheldonh ;; 46251231Ssheldonhesac 46317210Spst 46451231Ssheldonhcase ${sendmail_enable} in 46551231Ssheldonh[Yy][Ee][Ss]) 46654843Sobrien if [ -r /etc/mail/sendmail.cf ]; then 46751231Ssheldonh echo -n ' sendmail'; /usr/sbin/sendmail ${sendmail_flags} 46851231Ssheldonh fi 46951231Ssheldonh ;; 47051231Ssheldonhesac 47117161Spst 47257572Smarkmcase ${sshd_enable} in 47357572Smarkm[Yy][Ee][Ss]) 47457572Smarkm if [ -x ${sshd_program:-/usr/sbin/sshd} ]; then 47557572Smarkm echo -n ' sshd'; 47657572Smarkm ${sshd_program:-/usr/sbin/sshd} ${sshd_flags} 47757572Smarkm fi 47857572Smarkm ;; 47957572Smarkmesac 48057572Smarkm 48151231Ssheldonhcase ${usbd_enable} in 48251231Ssheldonh[Yy][Ee][Ss]) 48342498Sn_hibma echo -n ' usbd'; /usr/sbin/usbd ${usbd_flags} 48451231Ssheldonh ;; 48551231Ssheldonhesac 48642498Sn_hibma 48717161Spstecho '.' 48817161Spst 48916671Spst# Recover vi editor files. 49050612Simpfind /var/tmp/vi.recover ! -type f -a ! -type d -delete 49119314Spetervibackup=`echo /var/tmp/vi.recover/vi.*` 49250357Ssheldonhif [ "${vibackup}" != '/var/tmp/vi.recover/vi.*' ]; then 49316671Spst echo 'Recovering vi editor sessions' 49455511Speter for i in /var/tmp/vi.recover/vi.*; do 49519314Speter # Only test files that are readable. 49651231Ssheldonh if [ ! -r "${i}" ]; then 49719314Speter continue 49819314Speter fi 49919314Speter 50019314Speter # Unmodified nvi editor backup files either have the 50119314Speter # execute bit set or are zero length. Delete them. 50251231Ssheldonh if [ -x "${i}" -o ! -s "${i}" ]; then 50355451Speter rm -f "${i}" 50419314Speter fi 50516671Spst done 50619314Speter 50719314Speter # It is possible to get incomplete recovery files, if the editor 50819314Speter # crashes at the right time. 50919314Speter virecovery=`echo /var/tmp/vi.recover/recover.*` 51050357Ssheldonh if [ "${virecovery}" != "/var/tmp/vi.recover/recover.*" ]; then 51155511Speter for i in /var/tmp/vi.recover/recover.*; do 51219314Speter # Only test files that are readable. 51351231Ssheldonh if [ ! -r "${i}" ]; then 51419314Speter continue 51519314Speter fi 51619314Speter 51719314Speter # Delete any recovery files that are zero length, 51819314Speter # corrupted, or that have no corresponding backup file. 51919314Speter # Else send mail to the user. 52055453Speter recfile=`awk '/^X-vi-recover-path:/{print $2}' < "${i}"` 52151231Ssheldonh if [ -n "${recfile}" -a -s "${recfile}" ]; then 52255451Speter sendmail -t < "${i}" 52319314Speter else 52455451Speter rm -f "${i}" 52519314Speter fi 52619314Speter done 52719314Speter fi 52816671Spstfi 52916671Spst 53051231Ssheldonh# Make a bounds file for msgs(1) if there isn't one already 53151231Ssheldonh# "Delete important files with symlink" security hole? 53251231Ssheldonh# 53351231Ssheldonhif [ -d /var/msgs -a ! -f /var/msgs/bounds ]; then 53437899Snectar echo 0 > /var/msgs/bounds 53537899Snectarfi 53637899Snectar 53751231Ssheldonhcase ${update_motd} in 53851231Ssheldonh[Nn][Oo] | '') 53951231Ssheldonh ;; 54051231Ssheldonh*) 54151231Ssheldonh if T=`mktemp /tmp/_motd.XXXXXX`; then 54250357Ssheldonh uname -v | sed -e 's,^\([^#]*\) #\(.* [1-2][0-9][0-9][0-9]\).*/\([^\]*\) $,\1 (\3) #\2,' > ${T} 54350357Ssheldonh awk '{if (NR == 1) {if ($1 == "FreeBSD") {next} else {print "\n"$0}} else {print}}' < /etc/motd >> ${T} 54450357Ssheldonh cmp -s ${T} /etc/motd || { 54550357Ssheldonh cp ${T} /etc/motd 54649451Speter chmod 644 /etc/motd 54749451Speter } 54850357Ssheldonh rm -f ${T} 54949451Speter fi 55051231Ssheldonh ;; 55151231Ssheldonhesac 55251231Ssheldonh 55351617Snsayer# Configure implementation specific stuff 55451617Snsayer# 55551617Snsayerarch=`uname -m` 55651617Snsayerif [ -r /etc/rc.${arch} ]; then 55751617Snsayer . /etc/rc.${arch} 55851617Snsayerfi 55951617Snsayer 56051231Ssheldonh# Run rc.devfs if readable to customize devfs 56151231Ssheldonh# 56251231Ssheldonhif [ -r /etc/rc.devfs ]; then 56351231Ssheldonh sh /etc/rc.devfs 56441704Sdillonfi 56541704Sdillon 56664810Ssheldonhecho -n additional ABI support: 56764684Sobrien 56864684Sobrien# Start the Linux binary compatibility if requested. 56964684Sobrien# 57064684Sobriencase ${linux_enable} in 57164684Sobrien[Yy][Ee][Ss]) 57264809Ssheldonh echo -n ' linux' 57364809Ssheldonh if ! kldstat -v | grep -E 'linux(aout|elf)' > /dev/null; then 57464809Ssheldonh kldload linux > /dev/null 2>&1 57564809Ssheldonh fi 57664809Ssheldonh if [ -x /compat/linux/sbin/ldconfig ]; then 57764809Ssheldonh /compat/linux/sbin/ldconfig 57864809Ssheldonh fi 57964684Sobrien ;; 58064684Sobrienesac 58164684Sobrien 58264684Sobrien# Start the SysVR4 binary emulation if requested. 58364684Sobrien# 58464684Sobriencase ${svr4_enable} in 58564684Sobrien[Yy][Ee][Ss]) 58664809Ssheldonh echo -n ' svr4'; kldload svr4 > /dev/null 2>&1 58764684Sobrien ;; 58864684Sobrienesac 58964684Sobrien 59064810Ssheldonhecho . 59164810Ssheldonh 59241704Sdillon# Do traditional (but rather obsolete) rc.local file if it exists. If you 59343951Sjkh# use this file and want to make it programmatic, source /etc/defaults/rc.conf 59443951Sjkh# in /etc/rc.local and add your custom variables to /etc/rc.conf, as 59543951Sjkh# shown below. Please do not put local extensions into /etc/rc itself. 59641704Sdillon# Use /etc/rc.local 59741704Sdillon# 59851231Ssheldonh# ---- rc.local ---- 59951231Ssheldonh# if [ -r /etc/defaults/rc.conf ]; then 60051231Ssheldonh# . /etc/defaults/rc.conf 60159674Ssheldonh# source_rc_confs 60259674Ssheldonh# elif [ -r /etc/rc.conf ]; then 60359674Ssheldonh# . /etc/rc.conf 60451231Ssheldonh# fi 60551231Ssheldonh# 60651231Ssheldonh# ... additional startup conditionals ... 60751231Ssheldonh# ---- rc.local ---- 60851231Ssheldonh# 60951231Ssheldonhif [ -r /etc/rc.local ]; then 61043197Sdillon echo -n 'starting local daemons:' 61151231Ssheldonh sh /etc/rc.local 61243197Sdillon echo '.' 61341704Sdillonfi 61441704Sdillon 61551617Snsayer# For each valid dir in $local_startup, search for init scripts matching *.sh 61651617Snsayer# 61751617Snsayercase ${local_startup} in 61851617Snsayer[Nn][Oo] | '') 61951617Snsayer ;; 62051617Snsayer*) 62151617Snsayer echo -n 'Local package initialization:' 62251617Snsayer for dir in ${local_startup}; do 62351617Snsayer if [ -d "${dir}" ]; then 62451617Snsayer for script in ${dir}/*.sh; do 62551617Snsayer if [ -x "${script}" ]; then 62651617Snsayer (set -T 62751617Snsayer trap 'exit 1' 2 62851617Snsayer ${script} start) 62951617Snsayer fi 63051617Snsayer done 63151617Snsayer fi 63251617Snsayer done 63351617Snsayer echo . 63451617Snsayer ;; 63551617Snsayeresac 63651617Snsayer 63753314Sacheif [ -n "${network_pass3_done}" ]; then 63853314Sache network_pass4 63953314Sachefi 64053314Sache 64137106Sjkoshy# Raise kernel security level. This should be done only after `fsck' has 64237106Sjkoshy# repaired local file systems if you want the securelevel to be greater than 1. 64351231Ssheldonh# 64451231Ssheldonhcase ${kern_securelevel_enable} in 64551231Ssheldonh[Yy][Ee][Ss]) 64651231Ssheldonh if [ "${kern_securelevel}" -ge 0 ]; then 64751231Ssheldonh echo 'Raising kernel security level' 64851231Ssheldonh sysctl -w kern.securelevel=${kern_securelevel} 64951231Ssheldonh fi 65051231Ssheldonh ;; 65151231Ssheldonhesac 65237106Sjkoshy 65337Srgrimesdate 65437Srgrimesexit 0 655