rc revision 18460
1#!/bin/sh 2# $Id: rc,v 1.98 1996/09/02 13:09:54 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 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# Check the quotas 168if [ "X${check_quotas}" = X"YES" ]; then 169 echo 'checking quotas:' 170 quotacheck -a 171 echo ' done.' 172 quotaon -a 173fi 174 175# start system logging and name service (named needs to start before syslogd 176# if you don't have a /etc/resolv.conf) 177# 178echo -n starting system daemons: 179 180echo ' syslogd.'; syslogd 181 182echo -n starting network daemons: 183 184# $namedflags is imported from /etc/sysconfig 185if [ "X${namedflags}" != X"NO" ]; then 186 echo -n ' named'; named $namedflags 187fi 188 189# $ntpdate and $xntpdflags are imported from /etc/sysconfig. 190# If $ntpdate != NO, run ntpdate $ntpdate to set the date correctly. 191# If $xntpdflags != NO, start xntpd. 192if [ "X${ntpdate}" != X"NO" -o "X${xntpdflags}" != X"NO" ]; then 193 if [ "X${tickadjflags}" != X"NO" ]; then 194 echo -n ' tickadj'; tickadj ${tickadjflags--Aq} 195 fi 196 197 if [ "X${ntpdate}" != X"NO" ]; then 198 echo -n ' ntpdate'; ntpdate ${ntpdate} >/dev/null 2>&1 199 fi 200 201 if [ "X${xntpdflags}" != X"NO" ]; then 202 echo -n ' xntpd'; xntpd ${xntpdflags} 203 fi 204fi 205 206# $timedflags is imported from /etc/sysconfig; 207# if $timedflags == NO, timed isn't run. 208if [ "X${timedflags}" != X"NO" ]; then 209 echo -n ' timed'; timed $timedflags 210fi 211 212# Portmapper should always be run, to provide RPC services for inetd. 213if [ -x /usr/sbin/portmap ]; then 214 echo -n ' portmap'; portmap 215fi 216 217# Start ypserv if we're an NIS server. 218# Run yppasswdd only on the NIS master server 219if [ "X${nis_serverflags}" != X"NO" ]; then 220 echo -n ' ypserv'; ypserv ${nis_serverflags} 221 222 if [ "X${yppasswddflags}" != X"NO" ]; then 223 echo -n ' yppasswdd'; rpc.yppasswdd ${yppasswddflags} 224 fi 225fi 226 227# Start ypbind if we're an NIS client 228if [ "X${nis_clientflags}" != X"NO" ]; then 229 echo -n ' ypbind'; ypbind ${nis_clientflags} 230 if [ "X${nis_ypsetflags}" != X"NO" ]; then 231 echo -n ' ypset'; ypset ${nis_ypsetflags} 232 fi 233fi 234 235# $rwhod is imported from /etc/sysconfig; 236# if $rwhod is set to YES, rwhod is run. 237if [ "X${rwhod}" = X"YES" ]; then 238 echo -n ' rwhod'; rwhod 239fi 240 241if [ "X${nfs_server}" = X"YES" -a -r /etc/exports ]; then 242 echo -n ' mountd' 243 if [ "X${weak_mountd_authentication}" = X"YES" ]; then 244 mountd -n 245 else 246 mountd 247 fi 248 echo -n ' nfsd'; nfsd -u -t 4 249fi 250 251if [ "X${nfs_client}" = X"YES" ]; then 252 echo -n ' nfsiod'; nfsiod -n 4 253fi 254 255if [ "X${amdflags}" != X"NO" ]; then 256 echo -n ' amd' 257 amd ${amdflags} > /var/run/amd.pid 258fi 259 260# Kerberos runs ONLY on the Kerberos server machine 261if [ "X${kerberos_server}" = X"YES" ]; then 262 echo -n ' kerberos'; kerberos >> /var/log/kerberos.log & 263 echo -n ' kadmind'; \ 264 (sleep 20; kadmind -n >/dev/null 2>&1 &) & 265fi 266 267# IP multicast routing daemon 268if [ "X${mrouted}" != X"NO" -a -x /usr/sbin/mrouted ]; then 269 echo -n ' mrouted'; mrouted ${mrouted} 270fi 271 272echo -n ' inetd'; inetd 273echo '.' 274 275# build ps databases 276kvm_mkdb 277dev_mkdb 278 279# check the password temp/lock file 280if [ -f /etc/ptmp ] 281then 282 logger -s -p auth.err \ 283 "password file may be incorrect -- /etc/ptmp exists" 284fi 285 286if [ "X${accounting}" = X"YES" -a -d /var/account ]; then 287 echo 'turning on accounting' 288 if [ ! -e /var/account/acct ]; then 289 touch /var/account/acct 290 fi 291 accton /var/account/acct 292fi 293 294# Make shared lib searching a little faster. Leave /usr/lib first if you 295# add your own entries or you may come to grief. 296if [ -x /sbin/ldconfig ]; then 297 _LDC=/usr/lib 298 if [ -d /usr/lib/compat ]; then _LDC="${_LDC} /usr/lib/compat" ; fi 299 if [ -d /usr/X11R6/lib ]; then _LDC="${_LDC} /usr/X11R6/lib" ; fi 300 if [ -d /usr/X386/lib ]; then _LDC="${_LDC} /usr/X386/lib" ; fi 301 if [ -d /usr/local/lib ]; then _LDC="${_LDC} /usr/local/lib" ; fi 302 echo 'setting ldconfig path:' ${_LDC} 303 ldconfig ${_LDC} 304fi 305 306# Now start up miscellaneous daemons that don't belong anywhere else 307# 308echo -n standard daemons: 309echo -n ' cron'; cron 310 311if [ "X${lpd}" != X"NO" -a -x /usr/sbin/lpd ]; then 312 echo -n ' printer'; lpd 313fi 314 315# $sendmail_flags is imported from /etc/sysconfig; 316# if $sendmail_flags is something other than NO, sendmail is run. 317if [ "X${sendmail_flags}" != X"NO" -a -r /etc/sendmail.cf ]; then 318 echo -n ' sendmail'; /usr/sbin/sendmail ${sendmail_flags} 319fi 320 321echo '.' 322 323# configure implementation specific stuff 324arch=`uname -m` 325if [ -f /etc/rc.${arch} ]; then 326 . /etc/rc.${arch} 327fi 328 329# Recover vi editor files. 330virecovery=`echo /var/tmp/vi.recover/recover.*` 331if [ "$virecovery" != '/var/tmp/vi.recover/recover.*' ]; then 332 echo 'Recovering vi editor sessions' 333 for i in $virecovery; do 334 sendmail -t < $i 335 done 336fi 337 338# for each valid dir in $local_startup, search for init scripts matching *.sh 339if [ "X${local_startup}" != X"NO" ]; then 340 echo -n 'Local package startup:' 341 for dir in ${local_startup}; do 342 [ -d ${dir} ] && for script in ${dir}/*.sh; do 343 [ -x ${script} ] && ${script} start 344 done 345 done 346 echo . 347fi 348 349# Do traditional (but rather obsolete) rc.local file if it exists. 350[ -f /etc/rc.local ] && sh /etc/rc.local 351 352date 353exit 0 354