rc revision 16671
1709Swollman#!/bin/sh
216671Spst#	$Id: rc,v 1.92 1996/06/22 13:05:20 joerg 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
2515568Sasami# Configure ccd devices.
2615568Sasamiif [ -f /etc/ccd.conf ]
2715568Sasamithen
2815568Sasami	ccdconfig -C
2915568Sasamifi
3015568Sasami
313843Sdgswapon -a
323843Sdg
332164Sdgif [ $1x = autobootx ]
3437Srgrimesthen
3537Srgrimes	echo Automatic reboot in progress...
3637Srgrimes	fsck -p
3737Srgrimes	case $? in
3837Srgrimes	0)
3937Srgrimes		;;
4037Srgrimes	2)
4137Srgrimes		exit 1
4237Srgrimes		;;
4337Srgrimes	4)
4437Srgrimes		reboot
4537Srgrimes		echo "reboot failed... help!"
4637Srgrimes		exit 1
4737Srgrimes		;;
4837Srgrimes	8)
4937Srgrimes		echo "Automatic file system check failed... help!"
5037Srgrimes		exit 1
5137Srgrimes		;;
5237Srgrimes	12)
5337Srgrimes		echo "Reboot interrupted"
5437Srgrimes		exit 1
5537Srgrimes		;;
5637Srgrimes	130)
5737Srgrimes		# interrupt before catcher installed
5837Srgrimes		exit 1
5937Srgrimes		;;
6037Srgrimes	*)
6137Srgrimes		echo "Unknown error in reboot"
6237Srgrimes		exit 1
6337Srgrimes		;;
6437Srgrimes	esac
652164Sdgelse
662164Sdg	echo Skipping disk checks ...
6737Srgrimesfi
6837Srgrimes
6937Srgrimestrap "echo 'Reboot interrupted'; exit 1" 3
7037Srgrimes
713036Sdg# root must be read/write both for NFS diskless and for VFS LKMs before
723036Sdg# proceeding any further.
733036Sdgmount -u -o rw /
748530Sdgif [ $? != 0 ]; then
758530Sdg	echo "Filesystem mount failed, startup aborted"
768530Sdg	exit 1
778530Sdgfi
781692Sphk
7937Srgrimesumount -a >/dev/null 2>&1
808530Sdg
8137Srgrimesmount -a -t nonfs
828530Sdgif [ $? != 0 ]; then
838530Sdg	echo "Filesystem mount failed, startup aborted"
848530Sdg	exit 1
858530Sdgfi
8637Srgrimes
874091Sacheadjkerntz -i
88872Sache
897219Sjkh# If there is a global system configuration file, suck it in.
907219Sjkhif [ -f /etc/sysconfig ]; then
917219Sjkh	. /etc/sysconfig
927219Sjkhfi
937219Sjkh
941675Sache# configure serial devices
957219Sjkhif [ -f /etc/rc.serial ]; then
967293Sjkh	. /etc/rc.serial
971675Sachefi
981675Sache
9914596Snate# start up PC-card configuration
10014624Snateif [ -f /etc/rc.pccard ]; then
10114624Snate	. /etc/rc.pccard
10214596Snatefi
10314596Snate
1047487Srgrimes# start up the network
1057460Sjkhif [ -f /etc/netstart ]; then
1067750Srgrimes	sh /etc/netstart
1077460Sjkhfi
1087460Sjkh
1098540Srgrimesmount -a -t nfs >/dev/null 2>&1
1107487Srgrimes
1117487Srgrimes# Whack the pty perms back into shape.
1127487Srgrimeschmod 666 /dev/tty[pqrs]*
1137487Srgrimes
1147487Srgrimes# clean up left-over files
1157487Srgrimesrm -f /etc/nologin
1167487Srgrimesrm -f /var/spool/lock/*
1177761Sacherm -rf /var/spool/uucp/.Temp/*
1187487Srgrimesrm -f /dev/log
11915684Sjkh(cd /var/run && { cp /dev/null utmp; chmod 644 utmp; })
1207487Srgrimes
12116588Sjoerg#
12216588Sjoerg# Clearing /tmp at boot-time is essentially stupid, but seems to have
12316588Sjoerg# a long tradition.  It doesn't help in any way for long-living systems,
12416588Sjoerg# and it might accidentally clobber files you would rather like to have
12516588Sjoerg# preserved after a crash (if not using mfs /tmp anyway).
12616588Sjoerg#
12716588Sjoerg# See also the commented out example of another cleanup policy in
12816588Sjoerg# /etc/daily.
12916588Sjoerg#
1307487Srgrimesecho clearing /tmp
1317487Srgrimes
1327487Srgrimes# prune quickly with one rm, then use find to clean up /tmp/[lq]*
1337487Srgrimes# (not needed with mfs /tmp, but doesn't hurt there...)
1347487Srgrimes(cd /tmp && rm -rf [a-km-pr-zA-Z]* &&
1357487Srgrimes    find -d . ! -name . ! -name lost+found ! -name quotas -exec rm -rf -- {} \;)
1367487Srgrimes
13716588Sjoerg# The above is even more stupid since it prevents you from restarting
13816588Sjoerg# X11 after a system crash.  If you disable the above, make sure to
13916588Sjoerg# uncomment the line below.
14016588Sjoerg#
14116588Sjoerg# clean up leftover X lock files and local connection sockets
14216588Sjoerg#rm -f /tmp/.X*-lock /tmp/.X11-unix/*
14316588Sjoerg
14416588Sjoerg
1459305Sbde# enable dumpdev so that savecore can see it
1469305Sbdeif [ "X${dumpdev}" != X"NO" ]; then
1479305Sbde	dumpon ${dumpdev}
1489305Sbdefi
1499305Sbde
1507487Srgrimes# /var/crash should be a directory or a symbolic link
1517487Srgrimes# to the crash directory if core dumps are to be saved.
1527487Srgrimesif [ "X${savecore}" = X"YES" -a -d /var/crash ]; then
1537487Srgrimes	echo -n checking for core dump...
1547487Srgrimes	savecore /var/crash
1557487Srgrimesfi
1567487Srgrimes
1577487Srgrimes# snapshot any kernel -c changes back to disk
1587487Srgrimesecho 'recording kernel -c changes'
1597487Srgrimes/sbin/dset -q
1607487Srgrimes
1617487Srgrimes# Check the quotas
1627487Srgrimesif [ "X${check_quotas}" = X"YES" ]; then
1637487Srgrimes	echo 'checking quotas:'
1647487Srgrimes	quotacheck -a
1657487Srgrimes	echo ' done.'
1667487Srgrimes	quotaon -a
1677487Srgrimesfi
1687487Srgrimes
1697487Srgrimes# start system logging and name service (named needs to start before syslogd
1707487Srgrimes# if you don't have a /etc/resolv.conf)
1717259Sjkh#
1727487Srgrimesecho -n starting system daemons:
1737487Srgrimes
1747708Srgrimesecho ' syslogd.';			syslogd
1757487Srgrimes
1767487Srgrimesecho -n starting network daemons:
1777487Srgrimes
1787487Srgrimes# $namedflags is imported from /etc/sysconfig
1797487Srgrimesif [ "X${namedflags}" != "XNO" ]; then
1807708Srgrimes	echo -n ' named';		named $namedflags
181857Sdgfi
18237Srgrimes
1837487Srgrimes# $ntpdate and $xntpdflags are imported from /etc/sysconfig.
1847487Srgrimes# If $ntpdate != NO, run ntpdate $ntpdate to set the date correctly.
1857487Srgrimes# If $xntpdflags != NO, start xntpd.
1867487Srgrimesif [ "X${ntpdate}" != X"NO" -o "X${xntpdflags}" != X"NO" ]; then
1877487Srgrimes	if [ "X${tickadjflags}" != X"NO" ]; then
1887487Srgrimes		echo -n ' tickadj';	tickadj ${tickadjflags--Aq}
1897487Srgrimes	fi
190958Sache
1917487Srgrimes	if [ "X${ntpdate}" != X"NO" ]; then
1927487Srgrimes		echo -n ' ntpdate';	ntpdate ${ntpdate} >/dev/null 2>&1
1937487Srgrimes	fi
1947487Srgrimes
1957487Srgrimes	if [ "X${xntpdflags}" != X"NO" ]; then
1967487Srgrimes		echo -n ' xntpd';	xntpd ${xntpdflags}
1977487Srgrimes	fi
1981186Srgrimesfi
1991186Srgrimes
2007487Srgrimes# $timedflags is imported from /etc/sysconfig;
2017487Srgrimes# if $timedflags == NO, timed isn't run.
2027487Srgrimesif [ "X${timedflags}" != X"NO" ]; then
2037487Srgrimes	echo -n ' timed'; timed $timedflags
2047487Srgrimesfi
2057219Sjkh
2067487Srgrimes# Portmapper should always be run, to provide RPC services for inetd.
2077487Srgrimesif [ -x /usr/sbin/portmap ]; then
2087487Srgrimes	echo -n ' portmap';		portmap
2097487Srgrimesfi
2107238Sache
2117487Srgrimes# Start ypserv if we're an NIS server.
2127487Srgrimes# Run yppasswdd only on the NIS master server
2137487Srgrimesif [ "X${nis_serverflags}" != X"NO" ]; then
2147708Srgrimes	echo -n ' ypserv'; ypserv ${nis_serverflags}
2157238Sache
2167487Srgrimes	if [ "X${yppasswddflags}" != X"NO" ]; then
21714202Sadam		echo -n ' yppasswdd'; rpc.yppasswdd ${yppasswddflags}
2187487Srgrimes	fi
2197487Srgrimesfi
2207238Sache
2217487Srgrimes# Start ypbind if we're an NIS client
2227487Srgrimesif [ "X${nis_clientflags}" != X"NO" ]; then
2237708Srgrimes	echo -n ' ypbind'; ypbind ${nis_clientflags}
2249593Swollman	if [ "X${nis_ypsetflags}" != X"NO" ]; then
2259593Swollman		echo -n ' ypset'; ypset ${nis_ypsetflags}
2269593Swollman	fi
2277219Sjkhfi
2287219Sjkh
2297487Srgrimes# $rwhod is imported from /etc/sysconfig;
2307487Srgrimes# if $rwhod is set to YES, rwhod is run.
2317487Srgrimesif [ "X${rwhod}" = X"YES" ]; then
2327487Srgrimes	echo -n ' rwhod';	rwhod
2337238Sachefi
2347238Sache
2357487Srgrimesif [ "X${nfs_server}" = X"YES" -a -r /etc/exports ]; then
23610716Sjkh	echo -n ' mountd'
23713071Sjkh	if [ "X${weak_mountd_authentication}" = X"YES" ]; then
23810716Sjkh		mountd -n
23910716Sjkh	else
24010716Sjkh		mountd
24110716Sjkh	fi
2427487Srgrimes	echo -n ' nfsd';		nfsd -u -t 4
2437477Sachefi
2447477Sache
2457487Srgrimesif [ "X${nfs_client}" = X"YES" ]; then
2467487Srgrimes	echo -n ' nfsiod';		nfsiod -n 4
2477487Srgrimesfi
2487238Sache
2497487Srgrimesif [ "X${amdflags}" != X"NO" ]; then
25013455Sgraichen	echo -n ' amd'
25113996Sjkh	amd ${amdflags} > /var/run/amd.pid
2527238Sachefi
2537238Sache
2547487Srgrimes# Kerberos runs ONLY on the Kerberos server machine
2557487Srgrimesif [ "X${kerberos_server}" = X"YES" ]; then
2567487Srgrimes	echo -n ' kerberos';	kerberos >> /var/log/kerberos.log &
2577487Srgrimes	echo -n ' kadmind'; \
25812053Spst		(sleep 20; kadmind -n >/dev/null 2>&1 &) &
2597238Sachefi
2607238Sache
26113701Sgpalmer# IP multicast routing daemon
26213701Sgpalmerif [ "X${mrouted}" != X"NO" -a -x /usr/sbin/mrouted ]; then
26313701Sgpalmer	echo -n ' mrouted'; mrouted ${mrouted}
26413701Sgpalmerfi
26513701Sgpalmer
2667487Srgrimesecho -n ' inetd';		inetd
2677487Srgrimesecho '.'
2687487Srgrimes
2697487Srgrimes# build ps databases
2707487Srgrimeskvm_mkdb 
2717487Srgrimesdev_mkdb
2727487Srgrimes
2737487Srgrimes# check the password temp/lock file
2747487Srgrimesif [ -f /etc/ptmp ]
2757487Srgrimesthen
2767487Srgrimes	logger -s -p auth.err \
2777487Srgrimes	"password file may be incorrect -- /etc/ptmp exists"
2787238Sachefi
2797238Sache
2807487Srgrimesif [ "X${accounting}" = X"YES" -a -d /var/account ]; then
28111992Sache	echo 'turning on accounting'
28211992Sache	if [ ! -e /var/account/acct ]; then
28311992Sache		touch /var/account/acct
28411992Sache	fi
28511992Sache	accton /var/account/acct
2867238Sachefi
2877238Sache
2887487Srgrimes# Now start up miscellaneous daemons that don't belong anywhere else
2897487Srgrimes#
2907487Srgrimesecho -n standard daemons:
2917487Srgrimesecho -n ' cron';		cron
2927238Sache
29313659Sgpalmerif [ "X${lpd}" != X"NO" -a -x /usr/sbin/lpd ]; then
29413659Sgpalmer	echo -n ' printer';		lpd
29513659Sgpalmerfi
29613659Sgpalmer
2977487Srgrimes# $sendmail_flags is imported from /etc/sysconfig;
2987487Srgrimes# if $sendmail_flags is something other than NO, sendmail is run.
2997487Srgrimesif [ "X${sendmail_flags}" != X"NO" -a -r /etc/sendmail.cf ]; then
30012699Sache	echo -n ' sendmail';            /usr/sbin/sendmail ${sendmail_flags}
3017238Sachefi
3027238Sache
3037487Srgrimesecho '.'
3047238Sache
3057487Srgrimes# Make shared lib searching a little faster.  Leave /usr/lib first if you
3067487Srgrimes# add your own entries or you may come to grief.
3077487Srgrimesif [ -x /sbin/ldconfig ]; then
3087487Srgrimes	_LDC=/usr/lib
3097487Srgrimes	if [ -d /usr/X11R6/lib ]; then _LDC="${_LDC} /usr/X11R6/lib" ; fi
3107487Srgrimes	if [ -d /usr/X386/lib ]; then _LDC="${_LDC} /usr/X386/lib" ; fi
3117487Srgrimes	if [ -d /usr/local/lib ]; then _LDC="${_LDC} /usr/local/lib" ; fi
3127487Srgrimes	echo 'setting ldconfig path:' ${_LDC}
3137487Srgrimes	ldconfig ${_LDC}
3147296Sjkhfi
3157296Sjkh
3167487Srgrimes# configure implementation specific stuff
3177487Srgrimesarch=`uname -m`
31810895Sjkhif [ -f /etc/rc.${arch} ]; then
31910895Sjkh	. /etc/rc.${arch}
3207487Srgrimesfi
3217487Srgrimes
32216671Spst# Recover vi editor files.
32316671Spstvirecovery=`echo /var/tmp/vi.recover/recover.*`
32416671Spstif [ "$virecovery" != '/var/tmp/vi.recover/recover.*' ]; then
32516671Spst	echo 'Recovering vi editor sessions'
32616671Spst	for i in $virecovery; do
32716671Spst		sendmail -t < $i
32816671Spst	done
32916671Spstfi
33016671Spst
33113071Sjkh# for each valid dir in $local_startup, search for init scripts matching *.sh
33213071Sjkhif [ "X${local_startup}" != X"NO" ]; then
33316391Sjkh	echo -n 'Local package startup:'
33413071Sjkh	for dir in ${local_startup}; do
33513071Sjkh		[ -d ${dir} ] && for script in ${dir}/*.sh; do
33613071Sjkh			[ -x ${script} ] && ${script} start
33713071Sjkh		done
33810873Sjkh	done
33916391Sjkh	echo .
3407259Sjkhfi
34137Srgrimes
34210873Sjkh# Do traditional (but rather obsolete) rc.local file if it exists.
34310898Sjkh[ -f /etc/rc.local ] && sh /etc/rc.local
34410873Sjkh
34537Srgrimesdate
34637Srgrimesexit 0
347