rc revision 2164
1709Swollman#!/bin/sh 22164Sdg# $Id: rc,v 1.27 1994/06/06 17:45:37 phk Exp $ 3709Swollman# From: @(#)rc 5.27 (Berkeley) 6/5/91 437Srgrimes 537Srgrimes# System startup script run by init on autoboot 637Srgrimes# or after single-user. 737Srgrimes# Output and error are redirected to console by init, 837Srgrimes# and the console is the controlling terminal. 937Srgrimes 1037Srgrimesstty status '^T' 1137Srgrimes 1237Srgrimes# Set shell to ignore SIGINT (2), but not children; 1337Srgrimes# shell catches SIGQUIT (3) and returns to single user after fsck. 1437Srgrimestrap : 2 1537Srgrimestrap : 3 # shouldn't be needed 1637Srgrimes 1737SrgrimesHOME=/; export HOME 1837SrgrimesPATH=/sbin:/bin:/usr/sbin:/usr/bin 1937Srgrimesexport PATH 2037Srgrimes 212164Sdgif [ $1x = autobootx ] 2237Srgrimesthen 2337Srgrimes echo Automatic reboot in progress... 2437Srgrimes fsck -p 2537Srgrimes case $? in 2637Srgrimes 0) 2737Srgrimes ;; 2837Srgrimes 2) 2937Srgrimes exit 1 3037Srgrimes ;; 3137Srgrimes 4) 3237Srgrimes reboot 3337Srgrimes echo "reboot failed... help!" 3437Srgrimes exit 1 3537Srgrimes ;; 3637Srgrimes 8) 3737Srgrimes echo "Automatic file system check failed... help!" 3837Srgrimes exit 1 3937Srgrimes ;; 4037Srgrimes 12) 4137Srgrimes echo "Reboot interrupted" 4237Srgrimes exit 1 4337Srgrimes ;; 4437Srgrimes 130) 4537Srgrimes # interrupt before catcher installed 4637Srgrimes exit 1 4737Srgrimes ;; 4837Srgrimes *) 4937Srgrimes echo "Unknown error in reboot" 5037Srgrimes exit 1 5137Srgrimes ;; 5237Srgrimes esac 532164Sdgelse 542164Sdg echo Skipping disk checks ... 5537Srgrimesfi 5637Srgrimes 5737Srgrimestrap "echo 'Reboot interrupted'; exit 1" 3 5837Srgrimes 5937Srgrimesswapon -a 6037Srgrimes 611692Sphk# Check for diskless boot, and remount the root RW. 621692Sphka=`mount` 631692Sphkif [ 0 != `expr "$a" : '^[^/]*:/.* on /'` ] ; then 641692Sphk mount -u -o rw / 651692Sphkfi 661692Sphk 6737Srgrimesumount -a >/dev/null 2>&1 6837Srgrimesmount -a -t nonfs 6937Srgrimes 70872Sache# If the machine runs wall CMOS clock (compatible with MSDOS), 71872Sache# activate following line by creating empty file /etc/wall_cmos_clock 72872Sache# If this file not exist, following line does nothing (assumed 73872Sache# the machine runs UTC CMOS clock). See adjkerntz(8) for details. 74872Sacheadjkerntz -i 75872Sache 761675Sache# configure serial devices 771675Sacheif [ -f /etc/rc.serial ] 781675Sachethen 791675Sache sh /etc/rc.serial 801675Sachefi 811675Sache 8237Srgrimes# set hostname, turn on network 8337Srgrimesecho 'starting network' 8437Srgrimes. /etc/netstart 8537Srgrimes 8637Srgrimes# clean up left-over files 8737Srgrimesrm -f /etc/nologin 881534Sacherm -f /var/spool/lock/* 891534Sacherm -f /var/spool/uucp/.Temp/* 901534Sache# don't add .[a-z]* to rm, because of .adjkerntz file name 9137Srgrimes(cd /var/run && { rm -rf -- *; cp /dev/null utmp; chmod 644 utmp; }) 9237Srgrimes 9337Srgrimesecho -n 'starting system logger' 9437Srgrimesrm -f /dev/log 9537Srgrimessyslogd 9637Srgrimes 9737Srgrimes# $timedflags is imported from /etc/netstart; 9837Srgrimes# if $timedflags == NO, timed isn't run. 9937Srgrimesif [ X${timedflags} != X"NO" ]; then 10037Srgrimes echo -n ', time daemon'; timed $timedflags 10137Srgrimesfi 10237Srgrimesecho '.' 10337Srgrimes 10437Srgrimes# /var/crash should be a directory or a symbolic link 10537Srgrimes# to the crash directory if core dumps are to be saved. 10637Srgrimesif [ -d /var/crash ]; then 10737Srgrimes echo checking for core dump... 10837Srgrimes savecore /var/crash 10937Srgrimesfi 11037Srgrimes 11137Srgrimes# echo -n 'checking quotas:' 11237Srgrimes#quotacheck -a 11337Srgrimes# echo ' done.' 11437Srgrimes#quotaon -a 11537Srgrimes 11637Srgrimes# build ps databases 1172164Sdgkvm_mkdb /kernel 11837Srgrimesdev_mkdb 11937Srgrimes 12037Srgrimeschmod 666 /dev/tty[pqrs]* 12137Srgrimes 12237Srgrimes# check the password temp/lock file 12337Srgrimesif [ -f /etc/ptmp ] 12437Srgrimesthen 12537Srgrimes logger -s -p auth.err \ 12637Srgrimes 'password file may be incorrect -- /etc/ptmp exists' 12737Srgrimesfi 12837Srgrimes 1291185Srgrimes# Recover elvis editor files. 1301185Srgrimesecho preserving editor files 1311189Srgrimes(cd /var/tmp && /usr/libexec/elvispreserve "-the system rebooted" elv* && 1321185Srgrimes rm -f elvis[0-9a-f][0-9a-f][0-9a-f][0-9a-f]* \ 1331185Srgrimes elvis_[0-9a-f][0-9a-f][0-9a-f][0-9a-f]*) 1341185Srgrimes 1351185Srgrimes# Recover vi editor files. 1361185Srgrimesvirecovery=/var/tmp/vi.recover/recover.* 1371185Srgrimesif [ "$virecovery" != "/var/tmp/vi.recover/recover.*" ]; then 1381185Srgrimes echo 'Recovering vi editor sessions' 1391185Srgrimes for i in $virecovery; do 1401185Srgrimes sendmail -t < $i 1411185Srgrimes done 1421185Srgrimesfi 1431185Srgrimes 14437Srgrimesecho clearing /tmp 14537Srgrimes 14637Srgrimes# prune quickly with one rm, then use find to clean up /tmp/[lq]* 14737Srgrimes# (not needed with mfs /tmp, but doesn't hurt there...) 14837Srgrimes(cd /tmp && rm -rf [a-km-pr-zA-Z]* && 1491074Schmr find -d . ! -name . ! -name lost+found ! -name quotas -exec rm -rf -- {} \;) 15037Srgrimes 15137Srgrimes# echo 'turning on accounting'; accton /var/account/acct 15237Srgrimes 15337Srgrimesecho -n standard daemons: 1541001Sguidoecho -n ' cron'; cron 15537Srgrimesecho '.' 15637Srgrimes 15737Srgrimesecho -n starting network daemons: 15837Srgrimes 159857Sdg# Portmapper should always be run, to provide RPC services for inetd. 160857Sdgif [ -x /usr/sbin/portmap ]; then 161857Sdg echo -n ' portmap'; portmap 162857Sdgfi 163857Sdg 16437Srgrimes# $gated and $routedflags are imported from /etc/netstart. 16537Srgrimes# If $gated == YES, gated is used; otherwise routed. 16637Srgrimes# If $routedflags == NO, routed isn't run. 16737Srgrimesif [ X${gated} = X"YES" -a -r /etc/gated.conf ]; then 16837Srgrimes echo -n ' gated'; gated $gatedflags 1691412Sjkhelif [ X"${routedflags}" != X"NO" ]; then 17037Srgrimes echo -n ' routed'; routed $routedflags 17137Srgrimesfi 17237Srgrimes 17337Srgrimesif [ X${name_server} = X"YES" -a -r /etc/named.boot ]; then 17437Srgrimes echo -n ' named'; named 17537Srgrimesfi 17637Srgrimes 177908Swollman# $ntpdate and $xntpdflags are imported from /etc/netstart. 178908Swollman# If $ntpdate != NO, run ntpdate $ntpdate to set the date correctly. 179908Swollman# If $xntpdflags != NO, start xntpd. 180908Swollmanif [ X"${ntpdate}" != X"NO" ]; then 1811185Srgrimes echo ' ntpdate'; ntpdate $ntpdate 182908Swollmanfi 183908Swollman 184908Swollmanif [ X"${xntpdflags}" != X"NO" ]; then 1851218Sphk if [ X"${tickadjflags}" != X"NO" ]; then 1861218Sphk echo 'adjusting kernel for xntpd'; tickadj ${tickadjflags--A} 1871218Sphk fi 1881218Sphk echo 'starting xntpd'; xntpd ${xntpdflags} 189908Swollmanfi 190908Swollman 1911218Sphkif [ X"${ntpdate}" != X"NO" -o X"${xntpdflags}" != X"NO" ]; then 1921218Sphk echo -n 'starting more network daemons:' 1931218Sphkfi 1941218Sphk 19537Srgrimes# $rwhod is imported from /etc/netstart; 19637Srgrimes# if $rwhod is set to something other than NO, rwhod is run. 19737Srgrimesif [ ${rwhod-NO} != "NO" ]; then 19837Srgrimes echo -n ' rwhod'; rwhod 19937Srgrimesfi 20037Srgrimes 20137Srgrimesecho -n ' printer'; lpd 20237Srgrimes 20337Srgrimesif [ X${nfs_server} = X"YES" -a -r /etc/exports ]; then 20437Srgrimes echo -n ' mountd'; mountd 2052164Sdg echo -n ' nfsd'; nfsd -u -t 4 2062164Sdg echo -n ' nfsiod'; nfsiod -n 4 20737Srgrimesfi 20837Srgrimes 209709Swollman# $sendmail_flags is imported from /etc/netstart; 210709Swollman# if $sendmail_flags is something other than NO, sendmail is run. 211888Sacheif [ X"${sendmail_flags}" != X"NO" -a -r /etc/sendmail.cf ]; then 212709Swollman echo -n ' sendmail'; sendmail ${sendmail_flags} 213709Swollmanfi 214709Swollman 21537Srgrimesecho -n ' inetd'; inetd 21637Srgrimesecho '.' 21737Srgrimes 218958Sachemount -a -t nfs >/dev/null 2>&1 & # XXX shouldn't need background 219958Sache 2201681Sats# if [ -x /usr/libexec/xtend ]; then 2211681Sats# echo -n ' xtend'; /usr/libexec/xtend 2221681Sats# fi 2231668Spaul 2241186Srgrimes# Make shared lib searching a little faster. Leave /usr/lib first if you 2251186Srgrimes# add your own entries or you may come to grief. 2261186Srgrimesif [ -x /sbin/ldconfig ]; then 2271186Srgrimes _LDC=/usr/lib 2281308Srich if [ -d /usr/X11R6/lib ]; then _LDC="${_LDC} /usr/X11R6/lib" ; fi 2291186Srgrimes if [ -d /usr/X386/lib ]; then _LDC="${_LDC} /usr/X386/lib" ; fi 2301186Srgrimes if [ -d /usr/local/lib ]; then _LDC="${_LDC} /usr/local/lib" ; fi 2311186Srgrimes if [ -d /usr/gnu/lib ]; then _LDC="${_LDC} /usr/gnu/lib" ; fi 2321186Srgrimes echo 'setting ldconfig path:' ${_LDC} 2331186Srgrimes ldconfig ${_LDC} 2341186Srgrimesfi 2351186Srgrimes 23637Srgrimessh /etc/rc.local 23737Srgrimes 23837Srgrimesdate 23937Srgrimes 24037Srgrimesexit 0 241