rc revision 19076
1#!/bin/sh 2# $Id: rc,v 1.101 1996/10/08 20:02:57 peter 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 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# If there is a global system configuration file, suck it in. 90if [ -f /etc/sysconfig ]; then 91 . /etc/sysconfig 92fi 93 94# Add additional swapfile, if configured. 95if [ "x$swapfile" != "xNO" -a -w "$swapfile" -a -f /dev/vn0b ]; then 96 echo "Adding $swapfile as additional swap." 97 /usr/sbin/vnconfig /dev/vn0b $swapfile && swapon /dev/vn0b 98fi 99 100# configure serial devices 101if [ -f /etc/rc.serial ]; then 102 . /etc/rc.serial 103fi 104 105# start up PC-card configuration 106if [ -f /etc/rc.pccard ]; then 107 . /etc/rc.pccard 108fi 109 110# start up the network 111if [ -f /etc/netstart ]; then 112 sh /etc/netstart 113fi 114 115mount -a -t nfs >/dev/null 2>&1 116 117# Whack the pty perms back into shape. 118chmod 666 /dev/tty[pqrs]* 119 120# clean up left-over files 121rm -f /etc/nologin 122rm -f /var/spool/lock/* 123rm -rf /var/spool/uucp/.Temp/* 124rm -f /dev/log 125(cd /var/run && { cp /dev/null utmp; chmod 644 utmp; }) 126 127# 128# Clearing /tmp at boot-time is essentially stupid, but seems to have 129# a long tradition. It doesn't help in any way for long-living systems, 130# and it might accidentally clobber files you would rather like to have 131# preserved after a crash (if not using mfs /tmp anyway). 132# 133# See also the commented out example of another cleanup policy in 134# /etc/daily. 135# 136echo clearing /tmp 137 138# prune quickly with one rm, then use find to clean up /tmp/[lq]* 139# (not needed with mfs /tmp, but doesn't hurt there...) 140(cd /tmp && rm -rf [a-km-pr-zA-Z]* && 141 find -d . ! -name . ! -name lost+found ! -name quotas -exec rm -rf -- {} \;) 142 143# The above is even more stupid since it prevents you from restarting 144# X11 after a system crash. If you disable the above, make sure to 145# uncomment the line below. 146# 147# clean up leftover X lock files and local connection sockets 148#rm -f /tmp/.X*-lock /tmp/.X11-unix/* 149 150 151# enable dumpdev so that savecore can see it 152if [ "X${dumpdev}" != X"NO" ]; then 153 dumpon ${dumpdev} 154fi 155 156# /var/crash should be a directory or a symbolic link 157# to the crash directory if core dumps are to be saved. 158if [ "X${savecore}" = X"YES" -a -d /var/crash ]; then 159 echo -n checking for core dump... 160 savecore /var/crash 161fi 162 163# snapshot any kernel -c changes back to disk 164echo 'recording kernel -c changes' 165/sbin/dset -q 166 167# start system logging and name service (named needs to start before syslogd 168# if you don't have a /etc/resolv.conf) 169# 170echo -n starting system daemons: 171 172echo ' syslogd.'; syslogd 173 174echo -n starting early network daemons: 175 176# $namedflags is imported from /etc/sysconfig 177if [ "X${namedflags}" != X"NO" ]; then 178 echo -n ' named'; named $namedflags 179fi 180 181# $ntpdate and $xntpdflags are imported from /etc/sysconfig. 182# If $ntpdate != NO, run ntpdate $ntpdate to set the date correctly. 183# If $xntpdflags != NO, start xntpd. 184if [ "X${ntpdate}" != X"NO" -o "X${xntpdflags}" != X"NO" ]; then 185 if [ "X${tickadjflags}" != X"NO" ]; then 186 echo -n ' tickadj'; tickadj ${tickadjflags--Aq} 187 fi 188 189 if [ "X${ntpdate}" != X"NO" ]; then 190 echo -n ' ntpdate'; ntpdate ${ntpdate} >/dev/null 2>&1 191 fi 192 193 if [ "X${xntpdflags}" != X"NO" ]; then 194 echo -n ' xntpd'; xntpd ${xntpdflags} 195 fi 196fi 197 198# $timedflags is imported from /etc/sysconfig; 199# if $timedflags == NO, timed isn't run. 200if [ "X${timedflags}" != X"NO" ]; then 201 echo -n ' timed'; timed $timedflags 202fi 203 204# Portmapper should always be run, to provide RPC services for inetd. 205if [ -x /usr/sbin/portmap ]; then 206 echo -n ' portmap'; portmap 207fi 208 209# Start ypserv if we're an NIS server. 210# Run rpc.ypxfrd and rpc.yppasswdd only on the NIS master server. 211if [ "X${nis_serverflags}" != X"NO" ]; then 212 echo -n ' ypserv'; ypserv ${nis_serverflags} 213 214 if [ "X${ypxfrdflags}" != X"NO" ]; then 215 echo -n ' rpc.ypxfrd'; rpc.ypxfrd ${ypxfrdflags} 216 fi 217 218 if [ "X${yppasswddflags}" != X"NO" ]; then 219 echo -n ' rpc.yppasswdd'; rpc.yppasswdd ${yppasswddflags} 220 fi 221fi 222 223# Start ypbind if we're an NIS client 224if [ "X${nis_clientflags}" != X"NO" ]; then 225 echo -n ' ypbind'; ypbind ${nis_clientflags} 226 if [ "X${nis_ypsetflags}" != X"NO" ]; then 227 echo -n ' ypset'; ypset ${nis_ypsetflags} 228 fi 229fi 230 231echo '.' 232 233# Check the quotas (must be after ypbind if using NIS) 234if [ "X${check_quotas}" = X"YES" ]; then 235 echo -n 'checking quotas:' 236 quotacheck -a 237 echo ' done.' 238 quotaon -a 239fi 240 241echo -n starting other network daemons: 242 243if [ "X${nfs_server}" = X"YES" -a -r /etc/exports ]; then 244 echo -n ' mountd' 245 if [ "X${weak_mountd_authentication}" = X"YES" ]; then 246 mountd -n 247 else 248 mountd 249 fi 250 echo -n ' nfsd'; nfsd -u -t 4 251fi 252 253if [ "X${nfs_client}" = X"YES" ]; then 254 echo -n ' nfsiod'; nfsiod -n 4 255fi 256 257if [ "X${amdflags}" != X"NO" ]; then 258 echo -n ' amd' 259 amd -p ${amdflags} > /var/run/amd.pid 260fi 261 262# $rwhod is imported from /etc/sysconfig; 263# if $rwhod is set to YES, rwhod is run. 264if [ "X${rwhod}" = X"YES" ]; then 265 echo -n ' rwhod'; rwhod 266fi 267 268# Kerberos runs ONLY on the Kerberos server machine 269if [ "X${kerberos_server}" = X"YES" ]; then 270 echo -n ' kerberos'; kerberos >> /var/log/kerberos.log & 271 echo -n ' kadmind'; \ 272 (sleep 20; kadmind -n >/dev/null 2>&1 &) & 273fi 274 275# IP multicast routing daemon 276if [ "X${mrouted}" != X"NO" -a -x /usr/sbin/mrouted ]; then 277 echo -n ' mrouted'; mrouted ${mrouted} 278fi 279 280echo '.' 281 282# build ps databases 283kvm_mkdb 284dev_mkdb 285 286# check the password temp/lock file 287if [ -f /etc/ptmp ] 288then 289 logger -s -p auth.err \ 290 "password file may be incorrect -- /etc/ptmp exists" 291fi 292 293if [ "X${accounting}" = X"YES" -a -d /var/account ]; then 294 echo 'turning on accounting' 295 if [ ! -e /var/account/acct ]; then 296 touch /var/account/acct 297 fi 298 accton /var/account/acct 299fi 300 301# Make shared lib searching a little faster. Leave /usr/lib first if you 302# add your own entries or you may come to grief. 303if [ -x /sbin/ldconfig ]; then 304 _LDC=/usr/lib 305 if [ -d /usr/lib/compat ]; then _LDC="${_LDC} /usr/lib/compat" ; fi 306 if [ -d /usr/X11R6/lib ]; then _LDC="${_LDC} /usr/X11R6/lib" ; fi 307 if [ -d /usr/X386/lib ]; then _LDC="${_LDC} /usr/X386/lib" ; fi 308 if [ -d /usr/local/lib ]; then _LDC="${_LDC} /usr/local/lib" ; fi 309 echo 'setting ldconfig path:' ${_LDC} 310 ldconfig ${_LDC} 311fi 312 313# Now start up miscellaneous daemons that don't belong anywhere else 314# 315echo -n standard daemons: 316echo -n ' inetd'; inetd 317echo -n ' cron'; cron 318 319if [ "X${lpd}" != X"NO" -a -x /usr/sbin/lpd ]; then 320 echo -n ' printer'; lpd 321fi 322 323# $sendmail_flags is imported from /etc/sysconfig; 324# if $sendmail_flags is something other than NO, sendmail is run. 325if [ "X${sendmail_flags}" != X"NO" -a -r /etc/sendmail.cf ]; then 326 echo -n ' sendmail'; /usr/sbin/sendmail ${sendmail_flags} 327fi 328 329echo '.' 330 331# configure implementation specific stuff 332arch=`uname -m` 333if [ -f /etc/rc.${arch} ]; then 334 . /etc/rc.${arch} 335fi 336 337# Recover vi editor files. 338virecovery=`echo /var/tmp/vi.recover/recover.*` 339if [ "$virecovery" != '/var/tmp/vi.recover/recover.*' ]; then 340 echo 'Recovering vi editor sessions' 341 for i in $virecovery; do 342 sendmail -t < $i 343 done 344fi 345 346# for each valid dir in $local_startup, search for init scripts matching *.sh 347if [ "X${local_startup}" != X"NO" ]; then 348 echo -n 'Local package startup:' 349 for dir in ${local_startup}; do 350 [ -d ${dir} ] && for script in ${dir}/*.sh; do 351 [ -x ${script} ] && ${script} start 352 done 353 done 354 echo . 355fi 356 357# Do traditional (but rather obsolete) rc.local file if it exists. 358[ -f /etc/rc.local ] && sh /etc/rc.local 359 360date 361exit 0 362