rc revision 8460
1244557Sbrooks#!/bin/sh
2244557Sbrooks#	$Id: rc,v 1.63 1995/04/11 18:36:10 ache Exp $
3244557Sbrooks#	From: @(#)rc	5.27 (Berkeley) 6/5/91
4244557Sbrooks
5244557Sbrooks# System startup script run by init on autoboot
6244557Sbrooks# or after single-user.
7244557Sbrooks# Output and error are redirected to console by init,
8244557Sbrooks# and the console is the controlling terminal.
9244557Sbrooks
10244557Sbrooks# Note that almost all the user-configurable behavior is no longer in
11244557Sbrooks# this file, but rather in /etc/sysconfig.  Please check this file
12244557Sbrooks# first before contemplating any changes here.
13244557Sbrooks
14244557Sbrooksstty status '^T'
15244557Sbrooks
16244557Sbrooks# Set shell to ignore SIGINT (2), but not children;
17244557Sbrooks# shell catches SIGQUIT (3) and returns to single user after fsck.
18244557Sbrookstrap : 2
19244557Sbrookstrap : 3	# shouldn't be needed
20244557Sbrooks
21244557SbrooksHOME=/; export HOME
22244557SbrooksPATH=/sbin:/bin:/usr/sbin:/usr/bin
23244557Sbrooksexport PATH
24244557Sbrooks
25244557Sbrooksswapon -a
26244557Sbrooks
27244557Sbrooksif [ $1x = autobootx ]
28244557Sbrooksthen
29244557Sbrooks	echo Automatic reboot in progress...
30244557Sbrooks	fsck -p
31244557Sbrooks	case $? in
32244557Sbrooks	0)
33244557Sbrooks		;;
34244557Sbrooks	2)
35244557Sbrooks		exit 1
36244557Sbrooks		;;
37244557Sbrooks	4)
38244557Sbrooks		reboot
39244557Sbrooks		echo "reboot failed... help!"
40244557Sbrooks		exit 1
41244557Sbrooks		;;
42244557Sbrooks	8)
43244557Sbrooks		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 /
68
69umount -a >/dev/null 2>&1
70mount -a -t nonfs
71
72# If the machine runs wall CMOS clock (compatible with MSDOS),
73# activate following line by creating empty file /etc/wall_cmos_clock
74# If this file not exist, following line does nothing (assumed
75# the machine runs UTC CMOS clock). See adjkerntz(8) for details.
76adjkerntz -i
77
78# If there is a global system configuration file, suck it in.
79if [ -f /etc/sysconfig ]; then
80	. /etc/sysconfig
81fi
82
83# configure serial devices
84if [ -f /etc/rc.serial ]; then
85	. /etc/rc.serial
86fi
87
88# start up the network
89if [ -f /etc/netstart ]; then
90	sh /etc/netstart
91fi
92
93mount -a -t nfs >/dev/null 2>&1 &	# XXX shouldn't need background
94
95# Whack the pty perms back into shape.
96chmod 666 /dev/tty[pqrs]*
97
98# clean up left-over files
99rm -f /etc/nologin
100rm -f /var/spool/lock/*
101rm -rf /var/spool/uucp/.Temp/*
102rm -f /dev/log
103(cd /var/run && { rm -rf -- *; cp /dev/null utmp; chmod 644 utmp; })
104
105echo clearing /tmp
106
107# prune quickly with one rm, then use find to clean up /tmp/[lq]*
108# (not needed with mfs /tmp, but doesn't hurt there...)
109(cd /tmp && rm -rf [a-km-pr-zA-Z]* &&
110    find -d . ! -name . ! -name lost+found ! -name quotas -exec rm -rf -- {} \;)
111
112# /var/crash should be a directory or a symbolic link
113# to the crash directory if core dumps are to be saved.
114if [ "X${savecore}" = X"YES" -a -d /var/crash ]; then
115	echo -n checking for core dump...
116	savecore /var/crash
117fi
118
119# snapshot any kernel -c changes back to disk
120echo 'recording kernel -c changes'
121/sbin/dset -q
122
123# Check the quotas
124if [ "X${check_quotas}" = X"YES" ]; then
125	echo 'checking quotas:'
126	quotacheck -a
127	echo ' done.'
128	quotaon -a
129fi
130
131# start system logging and name service (named needs to start before syslogd
132# if you don't have a /etc/resolv.conf)
133#
134echo -n starting system daemons:
135
136echo ' syslogd.';			syslogd
137
138echo -n starting network daemons:
139
140# $namedflags is imported from /etc/sysconfig
141if [ "X${namedflags}" != "XNO" ]; then
142	echo -n ' named';		named $namedflags
143fi
144
145# $ntpdate and $xntpdflags are imported from /etc/sysconfig.
146# If $ntpdate != NO, run ntpdate $ntpdate to set the date correctly.
147# If $xntpdflags != NO, start xntpd.
148if [ "X${ntpdate}" != X"NO" -o "X${xntpdflags}" != X"NO" ]; then
149	if [ "X${tickadjflags}" != X"NO" ]; then
150		echo -n ' tickadj';	tickadj ${tickadjflags--Aq}
151	fi
152
153	if [ "X${ntpdate}" != X"NO" ]; then
154		echo -n ' ntpdate';	ntpdate ${ntpdate} >/dev/null 2>&1
155	fi
156
157	if [ "X${xntpdflags}" != X"NO" ]; then
158		echo -n ' xntpd';	xntpd ${xntpdflags}
159	fi
160fi
161
162# $timedflags is imported from /etc/sysconfig;
163# if $timedflags == NO, timed isn't run.
164if [ "X${timedflags}" != X"NO" ]; then
165	echo -n ' timed'; timed $timedflags
166fi
167
168# Portmapper should always be run, to provide RPC services for inetd.
169if [ -x /usr/sbin/portmap ]; then
170	echo -n ' portmap';		portmap
171fi
172
173# Start ypserv if we're an NIS server.
174# Run yppasswdd only on the NIS master server
175if [ "X${nis_serverflags}" != X"NO" ]; then
176	echo -n ' ypserv'; ypserv ${nis_serverflags}
177
178	if [ "X${yppasswddflags}" != X"NO" ]; then
179		echo -n ' yppasswdd'; yppasswdd ${yppasswddflags}
180	fi
181fi
182
183# Start ypbind if we're an NIS client
184if [ "X${nis_clientflags}" != X"NO" ]; then
185	echo -n ' ypbind'; ypbind ${nis_clientflags}
186fi
187
188# $rwhod is imported from /etc/sysconfig;
189# if $rwhod is set to YES, rwhod is run.
190if [ "X${rwhod}" = X"YES" ]; then
191	echo -n ' rwhod';	rwhod
192fi
193
194if [ "X${nfs_server}" = X"YES" -a -r /etc/exports ]; then
195	echo -n ' mountd';		mountd
196	echo -n ' nfsd';		nfsd -u -t 4
197fi
198
199if [ "X${nfs_client}" = X"YES" ]; then
200	echo -n ' nfsiod';		nfsiod -n 4
201fi
202
203if [ "X${amdflags}" != X"NO" ]; then
204	echo -n ' amd';			amd ${amdflags}
205fi
206
207# Kerberos runs ONLY on the Kerberos server machine
208if [ "X${kerberos_server}" = X"YES" ]; then
209	echo -n ' kerberos';	kerberos >> /var/log/kerberos.log &
210	echo -n ' kadmind'; \
211		(sleep 20; /usr/sbin/kadmind -n >/dev/null 2>&1 &) &
212fi
213
214echo -n ' inetd';		inetd
215echo '.'
216
217# build ps databases
218kvm_mkdb 
219dev_mkdb
220
221# check the password temp/lock file
222if [ -f /etc/ptmp ]
223then
224	logger -s -p auth.err \
225	"password file may be incorrect -- /etc/ptmp exists"
226fi
227
228# Recover vi editor files.
229virecovery=/var/tmp/vi.recover/recover.*
230if [ "$virecovery" != "/var/tmp/vi.recover/recover.*" ]; then
231	echo 'Recovering vi editor sessions'
232	for i in $virecovery; do
233		sendmail -t < $i
234	done
235fi
236
237if [ "X${accounting}" = X"YES" -a -d /var/account ]; then
238	echo 'turning on accounting';	accton /var/account/acct
239fi
240
241# Now start up miscellaneous daemons that don't belong anywhere else
242#
243echo -n standard daemons:
244echo -n ' cron';		cron
245echo -n ' printer';		lpd
246
247# $sendmail_flags is imported from /etc/sysconfig;
248# if $sendmail_flags is something other than NO, sendmail is run.
249if [ "X${sendmail_flags}" != X"NO" -a -r /etc/sendmail.cf ]; then
250	echo -n ' sendmail';		sendmail ${sendmail_flags} 
251fi
252
253echo '.'
254
255# Make shared lib searching a little faster.  Leave /usr/lib first if you
256# add your own entries or you may come to grief.
257if [ -x /sbin/ldconfig ]; then
258	_LDC=/usr/lib
259	if [ -d /usr/X11R6/lib ]; then _LDC="${_LDC} /usr/X11R6/lib" ; fi
260	if [ -d /usr/X386/lib ]; then _LDC="${_LDC} /usr/X386/lib" ; fi
261	if [ -d /usr/local/lib ]; then _LDC="${_LDC} /usr/local/lib" ; fi
262	if [ -d /usr/gnu/lib ]; then _LDC="${_LDC} /usr/gnu/lib" ; fi
263	echo 'setting ldconfig path:' ${_LDC}
264	ldconfig ${_LDC}
265fi
266
267# configure implementation specific stuff
268arch=`uname -m`
269if [ -f /etc/rc.$arch ]; then
270	. /etc/rc.$arch
271fi
272
273# Do traditional (but rather obsolete) rc.local file if it exists.
274if [ -f /etc/rc.local ]; then
275	sh /etc/rc.local
276fi
277
278date
279exit 0
280