rc revision 1.43
1#	@(#)rc	5.27 (Berkeley) 6/5/91
2#	$Id: rc,v 1.43 1994/06/03 05:02:10 jtc Exp $
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
20if [ -e /fastboot ]
21then
22	echo "Fast boot: skipping disk checks."
23elif [ $1x = autobootx ]
24then
25	echo "Automatic boot in progress: starting file system checks."
26	fsck -p
27	case $? in
28	0)
29		;;
30	2)
31		exit 1
32		;;
33	4)
34		echo "Rebooting..."
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 "Boot interrupted."
45		exit 1
46		;;
47	130)
48		# interrupt before catcher installed
49		exit 1
50		;;
51	*)
52		echo "Unknown error; help!"
53		exit 1
54		;;
55	esac
56fi
57
58trap "echo 'Boot interrupted.'; exit 1" 3
59
60swapon -a
61
62umount -a >/dev/null 2>&1
63mount -a -t nonfs
64rm -f /fastboot		# XXX (root now writeable)
65
66# set flags on ttys.  (do early, in case they use tty for SLIP in netstart)
67echo 'setting tty flags'
68ttyflags -a
69
70# set hostname, turn on network
71echo 'starting network'
72. /etc/netstart
73
74mount /usr >/dev/null 2>&1
75mount /var >/dev/null 2>&1
76
77# clean up left-over files
78rm -f /etc/nologin
79rm -f /var/spool/lock/LCK.*
80rm -f /var/spool/uucp/STST/*
81(cd /var/run && { rm -rf -- *; cp /dev/null utmp; chmod 644 utmp; })
82
83echo -n 'starting rpc daemons:'
84echo -n ' portmap';		portmap
85
86if [ -f /usr/sbin/ypbind -a -d /var/yp ]; then
87	echo -n ' ypbind';		ypbind
88fi
89
90# $nfs_server is imported from /etc/netstart;
91# if $nfs_server == YES, the machine is setup for being an nfs server
92if [ X${nfs_server} = X"YES" -a -r /etc/exports ]; then
93	rm -f /var/db/mountdtab	
94	echo -n ' mountd';		mountd
95	echo -n ' nfsd';		nfsd -u 0,0,4 -t 0,0
96fi
97
98# $nfs_client is imported from /etc/netstart;
99# if $nfs_client == YES, the machine is setup for being an nfs client
100if [ X${nfs_client} = X"YES" ]; then
101	echo -n ' nfsiod';		nfsiod 4
102fi
103
104if [ X${amd} = X"YES" -a -d ${amd_dir} -a -r ${amd_master} ]; then
105	echo -n ' amd'
106	amd -l syslog -x error,noinfo,nostats -p > /var/run/amd.pid \
107	    -a ${amd_dir} `cat ${amd_master}`
108fi
109
110echo '.'
111mount -a -t nfs
112
113echo -n 'starting system logger'
114rm -f /dev/log
115syslogd
116
117# $timed_flags is imported from /etc/netstart;
118# if $timed_flags == NO, timed isn't run.
119if [ "X${timed_flags}" != X"NO" ]; then
120	echo -n ', time daemon'; timed $timed_flags
121fi
122echo '.'
123
124# /var/crash should be a directory or a symbolic link
125# to the crash directory if core dumps are to be saved.
126if [ -d /var/crash ]; then
127	echo checking for core dump...
128	savecore /var/crash
129fi
130
131#				echo -n 'checking quotas:'
132#quotacheck -a
133#				echo ' done.'
134#quotaon -a
135
136# build ps databases
137echo 'building databases...'
138kvm_mkdb /netbsd
139dev_mkdb
140
141chmod 666 /dev/tty[pqrs]*
142
143# check the password temp/lock file
144if [ -f /etc/ptmp ]
145then
146	logger -s -p auth.err \
147	'password file may be incorrect -- /etc/ptmp exists'
148fi
149
150virecovery=/var/tmp/vi.recover/recover.*
151if [ "$virecovery" != "/var/tmp/vi.recover/recover.*" ]; then
152	echo preserving editor files
153	for i in $virecovery; do
154		sendmail -t < $i
155	done
156fi
157
158echo clearing /tmp
159
160# prune quickly with one rm, then use find to clean up /tmp/[lq]*
161# (not needed with mfs /tmp, but doesn't hurt there...)
162(cd /tmp && rm -rf [a-km-pr-zA-Z]* &&
163    find . ! -name . ! -name lost+found ! -name quotas \
164	-exec rm -rf -- {} \; -type d -prune)
165
166if [ -f /var/account/acct ]; then
167	echo 'turning on accounting';	accton /var/account/acct
168fi
169
170echo -n standard daemons:
171echo -n ' update';		update
172echo -n ' cron';		cron
173echo '.'
174
175echo -n starting network daemons:
176
177# $gated and $routed_flags are imported from /etc/netstart.
178# If $gated == YES, gated is used; otherwise routed.
179# If $routed_flags == NO, routed isn't run.
180if [ X${gated} = X"YES" -a -r /etc/gated.conf ]; then
181	echo -n ' gated';	gated $gated_flags
182elif [ "X${routed_flags}" != X"NO" ]; then
183	echo -n ' routed';	routed $routed_flags
184fi
185
186# $name_server is imported from /etc/netstart;
187# if $name_server == YES, named is run.
188if [ X${name_server} = X"YES" -a -r /etc/named.boot ]; then
189	echo -n ' named';		named
190fi
191
192# $rwhod is imported from /etc/netstart;
193# if $rwhod == YES, rwhod is run.
194if [ X${rwhod} = X"YES" ]; then
195	echo -n ' rwhod';	rwhod
196fi
197
198echo -n ' printer';		lpd
199
200# $sendmail_flags is imported from /etc/netstart;
201# If $sendmail_flags == NO or /etc/sendmail.cf doesn't exist, then
202# sendmail isn't run.
203if [ "X${sendmail_flags}" != X"NO" -a -r /etc/sendmail.cf ]; then
204	echo -n ' sendmail';		sendmail ${sendmail_flags}
205fi
206
207echo -n ' inetd';		inetd
208
209# $rarpd_flags is importent from /etc/netstart;
210# If $rarpd_flags == NO or /etc/ethers doesn't exist, then
211# rarpd isn't run.
212if [ "X${rarpd_flags}" != X"NO" -a -r /etc/ethers ]; then
213	echo -n ' rarpd';		rarpd ${rarpd_flags}
214fi
215
216# $bootparamd_flags is importent from /etc/netstart;
217# If $bootparamd_flags == NO or /etc/bootparams doesn't exist, then
218# bootparamd isn't run.
219if [ "X${bootparamd_flags}" != X"NO" -a -r /etc/bootparams ]; then
220	echo -n ' rpc.bootparamd';	rpc.bootparamd ${bootparamd_flags}
221fi
222
223echo '.'
224
225. /etc/rc.local
226
227date
228
229exit 0
230