rc revision 1675
1709Swollman#!/bin/sh
21675Sache#	$Id: rc,v 1.24 1994/06/01 17:04:01 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
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
21323Sswallaceif [ -e /fastboot ]
2237Srgrimesthen
2337Srgrimes	echo Fast boot ... skipping disk checks
2437Srgrimeselif [ $1x = autobootx ]
2537Srgrimesthen
2637Srgrimes	echo Automatic reboot in progress...
2737Srgrimes	fsck -p
2837Srgrimes	case $? in
2937Srgrimes	0)
3037Srgrimes		;;
3137Srgrimes	2)
3237Srgrimes		exit 1
3337Srgrimes		;;
3437Srgrimes	4)
3537Srgrimes		reboot
3637Srgrimes		echo "reboot failed... help!"
3737Srgrimes		exit 1
3837Srgrimes		;;
3937Srgrimes	8)
4037Srgrimes		echo "Automatic file system check failed... help!"
4137Srgrimes		exit 1
4237Srgrimes		;;
4337Srgrimes	12)
4437Srgrimes		echo "Reboot interrupted"
4537Srgrimes		exit 1
4637Srgrimes		;;
4737Srgrimes	130)
4837Srgrimes		# interrupt before catcher installed
4937Srgrimes		exit 1
5037Srgrimes		;;
5137Srgrimes	*)
5237Srgrimes		echo "Unknown error in reboot"
5337Srgrimes		exit 1
5437Srgrimes		;;
5537Srgrimes	esac
5637Srgrimesfi
5737Srgrimes
5837Srgrimestrap "echo 'Reboot interrupted'; exit 1" 3
5937Srgrimes
6037Srgrimesswapon -a
6137Srgrimes
6237Srgrimesumount -a >/dev/null 2>&1
6337Srgrimesmount -a -t nonfs
6437Srgrimesrm -f /fastboot		# XXX (root now writeable)
6537Srgrimes
66872Sache# If the machine runs wall CMOS clock (compatible with MSDOS),
67872Sache# activate following line by creating empty file /etc/wall_cmos_clock
68872Sache# If this file not exist, following line does nothing (assumed
69872Sache# the machine runs UTC CMOS clock). See adjkerntz(8) for details.
70872Sacheadjkerntz -i
71872Sache
721675Sache# configure serial devices
731675Sacheif [ -f /etc/rc.serial ]
741675Sachethen
751675Sache	sh /etc/rc.serial
761675Sachefi
771675Sache
7837Srgrimes# set hostname, turn on network
7937Srgrimesecho 'starting network'
8037Srgrimes. /etc/netstart
8137Srgrimes
8237Srgrimes# clean up left-over files
8337Srgrimesrm -f /etc/nologin
841534Sacherm -f /var/spool/lock/*
851534Sacherm -f /var/spool/uucp/.Temp/*
861534Sache# don't add .[a-z]* to rm, because of .adjkerntz file name
8737Srgrimes(cd /var/run && { rm -rf -- *; cp /dev/null utmp; chmod 644 utmp; })
8837Srgrimes
8937Srgrimesecho -n 'starting system logger'
9037Srgrimesrm -f /dev/log
9137Srgrimessyslogd
9237Srgrimes
9337Srgrimes# $timedflags is imported from /etc/netstart;
9437Srgrimes# if $timedflags == NO, timed isn't run.
9537Srgrimesif [ X${timedflags} != X"NO" ]; then
9637Srgrimes	echo -n ', time daemon'; timed $timedflags
9737Srgrimesfi
9837Srgrimesecho '.'
9937Srgrimes
10037Srgrimes# /var/crash should be a directory or a symbolic link
10137Srgrimes# to the crash directory if core dumps are to be saved.
10237Srgrimesif [ -d /var/crash ]; then
10337Srgrimes	echo checking for core dump...
10437Srgrimes	savecore /var/crash
10537Srgrimesfi
10637Srgrimes
10737Srgrimes#				echo -n 'checking quotas:'
10837Srgrimes#quotacheck -a
10937Srgrimes#				echo ' done.'
11037Srgrimes#quotaon -a
11137Srgrimes
11237Srgrimes# build ps databases
11337Srgrimeskvm_mkdb /386bsd
11437Srgrimesdev_mkdb
11537Srgrimes
11637Srgrimeschmod 666 /dev/tty[pqrs]*
11737Srgrimes
11837Srgrimes# check the password temp/lock file
11937Srgrimesif [ -f /etc/ptmp ]
12037Srgrimesthen
12137Srgrimes	logger -s -p auth.err \
12237Srgrimes	'password file may be incorrect -- /etc/ptmp exists'
12337Srgrimesfi
12437Srgrimes
1251185Srgrimes# Recover elvis editor files.
1261185Srgrimesecho preserving editor files
1271189Srgrimes(cd /var/tmp && /usr/libexec/elvispreserve "-the system rebooted" elv* &&
1281185Srgrimes	rm -f elvis[0-9a-f][0-9a-f][0-9a-f][0-9a-f]* \
1291185Srgrimes	elvis_[0-9a-f][0-9a-f][0-9a-f][0-9a-f]*)
1301185Srgrimes
1311185Srgrimes# Recover vi editor files.
1321185Srgrimesvirecovery=/var/tmp/vi.recover/recover.*
1331185Srgrimesif [ "$virecovery" != "/var/tmp/vi.recover/recover.*" ]; then
1341185Srgrimes	echo 'Recovering vi editor sessions'
1351185Srgrimes	for i in $virecovery; do
1361185Srgrimes		sendmail -t < $i
1371185Srgrimes	done
1381185Srgrimesfi
1391185Srgrimes
14037Srgrimesecho clearing /tmp
14137Srgrimes
14237Srgrimes# prune quickly with one rm, then use find to clean up /tmp/[lq]*
14337Srgrimes# (not needed with mfs /tmp, but doesn't hurt there...)
14437Srgrimes(cd /tmp && rm -rf [a-km-pr-zA-Z]* &&
1451074Schmr    find -d . ! -name . ! -name lost+found ! -name quotas -exec rm -rf -- {} \;)
14637Srgrimes
14737Srgrimes# echo 'turning on accounting';	accton /var/account/acct
14837Srgrimes
14937Srgrimesecho -n standard daemons:
1501001Sguidoecho -n ' cron';		cron
15137Srgrimesecho '.'
15237Srgrimes
15337Srgrimesecho -n starting network daemons:
15437Srgrimes
155857Sdg# Portmapper should always be run, to provide RPC services for inetd.
156857Sdgif [ -x /usr/sbin/portmap ]; then
157857Sdg	echo -n ' portmap';		portmap
158857Sdgfi
159857Sdg
16037Srgrimes# $gated and $routedflags are imported from /etc/netstart.
16137Srgrimes# If $gated == YES, gated is used; otherwise routed.
16237Srgrimes# If $routedflags == NO, routed isn't run.
16337Srgrimesif [ X${gated} = X"YES" -a -r /etc/gated.conf ]; then
16437Srgrimes	echo -n ' gated';	gated $gatedflags
1651412Sjkhelif [ X"${routedflags}" != X"NO" ]; then
16637Srgrimes	echo -n ' routed';	routed $routedflags
16737Srgrimesfi
16837Srgrimes
16937Srgrimesif [ X${name_server} = X"YES" -a -r /etc/named.boot ]; then
17037Srgrimes	echo -n ' named';		named
17137Srgrimesfi
17237Srgrimes
173908Swollman# $ntpdate and $xntpdflags are imported from /etc/netstart.
174908Swollman# If $ntpdate != NO, run ntpdate $ntpdate to set the date correctly.
175908Swollman# If $xntpdflags != NO, start xntpd.
176908Swollmanif [ X"${ntpdate}" != X"NO" ]; then
1771185Srgrimes	echo ' ntpdate';	ntpdate $ntpdate
178908Swollmanfi
179908Swollman
180908Swollmanif [ X"${xntpdflags}" != X"NO" ]; then
1811218Sphk	if [ X"${tickadjflags}" != X"NO" ]; then
1821218Sphk		echo 'adjusting kernel for xntpd'; tickadj ${tickadjflags--A}
1831218Sphk	fi
1841218Sphk	echo 'starting xntpd';	xntpd ${xntpdflags}
185908Swollmanfi
186908Swollman
1871218Sphkif [ X"${ntpdate}" != X"NO" -o X"${xntpdflags}" != X"NO" ]; then
1881218Sphk	echo -n 'starting more network daemons:'
1891218Sphkfi
1901218Sphk
19137Srgrimes# $rwhod is imported from /etc/netstart;
19237Srgrimes# if $rwhod is set to something other than NO, rwhod is run.
19337Srgrimesif [ ${rwhod-NO} != "NO" ]; then
19437Srgrimes	echo -n ' rwhod';	rwhod
19537Srgrimesfi
19637Srgrimes
19737Srgrimesecho -n ' printer';		lpd
19837Srgrimes
19937Srgrimesif [ X${nfs_server} = X"YES" -a -r /etc/exports ]; then
20037Srgrimes	echo -n ' mountd';		mountd
20137Srgrimes	echo -n ' nfsd';		nfsd -u 0,0,4 -t 0,0
20237Srgrimes	echo -n ' nfsiod';		nfsiod 4
20337Srgrimesfi
20437Srgrimes
205709Swollman# $sendmail_flags is imported from /etc/netstart;
206709Swollman# if $sendmail_flags is something other than NO, sendmail is run.
207888Sacheif [ X"${sendmail_flags}" != X"NO" -a -r /etc/sendmail.cf ]; then
208709Swollman	echo -n ' sendmail';		sendmail ${sendmail_flags} 
209709Swollmanfi
210709Swollman
21137Srgrimesecho -n ' inetd';		inetd
21237Srgrimesecho '.'
21337Srgrimes
214958Sachemount -a -t nfs >/dev/null 2>&1 &	# XXX shouldn't need background
215958Sache
2161668Spaulif [ -x /usr/libexec/xtend ]; then
2171668Spaul	echo -n ' xtend';   /usr/libexec/xtend
2181668Spaulfi
2191668Spaul
2201186Srgrimes# Make shared lib searching a little faster.  Leave /usr/lib first if you
2211186Srgrimes# add your own entries or you may come to grief.
2221186Srgrimesif [ -x /sbin/ldconfig ]; then
2231186Srgrimes	_LDC=/usr/lib
2241308Srich	if [ -d /usr/X11R6/lib ]; then _LDC="${_LDC} /usr/X11R6/lib" ; fi
2251186Srgrimes	if [ -d /usr/X386/lib ]; then _LDC="${_LDC} /usr/X386/lib" ; fi
2261186Srgrimes	if [ -d /usr/local/lib ]; then _LDC="${_LDC} /usr/local/lib" ; fi
2271186Srgrimes	if [ -d /usr/gnu/lib ]; then _LDC="${_LDC} /usr/gnu/lib" ; fi
2281186Srgrimes	echo 'setting ldconfig path:' ${_LDC}
2291186Srgrimes	ldconfig ${_LDC}
2301186Srgrimesfi
2311186Srgrimes
23237Srgrimessh /etc/rc.local
23337Srgrimes
23437Srgrimesdate
23537Srgrimes
23637Srgrimesexit 0
237