rc revision 38237
1#!/bin/sh 2# $Id: rc,v 1.147 1998/07/28 01:15:12 nectar 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 98clean_var() { 99 if [ ! -f /var/run/clean_var ]; then 100 rm -rf /var/run/* 101 rm -f /var/spool/lock/* 102 rm -rf /var/spool/uucp/.Temp/* 103 # Keep a copy of the boot messages around 104 dmesg >/var/run/dmesg.boot 105 # And an initial utmp file 106 (cd /var/run && cp /dev/null utmp && chmod 644 utmp; ) 107 touch /var/run/clean_var 108 fi 109} 110 111if [ -d /var/run -a -d /var/spool/lock -a -d /var/spool/uucp/.Temp ]; then 112 # network_pass1() *may* end up writing stuff to /var - we don't want to 113 # remove it immediately afterwards - *nor* to we want to fail to clean 114 # an nfs-mounted /var. 115 clean_var 116fi 117 118# Add additional swapfile, if configured. 119if [ "x$swapfile" != "xNO" -a -w "$swapfile" -a -b /dev/vn0b ]; then 120 echo "Adding $swapfile as additional swap." 121 vnconfig /dev/vn0b $swapfile && swapon /dev/vn0b 122fi 123 124# configure serial devices 125if [ -f /etc/rc.serial ]; then 126 . /etc/rc.serial 127fi 128 129# start up PC-card configuration 130if [ -f /etc/rc.pccard ]; then 131 . /etc/rc.pccard 132fi 133 134# start up the initial network configuration. 135if [ -f /etc/rc.network ]; then 136 . /etc/rc.network # We only need to do this once. 137 network_pass1 138fi 139 140mount -a -t nfs 141 142# Whack the pty perms back into shape. 143chmod 666 /dev/tty[pqrsPQRS]* 144 145# clean up left-over files 146rm -f /etc/nologin 147 148clean_var # If it hasn't already been done 149rm /var/run/clean_var 150 151# 152# Clearing /tmp at boot-time seems to have a long tradition. It doesn't 153# help in any way for long-living systems, and it might accidentally 154# clobber files you would rather like to have preserved after a crash 155# (if not using mfs /tmp anyway). 156# 157# See also the example of another cleanup policy in /etc/periodic/daily. 158# 159if [ "X${clear_tmp_enable}" = X"YES" ]; then 160 echo clearing /tmp 161 162 # prune quickly with one rm, then use find to clean up /tmp/[lq]* 163 # (not needed with mfs /tmp, but doesn't hurt there...) 164 (cd /tmp && rm -rf [a-km-pr-zA-Z]* && 165 find -d . ! -name . ! -name lost+found ! -name quotas -exec rm -rf -- {} \;) 166 167 # Also remove X lock files since it will prevent you from 168 # restarting X11 after a system crash. 169 rm -f /tmp/.X*-lock /tmp/.X11-unix/* 170fi 171 172# snapshot any kernel -c changes back to disk 173echo 'recording kernel -c changes' 174dset -q 175 176echo -n 'additional daemons:' 177# start system logging and name service (named needs to start before syslogd 178# if you don't have a /etc/resolv.conf) 179# 180if [ "X${syslogd_enable}" = X"YES" ]; then 181 # Transitional symlink (for the next couple of years :) until all 182 # binaries had a chance to move towards /var/run/log. 183 if [ ! -h /dev/log ] ; then 184 # might complain for r/o root f/s 185 ln -sf /var/run/log /dev/log 186 fi 187 188 rm -f /var/run/log 189 echo -n ' syslogd'; syslogd ${syslogd_flags} 190fi 191 192if [ "X${tickadj_enable}" = X"YES" ]; then 193 echo -n ' tickadj'; tickadj ${tickadj_flags--Aq} 194fi 195echo '.' 196 197# enable dumpdev so that savecore can see it 198# /var/crash should be a directory or a symbolic link 199# to the crash directory if core dumps are to be saved. 200if [ "X${dumpdev}" != X"NO" -a -e ${dumpdev} -a -d /var/crash ]; then 201 dumpon ${dumpdev} 202 echo -n checking for core dump... 203 savecore /var/crash 204fi 205 206if [ -n "$network_pass1_done" ]; then 207 network_pass2 208fi 209 210# Check the quotas (must be after ypbind if using NIS) 211if [ "X${check_quotas}" = X"YES" ]; then 212 echo -n 'checking quotas:' 213 quotacheck -a 214 echo ' done.' 215 quotaon -a 216fi 217 218if [ -n "$network_pass2_done" ]; then 219 network_pass3 220fi 221 222 223# build ps databases 224kvm_mkdb 225dev_mkdb 226 227# check the password temp/lock file 228if [ -f /etc/ptmp ] 229then 230 logger -s -p auth.err \ 231 "password file may be incorrect -- /etc/ptmp exists" 232fi 233 234if [ "X${accounting_enable}" = X"YES" -a -d /var/account ]; then 235 echo 'turning on accounting' 236 if [ ! -e /var/account/acct ]; then 237 touch /var/account/acct 238 fi 239 accton /var/account/acct 240fi 241 242# Make shared lib searching a little faster. Leave /usr/lib first if you 243# add your own entries or you may come to grief. 244_LDC=/usr/lib/aout 245for i in $ldconfig_paths; do 246 if test -d $i; then 247 _LDC="${_LDC} $i" 248 fi 249done 250echo 'setting ldconfig path:' ${_LDC} 251ldconfig ${_LDC} 252 253# Now start up miscellaneous daemons that don't belong anywhere else 254# 255echo -n starting standard daemons: 256if [ "X${inetd_enable}" != X"NO" ]; then 257 echo -n ' inetd'; inetd ${inetd_flags} 258fi 259 260if [ "X${cron_enable}" != X"NO" ]; then 261 echo -n ' cron'; cron 262fi 263 264if [ "X${lpd_enable}" = X"YES" ]; then 265 echo -n ' printer'; lpd ${lpd_flags} 266fi 267 268if [ "X${sendmail_enable}" = X"YES" -a -r /etc/sendmail.cf ]; then 269 echo -n ' sendmail'; /usr/sbin/sendmail ${sendmail_flags} 270fi 271 272echo '.' 273 274# configure implementation specific stuff 275arch=`uname -m` 276if [ -f /etc/rc.${arch} ]; then 277 . /etc/rc.${arch} 278fi 279 280# Recover vi editor files. 281vibackup=`echo /var/tmp/vi.recover/vi.*` 282if [ "$vibackup" != '/var/tmp/vi.recover/vi.*' ]; then 283 echo 'Recovering vi editor sessions' 284 for i in $vibackup; do 285 # Only test files that are readable. 286 if test ! -r $i; then 287 continue 288 fi 289 290 # Unmodified nvi editor backup files either have the 291 # execute bit set or are zero length. Delete them. 292 if test -x $i -o ! -s $i; then 293 rm -f $i 294 fi 295 done 296 297 # It is possible to get incomplete recovery files, if the editor 298 # crashes at the right time. 299 virecovery=`echo /var/tmp/vi.recover/recover.*` 300 if [ "$virecovery" != "/var/tmp/vi.recover/recover.*" ]; then 301 for i in $virecovery; do 302 # Only test files that are readable. 303 if test ! -r $i; then 304 continue 305 fi 306 307 # Delete any recovery files that are zero length, 308 # corrupted, or that have no corresponding backup file. 309 # Else send mail to the user. 310 recfile=`awk '/^X-vi-recover-path:/{print $2}' < $i` 311 if test -n "$recfile" -a -s "$recfile"; then 312 sendmail -t < $i 313 else 314 rm -f $i 315 fi 316 done 317 fi 318fi 319 320# make a bounds file for msgs(1) if there isn't one already 321if [ ! -f /var/msgs/bounds ]; then 322 echo 0 > /var/msgs/bounds 323fi 324 325# for each valid dir in $local_startup, search for init scripts matching *.sh 326if [ "X${local_startup}" != X"NO" ]; then 327 echo -n 'Local package initialization:' 328 for dir in ${local_startup}; do 329 [ -d ${dir} ] && for script in ${dir}/*.sh; do 330 [ -x ${script} ] && ${script} start 331 done 332 done 333 echo . 334fi 335 336# Do traditional (but rather obsolete) rc.local file if it exists. 337[ -f /etc/rc.local ] && sh /etc/rc.local 338 339# Raise kernel security level. This should be done only after `fsck' has 340# repaired local file systems if you want the securelevel to be greater than 1. 341if [ "X${kern_securelevel_enable}" != X"NO" -a "${kern_securelevel}" -ge 0 ]; 342then 343 echo 'Raising kernel security level' 344 sysctl -w kern.securelevel=${kern_securelevel} 345fi 346 347date 348exit 0 349