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