rc revision 12002
1#!/bin/sh
2#	$Id: rc,v 1.76 1995/11/01 00:22:45 ache 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 the network
98if [ -f /etc/netstart ]; then
99	sh /etc/netstart
100fi
101
102mount -a -t nfs >/dev/null 2>&1
103
104# Whack the pty perms back into shape.
105chmod 666 /dev/tty[pqrs]*
106
107# clean up left-over files
108rm -f /etc/nologin
109rm -f /var/spool/lock/*
110rm -rf /var/spool/uucp/.Temp/*
111rm -f /dev/log
112(cd /var/run && { rm -rf -- *; cp /dev/null utmp; chmod 644 utmp; })
113
114echo clearing /tmp
115
116# prune quickly with one rm, then use find to clean up /tmp/[lq]*
117# (not needed with mfs /tmp, but doesn't hurt there...)
118(cd /tmp && rm -rf [a-km-pr-zA-Z]* &&
119    find -d . ! -name . ! -name lost+found ! -name quotas -exec rm -rf -- {} \;)
120
121# enable dumpdev so that savecore can see it
122if [ "X${dumpdev}" != X"NO" ]; then
123	dumpon ${dumpdev}
124fi
125
126# /var/crash should be a directory or a symbolic link
127# to the crash directory if core dumps are to be saved.
128if [ "X${savecore}" = X"YES" -a -d /var/crash ]; then
129	echo -n checking for core dump...
130	savecore /var/crash
131fi
132
133# snapshot any kernel -c changes back to disk
134echo 'recording kernel -c changes'
135/sbin/dset -q
136
137# Check the quotas
138if [ "X${check_quotas}" = X"YES" ]; then
139	echo 'checking quotas:'
140	quotacheck -a
141	echo ' done.'
142	quotaon -a
143fi
144
145# start system logging and name service (named needs to start before syslogd
146# if you don't have a /etc/resolv.conf)
147#
148echo -n starting system daemons:
149
150echo ' syslogd.';			syslogd
151
152echo -n starting network daemons:
153
154# $namedflags is imported from /etc/sysconfig
155if [ "X${namedflags}" != "XNO" ]; then
156	echo -n ' named';		named $namedflags
157fi
158
159# $ntpdate and $xntpdflags are imported from /etc/sysconfig.
160# If $ntpdate != NO, run ntpdate $ntpdate to set the date correctly.
161# If $xntpdflags != NO, start xntpd.
162if [ "X${ntpdate}" != X"NO" -o "X${xntpdflags}" != X"NO" ]; then
163	if [ "X${tickadjflags}" != X"NO" ]; then
164		echo -n ' tickadj';	tickadj ${tickadjflags--Aq}
165	fi
166
167	if [ "X${ntpdate}" != X"NO" ]; then
168		echo -n ' ntpdate';	ntpdate ${ntpdate} >/dev/null 2>&1
169	fi
170
171	if [ "X${xntpdflags}" != X"NO" ]; then
172		echo -n ' xntpd';	xntpd ${xntpdflags}
173	fi
174fi
175
176# $timedflags is imported from /etc/sysconfig;
177# if $timedflags == NO, timed isn't run.
178if [ "X${timedflags}" != X"NO" ]; then
179	echo -n ' timed'; timed $timedflags
180fi
181
182# Portmapper should always be run, to provide RPC services for inetd.
183if [ -x /usr/sbin/portmap ]; then
184	echo -n ' portmap';		portmap
185fi
186
187# Start ypserv if we're an NIS server.
188# Run yppasswdd only on the NIS master server
189if [ "X${nis_serverflags}" != X"NO" ]; then
190	echo -n ' ypserv'; ypserv ${nis_serverflags}
191
192	if [ "X${yppasswddflags}" != X"NO" ]; then
193		echo -n ' yppasswdd'; yppasswdd ${yppasswddflags}
194	fi
195fi
196
197# Start ypbind if we're an NIS client
198if [ "X${nis_clientflags}" != X"NO" ]; then
199	echo -n ' ypbind'; ypbind ${nis_clientflags}
200	if [ "X${nis_ypsetflags}" != X"NO" ]; then
201		echo -n ' ypset'; ypset ${nis_ypsetflags}
202	fi
203fi
204
205# $rwhod is imported from /etc/sysconfig;
206# if $rwhod is set to YES, rwhod is run.
207if [ "X${rwhod}" = X"YES" ]; then
208	echo -n ' rwhod';	rwhod
209fi
210
211if [ "X${nfs_server}" = X"YES" -a -r /etc/exports ]; then
212	echo -n ' mountd'
213	if [ "X${pcnfsd}" = X"YES" ]; then
214		mountd -n
215	else
216		mountd
217	fi
218	echo -n ' nfsd';		nfsd -u -t 4
219fi
220
221if [ "X${nfs_client}" = X"YES" ]; then
222	echo -n ' nfsiod';		nfsiod -n 4
223fi
224
225if [ "X${amdflags}" != X"NO" ]; then
226	echo -n ' amd';			amd ${amdflags}
227fi
228
229# Kerberos runs ONLY on the Kerberos server machine
230if [ "X${kerberos_server}" = X"YES" ]; then
231	echo -n ' kerberos';	kerberos >> /var/log/kerberos.log &
232	echo -n ' kadmind'; \
233		(sleep 20; /usr/sbin/kadmind -n >/dev/null 2>&1 &) &
234fi
235
236echo -n ' inetd';		inetd
237echo '.'
238
239# build ps databases
240kvm_mkdb 
241dev_mkdb
242
243# check the password temp/lock file
244if [ -f /etc/ptmp ]
245then
246	logger -s -p auth.err \
247	"password file may be incorrect -- /etc/ptmp exists"
248fi
249
250# Recover vi editor files.
251virecovery=`echo /var/tmp/vi.recover/recover.*`
252if [ "$virecovery" != '/var/tmp/vi.recover/recover.*' ]; then
253	echo 'Recovering vi editor sessions'
254	for i in $virecovery; do
255		sendmail -t < $i
256	done
257fi
258
259if [ "X${accounting}" = X"YES" -a -d /var/account ]; then
260	echo 'turning on accounting'
261	if [ ! -e /var/account/acct ]; then
262		touch /var/account/acct
263	fi
264	accton /var/account/acct
265fi
266
267# Now start up miscellaneous daemons that don't belong anywhere else
268#
269echo -n standard daemons:
270echo -n ' cron';		cron
271echo -n ' printer';		lpd
272
273# $sendmail_flags is imported from /etc/sysconfig;
274# if $sendmail_flags is something other than NO, sendmail is run.
275if [ "X${sendmail_flags}" != X"NO" -a -r /etc/sendmail.cf ]; then
276	echo -n ' sendmail';		sendmail ${sendmail_flags} 
277fi
278
279echo '.'
280
281# Make shared lib searching a little faster.  Leave /usr/lib first if you
282# add your own entries or you may come to grief.
283if [ -x /sbin/ldconfig ]; then
284	_LDC=/usr/lib
285	if [ -d /usr/X11R6/lib ]; then _LDC="${_LDC} /usr/X11R6/lib" ; fi
286	if [ -d /usr/X386/lib ]; then _LDC="${_LDC} /usr/X386/lib" ; fi
287	if [ -d /usr/local/lib ]; then _LDC="${_LDC} /usr/local/lib" ; fi
288	echo 'setting ldconfig path:' ${_LDC}
289	ldconfig ${_LDC}
290fi
291
292# configure implementation specific stuff
293arch=`uname -m`
294if [ -f /etc/rc.${arch} ]; then
295	. /etc/rc.${arch}
296fi
297
298if [ "X${local_startup}" != X"NO" -a -d ${local_startup} ]; then
299	for script in ${local_startup}/*.sh; do
300		[ -x ${script} ] && ${script} start
301	done
302fi
303
304# Do traditional (but rather obsolete) rc.local file if it exists.
305[ -f /etc/rc.local ] && sh /etc/rc.local
306
307date
308exit 0
309