rc revision 9305
1#!/bin/sh
2#	$Id: rc,v 1.66 1995/05/15 19:50:59 rgrimes 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}
200fi
201
202# $rwhod is imported from /etc/sysconfig;
203# if $rwhod is set to YES, rwhod is run.
204if [ "X${rwhod}" = X"YES" ]; then
205	echo -n ' rwhod';	rwhod
206fi
207
208if [ "X${nfs_server}" = X"YES" -a -r /etc/exports ]; then
209	echo -n ' mountd';		mountd
210	echo -n ' nfsd';		nfsd -u -t 4
211fi
212
213if [ "X${nfs_client}" = X"YES" ]; then
214	echo -n ' nfsiod';		nfsiod -n 4
215fi
216
217if [ "X${amdflags}" != X"NO" ]; then
218	echo -n ' amd';			amd ${amdflags}
219fi
220
221# Kerberos runs ONLY on the Kerberos server machine
222if [ "X${kerberos_server}" = X"YES" ]; then
223	echo -n ' kerberos';	kerberos >> /var/log/kerberos.log &
224	echo -n ' kadmind'; \
225		(sleep 20; /usr/sbin/kadmind -n >/dev/null 2>&1 &) &
226fi
227
228echo -n ' inetd';		inetd
229echo '.'
230
231# build ps databases
232kvm_mkdb 
233dev_mkdb
234
235# check the password temp/lock file
236if [ -f /etc/ptmp ]
237then
238	logger -s -p auth.err \
239	"password file may be incorrect -- /etc/ptmp exists"
240fi
241
242# Recover vi editor files.
243virecovery=/var/tmp/vi.recover/recover.*
244if [ "$virecovery" != "/var/tmp/vi.recover/recover.*" ]; then
245	echo 'Recovering vi editor sessions'
246	for i in $virecovery; do
247		sendmail -t < $i
248	done
249fi
250
251if [ "X${accounting}" = X"YES" -a -d /var/account ]; then
252	echo 'turning on accounting';	accton /var/account/acct
253fi
254
255# Now start up miscellaneous daemons that don't belong anywhere else
256#
257echo -n standard daemons:
258echo -n ' cron';		cron
259echo -n ' printer';		lpd
260
261# $sendmail_flags is imported from /etc/sysconfig;
262# if $sendmail_flags is something other than NO, sendmail is run.
263if [ "X${sendmail_flags}" != X"NO" -a -r /etc/sendmail.cf ]; then
264	echo -n ' sendmail';		sendmail ${sendmail_flags} 
265fi
266
267echo '.'
268
269# Make shared lib searching a little faster.  Leave /usr/lib first if you
270# add your own entries or you may come to grief.
271if [ -x /sbin/ldconfig ]; then
272	_LDC=/usr/lib
273	if [ -d /usr/X11R6/lib ]; then _LDC="${_LDC} /usr/X11R6/lib" ; fi
274	if [ -d /usr/X386/lib ]; then _LDC="${_LDC} /usr/X386/lib" ; fi
275	if [ -d /usr/local/lib ]; then _LDC="${_LDC} /usr/local/lib" ; fi
276	if [ -d /usr/gnu/lib ]; then _LDC="${_LDC} /usr/gnu/lib" ; fi
277	echo 'setting ldconfig path:' ${_LDC}
278	ldconfig ${_LDC}
279fi
280
281# configure implementation specific stuff
282arch=`uname -m`
283if [ -f /etc/rc.$arch ]; then
284	. /etc/rc.$arch
285fi
286
287# Do traditional (but rather obsolete) rc.local file if it exists.
288if [ -f /etc/rc.local ]; then
289	sh /etc/rc.local
290fi
291
292date
293exit 0
294