rc revision 18812
1#!/bin/sh 2# $Id: rc,v 1.99 1996/09/22 06:36:49 imp 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 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${yppasswddflags}" != X"NO" ]; then 215 echo -n ' yppasswdd'; rpc.yppasswdd ${yppasswddflags} 216 fi 217fi 218 219# Start ypbind if we're an NIS client 220if [ "X${nis_clientflags}" != X"NO" ]; then 221 echo -n ' ypbind'; ypbind ${nis_clientflags} 222 if [ "X${nis_ypsetflags}" != X"NO" ]; then 223 echo -n ' ypset'; ypset ${nis_ypsetflags} 224 fi 225fi 226 227echo '.' 228 229# Check the quotas (must be after ypbind if using NIS) 230if [ "X${check_quotas}" = X"YES" ]; then 231 echo -n 'checking quotas:' 232 quotacheck -a 233 echo ' done.' 234 quotaon -a 235fi 236 237echo -n starting other network daemons: 238 239if [ "X${nfs_server}" = X"YES" -a -r /etc/exports ]; then 240 echo -n ' mountd' 241 if [ "X${weak_mountd_authentication}" = X"YES" ]; then 242 mountd -n 243 else 244 mountd 245 fi 246 echo -n ' nfsd'; nfsd -u -t 4 247fi 248 249if [ "X${nfs_client}" = X"YES" ]; then 250 echo -n ' nfsiod'; nfsiod -n 4 251fi 252 253if [ "X${amdflags}" != X"NO" ]; then 254 echo -n ' amd' 255 amd ${amdflags} > /var/run/amd.pid 256fi 257 258# $rwhod is imported from /etc/sysconfig; 259# if $rwhod is set to YES, rwhod is run. 260if [ "X${rwhod}" = X"YES" ]; then 261 echo -n ' rwhod'; rwhod 262fi 263 264# Kerberos runs ONLY on the Kerberos server machine 265if [ "X${kerberos_server}" = X"YES" ]; then 266 echo -n ' kerberos'; kerberos >> /var/log/kerberos.log & 267 echo -n ' kadmind'; \ 268 (sleep 20; kadmind -n >/dev/null 2>&1 &) & 269fi 270 271# IP multicast routing daemon 272if [ "X${mrouted}" != X"NO" -a -x /usr/sbin/mrouted ]; then 273 echo -n ' mrouted'; mrouted ${mrouted} 274fi 275 276echo '.' 277 278# build ps databases 279kvm_mkdb 280dev_mkdb 281 282# check the password temp/lock file 283if [ -f /etc/ptmp ] 284then 285 logger -s -p auth.err \ 286 "password file may be incorrect -- /etc/ptmp exists" 287fi 288 289if [ "X${accounting}" = X"YES" -a -d /var/account ]; then 290 echo 'turning on accounting' 291 if [ ! -e /var/account/acct ]; then 292 touch /var/account/acct 293 fi 294 accton /var/account/acct 295fi 296 297# Make shared lib searching a little faster. Leave /usr/lib first if you 298# add your own entries or you may come to grief. 299if [ -x /sbin/ldconfig ]; then 300 _LDC=/usr/lib 301 if [ -d /usr/lib/compat ]; then _LDC="${_LDC} /usr/lib/compat" ; fi 302 if [ -d /usr/X11R6/lib ]; then _LDC="${_LDC} /usr/X11R6/lib" ; fi 303 if [ -d /usr/X386/lib ]; then _LDC="${_LDC} /usr/X386/lib" ; fi 304 if [ -d /usr/local/lib ]; then _LDC="${_LDC} /usr/local/lib" ; fi 305 echo 'setting ldconfig path:' ${_LDC} 306 ldconfig ${_LDC} 307fi 308 309# Now start up miscellaneous daemons that don't belong anywhere else 310# 311echo -n standard daemons: 312echo -n ' inetd'; inetd 313echo -n ' cron'; cron 314 315if [ "X${lpd}" != X"NO" -a -x /usr/sbin/lpd ]; then 316 echo -n ' printer'; lpd 317fi 318 319# $sendmail_flags is imported from /etc/sysconfig; 320# if $sendmail_flags is something other than NO, sendmail is run. 321if [ "X${sendmail_flags}" != X"NO" -a -r /etc/sendmail.cf ]; then 322 echo -n ' sendmail'; /usr/sbin/sendmail ${sendmail_flags} 323fi 324 325echo '.' 326 327# configure implementation specific stuff 328arch=`uname -m` 329if [ -f /etc/rc.${arch} ]; then 330 . /etc/rc.${arch} 331fi 332 333# Recover vi editor files. 334virecovery=`echo /var/tmp/vi.recover/recover.*` 335if [ "$virecovery" != '/var/tmp/vi.recover/recover.*' ]; then 336 echo 'Recovering vi editor sessions' 337 for i in $virecovery; do 338 sendmail -t < $i 339 done 340fi 341 342# for each valid dir in $local_startup, search for init scripts matching *.sh 343if [ "X${local_startup}" != X"NO" ]; then 344 echo -n 'Local package startup:' 345 for dir in ${local_startup}; do 346 [ -d ${dir} ] && for script in ${dir}/*.sh; do 347 [ -x ${script} ] && ${script} start 348 done 349 done 350 echo . 351fi 352 353# Do traditional (but rather obsolete) rc.local file if it exists. 354[ -f /etc/rc.local ] && sh /etc/rc.local 355 356date 357exit 0 358