rc revision 1.58
1#	$NetBSD: rc,v 1.58 1996/08/09 10:29:48 thorpej Exp $
2#	from: @(#)rc	8.2 (Berkeley) 3/17/94
3
4# System startup script run by init on autoboot
5# or after single-user.
6# Output and error are redirected to console by init,
7# and the console is the controlling terminal.
8
9stty status '^T'
10
11# Set shell to ignore SIGINT (2), but not children;
12# shell catches SIGQUIT (3) and returns to single user after fsck.
13trap : 2
14trap : 3	# shouldn't be needed
15
16HOME=/; export HOME
17PATH=/sbin:/bin:/usr/sbin:/usr/bin
18export PATH
19
20# Configure ccd devices.
21if [ -f /etc/ccd.conf ]
22then
23	ccdconfig -C
24fi
25
26if [ -e /fastboot ]
27then
28	echo "Fast boot: skipping disk checks."
29elif [ $1x = autobootx ]
30then
31	echo "Automatic boot in progress: starting file system checks."
32	fsck -p
33	case $? in
34	0)
35		;;
36	2)
37		exit 1
38		;;
39	4)
40		echo "Rebooting..."
41		reboot
42		echo "Reboot failed; help!"
43		exit 1
44		;;
45	8)
46		echo "Automatic file system check failed; help!"
47		exit 1
48		;;
49	12)
50		echo "Boot interrupted."
51		exit 1
52		;;
53	130)
54		# interrupt before catcher installed
55		exit 1
56		;;
57	*)
58		echo "Unknown error; help!"
59		exit 1
60		;;
61	esac
62fi
63
64trap "echo 'Boot interrupted.'; exit 1" 3
65
66swapon -a
67
68umount -a >/dev/null 2>&1
69mount -a -t nonfs
70rm -f /fastboot		# XXX (root now writeable)
71
72# set flags on ttys.  (do early, in case they use tty for SLIP in netstart)
73echo 'setting tty flags'
74ttyflags -a
75
76# set hostname, turn on network
77echo 'starting network'
78. /etc/netstart
79
80mount /usr >/dev/null 2>&1
81mount /var >/dev/null 2>&1
82
83# clean up left-over files
84rm -f /etc/nologin
85rm -f /var/spool/lock/LCK.*
86rm -f /var/spool/uucp/STST/*
87(cd /var/run && { rm -rf -- *; install -c -m 664 -g utmp /dev/null utmp; })
88
89echo -n 'starting rpc daemons:'
90echo -n ' portmap';		portmap
91
92if [ X${ypserv_flags} != X"NO" ]; then
93	echo -n ' ypserv';		ypserv ${ypserv_flags}
94fi
95
96if [ X${yppasswdd_flags} != X"NO" ]; then
97	echo -n ' rpc.yppasswdd';	rpc.yppasswdd ${yppasswdd_flags}
98fi
99
100if [ X${ypbind_flags} != X"NO" ]; then
101	echo -n ' ypbind';		ypbind ${ypbind_flags}
102fi
103
104# $nfs_server is imported from /etc/netstart;
105# if $nfs_server == YES, the machine is setup for being an nfs server
106if [ X${nfs_server} = X"YES" -a -r /etc/exports ]; then
107	rm -f /var/db/mountdtab	
108	echo -n > /var/db/mountdtab
109	echo -n ' mountd';		mountd
110	echo -n ' nfsd';		nfsd -tun 4
111fi
112
113# $nfs_client is imported from /etc/netstart;
114# if $nfs_client == YES, the machine is setup for being an nfs client
115if [ X${nfs_client} = X"YES" ]; then
116	echo -n ' nfsiod';		nfsiod -n 4
117fi
118
119if [ X${amd} = X"YES" -a -d ${amd_dir} -a -r ${amd_master} ]; then
120	echo -n ' amd'
121	amd -l syslog -x error,noinfo,nostats -p \
122	    -a ${amd_dir} `cat ${amd_master}` > /var/run/amd.pid
123fi
124
125echo '.'
126mount -a -t nfs
127
128echo -n 'starting system logger'
129rm -f /dev/log
130syslogd
131
132# $timed_flags is imported from /etc/netstart;
133# if $timed_flags == NO, timed isn't run.
134if [ "X${timed_flags}" != X"NO" ]; then
135	echo -n ', time daemon'; timed $timed_flags
136fi
137echo '.'
138
139# /var/crash should be a directory or a symbolic link
140# to the crash directory if core dumps are to be saved.
141if [ -d /var/crash ]; then
142	echo checking for core dump...
143	savecore /var/crash
144fi
145
146				echo -n 'checking quotas:'
147quotacheck -a
148				echo ' done.'
149quotaon -a
150
151# build ps databases
152echo 'building databases...'
153kvm_mkdb /netbsd
154dev_mkdb
155
156chmod 666 /dev/tty[pqrs]*
157
158# check the password temp/lock file
159if [ -f /etc/ptmp ]
160then
161	logger -s -p auth.err \
162	'password file may be incorrect -- /etc/ptmp exists'
163fi
164
165virecovery=/var/tmp/vi.recover/recover.*
166if [ "$virecovery" != "/var/tmp/vi.recover/recover.*" ]; then
167	echo preserving editor files
168	for i in $virecovery; do
169		sendmail -t < $i
170	done
171fi
172
173echo clearing /tmp
174
175# prune quickly with one rm, then use find to clean up /tmp/[lq]*
176# (not needed with mfs /tmp, but doesn't hurt there...)
177(cd /tmp && rm -rf [a-km-pr-zA-Z]* &&
178    find . ! -name . ! -name lost+found ! -name quota.user \
179	! -name quota.group -exec rm -rf -- {} \; -type d -prune)
180
181if [ -f /var/account/acct ]; then
182	echo 'turning on accounting';	accton /var/account/acct
183fi
184
185echo -n standard daemons:
186echo -n ' update';		update
187echo -n ' cron';		cron
188echo '.'
189
190echo -n starting network daemons:
191
192# $gated and $routed_flags are imported from /etc/netstart.
193# If $gated == YES, gated is used; otherwise routed.
194# If $routed_flags == NO, routed isn't run.
195if [ X${gated} = X"YES" -a -r /etc/gated.conf ]; then
196	echo -n ' gated';		gated $gated_flags
197elif [ "X${routed_flags}" != X"NO" ]; then
198	echo -n ' routed';		routed $routed_flags
199fi
200
201# $mrouted_flags is imported from /etc/netstart;
202# If $mrouted_flags == NO, then mrouted isn't run.
203if [ "X${mrouted_flags}" != X"NO" ]; then
204	echo -n ' mrouted';		mrouted $mrouted_flags
205fi
206
207# $named_flags is imported from /etc/netstart;
208# if $named_flags != NO, named is run.
209if [ "X${named_flags}" != X"NO" ]; then
210	echo -n ' named';		named $named_flags
211fi
212
213# $rwhod is imported from /etc/netstart;
214# if $rwhod == YES, rwhod is run.
215if [ X${rwhod} = X"YES" ]; then
216	echo -n ' rwhod';		rwhod
217fi
218
219echo -n ' printer';		lpd
220
221# $sendmail_flags is imported from /etc/netstart;
222# If $sendmail_flags == NO or /etc/sendmail.cf doesn't exist, then
223# sendmail isn't run.  We call sendmail with a full path so that
224# SIGHUP works.
225if [ "X${sendmail_flags}" != X"NO" -a -r /etc/sendmail.cf ]; then
226	echo -n ' sendmail';		/usr/sbin/sendmail ${sendmail_flags}
227fi
228
229echo -n ' inetd';		inetd
230
231# $rarpd_flags is imported from /etc/netstart;
232# If $rarpd_flags == NO or /etc/ethers doesn't exist, then
233# rarpd isn't run.
234if [ "X${rarpd_flags}" != X"NO" -a -r /etc/ethers ]; then
235	echo -n ' rarpd';		rarpd ${rarpd_flags}
236fi
237
238# $bootparamd_flags is imported from /etc/netstart;
239# If $bootparamd_flags == NO or /etc/bootparams doesn't exist, then
240# bootparamd isn't run.
241if [ "X${bootparamd_flags}" != X"NO" -a -r /etc/bootparams ]; then
242	echo -n ' rpc.bootparamd';	rpc.bootparamd ${bootparamd_flags}
243fi
244
245# $rbootd_flags is imported from /etc/netstart;
246# If $rbootd_flags == NO or /etc/rbootd.conf doesn't exist, then
247# rbootd isn't run.
248if [ "X${rbootd_flags}" != X"NO" -a -r /etc/rbootd.conf ]; then
249	echo -n ' rbootd';		rbootd ${rbootd_flags}
250fi
251
252echo '.'
253
254. /etc/rc.local
255
256date
257exit 0
258