rc revision 9593
138451Smsmith#!/bin/sh 238451Smsmith# $Id: rc,v 1.67 1995/06/25 04:01:32 bde Exp $ 338451Smsmith# From: @(#)rc 5.27 (Berkeley) 6/5/91 438451Smsmith 538451Smsmith# System startup script run by init on autoboot 638451Smsmith# or after single-user. 738451Smsmith# Output and error are redirected to console by init, 838451Smsmith# and the console is the controlling terminal. 938451Smsmith 1038451Smsmith# Note that almost all the user-configurable behavior is no longer in 1138451Smsmith# this file, but rather in /etc/sysconfig. Please check this file 1238451Smsmith# first before contemplating any changes here. 1338451Smsmith 1438451Smsmithstty status '^T' 1538451Smsmith 1638451Smsmith# Set shell to ignore SIGINT (2), but not children; 1738451Smsmith# shell catches SIGQUIT (3) and returns to single user after fsck. 1838451Smsmithtrap : 2 1938451Smsmithtrap : 3 # shouldn't be needed 2038451Smsmith 2138451SmsmithHOME=/; export HOME 2238451SmsmithPATH=/sbin:/bin:/usr/sbin:/usr/bin 2338451Smsmithexport PATH 2438451Smsmith 2538451Smsmithswapon -a 2638451Smsmith 2738451Smsmithif [ $1x = autobootx ] 2838451Smsmiththen 2938451Smsmith echo Automatic reboot in progress... 3038451Smsmith fsck -p 3138451Smsmith case $? in 3238451Smsmith 0) 3338451Smsmith ;; 3438451Smsmith 2) 3538451Smsmith exit 1 3638451Smsmith ;; 3738451Smsmith 4) 3838451Smsmith reboot 3938451Smsmith echo "reboot failed... help!" 4038451Smsmith exit 1 4138451Smsmith ;; 4238451Smsmith 8) 4338451Smsmith echo "Automatic file system check failed... help!" 4438451Smsmith exit 1 4538451Smsmith ;; 4638451Smsmith 12) 4738451Smsmith echo "Reboot interrupted" 4838451Smsmith exit 1 4938451Smsmith ;; 5038451Smsmith 130) 5138451Smsmith # interrupt before catcher installed 5238451Smsmith exit 1 5338451Smsmith ;; 5438451Smsmith *) 5538451Smsmith echo "Unknown error in reboot" 5638451Smsmith exit 1 5738451Smsmith ;; 5838451Smsmith esac 5938451Smsmithelse 6038451Smsmith echo Skipping disk checks ... 6138451Smsmithfi 6238451Smsmith 6384221Sdillontrap "echo 'Reboot interrupted'; exit 1" 3 6484221Sdillon 6584221Sdillon# root must be read/write both for NFS diskless and for VFS LKMs before 6638451Smsmith# proceeding any further. 6738451Smsmithmount -u -o rw / 6838451Smsmithif [ $? != 0 ]; then 6965470Smsmith echo "Filesystem mount failed, startup aborted" 7038451Smsmith exit 1 7165470Smsmithfi 7265470Smsmith 7338451Smsmithumount -a >/dev/null 2>&1 7465470Smsmith 7565470Smsmithmount -a -t nonfs 7665470Smsmithif [ $? != 0 ]; then 7765470Smsmith echo "Filesystem mount failed, startup aborted" 78259540Smarcel exit 1 7965470Smsmithfi 80259540Smarcel 81259540Smarcel# If the machine runs wall CMOS clock (compatible with MSDOS), 8265470Smsmith# activate following line by creating empty file /etc/wall_cmos_clock 8365470Smsmith# If this file not exist, following line does nothing (assumed 8465470Smsmith# the machine runs UTC CMOS clock). See adjkerntz(8) for details. 8565470Smsmithadjkerntz -i 8665470Smsmith 8765470Smsmith# If there is a global system configuration file, suck it in. 8865470Smsmithif [ -f /etc/sysconfig ]; then 8965470Smsmith . /etc/sysconfig 9065470Smsmithfi 9165470Smsmith 9265470Smsmith# configure serial devices 9365470Smsmithif [ -f /etc/rc.serial ]; then 9465470Smsmith . /etc/rc.serial 9565470Smsmithfi 9665470Smsmith 9765470Smsmith# start up the network 9838451Smsmithif [ -f /etc/netstart ]; then 99 sh /etc/netstart 100fi 101 102mount -a -t nfs >/dev/null 2>&1 103 104# Whack the pty perms back into shape. 105chmod 666 /dev/tty[pqrs]* 106 107# clean up left-over files 108rm -f /etc/nologin 109rm -f /var/spool/lock/* 110rm -rf /var/spool/uucp/.Temp/* 111rm -f /dev/log 112(cd /var/run && { rm -rf -- *; cp /dev/null utmp; chmod 644 utmp; }) 113 114echo clearing /tmp 115 116# prune quickly with one rm, then use find to clean up /tmp/[lq]* 117# (not needed with mfs /tmp, but doesn't hurt there...) 118(cd /tmp && rm -rf [a-km-pr-zA-Z]* && 119 find -d . ! -name . ! -name lost+found ! -name quotas -exec rm -rf -- {} \;) 120 121# enable dumpdev so that savecore can see it 122if [ "X${dumpdev}" != X"NO" ]; then 123 dumpon ${dumpdev} 124fi 125 126# /var/crash should be a directory or a symbolic link 127# to the crash directory if core dumps are to be saved. 128if [ "X${savecore}" = X"YES" -a -d /var/crash ]; then 129 echo -n checking for core dump... 130 savecore /var/crash 131fi 132 133# snapshot any kernel -c changes back to disk 134echo 'recording kernel -c changes' 135/sbin/dset -q 136 137# Check the quotas 138if [ "X${check_quotas}" = X"YES" ]; then 139 echo 'checking quotas:' 140 quotacheck -a 141 echo ' done.' 142 quotaon -a 143fi 144 145# start system logging and name service (named needs to start before syslogd 146# if you don't have a /etc/resolv.conf) 147# 148echo -n starting system daemons: 149 150echo ' syslogd.'; syslogd 151 152echo -n starting network daemons: 153 154# $namedflags is imported from /etc/sysconfig 155if [ "X${namedflags}" != "XNO" ]; then 156 echo -n ' named'; named $namedflags 157fi 158 159# $ntpdate and $xntpdflags are imported from /etc/sysconfig. 160# If $ntpdate != NO, run ntpdate $ntpdate to set the date correctly. 161# If $xntpdflags != NO, start xntpd. 162if [ "X${ntpdate}" != X"NO" -o "X${xntpdflags}" != X"NO" ]; then 163 if [ "X${tickadjflags}" != X"NO" ]; then 164 echo -n ' tickadj'; tickadj ${tickadjflags--Aq} 165 fi 166 167 if [ "X${ntpdate}" != X"NO" ]; then 168 echo -n ' ntpdate'; ntpdate ${ntpdate} >/dev/null 2>&1 169 fi 170 171 if [ "X${xntpdflags}" != X"NO" ]; then 172 echo -n ' xntpd'; xntpd ${xntpdflags} 173 fi 174fi 175 176# $timedflags is imported from /etc/sysconfig; 177# if $timedflags == NO, timed isn't run. 178if [ "X${timedflags}" != X"NO" ]; then 179 echo -n ' timed'; timed $timedflags 180fi 181 182# Portmapper should always be run, to provide RPC services for inetd. 183if [ -x /usr/sbin/portmap ]; then 184 echo -n ' portmap'; portmap 185fi 186 187# Start ypserv if we're an NIS server. 188# Run yppasswdd only on the NIS master server 189if [ "X${nis_serverflags}" != X"NO" ]; then 190 echo -n ' ypserv'; ypserv ${nis_serverflags} 191 192 if [ "X${yppasswddflags}" != X"NO" ]; then 193 echo -n ' yppasswdd'; yppasswdd ${yppasswddflags} 194 fi 195fi 196 197# Start ypbind if we're an NIS client 198if [ "X${nis_clientflags}" != X"NO" ]; then 199 echo -n ' ypbind'; ypbind ${nis_clientflags} 200 if [ "X${nis_ypsetflags}" != X"NO" ]; then 201 echo -n ' ypset'; ypset ${nis_ypsetflags} 202 fi 203fi 204 205# $rwhod is imported from /etc/sysconfig; 206# if $rwhod is set to YES, rwhod is run. 207if [ "X${rwhod}" = X"YES" ]; then 208 echo -n ' rwhod'; rwhod 209fi 210 211if [ "X${nfs_server}" = X"YES" -a -r /etc/exports ]; then 212 echo -n ' mountd'; mountd 213 echo -n ' nfsd'; nfsd -u -t 4 214fi 215 216if [ "X${nfs_client}" = X"YES" ]; then 217 echo -n ' nfsiod'; nfsiod -n 4 218fi 219 220if [ "X${amdflags}" != X"NO" ]; then 221 echo -n ' amd'; amd ${amdflags} 222fi 223 224# Kerberos runs ONLY on the Kerberos server machine 225if [ "X${kerberos_server}" = X"YES" ]; then 226 echo -n ' kerberos'; kerberos >> /var/log/kerberos.log & 227 echo -n ' kadmind'; \ 228 (sleep 20; /usr/sbin/kadmind -n >/dev/null 2>&1 &) & 229fi 230 231echo -n ' inetd'; inetd 232echo '.' 233 234# build ps databases 235kvm_mkdb 236dev_mkdb 237 238# check the password temp/lock file 239if [ -f /etc/ptmp ] 240then 241 logger -s -p auth.err \ 242 "password file may be incorrect -- /etc/ptmp exists" 243fi 244 245# Recover vi editor files. 246virecovery=/var/tmp/vi.recover/recover.* 247if [ "$virecovery" != "/var/tmp/vi.recover/recover.*" ]; then 248 echo 'Recovering vi editor sessions' 249 for i in $virecovery; do 250 sendmail -t < $i 251 done 252fi 253 254if [ "X${accounting}" = X"YES" -a -d /var/account ]; then 255 echo 'turning on accounting'; accton /var/account/acct 256fi 257 258# Now start up miscellaneous daemons that don't belong anywhere else 259# 260echo -n standard daemons: 261echo -n ' cron'; cron 262echo -n ' printer'; lpd 263 264# $sendmail_flags is imported from /etc/sysconfig; 265# if $sendmail_flags is something other than NO, sendmail is run. 266if [ "X${sendmail_flags}" != X"NO" -a -r /etc/sendmail.cf ]; then 267 echo -n ' sendmail'; sendmail ${sendmail_flags} 268fi 269 270echo '.' 271 272# Make shared lib searching a little faster. Leave /usr/lib first if you 273# add your own entries or you may come to grief. 274if [ -x /sbin/ldconfig ]; then 275 _LDC=/usr/lib 276 if [ -d /usr/X11R6/lib ]; then _LDC="${_LDC} /usr/X11R6/lib" ; fi 277 if [ -d /usr/X386/lib ]; then _LDC="${_LDC} /usr/X386/lib" ; fi 278 if [ -d /usr/local/lib ]; then _LDC="${_LDC} /usr/local/lib" ; fi 279 if [ -d /usr/gnu/lib ]; then _LDC="${_LDC} /usr/gnu/lib" ; fi 280 echo 'setting ldconfig path:' ${_LDC} 281 ldconfig ${_LDC} 282fi 283 284# configure implementation specific stuff 285arch=`uname -m` 286if [ -f /etc/rc.$arch ]; then 287 . /etc/rc.$arch 288fi 289 290# Do traditional (but rather obsolete) rc.local file if it exists. 291if [ -f /etc/rc.local ]; then 292 sh /etc/rc.local 293fi 294 295date 296exit 0 297