rc revision 21228
1#!/bin/sh 2# $Id: rc,v 1.109 1997/01/02 16:28:33 phk 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/sysconfig. 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 ] 27then 28 ccdconfig -C 29fi 30 31swapon -a 32 33if [ $1x = autobootx ] 34then 35 echo Automatic reboot in progress... 36 fsck -p 37 case $? in 38 0) 39 ;; 40 2) 41 exit 1 42 ;; 43 4) 44 reboot 45 echo "reboot failed... help!" 46 exit 1 47 ;; 48 8) 49 echo "Automatic file system check failed... help!" 50 exit 1 51 ;; 52 12) 53 echo "Reboot interrupted" 54 exit 1 55 ;; 56 130) 57 # interrupt before catcher installed 58 exit 1 59 ;; 60 *) 61 echo "Unknown error in reboot" 62 exit 1 63 ;; 64 esac 65else 66 echo Skipping disk checks ... 67fi 68 69trap "echo 'Reboot interrupted'; exit 1" 3 70 71# root must be read/write both for NFS diskless and for VFS LKMs before 72# proceeding any further. 73mount -u -o rw / 74if [ $? != 0 ]; then 75 echo "Filesystem mount failed, startup aborted" 76 exit 1 77fi 78 79umount -a >/dev/null 2>&1 80 81mount -a -t nonfs 82if [ $? != 0 ]; then 83 echo "Filesystem mount failed, startup aborted" 84 exit 1 85fi 86 87adjkerntz -i 88 89# Keep a copy of the boot messages around 90/sbin/dmesg > /var/run/dmesg.boot 91 92# If there is a global system configuration file, suck it in. 93if [ -f /etc/sysconfig ]; then 94 . /etc/sysconfig 95fi 96 97# Add additional swapfile, if configured. 98if [ "x$swapfile" != "xNO" -a -w "$swapfile" -a -b /dev/vn0b ]; then 99 echo "Adding $swapfile as additional swap." 100 /usr/sbin/vnconfig /dev/vn0b $swapfile && swapon /dev/vn0b 101fi 102 103# configure serial devices 104if [ -f /etc/rc.serial ]; then 105 . /etc/rc.serial 106fi 107 108# start up PC-card configuration 109if [ -f /etc/rc.pccard ]; then 110 . /etc/rc.pccard 111fi 112 113# start up the network 114if [ -f /etc/netstart ]; then 115 sh /etc/netstart 116fi 117 118mount -a -t nfs >/dev/null 2>&1 119 120# Whack the pty perms back into shape. 121chmod 666 /dev/tty[pqrsPQRS]* 122 123# clean up left-over files 124rm -f /etc/nologin 125rm -f /var/spool/lock/* 126rm -rf /var/spool/uucp/.Temp/* 127(cd /var/run && { cp /dev/null utmp; chmod 644 utmp; }) 128 129# 130# Clearing /tmp at boot-time is essentially stupid, but seems to have 131# a long tradition. It doesn't help in any way for long-living systems, 132# and it might accidentally clobber files you would rather like to have 133# preserved after a crash (if not using mfs /tmp anyway). 134# 135# See also the commented out example of another cleanup policy in 136# /etc/daily. 137# 138echo clearing /tmp 139 140# prune quickly with one rm, then use find to clean up /tmp/[lq]* 141# (not needed with mfs /tmp, but doesn't hurt there...) 142(cd /tmp && rm -rf [a-km-pr-zA-Z]* && 143 find -d . ! -name . ! -name lost+found ! -name quotas -exec rm -rf -- {} \;) 144 145# The above is even more stupid since it prevents you from restarting 146# X11 after a system crash. If you disable the above, make sure to 147# uncomment the line below. 148# 149# clean up leftover X lock files and local connection sockets 150#rm -f /tmp/.X*-lock /tmp/.X11-unix/* 151 152 153# enable dumpdev so that savecore can see it 154if [ "X${dumpdev}" != X"NO" ]; then 155 dumpon ${dumpdev} 156fi 157 158# /var/crash should be a directory or a symbolic link 159# to the crash directory if core dumps are to be saved. 160if [ "X${savecore}" = X"YES" -a -d /var/crash ]; then 161 echo -n checking for core dump... 162 savecore /var/crash 163fi 164 165# snapshot any kernel -c changes back to disk 166echo 'recording kernel -c changes' 167/sbin/dset -q 168 169# start system logging and name service (named needs to start before syslogd 170# if you don't have a /etc/resolv.conf) 171# 172echo -n starting system daemons: 173 174# Transitional symlink (for the next couple of years :) until all 175# binaries had a chance to move towards /var/run/log. 176if [ ! -h /dev/log ] ; then 177 # might complain for r/o root f/s 178 ln -sf /var/run/log /dev/log 179fi 180rm -f /var/run/log 181echo ' syslogd.'; syslogd 182 183echo -n starting early network daemons: 184 185# $namedflags is imported from /etc/sysconfig 186if [ "X${namedflags}" != X"NO" ]; then 187 echo -n ' named'; named $namedflags 188fi 189 190# $ntpdate and $xntpdflags are imported from /etc/sysconfig. 191# If $ntpdate != NO, run ntpdate $ntpdate to set the date correctly. 192# If $xntpdflags != NO, start xntpd. 193if [ "X${ntpdate}" != X"NO" -o "X${xntpdflags}" != X"NO" ]; then 194 if [ "X${tickadjflags}" != X"NO" ]; then 195 echo -n ' tickadj'; tickadj ${tickadjflags--Aq} 196 fi 197 198 if [ "X${ntpdate}" != X"NO" ]; then 199 echo -n ' ntpdate'; ntpdate ${ntpdate} >/dev/null 2>&1 200 fi 201 202 if [ "X${xntpdflags}" != X"NO" ]; then 203 echo -n ' xntpd'; xntpd ${xntpdflags} 204 fi 205fi 206 207# $timedflags is imported from /etc/sysconfig; 208# if $timedflags == NO, timed isn't run. 209if [ "X${timedflags}" != X"NO" ]; then 210 echo -n ' timed'; timed $timedflags 211fi 212 213# Portmapper should always be run, to provide RPC services for inetd. 214if [ -x /usr/sbin/portmap ]; then 215 echo -n ' portmap'; portmap 216fi 217 218# Start ypserv if we're an NIS server. 219# Run rpc.ypxfrd and rpc.yppasswdd only on the NIS master server. 220if [ "X${nis_serverflags}" != X"NO" ]; then 221 echo -n ' ypserv'; ypserv ${nis_serverflags} 222 223 if [ "X${ypxfrdflags}" != X"NO" ]; then 224 echo -n ' rpc.ypxfrd'; rpc.ypxfrd ${ypxfrdflags} 225 fi 226 227 if [ "X${yppasswddflags}" != X"NO" ]; then 228 echo -n ' rpc.yppasswdd'; rpc.yppasswdd ${yppasswddflags} 229 fi 230fi 231 232# Start ypbind if we're an NIS client 233if [ "X${nis_clientflags}" != X"NO" ]; then 234 echo -n ' ypbind'; ypbind ${nis_clientflags} 235 if [ "X${nis_ypsetflags}" != X"NO" ]; then 236 echo -n ' ypset'; ypset ${nis_ypsetflags} 237 fi 238fi 239 240echo '.' 241 242# Check the quotas (must be after ypbind if using NIS) 243if [ "X${check_quotas}" = X"YES" ]; then 244 echo -n 'checking quotas:' 245 quotacheck -a 246 echo ' done.' 247 quotaon -a 248fi 249 250echo -n starting other network daemons: 251 252if [ "X${nfs_server}" = X"YES" -a -r /etc/exports ]; then 253 echo -n ' mountd' 254 if [ "X${weak_mountd_authentication}" = X"YES" ]; then 255 mountd -n 256 else 257 mountd 258 fi 259 echo -n ' nfsd'; nfsd -u -t 4 260# Warning: rpc.lockd is broken. 261# Only uncomment this line if the consequences are fully understood. 262# echo -n ' rpc.lockd'; rpc.lockd 263 echo -n ' rpc.statd'; rpc.statd 264fi 265 266if [ "X${nfs_client}" = X"YES" ]; then 267 echo -n ' nfsiod'; nfsiod -n 4 268fi 269 270if [ "X${amdflags}" != X"NO" ]; then 271 echo -n ' amd' 272 amd -p ${amdflags} > /var/run/amd.pid 273fi 274 275# $rwhod is imported from /etc/sysconfig; 276# if $rwhod is set to YES, rwhod is run. 277if [ "X${rwhod}" = X"YES" ]; then 278 echo -n ' rwhod'; rwhod 279fi 280 281# Kerberos runs ONLY on the Kerberos server machine 282if [ "X${kerberos_server}" = X"YES" ]; then 283 echo -n ' kerberos'; kerberos >> /var/log/kerberos.log & 284 echo -n ' kadmind'; \ 285 (sleep 20; kadmind -n >/dev/null 2>&1 &) & 286fi 287 288# IP multicast routing daemon 289if [ "X${mrouted}" != X"NO" -a -x /usr/sbin/mrouted ]; then 290 echo -n ' mrouted'; mrouted ${mrouted} 291fi 292 293echo '.' 294 295# build ps databases 296kvm_mkdb 297dev_mkdb 298 299# check the password temp/lock file 300if [ -f /etc/ptmp ] 301then 302 logger -s -p auth.err \ 303 "password file may be incorrect -- /etc/ptmp exists" 304fi 305 306if [ "X${accounting}" = X"YES" -a -d /var/account ]; then 307 echo 'turning on accounting' 308 if [ ! -e /var/account/acct ]; then 309 touch /var/account/acct 310 fi 311 accton /var/account/acct 312fi 313 314# Make shared lib searching a little faster. Leave /usr/lib first if you 315# add your own entries or you may come to grief. 316if [ -x /sbin/ldconfig ]; then 317 _LDC=/usr/lib 318 if [ -d /usr/lib/compat ]; then _LDC="${_LDC} /usr/lib/compat" ; fi 319 if [ -d /usr/X11R6/lib ]; then _LDC="${_LDC} /usr/X11R6/lib" ; fi 320 if [ -d /usr/X386/lib ]; then _LDC="${_LDC} /usr/X386/lib" ; fi 321 if [ -d /usr/local/lib ]; then _LDC="${_LDC} /usr/local/lib" ; fi 322 echo 'setting ldconfig path:' ${_LDC} 323 ldconfig ${_LDC} 324fi 325 326# Now start up miscellaneous daemons that don't belong anywhere else 327# 328echo -n standard daemons: 329echo -n ' inetd'; inetd 330echo -n ' cron'; cron 331 332if [ "X${lpd}" != X"NO" -a -x /usr/sbin/lpd ]; then 333 echo -n ' printer'; lpd 334fi 335 336# $sendmail_flags is imported from /etc/sysconfig; 337# if $sendmail_flags is something other than NO, sendmail is run. 338if [ "X${sendmail_flags}" != X"NO" -a -r /etc/sendmail.cf ]; then 339 echo -n ' sendmail'; /usr/sbin/sendmail ${sendmail_flags} 340fi 341 342echo '.' 343 344# configure implementation specific stuff 345arch=`uname -m` 346if [ -f /etc/rc.${arch} ]; then 347 . /etc/rc.${arch} 348fi 349 350# Recover vi editor files. 351vibackup=`echo /var/tmp/vi.recover/vi.*` 352if [ "$vibackup" != '/var/tmp/vi.recover/vi.*' ]; then 353 echo 'Recovering vi editor sessions' 354 for i in $vibackup; do 355 # Only test files that are readable. 356 if test ! -r $i; then 357 continue 358 fi 359 360 # Unmodified nvi editor backup files either have the 361 # execute bit set or are zero length. Delete them. 362 if test -x $i -o ! -s $i; then 363 rm -f $i 364 fi 365 done 366 367 # It is possible to get incomplete recovery files, if the editor 368 # crashes at the right time. 369 virecovery=`echo /var/tmp/vi.recover/recover.*` 370 if [ "$virecovery" != "/var/tmp/vi.recover/recover.*" ]; then 371 for i in $virecovery; do 372 # Only test files that are readable. 373 if test ! -r $i; then 374 continue 375 fi 376 377 # Delete any recovery files that are zero length, 378 # corrupted, or that have no corresponding backup file. 379 # Else send mail to the user. 380 recfile=`awk '/^X-vi-recover-path:/{print $2}' < $i` 381 if test -n "$recfile" -a -s "$recfile"; then 382 sendmail -t < $i 383 else 384 rm -f $i 385 fi 386 done 387 fi 388fi 389 390# for each valid dir in $local_startup, search for init scripts matching *.sh 391if [ "X${local_startup}" != X"NO" ]; then 392 echo -n 'Local package startup:' 393 for dir in ${local_startup}; do 394 [ -d ${dir} ] && for script in ${dir}/*.sh; do 395 [ -x ${script} ] && ${script} start 396 done 397 done 398 echo . 399fi 400 401# Do traditional (but rather obsolete) rc.local file if it exists. 402[ -f /etc/rc.local ] && sh /etc/rc.local 403 404date 405exit 0 406