rc revision 28305
1#!/bin/sh 2# $Id$ 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 98rm -f /var/run/* 99 100# Keep a copy of the boot messages around 101dmesg > /var/run/dmesg.boot 102 103# Add additional swapfile, if configured. 104if [ "x$swapfile" != "xNO" -a -w "$swapfile" -a -b /dev/vn0b ]; then 105 echo "Adding $swapfile as additional swap." 106 vnconfig /dev/vn0b $swapfile && swapon /dev/vn0b 107fi 108 109# configure serial devices 110if [ -f /etc/rc.serial ]; then 111 . /etc/rc.serial 112fi 113 114# start up PC-card configuration 115if [ -f /etc/rc.pccard ]; then 116 . /etc/rc.pccard 117fi 118 119# start up the initial network configuration. 120if [ -f /etc/rc.network ]; then 121 . /etc/rc.network # We only need to do this once. 122 network_pass1 123fi 124 125mount -a -t nfs >/dev/null 2>&1 126 127# Whack the pty perms back into shape. 128chmod 666 /dev/tty[pqrsPQRS]* 129 130# clean up left-over files 131rm -f /etc/nologin 132rm -f /var/spool/lock/* 133rm -rf /var/spool/uucp/.Temp/* 134rm -f /var/run/*.pid 135(cd /var/run && { cp /dev/null utmp; chmod 644 utmp; }) 136 137# enable dumpdev so that savecore can see it 138if [ "X${dumpdev}" != X"NO" -a -e ${dumpdev} ]; then 139 dumpon ${dumpdev} 140fi 141 142# /var/crash should be a directory or a symbolic link 143# to the crash directory if core dumps are to be saved. 144if [ "X${savecore_enable}" = X"YES" -a -d /var/crash ]; then 145 echo -n checking for core dump... 146 savecore /var/crash 147fi 148 149# snapshot any kernel -c changes back to disk 150echo 'recording kernel -c changes' 151dset -q 152 153echo -n 'additional daemons:' 154# start system logging and name service (named needs to start before syslogd 155# if you don't have a /etc/resolv.conf) 156# 157if [ "X${syslogd_enable}" = X"YES" ]; then 158 # Transitional symlink (for the next couple of years :) until all 159 # binaries had a chance to move towards /var/run/log. 160 if [ ! -h /dev/log ] ; then 161 # might complain for r/o root f/s 162 ln -sf /var/run/log /dev/log 163 fi 164 165 rm -f /var/run/log 166 echo -n ' syslogd'; syslogd ${syslogd_flags} 167fi 168 169if [ "X${tickadj_enable}" = X"YES" ]; then 170 echo -n ' tickadj'; tickadj ${tickadj_flags--Aq} 171fi 172echo '.' 173 174if [ -n "$network_pass1_done" ]; then 175 network_pass2 176fi 177 178# Check the quotas (must be after ypbind if using NIS) 179if [ "X${check_quotas}" = X"YES" ]; then 180 echo -n 'checking quotas:' 181 quotacheck -a 182 echo ' done.' 183 quotaon -a 184fi 185 186if [ -n "$network_pass2_done" ]; then 187 network_pass3 188fi 189 190 191# build ps databases 192kvm_mkdb 193dev_mkdb 194 195# check the password temp/lock file 196if [ -f /etc/ptmp ] 197then 198 logger -s -p auth.err \ 199 "password file may be incorrect -- /etc/ptmp exists" 200fi 201 202if [ "X${accounting_enable}" = X"YES" -a -d /var/account ]; then 203 echo 'turning on accounting' 204 if [ ! -e /var/account/acct ]; then 205 touch /var/account/acct 206 fi 207 accton /var/account/acct 208fi 209 210# Make shared lib searching a little faster. Leave /usr/lib first if you 211# add your own entries or you may come to grief. 212_LDC=/usr/lib 213if [ -d /usr/lib/compat ]; then _LDC="${_LDC} /usr/lib/compat" ; fi 214if [ -d /usr/X11R6/lib ]; then _LDC="${_LDC} /usr/X11R6/lib" ; fi 215if [ -d /usr/local/lib ]; then _LDC="${_LDC} /usr/local/lib" ; fi 216echo 'setting ldconfig path:' ${_LDC} 217ldconfig ${_LDC} 218 219# Now start up miscellaneous daemons that don't belong anywhere else 220# 221echo -n starting standard daemons: 222if [ "X${inetd_enable}" = X"YES" ]; then 223 echo -n ' inetd'; inetd ${inetd_flags} 224fi 225 226if [ "X${cron_enable}" = X"YES" ]; then 227 echo -n ' cron'; cron 228fi 229 230if [ "X${lpd_enable}" = X"YES" ]; then 231 echo -n ' printer'; lpd ${lpd_flags} 232fi 233 234if [ "X${sendmail_enable}" = X"YES" -a -r /etc/sendmail.cf ]; then 235 echo -n ' sendmail'; /usr/sbin/sendmail ${sendmail_flags} 236fi 237 238echo '.' 239 240# configure implementation specific stuff 241arch=`uname -m` 242if [ -f /etc/rc.${arch} ]; then 243 . /etc/rc.${arch} 244fi 245 246# Recover vi editor files. 247vibackup=`echo /var/tmp/vi.recover/vi.*` 248if [ "$vibackup" != '/var/tmp/vi.recover/vi.*' ]; then 249 echo 'Recovering vi editor sessions' 250 for i in $vibackup; do 251 # Only test files that are readable. 252 if test ! -r $i; then 253 continue 254 fi 255 256 # Unmodified nvi editor backup files either have the 257 # execute bit set or are zero length. Delete them. 258 if test -x $i -o ! -s $i; then 259 rm -f $i 260 fi 261 done 262 263 # It is possible to get incomplete recovery files, if the editor 264 # crashes at the right time. 265 virecovery=`echo /var/tmp/vi.recover/recover.*` 266 if [ "$virecovery" != "/var/tmp/vi.recover/recover.*" ]; then 267 for i in $virecovery; do 268 # Only test files that are readable. 269 if test ! -r $i; then 270 continue 271 fi 272 273 # Delete any recovery files that are zero length, 274 # corrupted, or that have no corresponding backup file. 275 # Else send mail to the user. 276 recfile=`awk '/^X-vi-recover-path:/{print $2}' < $i` 277 if test -n "$recfile" -a -s "$recfile"; then 278 sendmail -t < $i 279 else 280 rm -f $i 281 fi 282 done 283 fi 284fi 285 286# for each valid dir in $local_startup, search for init scripts matching *.sh 287if [ "X${local_startup}" != X"NO" ]; then 288 echo -n 'Local package initialization:' 289 for dir in ${local_startup}; do 290 [ -d ${dir} ] && for script in ${dir}/*.sh; do 291 [ -x ${script} ] && ${script} start 292 done 293 done 294 echo . 295fi 296 297# Do traditional (but rather obsolete) rc.local file if it exists. 298[ -f /etc/rc.local ] && sh /etc/rc.local 299 300date 301exit 0 302