rc revision 2777
1#!/bin/sh
2#	$Id: rc,v 1.28 1994/08/21 04:28:44 davidg 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
21if [ $1x = autobootx ]
22then
23	echo Automatic reboot in progress...
24	fsck -p
25	case $? in
26	0)
27		;;
28	2)
29		exit 1
30		;;
31	4)
32		reboot
33		echo "reboot failed... help!"
34		exit 1
35		;;
36	8)
37		echo "Automatic file system check failed... help!"
38		exit 1
39		;;
40	12)
41		echo "Reboot interrupted"
42		exit 1
43		;;
44	130)
45		# interrupt before catcher installed
46		exit 1
47		;;
48	*)
49		echo "Unknown error in reboot"
50		exit 1
51		;;
52	esac
53else
54	echo Skipping disk checks ...
55fi
56
57trap "echo 'Reboot interrupted'; exit 1" 3
58
59swapon -a
60
61# Check for diskless boot, and remount the root RW.
62a=`mount`
63if [ 0 != `expr "$a" : '^[^/]*:/.* on /'` ] ; then
64        mount -u -o rw /
65fi
66
67umount -a >/dev/null 2>&1
68mount -a -t nonfs
69
70# If the machine runs wall CMOS clock (compatible with MSDOS),
71# activate following line by creating empty file /etc/wall_cmos_clock
72# If this file not exist, following line does nothing (assumed
73# the machine runs UTC CMOS clock). See adjkerntz(8) for details.
74adjkerntz -i
75
76# configure serial devices
77if [ -f /etc/rc.serial ]
78then
79	sh /etc/rc.serial
80fi
81
82# set hostname, turn on network
83echo 'starting network'
84. /etc/netstart
85
86# clean up left-over files
87rm -f /etc/nologin
88rm -f /var/spool/lock/*
89rm -f /var/spool/uucp/.Temp/*
90# don't add .[a-z]* to rm, because of .adjkerntz file name
91(cd /var/run && { rm -rf -- *; cp /dev/null utmp; chmod 644 utmp; })
92
93echo -n 'starting system logger'
94rm -f /dev/log
95syslogd
96
97# $timedflags is imported from /etc/netstart;
98# if $timedflags == NO, timed isn't run.
99if [ X${timedflags} != X"NO" ]; then
100	echo -n ', time daemon'; timed $timedflags
101fi
102echo '.'
103
104# /var/crash should be a directory or a symbolic link
105# to the crash directory if core dumps are to be saved.
106if [ -d /var/crash ]; then
107	echo checking for core dump...
108	savecore /var/crash
109fi
110
111#				echo -n 'checking quotas:'
112#quotacheck -a
113#				echo ' done.'
114#quotaon -a
115
116# build ps databases
117kvm_mkdb /kernel
118dev_mkdb
119
120chmod 666 /dev/tty[pqrs]*
121
122# check the password temp/lock file
123if [ -f /etc/ptmp ]
124then
125	logger -s -p auth.err \
126	'password file may be incorrect -- /etc/ptmp exists'
127fi
128
129# Recover elvis editor files.
130echo preserving editor files
131(cd /var/tmp && /usr/libexec/elvispreserve "-the system rebooted" elv* &&
132	rm -f elvis[0-9a-f][0-9a-f][0-9a-f][0-9a-f]* \
133	elvis_[0-9a-f][0-9a-f][0-9a-f][0-9a-f]*)
134
135# Recover vi editor files.
136virecovery=/var/tmp/vi.recover/recover.*
137if [ "$virecovery" != "/var/tmp/vi.recover/recover.*" ]; then
138	echo 'Recovering vi editor sessions'
139	for i in $virecovery; do
140		sendmail -t < $i
141	done
142fi
143
144echo clearing /tmp
145
146# prune quickly with one rm, then use find to clean up /tmp/[lq]*
147# (not needed with mfs /tmp, but doesn't hurt there...)
148(cd /tmp && rm -rf [a-km-pr-zA-Z]* &&
149    find -d . ! -name . ! -name lost+found ! -name quotas -exec rm -rf -- {} \;)
150
151# echo 'turning on accounting';	accton /var/account/acct
152
153echo -n standard daemons:
154echo -n ' cron';		cron
155echo '.'
156
157echo -n starting network daemons:
158
159# Portmapper should always be run, to provide RPC services for inetd.
160if [ -x /usr/sbin/portmap ]; then
161	echo -n ' portmap';		portmap
162fi
163
164# $gated and $routedflags are imported from /etc/netstart.
165# If $gated == YES, gated is used; otherwise routed.
166# If $routedflags == NO, routed isn't run.
167if [ X${gated} = X"YES" -a -r /etc/gated.conf ]; then
168	echo -n ' gated';	gated $gatedflags
169elif [ X"${routedflags}" != X"NO" ]; then
170	echo -n ' routed';	routed $routedflags
171fi
172
173if [ X${name_server} = X"YES" -a -r /etc/named.boot ]; then
174	echo -n ' named';		named
175fi
176
177# $ntpdate and $xntpdflags are imported from /etc/netstart.
178# If $ntpdate != NO, run ntpdate $ntpdate to set the date correctly.
179# If $xntpdflags != NO, start xntpd.
180if [ X"${ntpdate}" != X"NO" ]; then
181	echo ' ntpdate';	ntpdate $ntpdate
182fi
183
184if [ X"${xntpdflags}" != X"NO" ]; then
185	if [ X"${tickadjflags}" != X"NO" ]; then
186		echo 'adjusting kernel for xntpd'; tickadj ${tickadjflags--A}
187	fi
188	echo 'starting xntpd';	xntpd ${xntpdflags}
189fi
190
191if [ X"${ntpdate}" != X"NO" -o X"${xntpdflags}" != X"NO" ]; then
192	echo -n 'starting more network daemons:'
193fi
194
195# $rwhod is imported from /etc/netstart;
196# if $rwhod is set to something other than NO, rwhod is run.
197if [ ${rwhod-NO} != "NO" ]; then
198	echo -n ' rwhod';	rwhod
199fi
200
201echo -n ' printer';		lpd
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 grep nfs /etc/fstab > /dev/null ; then
209	echo -n ' nfsiod';		nfsiod -n 4
210fi
211
212# $sendmail_flags is imported from /etc/netstart;
213# if $sendmail_flags is something other than NO, sendmail is run.
214if [ X"${sendmail_flags}" != X"NO" -a -r /etc/sendmail.cf ]; then
215	echo -n ' sendmail';		sendmail ${sendmail_flags} 
216fi
217
218echo -n ' inetd';		inetd
219echo '.'
220
221mount -a -t nfs >/dev/null 2>&1 &	# XXX shouldn't need background
222
223# if [ -x /usr/libexec/xtend ]; then
224# 	echo -n ' xtend';   /usr/libexec/xtend
225# fi
226
227# Make shared lib searching a little faster.  Leave /usr/lib first if you
228# add your own entries or you may come to grief.
229if [ -x /sbin/ldconfig ]; then
230	_LDC=/usr/lib
231	if [ -d /usr/X11R6/lib ]; then _LDC="${_LDC} /usr/X11R6/lib" ; fi
232	if [ -d /usr/X386/lib ]; then _LDC="${_LDC} /usr/X386/lib" ; fi
233	if [ -d /usr/local/lib ]; then _LDC="${_LDC} /usr/local/lib" ; fi
234	if [ -d /usr/gnu/lib ]; then _LDC="${_LDC} /usr/gnu/lib" ; fi
235	echo 'setting ldconfig path:' ${_LDC}
236	ldconfig ${_LDC}
237fi
238
239sh /etc/rc.local
240
241date
242
243exit 0
244