rc revision 24463
1#!/bin/sh
2#	$Id: rc,v 1.114 1997/03/16 15:26:32 joerg Exp $
3#	From: @(#)rc	5.27 (Berkeley) 6/5/91
4
5# System startup script run by init on autoboot
6# or after single-user.
7# Output and error are redirected to console by init,
8# and the console is the controlling terminal.
9
10# Note that almost all the user-configurable behavior is no longer in
11# this file, but rather in /etc/sysconfig.  Please check this file
12# first before contemplating any changes here.
13
14stty status '^T'
15
16# Set shell to ignore SIGINT (2), but not children;
17# shell catches SIGQUIT (3) and returns to single user after fsck.
18trap : 2
19trap : 3	# shouldn't be needed
20
21HOME=/; export HOME
22PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin
23export PATH
24
25# Configure ccd devices.
26if [ -f /etc/ccd.conf ]
27then
28	ccdconfig -C
29fi
30
31swapon -a
32
33if [ $1x = autobootx ]
34then
35	echo Automatic reboot in progress...
36	fsck -p
37	case $? in
38	0)
39		;;
40	2)
41		exit 1
42		;;
43	4)
44		reboot
45		echo "reboot failed... help!"
46		exit 1
47		;;
48	8)
49		echo "Automatic file system check failed... help!"
50		exit 1
51		;;
52	12)
53		echo "Reboot interrupted"
54		exit 1
55		;;
56	130)
57		# interrupt before catcher installed
58		exit 1
59		;;
60	*)
61		echo "Unknown error in reboot"
62		exit 1
63		;;
64	esac
65else
66	echo Skipping disk checks ...
67fi
68
69trap "echo 'Reboot interrupted'; exit 1" 3
70
71# root must be read/write both for NFS diskless and for VFS LKMs before
72# proceeding any further.
73mount -u -o rw /
74if [ $? != 0 ]; then
75	echo "Filesystem mount failed, startup aborted"
76	exit 1
77fi
78
79umount -a >/dev/null 2>&1
80
81mount -a -t nonfs
82if [ $? != 0 ]; then
83	echo "Filesystem mount failed, startup aborted"
84	exit 1
85fi
86
87adjkerntz -i
88
89# Keep a copy of the boot messages around
90/sbin/dmesg > /var/run/dmesg.boot
91
92# If there is a global system configuration file, suck it in.
93if [ -f /etc/sysconfig ]; then
94	. /etc/sysconfig
95fi
96
97# Add additional swapfile, if configured.
98if [ "x$swapfile" != "xNO" -a -w "$swapfile" -a -b /dev/vn0b ]; then
99	echo "Adding $swapfile as additional swap."
100	/usr/sbin/vnconfig /dev/vn0b $swapfile && swapon /dev/vn0b
101fi
102
103# configure serial devices
104if [ -f /etc/rc.serial ]; then
105	. /etc/rc.serial
106fi
107
108# start up PC-card configuration
109if [ -f /etc/rc.pccard ]; then
110	. /etc/rc.pccard
111fi
112
113# start up the network
114if [ -f /etc/netstart ]; then
115	sh /etc/netstart
116fi
117
118mount -a -t nfs >/dev/null 2>&1
119
120# Whack the pty perms back into shape.
121chmod 666 /dev/tty[pqrsPQRS]*
122
123# clean up left-over files
124rm -f /etc/nologin
125rm -f /var/spool/lock/*
126rm -rf /var/spool/uucp/.Temp/*
127(cd /var/run && { cp /dev/null utmp; chmod 644 utmp; })
128
129#
130# Clearing /tmp at boot-time is essentially stupid, but seems to have
131# a long tradition.  It doesn't help in any way for long-living systems,
132# and it might accidentally clobber files you would rather like to have
133# preserved after a crash (if not using mfs /tmp anyway).
134#
135# See also the commented out example of another cleanup policy in
136# /etc/daily.
137#
138echo clearing /tmp
139
140# prune quickly with one rm, then use find to clean up /tmp/[lq]*
141# (not needed with mfs /tmp, but doesn't hurt there...)
142(cd /tmp && rm -rf [a-km-pr-zA-Z]* &&
143    find -d . ! -name . ! -name lost+found ! -name quotas -exec rm -rf -- {} \;)
144
145# The above is even more stupid since it prevents you from restarting
146# X11 after a system crash.  If you disable the above, make sure to
147# uncomment the line below.
148#
149# clean up leftover X lock files and local connection sockets
150#rm -f /tmp/.X*-lock /tmp/.X11-unix/*
151
152
153# enable dumpdev so that savecore can see it
154if [ "X${dumpdev}" != X"NO" ]; then
155	dumpon ${dumpdev}
156fi
157
158# /var/crash should be a directory or a symbolic link
159# to the crash directory if core dumps are to be saved.
160if [ -d /var/crash ]; then
161	echo -n checking for core dump...
162	savecore /var/crash
163fi
164
165# snapshot any kernel -c changes back to disk
166echo 'recording kernel -c changes'
167/sbin/dset -q
168
169# start system logging and name service (named needs to start before syslogd
170# if you don't have a /etc/resolv.conf)
171#
172echo -n starting system daemons:
173
174# If syslogdflags == NO, syslog isn't run
175if [ "X${syslogdflags}" != X"NO" ] ; then
176
177	# Transitional symlink (for the next couple of years :) until all
178	# binaries had a chance to move towards /var/run/log.
179	if [ ! -h /dev/log ] ; then
180		# might complain for r/o root f/s
181		ln -sf /var/run/log /dev/log
182	fi
183
184	rm -f /var/run/log
185	echo ' syslogd.';		syslogd ${syslogdflags}
186fi
187
188echo -n starting early network daemons:
189
190# $namedflags is imported from /etc/sysconfig
191if [ "X${namedflags}" != X"NO" ]; then
192	echo -n ' named';		named $namedflags
193fi
194
195# $ntpdate and $xntpdflags are imported from /etc/sysconfig.
196# If $ntpdate != NO, run ntpdate $ntpdate to set the date correctly.
197# If $xntpdflags != NO, start xntpd.
198if [ "X${ntpdate}" != X"NO" -o "X${xntpdflags}" != X"NO" ]; then
199	if [ "X${tickadjflags}" != X"NO" ]; then
200		echo -n ' tickadj';	tickadj ${tickadjflags--Aq}
201	fi
202
203	if [ "X${ntpdate}" != X"NO" ]; then
204		echo -n ' ntpdate';	ntpdate ${ntpdate} >/dev/null 2>&1
205	fi
206
207	if [ "X${xntpdflags}" != X"NO" ]; then
208		echo -n ' xntpd';	xntpd ${xntpdflags}
209	fi
210fi
211
212# $timedflags is imported from /etc/sysconfig;
213# if $timedflags == NO, timed isn't run.
214if [ "X${timedflags}" != X"NO" ]; then
215	echo -n ' timed';		timed ${timedflags}
216fi
217
218# Portmapper should always be run, to provide RPC services for inetd.
219# if $portmapflags == NO, portmap isn't run.
220if [ -x /usr/sbin/portmap -a "X${portmapflags}" != X"NO" ]; then
221	echo -n ' portmap';		portmap ${portmapflags}
222fi
223
224# Start ypserv if we're an NIS server.
225# Run rpc.ypxfrd and rpc.yppasswdd only on the NIS master server.
226if [ "X${nis_serverflags}" != X"NO" ]; then
227	echo -n ' ypserv'; ypserv ${nis_serverflags}
228
229	if [ "X${ypxfrdflags}" != X"NO" ]; then
230		echo -n ' rpc.ypxfrd'; rpc.ypxfrd ${ypxfrdflags}
231	fi
232
233	if [ "X${yppasswddflags}" != X"NO" ]; then
234		echo -n ' rpc.yppasswdd'; rpc.yppasswdd ${yppasswddflags}
235	fi
236fi
237
238# Start ypbind if we're an NIS client
239if [ "X${nis_clientflags}" != X"NO" ]; then
240	echo -n ' ypbind'; ypbind ${nis_clientflags}
241	if [ "X${nis_ypsetflags}" != X"NO" ]; then
242		echo -n ' ypset'; ypset ${nis_ypsetflags}
243	fi
244fi
245
246echo '.'
247
248# Check the quotas (must be after ypbind if using NIS)
249if [ "X${check_quotas}" = X"YES" ]; then
250	echo -n 'checking quotas:'
251	quotacheck -a
252	echo ' done.'
253	quotaon -a
254fi
255
256echo -n starting other network daemons:
257
258if [ "X${nfs_server}" = X"YES" -a -r /etc/exports ]; then
259	echo -n ' mountd'
260	if [ "X${weak_mountd_authentication}" = X"YES" ]; then
261		mountd -n
262	else
263		mountd
264	fi
265	echo -n ' nfsd';		nfsd -u -t 4
266# Warning: rpc.lockd is broken.
267# Only uncomment this line if the consequences are fully understood.
268#	echo -n ' rpc.lockd';		rpc.lockd
269	echo -n ' rpc.statd';		rpc.statd
270fi
271
272if [ "X${nfs_client}" = X"YES" ]; then
273	echo -n ' nfsiod';		nfsiod -n 4
274fi
275
276if [ "X${amdflags}" != X"NO" ]; then
277	echo -n ' amd'
278	amd -p ${amdflags} > /var/run/amd.pid
279fi
280
281# $rwhod is imported from /etc/sysconfig;
282# if $rwhod is set to YES, rwhod is run.
283if [ "X${rwhod}" = X"YES" ]; then
284	echo -n ' rwhod';	rwhod
285fi
286
287# Kerberos runs ONLY on the Kerberos server machine
288if [ "X${kerberos_server}" = X"YES" ]; then
289	echo -n ' kerberos';	kerberos >> /var/log/kerberos.log &
290	echo -n ' kadmind'; \
291		(sleep 20; kadmind -n >/dev/null 2>&1 &) &
292fi
293
294# IP multicast routing daemon
295if [ "X${mrouted}" != X"NO" -a -x /usr/sbin/mrouted ]; then
296	echo -n ' mrouted'; mrouted ${mrouted}
297fi
298
299echo '.'
300
301# build ps databases
302kvm_mkdb 
303dev_mkdb
304
305# check the password temp/lock file
306if [ -f /etc/ptmp ]
307then
308	logger -s -p auth.err \
309	"password file may be incorrect -- /etc/ptmp exists"
310fi
311
312if [ "X${accounting}" = X"YES" -a -d /var/account ]; then
313	echo 'turning on accounting'
314	if [ ! -e /var/account/acct ]; then
315		touch /var/account/acct && chmod 600 /var/account/acct
316	fi
317	accton /var/account/acct
318fi
319
320# Make shared lib searching a little faster.  Leave /usr/lib first if you
321# add your own entries or you may come to grief.
322if [ -x /sbin/ldconfig ]; then
323	_LDC=/usr/lib
324	if [ -d /usr/lib/compat ]; then _LDC="${_LDC} /usr/lib/compat" ; fi
325	if [ -d /usr/X11R6/lib ]; then _LDC="${_LDC} /usr/X11R6/lib" ; fi
326	if [ -d /usr/X386/lib ]; then _LDC="${_LDC} /usr/X386/lib" ; fi
327	if [ -d /usr/local/lib ]; then _LDC="${_LDC} /usr/local/lib" ; fi
328	echo 'setting ldconfig path:' ${_LDC}
329	ldconfig ${_LDC}
330fi
331
332# Now start up miscellaneous daemons that don't belong anywhere else
333#
334echo -n standard daemons:
335echo -n ' inetd';		inetd
336echo -n ' cron';		cron
337
338if [ "X${lpd}" != X"NO" -a -x /usr/sbin/lpd ]; then
339	echo -n ' printer';		lpd
340fi
341
342# $sendmail_flags is imported from /etc/sysconfig;
343# if $sendmail_flags is something other than NO, sendmail is run.
344if [ "X${sendmail_flags}" != X"NO" -a -r /etc/sendmail.cf ]; then
345	echo -n ' sendmail';            /usr/sbin/sendmail ${sendmail_flags}
346fi
347
348echo '.'
349
350# configure implementation specific stuff
351arch=`uname -m`
352if [ -f /etc/rc.${arch} ]; then
353	. /etc/rc.${arch}
354fi
355
356# Recover vi editor files.
357vibackup=`echo /var/tmp/vi.recover/vi.*`
358if [ "$vibackup" != '/var/tmp/vi.recover/vi.*' ]; then
359	echo 'Recovering vi editor sessions'
360	for i in $vibackup; do
361		# Only test files that are readable.
362		if test ! -r $i; then
363			continue
364		fi
365
366		# Unmodified nvi editor backup files either have the
367		# execute bit set or are zero length.  Delete them.
368		if test -x $i -o ! -s $i; then
369			rm -f $i
370		fi
371	done
372
373	# It is possible to get incomplete recovery files, if the editor
374	# crashes at the right time.
375	virecovery=`echo /var/tmp/vi.recover/recover.*`
376	if [ "$virecovery" != "/var/tmp/vi.recover/recover.*" ]; then
377		for i in $virecovery; do
378			# Only test files that are readable.
379			if test ! -r $i; then
380				continue
381			fi
382
383			# Delete any recovery files that are zero length,
384			# corrupted, or that have no corresponding backup file.
385			# Else send mail to the user.
386			recfile=`awk '/^X-vi-recover-path:/{print $2}' < $i`
387			if test -n "$recfile" -a -s "$recfile"; then
388				sendmail -t < $i
389			else
390				rm -f $i
391			fi
392		done
393	fi
394fi
395
396# for each valid dir in $local_startup, search for init scripts matching *.sh
397if [ "X${local_startup}" != X"NO" ]; then
398	echo -n 'Local package startup:'
399	for dir in ${local_startup}; do
400		[ -d ${dir} ] && for script in ${dir}/*.sh; do
401			[ -x ${script} ] && ${script} start
402		done
403	done
404	echo .
405fi
406
407# Do traditional (but rather obsolete) rc.local file if it exists.
408[ -f /etc/rc.local ] && sh /etc/rc.local
409
410date
411exit 0
412