rc revision 25469
1#!/bin/sh 2# $Id: rc,v 1.120 1997/05/04 12:50:33 andreas 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# enable dumpdev so that savecore can see it 136if [ "X${dumpdev}" != X"NO" -a -e ${dumpdev} ]; then 137 dumpon ${dumpdev} 138fi 139 140# /var/crash should be a directory or a symbolic link 141# to the crash directory if core dumps are to be saved. 142if [ "X${savecore_enable}" = X"YES" -a -d /var/crash ]; then 143 echo -n checking for core dump... 144 savecore /var/crash 145fi 146 147# snapshot any kernel -c changes back to disk 148echo 'recording kernel -c changes' 149dset -q 150 151echo -n 'additional daemons:' 152# start system logging and name service (named needs to start before syslogd 153# if you don't have a /etc/resolv.conf) 154# 155if [ "X${syslogd_enable}" = X"YES" ]; then 156 # Transitional symlink (for the next couple of years :) until all 157 # binaries had a chance to move towards /var/run/log. 158 if [ ! -h /dev/log ] ; then 159 # might complain for r/o root f/s 160 ln -sf /var/run/log /dev/log 161 fi 162 163 rm -f /var/run/log 164 echo -n ' syslogd'; syslogd ${syslogd_flags} 165fi 166 167if [ "X${tickadj_enable}" = X"YES" ]; then 168 echo -n ' tickadj'; tickadj ${tickadj_flags--Aq} 169fi 170echo '.' 171 172if [ -n "$network_pass1_done" ]; then 173 network_pass2 174fi 175 176# Check the quotas (must be after ypbind if using NIS) 177if [ "X${check_quotas}" = X"YES" ]; then 178 echo -n 'checking quotas:' 179 quotacheck -a 180 echo ' done.' 181 quotaon -a 182fi 183 184if [ -n "$network_pass2_done" ]; then 185 network_pass3 186fi 187 188 189# build ps databases 190kvm_mkdb 191dev_mkdb 192 193# check the password temp/lock file 194if [ -f /etc/ptmp ] 195then 196 logger -s -p auth.err \ 197 "password file may be incorrect -- /etc/ptmp exists" 198fi 199 200if [ "X${accounting_enable}" = X"YES" -a -d /var/account ]; then 201 echo 'turning on accounting' 202 if [ ! -e /var/account/acct ]; then 203 touch /var/account/acct 204 fi 205 accton /var/account/acct 206fi 207 208# Make shared lib searching a little faster. Leave /usr/lib first if you 209# add your own entries or you may come to grief. 210_LDC=/usr/lib 211if [ -d /usr/lib/compat ]; then _LDC="${_LDC} /usr/lib/compat" ; fi 212if [ -d /usr/X11R6/lib ]; then _LDC="${_LDC} /usr/X11R6/lib" ; fi 213if [ -d /usr/local/lib ]; then _LDC="${_LDC} /usr/local/lib" ; fi 214echo 'setting ldconfig path:' ${_LDC} 215ldconfig ${_LDC} 216 217# Now start up miscellaneous daemons that don't belong anywhere else 218# 219echo -n starting standard daemons: 220echo -n ' inetd'; inetd 221echo -n ' cron'; cron 222 223if [ "X${lpd_enable}" = X"YES" ]; then 224 echo -n ' printer'; lpd 225fi 226 227if [ "X${sendmail_enable}" = X"YES" -a -r /etc/sendmail.cf ]; then 228 echo -n ' sendmail'; sendmail ${sendmail_flags} 229fi 230 231echo '.' 232 233# configure implementation specific stuff 234arch=`uname -m` 235if [ -f /etc/rc.${arch} ]; then 236 . /etc/rc.${arch} 237fi 238 239# Recover vi editor files. 240vibackup=`echo /var/tmp/vi.recover/vi.*` 241if [ "$vibackup" != '/var/tmp/vi.recover/vi.*' ]; then 242 echo 'Recovering vi editor sessions' 243 for i in $vibackup; do 244 # Only test files that are readable. 245 if test ! -r $i; then 246 continue 247 fi 248 249 # Unmodified nvi editor backup files either have the 250 # execute bit set or are zero length. Delete them. 251 if test -x $i -o ! -s $i; then 252 rm -f $i 253 fi 254 done 255 256 # It is possible to get incomplete recovery files, if the editor 257 # crashes at the right time. 258 virecovery=`echo /var/tmp/vi.recover/recover.*` 259 if [ "$virecovery" != "/var/tmp/vi.recover/recover.*" ]; then 260 for i in $virecovery; do 261 # Only test files that are readable. 262 if test ! -r $i; then 263 continue 264 fi 265 266 # Delete any recovery files that are zero length, 267 # corrupted, or that have no corresponding backup file. 268 # Else send mail to the user. 269 recfile=`awk '/^X-vi-recover-path:/{print $2}' < $i` 270 if test -n "$recfile" -a -s "$recfile"; then 271 sendmail -t < $i 272 else 273 rm -f $i 274 fi 275 done 276 fi 277fi 278 279# for each valid dir in $local_startup, search for init scripts matching *.sh 280if [ "X${local_startup}" != X"NO" ]; then 281 echo -n 'Local package startup:' 282 for dir in ${local_startup}; do 283 [ -d ${dir} ] && for script in ${dir}/*.sh; do 284 [ -x ${script} ] && ${script} start 285 done 286 done 287 echo . 288fi 289 290# Do traditional (but rather obsolete) rc.local file if it exists. 291[ -f /etc/rc.local ] && sh /etc/rc.local 292 293date 294exit 0 295