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