rc revision 7238
1#!/bin/sh
2#	$Id: rc,v 1.49 1995/03/21 16:44:03 wollman 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
10stty status '^T'
11
12# Set shell to ignore SIGINT (2), but not children;
13# shell catches SIGQUIT (3) and returns to single user after fsck.
14trap : 2
15trap : 3	# shouldn't be needed
16
17HOME=/; export HOME
18PATH=/sbin:/bin:/usr/sbin:/usr/bin
19export PATH
20
21swapon -a
22
23if [ $1x = autobootx ]
24then
25	echo Automatic reboot in progress...
26	fsck -p
27	case $? in
28	0)
29		;;
30	2)
31		exit 1
32		;;
33	4)
34		reboot
35		echo "reboot failed... help!"
36		exit 1
37		;;
38	8)
39		echo "Automatic file system check failed... help!"
40		exit 1
41		;;
42	12)
43		echo "Reboot interrupted"
44		exit 1
45		;;
46	130)
47		# interrupt before catcher installed
48		exit 1
49		;;
50	*)
51		echo "Unknown error in reboot"
52		exit 1
53		;;
54	esac
55else
56	echo Skipping disk checks ...
57fi
58
59trap "echo 'Reboot interrupted'; exit 1" 3
60
61# root must be read/write both for NFS diskless and for VFS LKMs before
62# proceeding any further.
63mount -u -o rw /
64
65umount -a >/dev/null 2>&1
66mount -a -t nonfs
67
68# If the machine runs wall CMOS clock (compatible with MSDOS),
69# activate following line by creating empty file /etc/wall_cmos_clock
70# If this file not exist, following line does nothing (assumed
71# the machine runs UTC CMOS clock). See adjkerntz(8) for details.
72adjkerntz -i
73
74# If there is a global system configuration file, suck it in.
75if [ -f /etc/sysconfig ]; then
76	. /etc/sysconfig
77fi
78
79# configure serial devices
80if [ -f /etc/rc.serial ]; then
81	sh /etc/rc.serial
82fi
83
84# set hostname, turn on network
85echo 'starting network'
86. /etc/netstart
87
88# clean up left-over files
89rm -f /etc/nologin
90rm -f /var/spool/lock/*
91rm -f /var/spool/uucp/.Temp/*
92(cd /var/run && { rm -rf -- *; cp /dev/null utmp; chmod 644 utmp; })
93
94echo -n ' system logger'
95rm -f /dev/log
96syslogd
97
98# $timedflags is imported from /etc/sysconfig;
99# if $timedflags == NO, timed isn't run.
100if [ "X${timedflags}" != X"NO" ]; then
101	echo -n ' time daemon'; timed $timedflags
102fi
103echo '.'
104
105# /var/crash should be a directory or a symbolic link
106# to the crash directory if core dumps are to be saved.
107if [ "X${savecore}" = X"YES" -a -d /var/crash ]; then
108	echo; echo -n checking for core dump...
109	savecore /var/crash
110	echo done.
111fi
112
113if [ "X${check_quotas}" = X"YES" ]; then
114	echo ' checking quotas:'
115	quotacheck -a
116	echo ' done.'
117	quotaon -a
118fi
119
120# build ps databases
121kvm_mkdb 
122dev_mkdb
123
124# snapshot any kernel -c changes back to disk
125/sbin/dset -q
126
127chmod 666 /dev/tty[pqrs]*
128
129# check the password temp/lock file
130if [ -f /etc/ptmp ]
131then
132	logger -s -p auth.err \
133	'password file may be incorrect -- /etc/ptmp exists'
134fi
135
136# Recover vi editor files.
137virecovery=/var/tmp/vi.recover/recover.*
138if [ "$virecovery" != "/var/tmp/vi.recover/recover.*" ]; then
139	echo 'Recovering vi editor sessions'
140	for i in $virecovery; do
141		sendmail -t < $i
142	done
143fi
144
145echo clearing /tmp
146
147# prune quickly with one rm, then use find to clean up /tmp/[lq]*
148# (not needed with mfs /tmp, but doesn't hurt there...)
149(cd /tmp && rm -rf [a-km-pr-zA-Z]* &&
150    find -d . ! -name . ! -name lost+found ! -name quotas -exec rm -rf -- {} \;)
151
152if [ "X${accounting}" = X"YES" -a -d /var/account ]; then
153	echo 'turning on accounting';	accton /var/account/acct
154fi
155
156echo -n standard daemons:
157echo -n ' cron';		cron
158echo '.'
159
160echo -n starting network daemons:
161
162# Portmapper should always be run, to provide RPC services for inetd.
163if [ -x /usr/sbin/portmap ]; then
164	echo -n ' portmap';		portmap
165fi
166
167# $gated and $routedflags are imported from /etc/sysconfig.
168# If $gated == YES, gated is used; otherwise routed.
169# If $routedflags == NO, routed isn't run.
170if [ "X${gated}" = X"YES" -a -r /etc/gated.conf ]; then
171	echo -n ' gated';	gated $gatedflags
172elif [ "X${routedflags}" != X"NO" ]; then
173	echo -n ' routed';	routed $routedflags
174fi
175
176# $namedflags is imported from /etc/sysconfig
177if [ "X${namedflags}" != "XNO" ]; then
178	echo -n ' named';	named $namedflags
179fi
180
181# $ntpdate and $xntpdflags are imported from /etc/sysconfig.
182# If $ntpdate != NO, run ntpdate $ntpdate to set the date correctly.
183# If $xntpdflags != NO, start xntpd.
184if [ "X${ntpdate}" != X"NO" -o "X${xntpdflags}" != X"NO" ]; then
185	if [ "X${tickadjflags}" != X"NO" ]; then
186		echo -n ' tickadj';	tickadj ${tickadjflags--Aq}
187	fi
188
189	if [ "X${ntpdate}" != X"NO" ]; then
190		echo -n ' ntpdate';	ntpdate ${ntpdate}
191	fi
192
193	if [ "X${xntpdflags}" != X"NO" ]; then
194		echo -n ' xntpd';	xntpd ${xntpdflags}
195	fi
196fi
197
198# $rwhod is imported from /etc/sysconfig;
199# if $rwhod is set to YES, rwhod is run.
200if [ "X${rwhod}" = X"YES" ]; then
201	echo -n ' rwhod';	rwhod
202fi
203
204echo -n ' printer';		lpd
205
206if [ "X${nfs_server}" = X"YES" -a -r /etc/exports ]; then
207	echo -n ' mountd';		mountd
208	echo -n ' nfsd';		nfsd -u -t 4
209fi
210
211if [ "X${nfs_client}" = X"YES" ]; then
212	echo -n ' nfsiod';		nfsiod -n 4
213fi
214
215if [ "X${amdflags}" != X"NO" ]; then
216	echo -n ' amd';			amd ${amdflags}
217fi
218
219# $sendmail_flags is imported from /etc/sysconfig;
220# if $sendmail_flags is something other than NO, sendmail is run.
221if [ "X${sendmail_flags}" != X"NO" -a -r /etc/sendmail.cf ]; then
222	echo -n ' sendmail';		sendmail ${sendmail_flags} 
223fi
224
225# Kerberos runs ONLY on the Kerberos server machine
226if [ "X${kerberos_server}" = X"YES" ]; then
227	echo -n ' kerberos';	kerberos >> /var/log/kerberos.log &
228	echo -n ' kadmind'; \
229		(sleep 20; /usr/sbin/kadmind -n >/dev/null 2>&1 &) &
230fi
231
232# Start ypserv if we're an NIS server.
233# Run yppasswdd only on the NIS master server
234if [ "X${nis_serverflags}" != X"NO" ]; then
235        echo -n ' ypserv'; ypserv ${nis_serverflags}
236
237	if [ "X${yppasswddflags}" != X"NO" ]; then
238	        echo -n ' yppasswdd'; yppasswdd ${yppasswddflags}
239	fi
240fi
241
242
243# Start ypbind if we're an NIS client
244if [ "X${nis_clientflags}" != X"NO" ]; then
245        echo -n ' ypbind'; ypbind ${nis_clientflags}
246fi
247
248echo -n ' inetd';		inetd
249echo '.'
250
251mount -a -t nfs >/dev/null 2>&1 &	# XXX shouldn't need background
252
253if [ "X${xtend}" != X"NO" -a -x /usr/libexec/xtend ]; then
254 	echo -n ' xtend';   /usr/libexec/xtend
255fi
256
257# Make shared lib searching a little faster.  Leave /usr/lib first if you
258# add your own entries or you may come to grief.
259if [ -x /sbin/ldconfig ]; then
260	_LDC=/usr/lib
261	if [ -d /usr/X11R6/lib ]; then _LDC="${_LDC} /usr/X11R6/lib" ; fi
262	if [ -d /usr/X386/lib ]; then _LDC="${_LDC} /usr/X386/lib" ; fi
263	if [ -d /usr/local/lib ]; then _LDC="${_LDC} /usr/local/lib" ; fi
264	if [ -d /usr/gnu/lib ]; then _LDC="${_LDC} /usr/gnu/lib" ; fi
265	echo 'setting ldconfig path:' ${_LDC}
266	ldconfig ${_LDC}
267fi
268
269######################### Start Of Syscons Section #######################
270
271kbdadjust=NO
272[ "X${keymap}" != X"NO" -o "X${keyrate}" != X"NO" ] && kbdadjust=YES
273vidadjust=NO
274[ "X${scrnmap}" != X"NO" -o "X${font8x16}" != X"NO" -o \
275	"X${font8x14}" != X"NO" -o "X${font8x8}" != X"NO" -o \
276	"X${blanktime}" != X"NO" ] && vidadjust=YES
277
278[ "X${kbdajust}" != X"NO" -o "X${vidajust}" != X"NO" -o \
279	"X${saver}" != X"NO" ] && echo "starting syscons:"
280
281[ "X${kbdajust}" != X"NO" ] && echo "kbdcontrol: "
282
283# keymap
284if [ "X${keymap}" != X"NO" ]; then
285	echo -n "keymap "
286	kbdcontrol -l ${keymap}
287fi
288
289# keyrate
290if [ "X${keyrate}" != X"NO" ]; then
291	echo -n "keyrate "
292	kbdcontrol -r ${keyrate}
293fi
294
295[ "X${kbdajust}" != X"NO" ] && echo
296[ "X${vidajust}" != X"NO" ] && echo "vidcontrol: "
297
298# screen mapping
299if [ "X${scrnmap}" != X"NO" ]; then
300	echo -n "screen_map "
301	vidcontrol -l ${scrnmap}
302fi
303
304# font 8x16
305if [ "X${font8x16}" != X"NO" ]; then
306	echo -n "font8x16 "
307	vidcontrol -f 8x16 ${font8x16}
308fi
309
310# font 8x14
311if [ "X${font8x14}" != X"NO" ]; then
312	echo -n "font8x14 "
313	vidcontrol -f 8x14 ${font8x14}
314fi
315
316# font 8x8
317if [ "X${font8x8}" != X"NO" ]; then
318	echo -n "font8x8 "
319	vidcontrol -f 8x8 ${font8x8}
320fi
321
322# blank time
323if [ "X${blanktime}" != X"NO" ]; then
324	echo -n "blank_time "
325	vidcontrol -t ${blanktime}
326fi
327
328[ "X${vidajust}" != X"NO" ] && echo
329
330# screen saver
331if [ "X${saver}" != X"NO" ] ; then
332	echo -n "screensaver: "
333	modstat | grep _saver || modload -u -o /tmp/saver_mod -e \
334				 saver_init -q /lkm/${saver}_saver_mod.o
335fi
336
337######################### End Of Syscons Section #######################
338
339. /etc/rc.local
340
341date
342
343exit 0
344