rc revision 7487
1281348Scy#!/bin/sh
2281348Scy#	$Id: rc,v 1.59 1995/03/30 00:01:08 ache Exp $
3281348Scy#	From: @(#)rc	5.27 (Berkeley) 6/5/91
4281348Scy
5281348Scy# System startup script run by init on autoboot
6281348Scy# or after single-user.
7281348Scy# Output and error are redirected to console by init,
8281348Scy# and the console is the controlling terminal.
9281348Scy
10281348Scystty status '^T'
11281348Scy
12281348Scy# Set shell to ignore SIGINT (2), but not children;
13281348Scy# shell catches SIGQUIT (3) and returns to single user after fsck.
14281348Scytrap : 2
15281348Scytrap : 3	# shouldn't be needed
16281348Scy
17281348ScyHOME=/; export HOME
18281348ScyPATH=/sbin:/bin:/usr/sbin:/usr/bin
19281348Scyexport PATH
20281348Scy
21281348Scyswapon -a
22281348Scy
23281348Scyif [ $1x = autobootx ]
24281348Scythen
25281348Scy	echo Automatic reboot in progress...
26281348Scy	fsck -p
27281348Scy	case $? in
28281348Scy	0)
29281348Scy		;;
30281348Scy	2)
31281348Scy		exit 1
32281348Scy		;;
33281348Scy	4)
34281348Scy		reboot
35281348Scy		echo "reboot failed... help!"
36281348Scy		exit 1
37281348Scy		;;
38281348Scy	8)
39281348Scy		echo "Automatic file system check failed... help!"
40281348Scy		exit 1
41281348Scy		;;
42281348Scy	12)
43281348Scy		echo "Reboot interrupted"
44281348Scy		exit 1
45281348Scy		;;
46281348Scy	130)
47281348Scy		# interrupt before catcher installed
48281348Scy		exit 1
49281348Scy		;;
50281348Scy	*)
51281348Scy		echo "Unknown error in reboot"
52281348Scy		exit 1
53281348Scy		;;
54281348Scy	esac
55281348Scyelse
56281348Scy	echo Skipping disk checks ...
57281348Scyfi
58281348Scy
59281348Scytrap "echo 'Reboot interrupted'; exit 1" 3
60281348Scy
61281348Scy# root must be read/write both for NFS diskless and for VFS LKMs before
62281348Scy# proceeding any further.
63281348Scymount -u -o rw /
64281348Scy
65281348Scyumount -a >/dev/null 2>&1
66281348Scymount -a -t nonfs
67281348Scy
68281348Scy# If the machine runs wall CMOS clock (compatible with MSDOS),
69281348Scy# activate following line by creating empty file /etc/wall_cmos_clock
70281348Scy# If this file not exist, following line does nothing (assumed
71281348Scy# the machine runs UTC CMOS clock). See adjkerntz(8) for details.
72281348Scyadjkerntz -i
73281348Scy
74281348Scy# If there is a global system configuration file, suck it in.
75281348Scyif [ -f /etc/sysconfig ]; then
76281348Scy	. /etc/sysconfig
77281348Scyfi
78281348Scy
79281348Scy# configure serial devices
80281348Scyif [ -f /etc/rc.serial ]; then
81281348Scy	. /etc/rc.serial
82281348Scyfi
83281348Scy
84281348Scy# start up the network
85281348Scyif [ -f /etc/netstart ]; then
86281348Scy	. /etc/netstart
87281348Scyfi
88281348Scy
89281348Scymount -a -t nfs >/dev/null 2>&1 &	# XXX shouldn't need background
90281348Scy
91281348Scy# Whack the pty perms back into shape.
92281348Scychmod 666 /dev/tty[pqrs]*
93281348Scy
94281348Scy# clean up left-over files
95281348Scyrm -f /etc/nologin
96281348Scyrm -f /var/spool/lock/*
97281348Scyrm -f /var/spool/uucp/.Temp/*
98281348Scyrm -f /dev/log
99281348Scy(cd /var/run && { rm -rf -- *; cp /dev/null utmp; chmod 644 utmp; })
100281348Scy
101281348Scyecho clearing /tmp
102281348Scy
103281348Scy# prune quickly with one rm, then use find to clean up /tmp/[lq]*
104281348Scy# (not needed with mfs /tmp, but doesn't hurt there...)
105281348Scy(cd /tmp && rm -rf [a-km-pr-zA-Z]* &&
106281348Scy    find -d . ! -name . ! -name lost+found ! -name quotas -exec rm -rf -- {} \;)
107281348Scy
108281348Scy# /var/crash should be a directory or a symbolic link
109281348Scy# to the crash directory if core dumps are to be saved.
110281348Scyif [ "X${savecore}" = X"YES" -a -d /var/crash ]; then
111281348Scy	echo -n checking for core dump...
112281348Scy	savecore /var/crash
113281348Scyfi
114281348Scy
115281348Scy# snapshot any kernel -c changes back to disk
116281348Scyecho 'recording kernel -c changes'
117281348Scy/sbin/dset -q
118281348Scy
119281348Scy# Check the quotas
120281348Scyif [ "X${check_quotas}" = X"YES" ]; then
121281348Scy	echo 'checking quotas:'
122281348Scy	quotacheck -a
123281348Scy	echo ' done.'
124281348Scy	quotaon -a
125281348Scyfi
126281348Scy
127281348Scy# start system logging and name service (named needs to start before syslogd
128281348Scy# if you don't have a /etc/resolv.conf)
129281348Scy#
130281348Scyecho -n starting system daemons:
131281348Scy
132281348Scyecho ' syslogd.';                       syslogd
133281348Scy
134281348Scyecho -n starting network daemons:
135281348Scy
136281348Scy# $namedflags is imported from /etc/sysconfig
137281348Scyif [ "X${namedflags}" != "XNO" ]; then
138281348Scy	echo -n ' named';	named $namedflags
139281348Scyfi
140281348Scy
141281348Scy# $ntpdate and $xntpdflags are imported from /etc/sysconfig.
142281348Scy# If $ntpdate != NO, run ntpdate $ntpdate to set the date correctly.
143281348Scy# If $xntpdflags != NO, start xntpd.
144281348Scyif [ "X${ntpdate}" != X"NO" -o "X${xntpdflags}" != X"NO" ]; then
145281348Scy	if [ "X${tickadjflags}" != X"NO" ]; then
146281348Scy		echo -n ' tickadj';	tickadj ${tickadjflags--Aq}
147281348Scy	fi
148281348Scy
149281348Scy	if [ "X${ntpdate}" != X"NO" ]; then
150281348Scy		echo -n ' ntpdate';	ntpdate ${ntpdate} >/dev/null 2>&1
151281348Scy	fi
152281348Scy
153281348Scy	if [ "X${xntpdflags}" != X"NO" ]; then
154281348Scy		echo -n ' xntpd';	xntpd ${xntpdflags}
155281348Scy	fi
156281348Scyfi
157281348Scy
158281348Scy# $timedflags is imported from /etc/sysconfig;
159281348Scy# if $timedflags == NO, timed isn't run.
160281348Scyif [ "X${timedflags}" != X"NO" ]; then
161281348Scy	echo -n ' timed'; timed $timedflags
162281348Scyfi
163281348Scy
164# Portmapper should always be run, to provide RPC services for inetd.
165if [ -x /usr/sbin/portmap ]; then
166	echo -n ' portmap';		portmap
167fi
168
169# Start ypserv if we're an NIS server.
170# Run yppasswdd only on the NIS master server
171if [ "X${nis_serverflags}" != X"NO" ]; then
172        echo -n ' ypserv'; ypserv ${nis_serverflags}
173
174	if [ "X${yppasswddflags}" != X"NO" ]; then
175	        echo -n ' yppasswdd'; yppasswdd ${yppasswddflags}
176	fi
177fi
178
179# Start ypbind if we're an NIS client
180if [ "X${nis_clientflags}" != X"NO" ]; then
181        echo -n ' ypbind'; ypbind ${nis_clientflags}
182fi
183
184# $rwhod is imported from /etc/sysconfig;
185# if $rwhod is set to YES, rwhod is run.
186if [ "X${rwhod}" = X"YES" ]; then
187	echo -n ' rwhod';	rwhod
188fi
189
190if [ "X${nfs_server}" = X"YES" -a -r /etc/exports ]; then
191	echo -n ' mountd';		mountd
192	echo -n ' nfsd';		nfsd -u -t 4
193fi
194
195if [ "X${nfs_client}" = X"YES" ]; then
196	echo -n ' nfsiod';		nfsiod -n 4
197fi
198
199if [ "X${amdflags}" != X"NO" ]; then
200	echo -n ' amd';			amd ${amdflags}
201fi
202
203# Kerberos runs ONLY on the Kerberos server machine
204if [ "X${kerberos_server}" = X"YES" ]; then
205	echo -n ' kerberos';	kerberos >> /var/log/kerberos.log &
206	echo -n ' kadmind'; \
207		(sleep 20; /usr/sbin/kadmind -n >/dev/null 2>&1 &) &
208fi
209
210echo -n ' inetd';		inetd
211echo '.'
212
213# build ps databases
214kvm_mkdb 
215dev_mkdb
216
217# check the password temp/lock file
218if [ -f /etc/ptmp ]
219then
220	logger -s -p auth.err \
221	"password file may be incorrect -- /etc/ptmp exists"
222fi
223
224# Recover vi editor files.
225virecovery=/var/tmp/vi.recover/recover.*
226if [ "$virecovery" != "/var/tmp/vi.recover/recover.*" ]; then
227	echo 'Recovering vi editor sessions'
228	for i in $virecovery; do
229		sendmail -t < $i
230	done
231fi
232
233if [ "X${accounting}" = X"YES" -a -d /var/account ]; then
234	echo 'turning on accounting';	accton /var/account/acct
235fi
236
237# Now start up miscellaneous daemons that don't belong anywhere else
238#
239echo -n standard daemons:
240echo -n ' cron';		cron
241echo -n ' printer';             lpd
242
243# $sendmail_flags is imported from /etc/sysconfig;
244# if $sendmail_flags is something other than NO, sendmail is run.
245if [ "X${sendmail_flags}" != X"NO" -a -r /etc/sendmail.cf ]; then
246	echo -n ' sendmail';		sendmail ${sendmail_flags} 
247fi
248
249echo '.'
250
251# Make shared lib searching a little faster.  Leave /usr/lib first if you
252# add your own entries or you may come to grief.
253if [ -x /sbin/ldconfig ]; then
254	_LDC=/usr/lib
255	if [ -d /usr/X11R6/lib ]; then _LDC="${_LDC} /usr/X11R6/lib" ; fi
256	if [ -d /usr/X386/lib ]; then _LDC="${_LDC} /usr/X386/lib" ; fi
257	if [ -d /usr/local/lib ]; then _LDC="${_LDC} /usr/local/lib" ; fi
258	if [ -d /usr/gnu/lib ]; then _LDC="${_LDC} /usr/gnu/lib" ; fi
259	echo 'setting ldconfig path:' ${_LDC}
260	ldconfig ${_LDC}
261fi
262
263# configure implementation specific stuff
264arch=`uname -m`
265if [ -f /etc/rc.$arch ]; then
266	. /etc/rc.$arch
267fi
268
269# Do traditional (but rather obsolete) rc.local file if it exists.
270if [ -f /etc/rc.local ]; then
271	sh /etc/rc.local
272fi
273
274date
275exit 0
276