rc revision 25339
1#!/bin/sh 2# $Id: rc,v 1.117 1997/04/27 03:59:13 jkh Exp $ 3# From: @(#)rc 5.27 (Berkeley) 6/5/91 4 5# System startup script run by init on autoboot 6# or after single-user. 7# Output and error are redirected to console by init, 8# and the console is the controlling terminal. 9 10# Note that almost all the user-configurable behavior is no longer in 11# this file, but rather in /etc/rc.conf. Please check this file 12# first before contemplating any changes here. 13 14stty status '^T' 15 16# Set shell to ignore SIGINT (2), but not children; 17# shell catches SIGQUIT (3) and returns to single user after fsck. 18trap : 2 19trap : 3 # shouldn't be needed 20 21HOME=/; export HOME 22PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin 23export PATH 24 25# Configure ccd devices. 26if [ -f /etc/ccd.conf ]; then 27 ccdconfig -C 28fi 29 30swapon -a 31 32if [ $1x = autobootx ]; then 33 echo Automatic reboot in progress... 34 fsck -p 35 case $? in 36 0) 37 ;; 38 2) 39 exit 1 40 ;; 41 4) 42 reboot 43 echo "reboot failed... help!" 44 exit 1 45 ;; 46 8) 47 echo "Automatic file system check failed... help!" 48 exit 1 49 ;; 50 12) 51 echo "Reboot interrupted" 52 exit 1 53 ;; 54 130) 55 # interrupt before catcher installed 56 exit 1 57 ;; 58 *) 59 echo "Unknown error in reboot" 60 exit 1 61 ;; 62 esac 63else 64 echo Skipping disk checks ... 65fi 66 67trap "echo 'Reboot interrupted'; exit 1" 3 68 69# root must be read/write both for NFS diskless and for VFS LKMs before 70# proceeding any further. 71mount -u -o rw / 72if [ $? != 0 ]; then 73 echo "Filesystem mount failed, startup aborted" 74 exit 1 75fi 76 77umount -a >/dev/null 2>&1 78 79mount -a -t nonfs 80if [ $? != 0 ]; then 81 echo "Filesystem mount failed, startup aborted" 82 exit 1 83fi 84 85# If there is a global system configuration file, suck it in. 86if [ -f /etc/rc.conf ]; then 87 . /etc/rc.conf 88fi 89 90# If old file exists, whine until they fix it. 91if [ -f /etc/sysconfig ]; then 92 echo "Warning: /etc/sysconfig has been replaced by /etc/rc.conf." 93 echo "You should switch to /etc/rc.conf ASAP to eliminate this warning." 94fi 95 96adjkerntz -i 97 98# Keep a copy of the boot messages around 99dmesg > /var/run/dmesg.boot 100 101 102# Add additional swapfile, if configured. 103if [ "x$swapfile" != "xNO" -a -w "$swapfile" -a -b /dev/vn0b ]; then 104 echo "Adding $swapfile as additional swap." 105 vnconfig /dev/vn0b $swapfile && swapon /dev/vn0b 106fi 107 108# configure serial devices 109if [ -f /etc/rc.serial ]; then 110 . /etc/rc.serial 111fi 112 113# start up PC-card configuration 114if [ -f /etc/rc.pccard ]; then 115 . /etc/rc.pccard 116fi 117 118# start up the initial network configuration. 119if [ -f /etc/rc.network ]; then 120 . /etc/rc.network # We only need to do this once. 121 network_pass1 122fi 123 124mount -a -t nfs >/dev/null 2>&1 125 126# Whack the pty perms back into shape. 127chmod 666 /dev/tty[pqrsPQRS]* 128 129# clean up left-over files 130rm -f /etc/nologin 131rm -f /var/spool/lock/* 132rm -rf /var/spool/uucp/.Temp/* 133(cd /var/run && { cp /dev/null utmp; chmod 644 utmp; }) 134 135# 136# Clearing /tmp at boot-time is essentially stupid, but seems to have 137# a long tradition. It doesn't help in any way for long-living systems, 138# and it might accidentally clobber files you would rather like to have 139# preserved after a crash (if not using mfs /tmp anyway). 140# 141# See also the commented out example of another cleanup policy in 142# /etc/daily. 143# 144echo clearing /tmp 145 146# prune quickly with one rm, then use find to clean up /tmp/[lq]* 147# (not needed with mfs /tmp, but doesn't hurt there...) 148(cd /tmp && rm -rf [a-km-pr-zA-Z]* && 149 find -d . ! -name . ! -name lost+found ! -name quotas -exec rm -rf -- {} \;) 150 151# The above is even more stupid since it prevents you from restarting 152# X11 after a system crash. If you disable the above, make sure to 153# uncomment the line below. 154# 155# clean up leftover X lock files and local connection sockets 156#rm -f /tmp/.X*-lock /tmp/.X11-unix/* 157 158 159# enable dumpdev so that savecore can see it 160if [ "X${dumpdev}" != X"NO" ]; then 161 dumpon ${dumpdev} 162fi 163 164# /var/crash should be a directory or a symbolic link 165# to the crash directory if core dumps are to be saved. 166if [ -d /var/crash ]; then 167 echo -n checking for core dump... 168 savecore /var/crash 169fi 170 171# snapshot any kernel -c changes back to disk 172echo 'recording kernel -c changes' 173dset -q 174 175echo -n 'additional daemons:' 176# start system logging and name service (named needs to start before syslogd 177# if you don't have a /etc/resolv.conf) 178# 179# If syslogdflags == NO, syslog isn't run 180if [ "X${syslogdflags}" != X"NO" ] ; then 181 182 # Transitional symlink (for the next couple of years :) until all 183 # binaries had a chance to move towards /var/run/log. 184 if [ ! -h /dev/log ] ; then 185 # might complain for r/o root f/s 186 ln -sf /var/run/log /dev/log 187 fi 188 189 rm -f /var/run/log 190 echo -n ' syslogd'; syslogd ${syslogd_flags} 191fi 192 193if [ "X${tickadj_enable}" = X"YES" ]; then 194 echo -n ' tickadj'; tickadj ${tickadj_flags--Aq} 195fi 196echo '.' 197 198if [ -n "$network_pass1_done" ]; then 199 network_pass2 200fi 201 202# Check the quotas (must be after ypbind if using NIS) 203if [ "X${check_quotas}" = X"YES" ]; then 204 echo -n 'checking quotas:' 205 quotacheck -a 206 echo ' done.' 207 quotaon -a 208fi 209 210if [ -n "$network_pass2_done" ]; then 211 network_pass3 212fi 213 214 215# build ps databases 216kvm_mkdb 217dev_mkdb 218 219# check the password temp/lock file 220if [ -f /etc/ptmp ] 221then 222 logger -s -p auth.err \ 223 "password file may be incorrect -- /etc/ptmp exists" 224fi 225 226if [ "X${accounting_enable}" = X"YES" -a -d /var/account ]; then 227 echo 'turning on accounting' 228 if [ ! -e /var/account/acct ]; then 229 touch /var/account/acct && chmod 600 /var/account/acct 230 fi 231 accton /var/account/acct 232fi 233 234# Make shared lib searching a little faster. Leave /usr/lib first if you 235# add your own entries or you may come to grief. 236_LDC=/usr/lib 237if [ -d /usr/lib/compat ]; then _LDC="${_LDC} /usr/lib/compat" ; fi 238if [ -d /usr/X11R6/lib ]; then _LDC="${_LDC} /usr/X11R6/lib" ; fi 239if [ -d /usr/local/lib ]; then _LDC="${_LDC} /usr/local/lib" ; fi 240echo 'setting ldconfig path:' ${_LDC} 241ldconfig ${_LDC} 242 243# Now start up miscellaneous daemons that don't belong anywhere else 244# 245echo -n starting standard daemons: 246echo -n ' inetd'; inetd 247echo -n ' cron'; cron 248 249if [ "X${lpd_enable}" = X"YES" ]; then 250 echo -n ' printer'; lpd 251fi 252 253if [ "X${sendmail_enable}" = X"YES" -a -r /etc/sendmail.cf ]; then 254 echo -n ' sendmail'; sendmail ${sendmail_flags} 255fi 256 257echo '.' 258 259# configure implementation specific stuff 260arch=`uname -m` 261if [ -f /etc/rc.${arch} ]; then 262 . /etc/rc.${arch} 263fi 264 265# Recover vi editor files. 266vibackup=`echo /var/tmp/vi.recover/vi.*` 267if [ "$vibackup" != '/var/tmp/vi.recover/vi.*' ]; then 268 echo 'Recovering vi editor sessions' 269 for i in $vibackup; do 270 # Only test files that are readable. 271 if test ! -r $i; then 272 continue 273 fi 274 275 # Unmodified nvi editor backup files either have the 276 # execute bit set or are zero length. Delete them. 277 if test -x $i -o ! -s $i; then 278 rm -f $i 279 fi 280 done 281 282 # It is possible to get incomplete recovery files, if the editor 283 # crashes at the right time. 284 virecovery=`echo /var/tmp/vi.recover/recover.*` 285 if [ "$virecovery" != "/var/tmp/vi.recover/recover.*" ]; then 286 for i in $virecovery; do 287 # Only test files that are readable. 288 if test ! -r $i; then 289 continue 290 fi 291 292 # Delete any recovery files that are zero length, 293 # corrupted, or that have no corresponding backup file. 294 # Else send mail to the user. 295 recfile=`awk '/^X-vi-recover-path:/{print $2}' < $i` 296 if test -n "$recfile" -a -s "$recfile"; then 297 sendmail -t < $i 298 else 299 rm -f $i 300 fi 301 done 302 fi 303fi 304 305# for each valid dir in $local_startup, search for init scripts matching *.sh 306if [ "X${local_startup}" != X"NO" ]; then 307 echo -n 'Local package startup:' 308 for dir in ${local_startup}; do 309 [ -d ${dir} ] && for script in ${dir}/*.sh; do 310 [ -x ${script} ] && ${script} start 311 done 312 done 313 echo . 314fi 315 316# Do traditional (but rather obsolete) rc.local file if it exists. 317[ -f /etc/rc.local ] && sh /etc/rc.local 318 319date 320exit 0 321