rc revision 19226
1#!/bin/sh
2#	$Id: rc,v 1.102 1996/10/21 20:09:30 wpaul 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
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# If there is a global system configuration file, suck it in.
90if [ -f /etc/sysconfig ]; then
91	. /etc/sysconfig
92fi
93
94# Add additional swapfile, if configured.
95if [ "x$swapfile" != "xNO" -a -w "$swapfile" -a -f /dev/vn0b ]; then
96	echo "Adding $swapfile as additional swap."
97	/usr/sbin/vnconfig /dev/vn0b $swapfile && swapon /dev/vn0b
98fi
99
100# configure serial devices
101if [ -f /etc/rc.serial ]; then
102	. /etc/rc.serial
103fi
104
105# start up PC-card configuration
106if [ -f /etc/rc.pccard ]; then
107	. /etc/rc.pccard
108fi
109
110# start up the network
111if [ -f /etc/netstart ]; then
112	sh /etc/netstart
113fi
114
115mount -a -t nfs >/dev/null 2>&1
116
117# Whack the pty perms back into shape.
118chmod 666 /dev/tty[pqrs]*
119
120# clean up left-over files
121rm -f /etc/nologin
122rm -f /var/spool/lock/*
123rm -rf /var/spool/uucp/.Temp/*
124(cd /var/run && { cp /dev/null utmp; chmod 644 utmp; })
125
126#
127# Clearing /tmp at boot-time is essentially stupid, but seems to have
128# a long tradition.  It doesn't help in any way for long-living systems,
129# and it might accidentally clobber files you would rather like to have
130# preserved after a crash (if not using mfs /tmp anyway).
131#
132# See also the commented out example of another cleanup policy in
133# /etc/daily.
134#
135echo clearing /tmp
136
137# prune quickly with one rm, then use find to clean up /tmp/[lq]*
138# (not needed with mfs /tmp, but doesn't hurt there...)
139(cd /tmp && rm -rf [a-km-pr-zA-Z]* &&
140    find -d . ! -name . ! -name lost+found ! -name quotas -exec rm -rf -- {} \;)
141
142# The above is even more stupid since it prevents you from restarting
143# X11 after a system crash.  If you disable the above, make sure to
144# uncomment the line below.
145#
146# clean up leftover X lock files and local connection sockets
147#rm -f /tmp/.X*-lock /tmp/.X11-unix/*
148
149
150# enable dumpdev so that savecore can see it
151if [ "X${dumpdev}" != X"NO" ]; then
152	dumpon ${dumpdev}
153fi
154
155# /var/crash should be a directory or a symbolic link
156# to the crash directory if core dumps are to be saved.
157if [ "X${savecore}" = X"YES" -a -d /var/crash ]; then
158	echo -n checking for core dump...
159	savecore /var/crash
160fi
161
162# snapshot any kernel -c changes back to disk
163echo 'recording kernel -c changes'
164/sbin/dset -q
165
166# start system logging and name service (named needs to start before syslogd
167# if you don't have a /etc/resolv.conf)
168#
169echo -n starting system daemons:
170
171# Transitional symlink (for the next couple of years :) until all
172# binaries had a chance to move towards /var/run/log.
173if [ ! -h /dev/log ] ; then
174	# might complain for r/o root f/s
175	ln -sf /var/run/log /dev/log
176fi
177rm -f /var/run/log
178echo ' syslogd.';			syslogd
179
180echo -n starting early network daemons:
181
182# $namedflags is imported from /etc/sysconfig
183if [ "X${namedflags}" != X"NO" ]; then
184	echo -n ' named';		named $namedflags
185fi
186
187# $ntpdate and $xntpdflags are imported from /etc/sysconfig.
188# If $ntpdate != NO, run ntpdate $ntpdate to set the date correctly.
189# If $xntpdflags != NO, start xntpd.
190if [ "X${ntpdate}" != X"NO" -o "X${xntpdflags}" != X"NO" ]; then
191	if [ "X${tickadjflags}" != X"NO" ]; then
192		echo -n ' tickadj';	tickadj ${tickadjflags--Aq}
193	fi
194
195	if [ "X${ntpdate}" != X"NO" ]; then
196		echo -n ' ntpdate';	ntpdate ${ntpdate} >/dev/null 2>&1
197	fi
198
199	if [ "X${xntpdflags}" != X"NO" ]; then
200		echo -n ' xntpd';	xntpd ${xntpdflags}
201	fi
202fi
203
204# $timedflags is imported from /etc/sysconfig;
205# if $timedflags == NO, timed isn't run.
206if [ "X${timedflags}" != X"NO" ]; then
207	echo -n ' timed'; timed $timedflags
208fi
209
210# Portmapper should always be run, to provide RPC services for inetd.
211if [ -x /usr/sbin/portmap ]; then
212	echo -n ' portmap';		portmap
213fi
214
215# Start ypserv if we're an NIS server.
216# Run rpc.ypxfrd and rpc.yppasswdd only on the NIS master server.
217if [ "X${nis_serverflags}" != X"NO" ]; then
218	echo -n ' ypserv'; ypserv ${nis_serverflags}
219
220	if [ "X${ypxfrdflags}" != X"NO" ]; then
221		echo -n ' rpc.ypxfrd'; rpc.ypxfrd ${ypxfrdflags}
222	fi
223
224	if [ "X${yppasswddflags}" != X"NO" ]; then
225		echo -n ' rpc.yppasswdd'; rpc.yppasswdd ${yppasswddflags}
226	fi
227fi
228
229# Start ypbind if we're an NIS client
230if [ "X${nis_clientflags}" != X"NO" ]; then
231	echo -n ' ypbind'; ypbind ${nis_clientflags}
232	if [ "X${nis_ypsetflags}" != X"NO" ]; then
233		echo -n ' ypset'; ypset ${nis_ypsetflags}
234	fi
235fi
236
237echo '.'
238
239# Check the quotas (must be after ypbind if using NIS)
240if [ "X${check_quotas}" = X"YES" ]; then
241	echo -n 'checking quotas:'
242	quotacheck -a
243	echo ' done.'
244	quotaon -a
245fi
246
247echo -n starting other network daemons:
248
249if [ "X${nfs_server}" = X"YES" -a -r /etc/exports ]; then
250	echo -n ' mountd'
251	if [ "X${weak_mountd_authentication}" = X"YES" ]; then
252		mountd -n
253	else
254		mountd
255	fi
256	echo -n ' nfsd';		nfsd -u -t 4
257fi
258
259if [ "X${nfs_client}" = X"YES" ]; then
260	echo -n ' nfsiod';		nfsiod -n 4
261fi
262
263if [ "X${amdflags}" != X"NO" ]; then
264	echo -n ' amd'
265	amd -p ${amdflags} > /var/run/amd.pid
266fi
267
268# $rwhod is imported from /etc/sysconfig;
269# if $rwhod is set to YES, rwhod is run.
270if [ "X${rwhod}" = X"YES" ]; then
271	echo -n ' rwhod';	rwhod
272fi
273
274# Kerberos runs ONLY on the Kerberos server machine
275if [ "X${kerberos_server}" = X"YES" ]; then
276	echo -n ' kerberos';	kerberos >> /var/log/kerberos.log &
277	echo -n ' kadmind'; \
278		(sleep 20; kadmind -n >/dev/null 2>&1 &) &
279fi
280
281# IP multicast routing daemon
282if [ "X${mrouted}" != X"NO" -a -x /usr/sbin/mrouted ]; then
283	echo -n ' mrouted'; mrouted ${mrouted}
284fi
285
286echo '.'
287
288# build ps databases
289kvm_mkdb 
290dev_mkdb
291
292# check the password temp/lock file
293if [ -f /etc/ptmp ]
294then
295	logger -s -p auth.err \
296	"password file may be incorrect -- /etc/ptmp exists"
297fi
298
299if [ "X${accounting}" = X"YES" -a -d /var/account ]; then
300	echo 'turning on accounting'
301	if [ ! -e /var/account/acct ]; then
302		touch /var/account/acct
303	fi
304	accton /var/account/acct
305fi
306
307# Make shared lib searching a little faster.  Leave /usr/lib first if you
308# add your own entries or you may come to grief.
309if [ -x /sbin/ldconfig ]; then
310	_LDC=/usr/lib
311	if [ -d /usr/lib/compat ]; then _LDC="${_LDC} /usr/lib/compat" ; fi
312	if [ -d /usr/X11R6/lib ]; then _LDC="${_LDC} /usr/X11R6/lib" ; fi
313	if [ -d /usr/X386/lib ]; then _LDC="${_LDC} /usr/X386/lib" ; fi
314	if [ -d /usr/local/lib ]; then _LDC="${_LDC} /usr/local/lib" ; fi
315	echo 'setting ldconfig path:' ${_LDC}
316	ldconfig ${_LDC}
317fi
318
319# Now start up miscellaneous daemons that don't belong anywhere else
320#
321echo -n standard daemons:
322echo -n ' inetd';		inetd
323echo -n ' cron';		cron
324
325if [ "X${lpd}" != X"NO" -a -x /usr/sbin/lpd ]; then
326	echo -n ' printer';		lpd
327fi
328
329# $sendmail_flags is imported from /etc/sysconfig;
330# if $sendmail_flags is something other than NO, sendmail is run.
331if [ "X${sendmail_flags}" != X"NO" -a -r /etc/sendmail.cf ]; then
332	echo -n ' sendmail';            /usr/sbin/sendmail ${sendmail_flags}
333fi
334
335echo '.'
336
337# configure implementation specific stuff
338arch=`uname -m`
339if [ -f /etc/rc.${arch} ]; then
340	. /etc/rc.${arch}
341fi
342
343# Recover vi editor files.
344virecovery=`echo /var/tmp/vi.recover/recover.*`
345if [ "$virecovery" != '/var/tmp/vi.recover/recover.*' ]; then
346	echo 'Recovering vi editor sessions'
347	for i in $virecovery; do
348		sendmail -t < $i
349	done
350fi
351
352# for each valid dir in $local_startup, search for init scripts matching *.sh
353if [ "X${local_startup}" != X"NO" ]; then
354	echo -n 'Local package startup:'
355	for dir in ${local_startup}; do
356		[ -d ${dir} ] && for script in ${dir}/*.sh; do
357			[ -x ${script} ] && ${script} start
358		done
359	done
360	echo .
361fi
362
363# Do traditional (but rather obsolete) rc.local file if it exists.
364[ -f /etc/rc.local ] && sh /etc/rc.local
365
366date
367exit 0
368