rc revision 24759
1#!/bin/sh
2#	$Id: rc,v 1.115 1997/04/01 01:00:34 pst 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	if [ "X${nfs_reserved_port_only}" = X"YES" ]; then
266		sysctl -w vfs.nfs.nfs_privport=1
267	fi
268	echo -n ' nfsd';		nfsd -u -t 4
269# Warning: rpc.lockd is broken.
270# Only uncomment this line if the consequences are fully understood.
271#	echo -n ' rpc.lockd';		rpc.lockd
272	echo -n ' rpc.statd';		rpc.statd
273fi
274
275if [ "X${nfs_client}" = X"YES" ]; then
276	echo -n ' nfsiod';		nfsiod -n 4
277fi
278
279if [ "X${amdflags}" != X"NO" ]; then
280	echo -n ' amd'
281	amd -p ${amdflags} > /var/run/amd.pid
282fi
283
284# $rwhod is imported from /etc/sysconfig;
285# if $rwhod is set to YES, rwhod is run.
286if [ "X${rwhod}" = X"YES" ]; then
287	echo -n ' rwhod';	rwhod
288fi
289
290# Kerberos runs ONLY on the Kerberos server machine
291if [ "X${kerberos_server}" = X"YES" ]; then
292	echo -n ' kerberos';	kerberos >> /var/log/kerberos.log &
293	echo -n ' kadmind'; \
294		(sleep 20; kadmind -n >/dev/null 2>&1 &) &
295fi
296
297# IP multicast routing daemon
298if [ "X${mrouted}" != X"NO" -a -x /usr/sbin/mrouted ]; then
299	echo -n ' mrouted'; mrouted ${mrouted}
300fi
301
302echo '.'
303
304# build ps databases
305kvm_mkdb 
306dev_mkdb
307
308# check the password temp/lock file
309if [ -f /etc/ptmp ]
310then
311	logger -s -p auth.err \
312	"password file may be incorrect -- /etc/ptmp exists"
313fi
314
315if [ "X${accounting}" = X"YES" -a -d /var/account ]; then
316	echo 'turning on accounting'
317	if [ ! -e /var/account/acct ]; then
318		touch /var/account/acct && chmod 600 /var/account/acct
319	fi
320	accton /var/account/acct
321fi
322
323# Make shared lib searching a little faster.  Leave /usr/lib first if you
324# add your own entries or you may come to grief.
325if [ -x /sbin/ldconfig ]; then
326	_LDC=/usr/lib
327	if [ -d /usr/lib/compat ]; then _LDC="${_LDC} /usr/lib/compat" ; fi
328	if [ -d /usr/X11R6/lib ]; then _LDC="${_LDC} /usr/X11R6/lib" ; fi
329	if [ -d /usr/X386/lib ]; then _LDC="${_LDC} /usr/X386/lib" ; fi
330	if [ -d /usr/local/lib ]; then _LDC="${_LDC} /usr/local/lib" ; fi
331	echo 'setting ldconfig path:' ${_LDC}
332	ldconfig ${_LDC}
333fi
334
335# Now start up miscellaneous daemons that don't belong anywhere else
336#
337echo -n standard daemons:
338echo -n ' inetd';		inetd
339echo -n ' cron';		cron
340
341if [ "X${lpd}" != X"NO" -a -x /usr/sbin/lpd ]; then
342	echo -n ' printer';		lpd
343fi
344
345# $sendmail_flags is imported from /etc/sysconfig;
346# if $sendmail_flags is something other than NO, sendmail is run.
347if [ "X${sendmail_flags}" != X"NO" -a -r /etc/sendmail.cf ]; then
348	echo -n ' sendmail';            /usr/sbin/sendmail ${sendmail_flags}
349fi
350
351echo '.'
352
353# configure implementation specific stuff
354arch=`uname -m`
355if [ -f /etc/rc.${arch} ]; then
356	. /etc/rc.${arch}
357fi
358
359# Recover vi editor files.
360vibackup=`echo /var/tmp/vi.recover/vi.*`
361if [ "$vibackup" != '/var/tmp/vi.recover/vi.*' ]; then
362	echo 'Recovering vi editor sessions'
363	for i in $vibackup; do
364		# Only test files that are readable.
365		if test ! -r $i; then
366			continue
367		fi
368
369		# Unmodified nvi editor backup files either have the
370		# execute bit set or are zero length.  Delete them.
371		if test -x $i -o ! -s $i; then
372			rm -f $i
373		fi
374	done
375
376	# It is possible to get incomplete recovery files, if the editor
377	# crashes at the right time.
378	virecovery=`echo /var/tmp/vi.recover/recover.*`
379	if [ "$virecovery" != "/var/tmp/vi.recover/recover.*" ]; then
380		for i in $virecovery; do
381			# Only test files that are readable.
382			if test ! -r $i; then
383				continue
384			fi
385
386			# Delete any recovery files that are zero length,
387			# corrupted, or that have no corresponding backup file.
388			# Else send mail to the user.
389			recfile=`awk '/^X-vi-recover-path:/{print $2}' < $i`
390			if test -n "$recfile" -a -s "$recfile"; then
391				sendmail -t < $i
392			else
393				rm -f $i
394			fi
395		done
396	fi
397fi
398
399# for each valid dir in $local_startup, search for init scripts matching *.sh
400if [ "X${local_startup}" != X"NO" ]; then
401	echo -n 'Local package startup:'
402	for dir in ${local_startup}; do
403		[ -d ${dir} ] && for script in ${dir}/*.sh; do
404			[ -x ${script} ] && ${script} start
405		done
406	done
407	echo .
408fi
409
410# Do traditional (but rather obsolete) rc.local file if it exists.
411[ -f /etc/rc.local ] && sh /etc/rc.local
412
413date
414exit 0
415