rc revision 14596
1#!/bin/sh
2#	$Id: rc,v 1.85 1996/02/23 10:44:49 adam 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
25swapon -a
26
27if [ $1x = autobootx ]
28then
29	echo Automatic reboot in progress...
30	fsck -p
31	case $? in
32	0)
33		;;
34	2)
35		exit 1
36		;;
37	4)
38		reboot
39		echo "reboot failed... help!"
40		exit 1
41		;;
42	8)
43		echo "Automatic file system check failed... help!"
44		exit 1
45		;;
46	12)
47		echo "Reboot interrupted"
48		exit 1
49		;;
50	130)
51		# interrupt before catcher installed
52		exit 1
53		;;
54	*)
55		echo "Unknown error in reboot"
56		exit 1
57		;;
58	esac
59else
60	echo Skipping disk checks ...
61fi
62
63trap "echo 'Reboot interrupted'; exit 1" 3
64
65# root must be read/write both for NFS diskless and for VFS LKMs before
66# proceeding any further.
67mount -u -o rw /
68if [ $? != 0 ]; then
69	echo "Filesystem mount failed, startup aborted"
70	exit 1
71fi
72
73umount -a >/dev/null 2>&1
74
75mount -a -t nonfs
76if [ $? != 0 ]; then
77	echo "Filesystem mount failed, startup aborted"
78	exit 1
79fi
80
81# If the machine runs wall CMOS clock (compatible with MSDOS),
82# activate following line by creating empty file /etc/wall_cmos_clock
83# If this file not exist, following line does nothing (assumed
84# the machine runs UTC CMOS clock). See adjkerntz(8) for details.
85adjkerntz -i
86
87# If there is a global system configuration file, suck it in.
88if [ -f /etc/sysconfig ]; then
89	. /etc/sysconfig
90fi
91
92# configure serial devices
93if [ -f /etc/rc.serial ]; then
94	. /etc/rc.serial
95fi
96
97# start up PC-card configuration
98if [ -f /etc/pccardstart ]; then
99	. /etc/pccardstart
100fi
101
102# start up the network
103if [ -f /etc/netstart ]; then
104	sh /etc/netstart
105fi
106
107mount -a -t nfs >/dev/null 2>&1
108
109# Whack the pty perms back into shape.
110chmod 666 /dev/tty[pqrs]*
111
112# clean up left-over files
113rm -f /etc/nologin
114rm -f /var/spool/lock/*
115rm -rf /var/spool/uucp/.Temp/*
116rm -f /dev/log
117(cd /var/run && { rm -rf -- *; cp /dev/null utmp; chmod 644 utmp; })
118
119echo clearing /tmp
120
121# prune quickly with one rm, then use find to clean up /tmp/[lq]*
122# (not needed with mfs /tmp, but doesn't hurt there...)
123(cd /tmp && rm -rf [a-km-pr-zA-Z]* &&
124    find -d . ! -name . ! -name lost+found ! -name quotas -exec rm -rf -- {} \;)
125
126# enable dumpdev so that savecore can see it
127if [ "X${dumpdev}" != X"NO" ]; then
128	dumpon ${dumpdev}
129fi
130
131# /var/crash should be a directory or a symbolic link
132# to the crash directory if core dumps are to be saved.
133if [ "X${savecore}" = X"YES" -a -d /var/crash ]; then
134	echo -n checking for core dump...
135	savecore /var/crash
136fi
137
138# snapshot any kernel -c changes back to disk
139echo 'recording kernel -c changes'
140/sbin/dset -q
141
142# Check the quotas
143if [ "X${check_quotas}" = X"YES" ]; then
144	echo 'checking quotas:'
145	quotacheck -a
146	echo ' done.'
147	quotaon -a
148fi
149
150# start system logging and name service (named needs to start before syslogd
151# if you don't have a /etc/resolv.conf)
152#
153echo -n starting system daemons:
154
155echo ' syslogd.';			syslogd
156
157echo -n starting network daemons:
158
159# $namedflags is imported from /etc/sysconfig
160if [ "X${namedflags}" != "XNO" ]; then
161	echo -n ' named';		named $namedflags
162fi
163
164# $ntpdate and $xntpdflags are imported from /etc/sysconfig.
165# If $ntpdate != NO, run ntpdate $ntpdate to set the date correctly.
166# If $xntpdflags != NO, start xntpd.
167if [ "X${ntpdate}" != X"NO" -o "X${xntpdflags}" != X"NO" ]; then
168	if [ "X${tickadjflags}" != X"NO" ]; then
169		echo -n ' tickadj';	tickadj ${tickadjflags--Aq}
170	fi
171
172	if [ "X${ntpdate}" != X"NO" ]; then
173		echo -n ' ntpdate';	ntpdate ${ntpdate} >/dev/null 2>&1
174	fi
175
176	if [ "X${xntpdflags}" != X"NO" ]; then
177		echo -n ' xntpd';	xntpd ${xntpdflags}
178	fi
179fi
180
181# $timedflags is imported from /etc/sysconfig;
182# if $timedflags == NO, timed isn't run.
183if [ "X${timedflags}" != X"NO" ]; then
184	echo -n ' timed'; timed $timedflags
185fi
186
187# Portmapper should always be run, to provide RPC services for inetd.
188if [ -x /usr/sbin/portmap ]; then
189	echo -n ' portmap';		portmap
190fi
191
192# Start ypserv if we're an NIS server.
193# Run yppasswdd only on the NIS master server
194if [ "X${nis_serverflags}" != X"NO" ]; then
195	echo -n ' ypserv'; ypserv ${nis_serverflags}
196
197	if [ "X${yppasswddflags}" != X"NO" ]; then
198		echo -n ' yppasswdd'; rpc.yppasswdd ${yppasswddflags}
199	fi
200fi
201
202# Start ypbind if we're an NIS client
203if [ "X${nis_clientflags}" != X"NO" ]; then
204	echo -n ' ypbind'; ypbind ${nis_clientflags}
205	if [ "X${nis_ypsetflags}" != X"NO" ]; then
206		echo -n ' ypset'; ypset ${nis_ypsetflags}
207	fi
208fi
209
210# $rwhod is imported from /etc/sysconfig;
211# if $rwhod is set to YES, rwhod is run.
212if [ "X${rwhod}" = X"YES" ]; then
213	echo -n ' rwhod';	rwhod
214fi
215
216if [ "X${nfs_server}" = X"YES" -a -r /etc/exports ]; then
217	echo -n ' mountd'
218	if [ "X${weak_mountd_authentication}" = X"YES" ]; then
219		mountd -n
220	else
221		mountd
222	fi
223	echo -n ' nfsd';		nfsd -u -t 4
224fi
225
226if [ "X${nfs_client}" = X"YES" ]; then
227	echo -n ' nfsiod';		nfsiod -n 4
228fi
229
230if [ "X${amdflags}" != X"NO" ]; then
231	echo -n ' amd'
232	amd ${amdflags} > /var/run/amd.pid
233fi
234
235# Kerberos runs ONLY on the Kerberos server machine
236if [ "X${kerberos_server}" = X"YES" ]; then
237	echo -n ' kerberos';	kerberos >> /var/log/kerberos.log &
238	echo -n ' kadmind'; \
239		(sleep 20; kadmind -n >/dev/null 2>&1 &) &
240fi
241
242# IP multicast routing daemon
243if [ "X${mrouted}" != X"NO" -a -x /usr/sbin/mrouted ]; then
244	echo -n ' mrouted'; mrouted ${mrouted}
245fi
246
247echo -n ' inetd';		inetd
248echo '.'
249
250# build ps databases
251kvm_mkdb 
252dev_mkdb
253
254# check the password temp/lock file
255if [ -f /etc/ptmp ]
256then
257	logger -s -p auth.err \
258	"password file may be incorrect -- /etc/ptmp exists"
259fi
260
261# Recover vi editor files.
262virecovery=`echo /var/tmp/vi.recover/recover.*`
263if [ "$virecovery" != '/var/tmp/vi.recover/recover.*' ]; then
264	echo 'Recovering vi editor sessions'
265	for i in $virecovery; do
266		sendmail -t < $i
267	done
268fi
269
270if [ "X${accounting}" = X"YES" -a -d /var/account ]; then
271	echo 'turning on accounting'
272	if [ ! -e /var/account/acct ]; then
273		touch /var/account/acct
274	fi
275	accton /var/account/acct
276fi
277
278# Now start up miscellaneous daemons that don't belong anywhere else
279#
280echo -n standard daemons:
281echo -n ' cron';		cron
282
283if [ "X${lpd}" != X"NO" -a -x /usr/sbin/lpd ]; then
284	echo -n ' printer';		lpd
285fi
286
287# $sendmail_flags is imported from /etc/sysconfig;
288# if $sendmail_flags is something other than NO, sendmail is run.
289if [ "X${sendmail_flags}" != X"NO" -a -r /etc/sendmail.cf ]; then
290	echo -n ' sendmail';            /usr/sbin/sendmail ${sendmail_flags}
291fi
292
293echo '.'
294
295# Make shared lib searching a little faster.  Leave /usr/lib first if you
296# add your own entries or you may come to grief.
297if [ -x /sbin/ldconfig ]; then
298	_LDC=/usr/lib
299	if [ -d /usr/X11R6/lib ]; then _LDC="${_LDC} /usr/X11R6/lib" ; fi
300	if [ -d /usr/X386/lib ]; then _LDC="${_LDC} /usr/X386/lib" ; fi
301	if [ -d /usr/local/lib ]; then _LDC="${_LDC} /usr/local/lib" ; fi
302	echo 'setting ldconfig path:' ${_LDC}
303	ldconfig ${_LDC}
304fi
305
306# configure implementation specific stuff
307arch=`uname -m`
308if [ -f /etc/rc.${arch} ]; then
309	. /etc/rc.${arch}
310fi
311
312# for each valid dir in $local_startup, search for init scripts matching *.sh
313if [ "X${local_startup}" != X"NO" ]; then
314	for dir in ${local_startup}; do
315		[ -d ${dir} ] && for script in ${dir}/*.sh; do
316			[ -x ${script} ] && ${script} start
317		done
318	done
319fi
320
321# Do traditional (but rather obsolete) rc.local file if it exists.
322[ -f /etc/rc.local ] && sh /etc/rc.local
323
324date
325exit 0
326