rc revision 10895
1709Swollman#!/bin/sh 210895Sjkh# $Id: rc,v 1.71 1995/09/18 19:17:13 paul 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 108460Sjkh# Note that almost all the user-configurable behavior is no longer in 118460Sjkh# this file, but rather in /etc/sysconfig. Please check this file 128460Sjkh# first before contemplating any changes here. 138460Sjkh 1437Srgrimesstty status '^T' 1537Srgrimes 1637Srgrimes# Set shell to ignore SIGINT (2), but not children; 1737Srgrimes# shell catches SIGQUIT (3) and returns to single user after fsck. 1837Srgrimestrap : 2 1937Srgrimestrap : 3 # shouldn't be needed 2037Srgrimes 2137SrgrimesHOME=/; export HOME 2237SrgrimesPATH=/sbin:/bin:/usr/sbin:/usr/bin 2337Srgrimesexport PATH 2437Srgrimes 253843Sdgswapon -a 263843Sdg 272164Sdgif [ $1x = autobootx ] 2837Srgrimesthen 2937Srgrimes echo Automatic reboot in progress... 3037Srgrimes fsck -p 3137Srgrimes case $? in 3237Srgrimes 0) 3337Srgrimes ;; 3437Srgrimes 2) 3537Srgrimes exit 1 3637Srgrimes ;; 3737Srgrimes 4) 3837Srgrimes reboot 3937Srgrimes echo "reboot failed... help!" 4037Srgrimes exit 1 4137Srgrimes ;; 4237Srgrimes 8) 4337Srgrimes echo "Automatic file system check failed... help!" 4437Srgrimes exit 1 4537Srgrimes ;; 4637Srgrimes 12) 4737Srgrimes echo "Reboot interrupted" 4837Srgrimes exit 1 4937Srgrimes ;; 5037Srgrimes 130) 5137Srgrimes # interrupt before catcher installed 5237Srgrimes exit 1 5337Srgrimes ;; 5437Srgrimes *) 5537Srgrimes echo "Unknown error in reboot" 5637Srgrimes exit 1 5737Srgrimes ;; 5837Srgrimes esac 592164Sdgelse 602164Sdg echo Skipping disk checks ... 6137Srgrimesfi 6237Srgrimes 6337Srgrimestrap "echo 'Reboot interrupted'; exit 1" 3 6437Srgrimes 653036Sdg# root must be read/write both for NFS diskless and for VFS LKMs before 663036Sdg# proceeding any further. 673036Sdgmount -u -o rw / 688530Sdgif [ $? != 0 ]; then 698530Sdg echo "Filesystem mount failed, startup aborted" 708530Sdg exit 1 718530Sdgfi 721692Sphk 7337Srgrimesumount -a >/dev/null 2>&1 748530Sdg 7537Srgrimesmount -a -t nonfs 768530Sdgif [ $? != 0 ]; then 778530Sdg echo "Filesystem mount failed, startup aborted" 788530Sdg exit 1 798530Sdgfi 8037Srgrimes 81872Sache# If the machine runs wall CMOS clock (compatible with MSDOS), 82872Sache# activate following line by creating empty file /etc/wall_cmos_clock 83872Sache# If this file not exist, following line does nothing (assumed 84872Sache# the machine runs UTC CMOS clock). See adjkerntz(8) for details. 854091Sacheadjkerntz -i 86872Sache 877219Sjkh# If there is a global system configuration file, suck it in. 887219Sjkhif [ -f /etc/sysconfig ]; then 897219Sjkh . /etc/sysconfig 907219Sjkhfi 917219Sjkh 921675Sache# configure serial devices 937219Sjkhif [ -f /etc/rc.serial ]; then 947293Sjkh . /etc/rc.serial 951675Sachefi 961675Sache 977487Srgrimes# start up the network 987460Sjkhif [ -f /etc/netstart ]; then 997750Srgrimes sh /etc/netstart 1007460Sjkhfi 1017460Sjkh 1028540Srgrimesmount -a -t nfs >/dev/null 2>&1 1037487Srgrimes 1047487Srgrimes# Whack the pty perms back into shape. 1057487Srgrimeschmod 666 /dev/tty[pqrs]* 1067487Srgrimes 1077487Srgrimes# clean up left-over files 1087487Srgrimesrm -f /etc/nologin 1097487Srgrimesrm -f /var/spool/lock/* 1107761Sacherm -rf /var/spool/uucp/.Temp/* 1117487Srgrimesrm -f /dev/log 1127487Srgrimes(cd /var/run && { rm -rf -- *; cp /dev/null utmp; chmod 644 utmp; }) 1137487Srgrimes 1147487Srgrimesecho clearing /tmp 1157487Srgrimes 1167487Srgrimes# prune quickly with one rm, then use find to clean up /tmp/[lq]* 1177487Srgrimes# (not needed with mfs /tmp, but doesn't hurt there...) 1187487Srgrimes(cd /tmp && rm -rf [a-km-pr-zA-Z]* && 1197487Srgrimes find -d . ! -name . ! -name lost+found ! -name quotas -exec rm -rf -- {} \;) 1207487Srgrimes 1219305Sbde# enable dumpdev so that savecore can see it 1229305Sbdeif [ "X${dumpdev}" != X"NO" ]; then 1239305Sbde dumpon ${dumpdev} 1249305Sbdefi 1259305Sbde 1267487Srgrimes# /var/crash should be a directory or a symbolic link 1277487Srgrimes# to the crash directory if core dumps are to be saved. 1287487Srgrimesif [ "X${savecore}" = X"YES" -a -d /var/crash ]; then 1297487Srgrimes echo -n checking for core dump... 1307487Srgrimes savecore /var/crash 1317487Srgrimesfi 1327487Srgrimes 1337487Srgrimes# snapshot any kernel -c changes back to disk 1347487Srgrimesecho 'recording kernel -c changes' 1357487Srgrimes/sbin/dset -q 1367487Srgrimes 1377487Srgrimes# Check the quotas 1387487Srgrimesif [ "X${check_quotas}" = X"YES" ]; then 1397487Srgrimes echo 'checking quotas:' 1407487Srgrimes quotacheck -a 1417487Srgrimes echo ' done.' 1427487Srgrimes quotaon -a 1437487Srgrimesfi 1447487Srgrimes 1457487Srgrimes# start system logging and name service (named needs to start before syslogd 1467487Srgrimes# if you don't have a /etc/resolv.conf) 1477259Sjkh# 1487487Srgrimesecho -n starting system daemons: 1497487Srgrimes 1507708Srgrimesecho ' syslogd.'; syslogd 1517487Srgrimes 1527487Srgrimesecho -n starting network daemons: 1537487Srgrimes 1547487Srgrimes# $namedflags is imported from /etc/sysconfig 1557487Srgrimesif [ "X${namedflags}" != "XNO" ]; then 1567708Srgrimes echo -n ' named'; named $namedflags 157857Sdgfi 15837Srgrimes 1597487Srgrimes# $ntpdate and $xntpdflags are imported from /etc/sysconfig. 1607487Srgrimes# If $ntpdate != NO, run ntpdate $ntpdate to set the date correctly. 1617487Srgrimes# If $xntpdflags != NO, start xntpd. 1627487Srgrimesif [ "X${ntpdate}" != X"NO" -o "X${xntpdflags}" != X"NO" ]; then 1637487Srgrimes if [ "X${tickadjflags}" != X"NO" ]; then 1647487Srgrimes echo -n ' tickadj'; tickadj ${tickadjflags--Aq} 1657487Srgrimes fi 166958Sache 1677487Srgrimes if [ "X${ntpdate}" != X"NO" ]; then 1687487Srgrimes echo -n ' ntpdate'; ntpdate ${ntpdate} >/dev/null 2>&1 1697487Srgrimes fi 1707487Srgrimes 1717487Srgrimes if [ "X${xntpdflags}" != X"NO" ]; then 1727487Srgrimes echo -n ' xntpd'; xntpd ${xntpdflags} 1737487Srgrimes fi 1741186Srgrimesfi 1751186Srgrimes 1767487Srgrimes# $timedflags is imported from /etc/sysconfig; 1777487Srgrimes# if $timedflags == NO, timed isn't run. 1787487Srgrimesif [ "X${timedflags}" != X"NO" ]; then 1797487Srgrimes echo -n ' timed'; timed $timedflags 1807487Srgrimesfi 1817219Sjkh 1827487Srgrimes# Portmapper should always be run, to provide RPC services for inetd. 1837487Srgrimesif [ -x /usr/sbin/portmap ]; then 1847487Srgrimes echo -n ' portmap'; portmap 1857487Srgrimesfi 1867238Sache 1877487Srgrimes# Start ypserv if we're an NIS server. 1887487Srgrimes# Run yppasswdd only on the NIS master server 1897487Srgrimesif [ "X${nis_serverflags}" != X"NO" ]; then 1907708Srgrimes echo -n ' ypserv'; ypserv ${nis_serverflags} 1917238Sache 1927487Srgrimes if [ "X${yppasswddflags}" != X"NO" ]; then 1937708Srgrimes echo -n ' yppasswdd'; yppasswdd ${yppasswddflags} 1947487Srgrimes fi 1957487Srgrimesfi 1967238Sache 1977487Srgrimes# Start ypbind if we're an NIS client 1987487Srgrimesif [ "X${nis_clientflags}" != X"NO" ]; then 1997708Srgrimes echo -n ' ypbind'; ypbind ${nis_clientflags} 2009593Swollman if [ "X${nis_ypsetflags}" != X"NO" ]; then 2019593Swollman echo -n ' ypset'; ypset ${nis_ypsetflags} 2029593Swollman fi 2037219Sjkhfi 2047219Sjkh 2057487Srgrimes# $rwhod is imported from /etc/sysconfig; 2067487Srgrimes# if $rwhod is set to YES, rwhod is run. 2077487Srgrimesif [ "X${rwhod}" = X"YES" ]; then 2087487Srgrimes echo -n ' rwhod'; rwhod 2097238Sachefi 2107238Sache 2117487Srgrimesif [ "X${nfs_server}" = X"YES" -a -r /etc/exports ]; then 21210716Sjkh echo -n ' mountd' 21310716Sjkh if [ "X${pcnfsd}" = X"YES" ]; then 21410716Sjkh mountd -n 21510716Sjkh else 21610716Sjkh mountd 21710716Sjkh fi 2187487Srgrimes echo -n ' nfsd'; nfsd -u -t 4 2197477Sachefi 2207477Sache 2217487Srgrimesif [ "X${nfs_client}" = X"YES" ]; then 2227487Srgrimes echo -n ' nfsiod'; nfsiod -n 4 2237487Srgrimesfi 2247238Sache 2257487Srgrimesif [ "X${amdflags}" != X"NO" ]; then 2267487Srgrimes echo -n ' amd'; amd ${amdflags} 2277238Sachefi 2287238Sache 2297487Srgrimes# Kerberos runs ONLY on the Kerberos server machine 2307487Srgrimesif [ "X${kerberos_server}" = X"YES" ]; then 2317487Srgrimes echo -n ' kerberos'; kerberos >> /var/log/kerberos.log & 2327487Srgrimes echo -n ' kadmind'; \ 2337487Srgrimes (sleep 20; /usr/sbin/kadmind -n >/dev/null 2>&1 &) & 2347238Sachefi 2357238Sache 2367487Srgrimesecho -n ' inetd'; inetd 2377487Srgrimesecho '.' 2387487Srgrimes 2397487Srgrimes# build ps databases 2407487Srgrimeskvm_mkdb 2417487Srgrimesdev_mkdb 2427487Srgrimes 2437487Srgrimes# check the password temp/lock file 2447487Srgrimesif [ -f /etc/ptmp ] 2457487Srgrimesthen 2467487Srgrimes logger -s -p auth.err \ 2477487Srgrimes "password file may be incorrect -- /etc/ptmp exists" 2487238Sachefi 2497238Sache 2507487Srgrimes# Recover vi editor files. 2517487Srgrimesvirecovery=/var/tmp/vi.recover/recover.* 2527487Srgrimesif [ "$virecovery" != "/var/tmp/vi.recover/recover.*" ]; then 2537487Srgrimes echo 'Recovering vi editor sessions' 2547487Srgrimes for i in $virecovery; do 2557487Srgrimes sendmail -t < $i 2567487Srgrimes done 2577238Sachefi 2587238Sache 2597487Srgrimesif [ "X${accounting}" = X"YES" -a -d /var/account ]; then 2607487Srgrimes echo 'turning on accounting'; accton /var/account/acct 2617238Sachefi 2627238Sache 2637487Srgrimes# Now start up miscellaneous daemons that don't belong anywhere else 2647487Srgrimes# 2657487Srgrimesecho -n standard daemons: 2667487Srgrimesecho -n ' cron'; cron 2677708Srgrimesecho -n ' printer'; lpd 2687238Sache 2697487Srgrimes# $sendmail_flags is imported from /etc/sysconfig; 2707487Srgrimes# if $sendmail_flags is something other than NO, sendmail is run. 2717487Srgrimesif [ "X${sendmail_flags}" != X"NO" -a -r /etc/sendmail.cf ]; then 2727487Srgrimes echo -n ' sendmail'; sendmail ${sendmail_flags} 2737238Sachefi 2747238Sache 2757487Srgrimesecho '.' 2767238Sache 2777487Srgrimes# Make shared lib searching a little faster. Leave /usr/lib first if you 2787487Srgrimes# add your own entries or you may come to grief. 2797487Srgrimesif [ -x /sbin/ldconfig ]; then 2807487Srgrimes _LDC=/usr/lib 2817487Srgrimes if [ -d /usr/X11R6/lib ]; then _LDC="${_LDC} /usr/X11R6/lib" ; fi 2827487Srgrimes if [ -d /usr/X386/lib ]; then _LDC="${_LDC} /usr/X386/lib" ; fi 2837487Srgrimes if [ -d /usr/local/lib ]; then _LDC="${_LDC} /usr/local/lib" ; fi 2847487Srgrimes if [ -d /usr/gnu/lib ]; then _LDC="${_LDC} /usr/gnu/lib" ; fi 2857487Srgrimes echo 'setting ldconfig path:' ${_LDC} 2867487Srgrimes ldconfig ${_LDC} 2877296Sjkhfi 2887296Sjkh 2897487Srgrimes# configure implementation specific stuff 2907487Srgrimesarch=`uname -m` 29110895Sjkhif [ -f /etc/rc.${arch} ]; then 29210895Sjkh . /etc/rc.${arch} 2937487Srgrimesfi 2947487Srgrimes 29510895Sjkhif [ "X${local_startup}" != X"NO" -a -d ${local_startup} ]; then 29610895Sjkh for script in ${local_startup}/*.sh; do 29710895Sjkh [ -x ${script} ] && ${script} start 29810873Sjkh done 2997259Sjkhfi 30037Srgrimes 30110873Sjkh# Do traditional (but rather obsolete) rc.local file if it exists. 30210873Sjkh[ -x /etc/rc.local ] && /etc/rc.local 30310873Sjkh 30437Srgrimesdate 30537Srgrimesexit 0 306