rc revision 7112
1214501Srpaulo#!/bin/sh
2214501Srpaulo#	$Id: rc,v 1.46 1995/03/16 16:58:00 wollman Exp $
3252726Srpaulo#	From: @(#)rc	5.27 (Berkeley) 6/5/91
4214501Srpaulo
5252726Srpaulo# System startup script run by init on autoboot
6252726Srpaulo# or after single-user.
7214501Srpaulo# Output and error are redirected to console by init,
8214501Srpaulo# and the console is the controlling terminal.
9214501Srpaulo
10214501Srpaulostty status '^T'
11214501Srpaulo
12252726Srpaulo# Set shell to ignore SIGINT (2), but not children;
13252726Srpaulo# shell catches SIGQUIT (3) and returns to single user after fsck.
14214501Srpaulotrap : 2
15214501Srpaulotrap : 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# This stuff needed for proper daemons tuning, comsat f.e.
69# See profile and csh.login also.
70# Uncomment next line if you want to setup your 8-bit locale at program
71# startup automatically
72# ENABLE_STARTUP_LOCALE=; export ENABLE_STARTUP_LOCALE
73# Uncomment next line to activate russian locale
74# LANG=ru_SU.KOI8-R; export LANG
75# Uncomment next line to activate italian locale
76# LANG=it_IT.ISO8859-1; export LANG
77# For full locales list check /usr/share/locale/*
78
79# If the machine runs wall CMOS clock (compatible with MSDOS),
80# activate following line by creating empty file /etc/wall_cmos_clock
81# If this file not exist, following line does nothing (assumed
82# the machine runs UTC CMOS clock). See adjkerntz(8) for details.
83adjkerntz -i
84
85# configure serial devices
86if [ -f /etc/rc.serial ]
87then
88	sh /etc/rc.serial
89fi
90
91# set hostname, turn on network
92echo 'starting network'
93. /etc/netstart
94
95# clean up left-over files
96rm -f /etc/nologin
97rm -f /var/spool/lock/*
98rm -f /var/spool/uucp/.Temp/*
99(cd /var/run && { rm -rf -- *; cp /dev/null utmp; chmod 644 utmp; })
100
101echo -n 'starting system logger'
102rm -f /dev/log
103syslogd
104
105# $timedflags is imported from /etc/netstart;
106# if $timedflags == NO, timed isn't run.
107if [ X"${timedflags}" != X"NO" ]; then
108	echo -n ', time daemon'; timed $timedflags
109fi
110echo '.'
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"NO" -a -d /var/crash ]; then
115	echo checking for core dump...
116	savecore /var/crash
117fi
118
119#				echo -n 'checking quotas:'
120#quotacheck -a
121#				echo ' done.'
122#quotaon -a
123
124# build ps databases
125kvm_mkdb 
126dev_mkdb
127
128# snapshot any kernel changes back to disk
129#/sbin/dset -q
130
131chmod 666 /dev/tty[pqrs]*
132
133# check the password temp/lock file
134if [ -f /etc/ptmp ]
135then
136	logger -s -p auth.err \
137	'password file may be incorrect -- /etc/ptmp exists'
138fi
139
140# Recover vi editor files.
141virecovery=/var/tmp/vi.recover/recover.*
142if [ "$virecovery" != "/var/tmp/vi.recover/recover.*" ]; then
143	echo 'Recovering vi editor sessions'
144	for i in $virecovery; do
145		sendmail -t < $i
146	done
147fi
148
149echo clearing /tmp
150
151# prune quickly with one rm, then use find to clean up /tmp/[lq]*
152# (not needed with mfs /tmp, but doesn't hurt there...)
153(cd /tmp && rm -rf [a-km-pr-zA-Z]* &&
154    find -d . ! -name . ! -name lost+found ! -name quotas -exec rm -rf -- {} \;)
155
156# echo 'turning on accounting';	accton /var/account/acct
157
158echo -n standard daemons:
159echo -n ' cron';		cron
160echo '.'
161
162echo -n starting network daemons:
163
164# Portmapper should always be run, to provide RPC services for inetd.
165if [ -x /usr/sbin/portmap ]; then
166	echo -n ' portmap';		portmap
167fi
168
169# $gated and $routedflags are imported from /etc/netstart.
170# If $gated == YES, gated is used; otherwise routed.
171# If $routedflags == NO, routed isn't run.
172if [ X${gated} = X"YES" -a -r /etc/gated.conf ]; then
173	echo -n ' gated';	gated $gatedflags
174elif [ X"${routedflags}" != X"NO" ]; then
175	echo -n ' routed';	routed $routedflags
176fi
177
178if [ X${name_server} = X"YES" -a -r /etc/namedb/named.boot ]; then
179	echo -n ' named';		named -b /etc/namedb/named.boot
180fi
181
182# $ntpdate and $xntpdflags are imported from /etc/netstart.
183# If $ntpdate != NO, run ntpdate $ntpdate to set the date correctly.
184# If $xntpdflags != NO, start xntpd.
185if [ X"${ntpdate}" != X"NO" -o X"${xntpdflags}" != X"NO" ]; then
186	if [ X"${tickadjflags}" != X"NO" ]; then
187		echo -n ' tickadj';	tickadj ${tickadjflags--Aq}
188	fi
189
190	if [ X"${ntpdate}" != X"NO" ]; then
191		echo -n ' ntpdate';	ntpdate ${ntpdate}
192	fi
193
194	if [ X"${xntpdflags}" != X"NO" ]; then
195		echo -n ' xntpd';	xntpd ${xntpdflags}
196	fi
197fi
198
199# $rwhod is imported from /etc/netstart;
200# if $rwhod is set to something other than NO, rwhod is run.
201if [ X"${rwhod}" != X"NO" ]; then
202	echo -n ' rwhod';	rwhod
203fi
204
205echo -n ' printer';		lpd
206
207if [ X${nfs_server} = X"YES" -a -r /etc/exports ]; then
208	echo -n ' mountd';		mountd
209	echo -n ' nfsd';		nfsd -u -t 4
210fi
211
212if [ X"${nfs_client}" != X"NO" ]; then
213	echo -n ' nfsiod';		nfsiod -n 4
214fi
215
216if [ X"${amdflags}" != X"NO" ]; then
217	echo -n ' amd';			amd ${amdflags}
218fi
219
220# $sendmail_flags is imported from /etc/netstart;
221# if $sendmail_flags is something other than NO, sendmail is run.
222if [ X"${sendmail_flags}" != X"NO" -a -r /etc/sendmail.cf ]; then
223	echo -n ' sendmail';		sendmail ${sendmail_flags} 
224fi
225
226# Kerberos runs ONLY on the Kerberos server machine
227if [ X"${kerberos_server}" = X"YES" ]; then
228	echo -n ' kerberos';	kerberos >> /var/log/kerberos.log &
229	echo -n ' kadmind'; \
230		(sleep 20; /usr/sbin/kadmind -n >/dev/null 2>&1 &) &
231fi
232
233# Start ypserv if we're an NIS server.
234# Run yppasswdd only on the NIS master server
235if [ X"${nis_serverflags}" != X"NO" ]; then
236        echo -n ' ypserv'; ypserv $nis_serverflags
237
238	if [ X"${yppasswddflags}" != X"NO" ]; then
239	        echo -n ' yppasswdd'; yppasswdd $yppasswddflags
240	fi
241fi
242
243
244# Start ypbind if we're an NIS client
245if [ X"${nis_clientflags}" != X"NO" ]; then
246        echo -n ' ypbind'; ypbind $nis_clientflags
247fi
248
249echo -n ' inetd';		inetd
250echo '.'
251
252mount -a -t nfs >/dev/null 2>&1 &	# XXX shouldn't need background
253
254# if [ -x /usr/libexec/xtend ]; then
255# 	echo -n ' xtend';   /usr/libexec/xtend
256# fi
257
258# Make shared lib searching a little faster.  Leave /usr/lib first if you
259# add your own entries or you may come to grief.
260if [ -x /sbin/ldconfig ]; then
261	_LDC=/usr/lib
262	if [ -d /usr/X11R6/lib ]; then _LDC="${_LDC} /usr/X11R6/lib" ; fi
263	if [ -d /usr/X386/lib ]; then _LDC="${_LDC} /usr/X386/lib" ; fi
264	if [ -d /usr/local/lib ]; then _LDC="${_LDC} /usr/local/lib" ; fi
265	if [ -d /usr/gnu/lib ]; then _LDC="${_LDC} /usr/gnu/lib" ; fi
266	echo 'setting ldconfig path:' ${_LDC}
267	ldconfig ${_LDC}
268fi
269
270. /etc/rc.local
271
272date
273
274exit 0
275