rc revision 7750
1709Swollman#!/bin/sh
27750Srgrimes#	$Id: rc,v 1.61 1995/04/09 09:54:42 rgrimes 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
213843Sdgswapon -a
223843Sdg
232164Sdgif [ $1x = autobootx ]
2437Srgrimesthen
2537Srgrimes	echo Automatic reboot in progress...
2637Srgrimes	fsck -p
2737Srgrimes	case $? in
2837Srgrimes	0)
2937Srgrimes		;;
3037Srgrimes	2)
3137Srgrimes		exit 1
3237Srgrimes		;;
3337Srgrimes	4)
3437Srgrimes		reboot
3537Srgrimes		echo "reboot failed... help!"
3637Srgrimes		exit 1
3737Srgrimes		;;
3837Srgrimes	8)
3937Srgrimes		echo "Automatic file system check failed... help!"
4037Srgrimes		exit 1
4137Srgrimes		;;
4237Srgrimes	12)
4337Srgrimes		echo "Reboot interrupted"
4437Srgrimes		exit 1
4537Srgrimes		;;
4637Srgrimes	130)
4737Srgrimes		# interrupt before catcher installed
4837Srgrimes		exit 1
4937Srgrimes		;;
5037Srgrimes	*)
5137Srgrimes		echo "Unknown error in reboot"
5237Srgrimes		exit 1
5337Srgrimes		;;
5437Srgrimes	esac
552164Sdgelse
562164Sdg	echo Skipping disk checks ...
5737Srgrimesfi
5837Srgrimes
5937Srgrimestrap "echo 'Reboot interrupted'; exit 1" 3
6037Srgrimes
613036Sdg# root must be read/write both for NFS diskless and for VFS LKMs before
623036Sdg# proceeding any further.
633036Sdgmount -u -o rw /
641692Sphk
6537Srgrimesumount -a >/dev/null 2>&1
6637Srgrimesmount -a -t nonfs
6737Srgrimes
68872Sache# If the machine runs wall CMOS clock (compatible with MSDOS),
69872Sache# activate following line by creating empty file /etc/wall_cmos_clock
70872Sache# If this file not exist, following line does nothing (assumed
71872Sache# the machine runs UTC CMOS clock). See adjkerntz(8) for details.
724091Sacheadjkerntz -i
73872Sache
747219Sjkh# If there is a global system configuration file, suck it in.
757219Sjkhif [ -f /etc/sysconfig ]; then
767219Sjkh	. /etc/sysconfig
777219Sjkhfi
787219Sjkh
791675Sache# configure serial devices
807219Sjkhif [ -f /etc/rc.serial ]; then
817293Sjkh	. /etc/rc.serial
821675Sachefi
831675Sache
847487Srgrimes# start up the network
857460Sjkhif [ -f /etc/netstart ]; then
867750Srgrimes	sh /etc/netstart
877460Sjkhfi
887460Sjkh
897487Srgrimesmount -a -t nfs >/dev/null 2>&1 &	# XXX shouldn't need background
907487Srgrimes
917487Srgrimes# Whack the pty perms back into shape.
927487Srgrimeschmod 666 /dev/tty[pqrs]*
937487Srgrimes
947487Srgrimes# clean up left-over files
957487Srgrimesrm -f /etc/nologin
967487Srgrimesrm -f /var/spool/lock/*
977487Srgrimesrm -f /var/spool/uucp/.Temp/*
987487Srgrimesrm -f /dev/log
997487Srgrimes(cd /var/run && { rm -rf -- *; cp /dev/null utmp; chmod 644 utmp; })
1007487Srgrimes
1017487Srgrimesecho clearing /tmp
1027487Srgrimes
1037487Srgrimes# prune quickly with one rm, then use find to clean up /tmp/[lq]*
1047487Srgrimes# (not needed with mfs /tmp, but doesn't hurt there...)
1057487Srgrimes(cd /tmp && rm -rf [a-km-pr-zA-Z]* &&
1067487Srgrimes    find -d . ! -name . ! -name lost+found ! -name quotas -exec rm -rf -- {} \;)
1077487Srgrimes
1087487Srgrimes# /var/crash should be a directory or a symbolic link
1097487Srgrimes# to the crash directory if core dumps are to be saved.
1107487Srgrimesif [ "X${savecore}" = X"YES" -a -d /var/crash ]; then
1117487Srgrimes	echo -n checking for core dump...
1127487Srgrimes	savecore /var/crash
1137487Srgrimesfi
1147487Srgrimes
1157487Srgrimes# snapshot any kernel -c changes back to disk
1167487Srgrimesecho 'recording kernel -c changes'
1177487Srgrimes/sbin/dset -q
1187487Srgrimes
1197487Srgrimes# Check the quotas
1207487Srgrimesif [ "X${check_quotas}" = X"YES" ]; then
1217487Srgrimes	echo 'checking quotas:'
1227487Srgrimes	quotacheck -a
1237487Srgrimes	echo ' done.'
1247487Srgrimes	quotaon -a
1257487Srgrimesfi
1267487Srgrimes
1277487Srgrimes# start system logging and name service (named needs to start before syslogd
1287487Srgrimes# if you don't have a /etc/resolv.conf)
1297259Sjkh#
1307487Srgrimesecho -n starting system daemons:
1317487Srgrimes
1327708Srgrimesecho ' syslogd.';			syslogd
1337487Srgrimes
1347487Srgrimesecho -n starting network daemons:
1357487Srgrimes
1367487Srgrimes# $namedflags is imported from /etc/sysconfig
1377487Srgrimesif [ "X${namedflags}" != "XNO" ]; then
1387708Srgrimes	echo -n ' named';		named $namedflags
139857Sdgfi
14037Srgrimes
1417487Srgrimes# $ntpdate and $xntpdflags are imported from /etc/sysconfig.
1427487Srgrimes# If $ntpdate != NO, run ntpdate $ntpdate to set the date correctly.
1437487Srgrimes# If $xntpdflags != NO, start xntpd.
1447487Srgrimesif [ "X${ntpdate}" != X"NO" -o "X${xntpdflags}" != X"NO" ]; then
1457487Srgrimes	if [ "X${tickadjflags}" != X"NO" ]; then
1467487Srgrimes		echo -n ' tickadj';	tickadj ${tickadjflags--Aq}
1477487Srgrimes	fi
148958Sache
1497487Srgrimes	if [ "X${ntpdate}" != X"NO" ]; then
1507487Srgrimes		echo -n ' ntpdate';	ntpdate ${ntpdate} >/dev/null 2>&1
1517487Srgrimes	fi
1527487Srgrimes
1537487Srgrimes	if [ "X${xntpdflags}" != X"NO" ]; then
1547487Srgrimes		echo -n ' xntpd';	xntpd ${xntpdflags}
1557487Srgrimes	fi
1561186Srgrimesfi
1571186Srgrimes
1587487Srgrimes# $timedflags is imported from /etc/sysconfig;
1597487Srgrimes# if $timedflags == NO, timed isn't run.
1607487Srgrimesif [ "X${timedflags}" != X"NO" ]; then
1617487Srgrimes	echo -n ' timed'; timed $timedflags
1627487Srgrimesfi
1637219Sjkh
1647487Srgrimes# Portmapper should always be run, to provide RPC services for inetd.
1657487Srgrimesif [ -x /usr/sbin/portmap ]; then
1667487Srgrimes	echo -n ' portmap';		portmap
1677487Srgrimesfi
1687238Sache
1697487Srgrimes# Start ypserv if we're an NIS server.
1707487Srgrimes# Run yppasswdd only on the NIS master server
1717487Srgrimesif [ "X${nis_serverflags}" != X"NO" ]; then
1727708Srgrimes	echo -n ' ypserv'; ypserv ${nis_serverflags}
1737238Sache
1747487Srgrimes	if [ "X${yppasswddflags}" != X"NO" ]; then
1757708Srgrimes		echo -n ' yppasswdd'; yppasswdd ${yppasswddflags}
1767487Srgrimes	fi
1777487Srgrimesfi
1787238Sache
1797487Srgrimes# Start ypbind if we're an NIS client
1807487Srgrimesif [ "X${nis_clientflags}" != X"NO" ]; then
1817708Srgrimes	echo -n ' ypbind'; ypbind ${nis_clientflags}
1827219Sjkhfi
1837219Sjkh
1847487Srgrimes# $rwhod is imported from /etc/sysconfig;
1857487Srgrimes# if $rwhod is set to YES, rwhod is run.
1867487Srgrimesif [ "X${rwhod}" = X"YES" ]; then
1877487Srgrimes	echo -n ' rwhod';	rwhod
1887238Sachefi
1897238Sache
1907487Srgrimesif [ "X${nfs_server}" = X"YES" -a -r /etc/exports ]; then
1917487Srgrimes	echo -n ' mountd';		mountd
1927487Srgrimes	echo -n ' nfsd';		nfsd -u -t 4
1937477Sachefi
1947477Sache
1957487Srgrimesif [ "X${nfs_client}" = X"YES" ]; then
1967487Srgrimes	echo -n ' nfsiod';		nfsiod -n 4
1977487Srgrimesfi
1987238Sache
1997487Srgrimesif [ "X${amdflags}" != X"NO" ]; then
2007487Srgrimes	echo -n ' amd';			amd ${amdflags}
2017238Sachefi
2027238Sache
2037487Srgrimes# Kerberos runs ONLY on the Kerberos server machine
2047487Srgrimesif [ "X${kerberos_server}" = X"YES" ]; then
2057487Srgrimes	echo -n ' kerberos';	kerberos >> /var/log/kerberos.log &
2067487Srgrimes	echo -n ' kadmind'; \
2077487Srgrimes		(sleep 20; /usr/sbin/kadmind -n >/dev/null 2>&1 &) &
2087238Sachefi
2097238Sache
2107487Srgrimesecho -n ' inetd';		inetd
2117487Srgrimesecho '.'
2127487Srgrimes
2137487Srgrimes# build ps databases
2147487Srgrimeskvm_mkdb 
2157487Srgrimesdev_mkdb
2167487Srgrimes
2177487Srgrimes# check the password temp/lock file
2187487Srgrimesif [ -f /etc/ptmp ]
2197487Srgrimesthen
2207487Srgrimes	logger -s -p auth.err \
2217487Srgrimes	"password file may be incorrect -- /etc/ptmp exists"
2227238Sachefi
2237238Sache
2247487Srgrimes# Recover vi editor files.
2257487Srgrimesvirecovery=/var/tmp/vi.recover/recover.*
2267487Srgrimesif [ "$virecovery" != "/var/tmp/vi.recover/recover.*" ]; then
2277487Srgrimes	echo 'Recovering vi editor sessions'
2287487Srgrimes	for i in $virecovery; do
2297487Srgrimes		sendmail -t < $i
2307487Srgrimes	done
2317238Sachefi
2327238Sache
2337487Srgrimesif [ "X${accounting}" = X"YES" -a -d /var/account ]; then
2347487Srgrimes	echo 'turning on accounting';	accton /var/account/acct
2357238Sachefi
2367238Sache
2377487Srgrimes# Now start up miscellaneous daemons that don't belong anywhere else
2387487Srgrimes#
2397487Srgrimesecho -n standard daemons:
2407487Srgrimesecho -n ' cron';		cron
2417708Srgrimesecho -n ' printer';		lpd
2427238Sache
2437487Srgrimes# $sendmail_flags is imported from /etc/sysconfig;
2447487Srgrimes# if $sendmail_flags is something other than NO, sendmail is run.
2457487Srgrimesif [ "X${sendmail_flags}" != X"NO" -a -r /etc/sendmail.cf ]; then
2467487Srgrimes	echo -n ' sendmail';		sendmail ${sendmail_flags} 
2477238Sachefi
2487238Sache
2497487Srgrimesecho '.'
2507238Sache
2517487Srgrimes# Make shared lib searching a little faster.  Leave /usr/lib first if you
2527487Srgrimes# add your own entries or you may come to grief.
2537487Srgrimesif [ -x /sbin/ldconfig ]; then
2547487Srgrimes	_LDC=/usr/lib
2557487Srgrimes	if [ -d /usr/X11R6/lib ]; then _LDC="${_LDC} /usr/X11R6/lib" ; fi
2567487Srgrimes	if [ -d /usr/X386/lib ]; then _LDC="${_LDC} /usr/X386/lib" ; fi
2577487Srgrimes	if [ -d /usr/local/lib ]; then _LDC="${_LDC} /usr/local/lib" ; fi
2587487Srgrimes	if [ -d /usr/gnu/lib ]; then _LDC="${_LDC} /usr/gnu/lib" ; fi
2597487Srgrimes	echo 'setting ldconfig path:' ${_LDC}
2607487Srgrimes	ldconfig ${_LDC}
2617296Sjkhfi
2627296Sjkh
2637487Srgrimes# configure implementation specific stuff
2647487Srgrimesarch=`uname -m`
2657487Srgrimesif [ -f /etc/rc.$arch ]; then
2667487Srgrimes	. /etc/rc.$arch
2677487Srgrimesfi
2687487Srgrimes
2697259Sjkh# Do traditional (but rather obsolete) rc.local file if it exists.
2707259Sjkhif [ -f /etc/rc.local ]; then
2717259Sjkh	sh /etc/rc.local
2727259Sjkhfi
27337Srgrimes
27437Srgrimesdate
27537Srgrimesexit 0
276