rc revision 8460
1709Swollman#!/bin/sh
28460Sjkh#	$Id: rc,v 1.63 1995/04/11 18:36:10 ache 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 /
681692Sphk
6937Srgrimesumount -a >/dev/null 2>&1
7037Srgrimesmount -a -t nonfs
7137Srgrimes
72872Sache# If the machine runs wall CMOS clock (compatible with MSDOS),
73872Sache# activate following line by creating empty file /etc/wall_cmos_clock
74872Sache# If this file not exist, following line does nothing (assumed
75872Sache# the machine runs UTC CMOS clock). See adjkerntz(8) for details.
764091Sacheadjkerntz -i
77872Sache
787219Sjkh# If there is a global system configuration file, suck it in.
797219Sjkhif [ -f /etc/sysconfig ]; then
807219Sjkh	. /etc/sysconfig
817219Sjkhfi
827219Sjkh
831675Sache# configure serial devices
847219Sjkhif [ -f /etc/rc.serial ]; then
857293Sjkh	. /etc/rc.serial
861675Sachefi
871675Sache
887487Srgrimes# start up the network
897460Sjkhif [ -f /etc/netstart ]; then
907750Srgrimes	sh /etc/netstart
917460Sjkhfi
927460Sjkh
937487Srgrimesmount -a -t nfs >/dev/null 2>&1 &	# XXX shouldn't need background
947487Srgrimes
957487Srgrimes# Whack the pty perms back into shape.
967487Srgrimeschmod 666 /dev/tty[pqrs]*
977487Srgrimes
987487Srgrimes# clean up left-over files
997487Srgrimesrm -f /etc/nologin
1007487Srgrimesrm -f /var/spool/lock/*
1017761Sacherm -rf /var/spool/uucp/.Temp/*
1027487Srgrimesrm -f /dev/log
1037487Srgrimes(cd /var/run && { rm -rf -- *; cp /dev/null utmp; chmod 644 utmp; })
1047487Srgrimes
1057487Srgrimesecho clearing /tmp
1067487Srgrimes
1077487Srgrimes# prune quickly with one rm, then use find to clean up /tmp/[lq]*
1087487Srgrimes# (not needed with mfs /tmp, but doesn't hurt there...)
1097487Srgrimes(cd /tmp && rm -rf [a-km-pr-zA-Z]* &&
1107487Srgrimes    find -d . ! -name . ! -name lost+found ! -name quotas -exec rm -rf -- {} \;)
1117487Srgrimes
1127487Srgrimes# /var/crash should be a directory or a symbolic link
1137487Srgrimes# to the crash directory if core dumps are to be saved.
1147487Srgrimesif [ "X${savecore}" = X"YES" -a -d /var/crash ]; then
1157487Srgrimes	echo -n checking for core dump...
1167487Srgrimes	savecore /var/crash
1177487Srgrimesfi
1187487Srgrimes
1197487Srgrimes# snapshot any kernel -c changes back to disk
1207487Srgrimesecho 'recording kernel -c changes'
1217487Srgrimes/sbin/dset -q
1227487Srgrimes
1237487Srgrimes# Check the quotas
1247487Srgrimesif [ "X${check_quotas}" = X"YES" ]; then
1257487Srgrimes	echo 'checking quotas:'
1267487Srgrimes	quotacheck -a
1277487Srgrimes	echo ' done.'
1287487Srgrimes	quotaon -a
1297487Srgrimesfi
1307487Srgrimes
1317487Srgrimes# start system logging and name service (named needs to start before syslogd
1327487Srgrimes# if you don't have a /etc/resolv.conf)
1337259Sjkh#
1347487Srgrimesecho -n starting system daemons:
1357487Srgrimes
1367708Srgrimesecho ' syslogd.';			syslogd
1377487Srgrimes
1387487Srgrimesecho -n starting network daemons:
1397487Srgrimes
1407487Srgrimes# $namedflags is imported from /etc/sysconfig
1417487Srgrimesif [ "X${namedflags}" != "XNO" ]; then
1427708Srgrimes	echo -n ' named';		named $namedflags
143857Sdgfi
14437Srgrimes
1457487Srgrimes# $ntpdate and $xntpdflags are imported from /etc/sysconfig.
1467487Srgrimes# If $ntpdate != NO, run ntpdate $ntpdate to set the date correctly.
1477487Srgrimes# If $xntpdflags != NO, start xntpd.
1487487Srgrimesif [ "X${ntpdate}" != X"NO" -o "X${xntpdflags}" != X"NO" ]; then
1497487Srgrimes	if [ "X${tickadjflags}" != X"NO" ]; then
1507487Srgrimes		echo -n ' tickadj';	tickadj ${tickadjflags--Aq}
1517487Srgrimes	fi
152958Sache
1537487Srgrimes	if [ "X${ntpdate}" != X"NO" ]; then
1547487Srgrimes		echo -n ' ntpdate';	ntpdate ${ntpdate} >/dev/null 2>&1
1557487Srgrimes	fi
1567487Srgrimes
1577487Srgrimes	if [ "X${xntpdflags}" != X"NO" ]; then
1587487Srgrimes		echo -n ' xntpd';	xntpd ${xntpdflags}
1597487Srgrimes	fi
1601186Srgrimesfi
1611186Srgrimes
1627487Srgrimes# $timedflags is imported from /etc/sysconfig;
1637487Srgrimes# if $timedflags == NO, timed isn't run.
1647487Srgrimesif [ "X${timedflags}" != X"NO" ]; then
1657487Srgrimes	echo -n ' timed'; timed $timedflags
1667487Srgrimesfi
1677219Sjkh
1687487Srgrimes# Portmapper should always be run, to provide RPC services for inetd.
1697487Srgrimesif [ -x /usr/sbin/portmap ]; then
1707487Srgrimes	echo -n ' portmap';		portmap
1717487Srgrimesfi
1727238Sache
1737487Srgrimes# Start ypserv if we're an NIS server.
1747487Srgrimes# Run yppasswdd only on the NIS master server
1757487Srgrimesif [ "X${nis_serverflags}" != X"NO" ]; then
1767708Srgrimes	echo -n ' ypserv'; ypserv ${nis_serverflags}
1777238Sache
1787487Srgrimes	if [ "X${yppasswddflags}" != X"NO" ]; then
1797708Srgrimes		echo -n ' yppasswdd'; yppasswdd ${yppasswddflags}
1807487Srgrimes	fi
1817487Srgrimesfi
1827238Sache
1837487Srgrimes# Start ypbind if we're an NIS client
1847487Srgrimesif [ "X${nis_clientflags}" != X"NO" ]; then
1857708Srgrimes	echo -n ' ypbind'; ypbind ${nis_clientflags}
1867219Sjkhfi
1877219Sjkh
1887487Srgrimes# $rwhod is imported from /etc/sysconfig;
1897487Srgrimes# if $rwhod is set to YES, rwhod is run.
1907487Srgrimesif [ "X${rwhod}" = X"YES" ]; then
1917487Srgrimes	echo -n ' rwhod';	rwhod
1927238Sachefi
1937238Sache
1947487Srgrimesif [ "X${nfs_server}" = X"YES" -a -r /etc/exports ]; then
1957487Srgrimes	echo -n ' mountd';		mountd
1967487Srgrimes	echo -n ' nfsd';		nfsd -u -t 4
1977477Sachefi
1987477Sache
1997487Srgrimesif [ "X${nfs_client}" = X"YES" ]; then
2007487Srgrimes	echo -n ' nfsiod';		nfsiod -n 4
2017487Srgrimesfi
2027238Sache
2037487Srgrimesif [ "X${amdflags}" != X"NO" ]; then
2047487Srgrimes	echo -n ' amd';			amd ${amdflags}
2057238Sachefi
2067238Sache
2077487Srgrimes# Kerberos runs ONLY on the Kerberos server machine
2087487Srgrimesif [ "X${kerberos_server}" = X"YES" ]; then
2097487Srgrimes	echo -n ' kerberos';	kerberos >> /var/log/kerberos.log &
2107487Srgrimes	echo -n ' kadmind'; \
2117487Srgrimes		(sleep 20; /usr/sbin/kadmind -n >/dev/null 2>&1 &) &
2127238Sachefi
2137238Sache
2147487Srgrimesecho -n ' inetd';		inetd
2157487Srgrimesecho '.'
2167487Srgrimes
2177487Srgrimes# build ps databases
2187487Srgrimeskvm_mkdb 
2197487Srgrimesdev_mkdb
2207487Srgrimes
2217487Srgrimes# check the password temp/lock file
2227487Srgrimesif [ -f /etc/ptmp ]
2237487Srgrimesthen
2247487Srgrimes	logger -s -p auth.err \
2257487Srgrimes	"password file may be incorrect -- /etc/ptmp exists"
2267238Sachefi
2277238Sache
2287487Srgrimes# Recover vi editor files.
2297487Srgrimesvirecovery=/var/tmp/vi.recover/recover.*
2307487Srgrimesif [ "$virecovery" != "/var/tmp/vi.recover/recover.*" ]; then
2317487Srgrimes	echo 'Recovering vi editor sessions'
2327487Srgrimes	for i in $virecovery; do
2337487Srgrimes		sendmail -t < $i
2347487Srgrimes	done
2357238Sachefi
2367238Sache
2377487Srgrimesif [ "X${accounting}" = X"YES" -a -d /var/account ]; then
2387487Srgrimes	echo 'turning on accounting';	accton /var/account/acct
2397238Sachefi
2407238Sache
2417487Srgrimes# Now start up miscellaneous daemons that don't belong anywhere else
2427487Srgrimes#
2437487Srgrimesecho -n standard daemons:
2447487Srgrimesecho -n ' cron';		cron
2457708Srgrimesecho -n ' printer';		lpd
2467238Sache
2477487Srgrimes# $sendmail_flags is imported from /etc/sysconfig;
2487487Srgrimes# if $sendmail_flags is something other than NO, sendmail is run.
2497487Srgrimesif [ "X${sendmail_flags}" != X"NO" -a -r /etc/sendmail.cf ]; then
2507487Srgrimes	echo -n ' sendmail';		sendmail ${sendmail_flags} 
2517238Sachefi
2527238Sache
2537487Srgrimesecho '.'
2547238Sache
2557487Srgrimes# Make shared lib searching a little faster.  Leave /usr/lib first if you
2567487Srgrimes# add your own entries or you may come to grief.
2577487Srgrimesif [ -x /sbin/ldconfig ]; then
2587487Srgrimes	_LDC=/usr/lib
2597487Srgrimes	if [ -d /usr/X11R6/lib ]; then _LDC="${_LDC} /usr/X11R6/lib" ; fi
2607487Srgrimes	if [ -d /usr/X386/lib ]; then _LDC="${_LDC} /usr/X386/lib" ; fi
2617487Srgrimes	if [ -d /usr/local/lib ]; then _LDC="${_LDC} /usr/local/lib" ; fi
2627487Srgrimes	if [ -d /usr/gnu/lib ]; then _LDC="${_LDC} /usr/gnu/lib" ; fi
2637487Srgrimes	echo 'setting ldconfig path:' ${_LDC}
2647487Srgrimes	ldconfig ${_LDC}
2657296Sjkhfi
2667296Sjkh
2677487Srgrimes# configure implementation specific stuff
2687487Srgrimesarch=`uname -m`
2697487Srgrimesif [ -f /etc/rc.$arch ]; then
2707487Srgrimes	. /etc/rc.$arch
2717487Srgrimesfi
2727487Srgrimes
2737259Sjkh# Do traditional (but rather obsolete) rc.local file if it exists.
2747259Sjkhif [ -f /etc/rc.local ]; then
2757259Sjkh	sh /etc/rc.local
2767259Sjkhfi
27737Srgrimes
27837Srgrimesdate
27937Srgrimesexit 0
280