rc revision 8530
1#!/bin/sh
2#	$Id: rc,v 1.64 1995/05/11 21:11:17 jkh 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 &	# XXX shouldn't need background
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# /var/crash should be a directory or a symbolic link
122# to the crash directory if core dumps are to be saved.
123if [ "X${savecore}" = X"YES" -a -d /var/crash ]; then
124	echo -n checking for core dump...
125	savecore /var/crash
126fi
127
128# snapshot any kernel -c changes back to disk
129echo 'recording kernel -c changes'
130/sbin/dset -q
131
132# Check the quotas
133if [ "X${check_quotas}" = X"YES" ]; then
134	echo 'checking quotas:'
135	quotacheck -a
136	echo ' done.'
137	quotaon -a
138fi
139
140# start system logging and name service (named needs to start before syslogd
141# if you don't have a /etc/resolv.conf)
142#
143echo -n starting system daemons:
144
145echo ' syslogd.';			syslogd
146
147echo -n starting network daemons:
148
149# $namedflags is imported from /etc/sysconfig
150if [ "X${namedflags}" != "XNO" ]; then
151	echo -n ' named';		named $namedflags
152fi
153
154# $ntpdate and $xntpdflags are imported from /etc/sysconfig.
155# If $ntpdate != NO, run ntpdate $ntpdate to set the date correctly.
156# If $xntpdflags != NO, start xntpd.
157if [ "X${ntpdate}" != X"NO" -o "X${xntpdflags}" != X"NO" ]; then
158	if [ "X${tickadjflags}" != X"NO" ]; then
159		echo -n ' tickadj';	tickadj ${tickadjflags--Aq}
160	fi
161
162	if [ "X${ntpdate}" != X"NO" ]; then
163		echo -n ' ntpdate';	ntpdate ${ntpdate} >/dev/null 2>&1
164	fi
165
166	if [ "X${xntpdflags}" != X"NO" ]; then
167		echo -n ' xntpd';	xntpd ${xntpdflags}
168	fi
169fi
170
171# $timedflags is imported from /etc/sysconfig;
172# if $timedflags == NO, timed isn't run.
173if [ "X${timedflags}" != X"NO" ]; then
174	echo -n ' timed'; timed $timedflags
175fi
176
177# Portmapper should always be run, to provide RPC services for inetd.
178if [ -x /usr/sbin/portmap ]; then
179	echo -n ' portmap';		portmap
180fi
181
182# Start ypserv if we're an NIS server.
183# Run yppasswdd only on the NIS master server
184if [ "X${nis_serverflags}" != X"NO" ]; then
185	echo -n ' ypserv'; ypserv ${nis_serverflags}
186
187	if [ "X${yppasswddflags}" != X"NO" ]; then
188		echo -n ' yppasswdd'; yppasswdd ${yppasswddflags}
189	fi
190fi
191
192# Start ypbind if we're an NIS client
193if [ "X${nis_clientflags}" != X"NO" ]; then
194	echo -n ' ypbind'; ypbind ${nis_clientflags}
195fi
196
197# $rwhod is imported from /etc/sysconfig;
198# if $rwhod is set to YES, rwhod is run.
199if [ "X${rwhod}" = X"YES" ]; then
200	echo -n ' rwhod';	rwhod
201fi
202
203if [ "X${nfs_server}" = X"YES" -a -r /etc/exports ]; then
204	echo -n ' mountd';		mountd
205	echo -n ' nfsd';		nfsd -u -t 4
206fi
207
208if [ "X${nfs_client}" = X"YES" ]; then
209	echo -n ' nfsiod';		nfsiod -n 4
210fi
211
212if [ "X${amdflags}" != X"NO" ]; then
213	echo -n ' amd';			amd ${amdflags}
214fi
215
216# Kerberos runs ONLY on the Kerberos server machine
217if [ "X${kerberos_server}" = X"YES" ]; then
218	echo -n ' kerberos';	kerberos >> /var/log/kerberos.log &
219	echo -n ' kadmind'; \
220		(sleep 20; /usr/sbin/kadmind -n >/dev/null 2>&1 &) &
221fi
222
223echo -n ' inetd';		inetd
224echo '.'
225
226# build ps databases
227kvm_mkdb 
228dev_mkdb
229
230# check the password temp/lock file
231if [ -f /etc/ptmp ]
232then
233	logger -s -p auth.err \
234	"password file may be incorrect -- /etc/ptmp exists"
235fi
236
237# Recover vi editor files.
238virecovery=/var/tmp/vi.recover/recover.*
239if [ "$virecovery" != "/var/tmp/vi.recover/recover.*" ]; then
240	echo 'Recovering vi editor sessions'
241	for i in $virecovery; do
242		sendmail -t < $i
243	done
244fi
245
246if [ "X${accounting}" = X"YES" -a -d /var/account ]; then
247	echo 'turning on accounting';	accton /var/account/acct
248fi
249
250# Now start up miscellaneous daemons that don't belong anywhere else
251#
252echo -n standard daemons:
253echo -n ' cron';		cron
254echo -n ' printer';		lpd
255
256# $sendmail_flags is imported from /etc/sysconfig;
257# if $sendmail_flags is something other than NO, sendmail is run.
258if [ "X${sendmail_flags}" != X"NO" -a -r /etc/sendmail.cf ]; then
259	echo -n ' sendmail';		sendmail ${sendmail_flags} 
260fi
261
262echo '.'
263
264# Make shared lib searching a little faster.  Leave /usr/lib first if you
265# add your own entries or you may come to grief.
266if [ -x /sbin/ldconfig ]; then
267	_LDC=/usr/lib
268	if [ -d /usr/X11R6/lib ]; then _LDC="${_LDC} /usr/X11R6/lib" ; fi
269	if [ -d /usr/X386/lib ]; then _LDC="${_LDC} /usr/X386/lib" ; fi
270	if [ -d /usr/local/lib ]; then _LDC="${_LDC} /usr/local/lib" ; fi
271	if [ -d /usr/gnu/lib ]; then _LDC="${_LDC} /usr/gnu/lib" ; fi
272	echo 'setting ldconfig path:' ${_LDC}
273	ldconfig ${_LDC}
274fi
275
276# configure implementation specific stuff
277arch=`uname -m`
278if [ -f /etc/rc.$arch ]; then
279	. /etc/rc.$arch
280fi
281
282# Do traditional (but rather obsolete) rc.local file if it exists.
283if [ -f /etc/rc.local ]; then
284	sh /etc/rc.local
285fi
286
287date
288exit 0
289