rc revision 1.67 1 1.67 mycroft # $NetBSD: rc,v 1.67 1997/03/10 09:16:13 mycroft Exp $
2 1.45 cgd # from: @(#)rc 8.2 (Berkeley) 3/17/94
3 1.1 cgd
4 1.1 cgd # System startup script run by init on autoboot
5 1.1 cgd # or after single-user.
6 1.1 cgd # Output and error are redirected to console by init,
7 1.1 cgd # and the console is the controlling terminal.
8 1.1 cgd
9 1.1 cgd stty status '^T'
10 1.1 cgd
11 1.1 cgd # Set shell to ignore SIGINT (2), but not children;
12 1.1 cgd # shell catches SIGQUIT (3) and returns to single user after fsck.
13 1.1 cgd trap : 2
14 1.1 cgd trap : 3 # shouldn't be needed
15 1.1 cgd
16 1.1 cgd HOME=/; export HOME
17 1.1 cgd PATH=/sbin:/bin:/usr/sbin:/usr/bin
18 1.1 cgd export PATH
19 1.50 thorpej
20 1.50 thorpej # Configure ccd devices.
21 1.63 mrg if [ -f /etc/ccd.conf ]; then
22 1.50 thorpej ccdconfig -C
23 1.50 thorpej fi
24 1.1 cgd
25 1.63 mrg if [ -e /fastboot ]; then
26 1.38 cgd echo "Fast boot: skipping disk checks."
27 1.63 mrg elif [ $1x = autobootx ]; then
28 1.38 cgd echo "Automatic boot in progress: starting file system checks."
29 1.1 cgd fsck -p
30 1.1 cgd case $? in
31 1.1 cgd 0)
32 1.1 cgd ;;
33 1.1 cgd 2)
34 1.1 cgd exit 1
35 1.1 cgd ;;
36 1.1 cgd 4)
37 1.35 cgd echo "Rebooting..."
38 1.1 cgd reboot
39 1.38 cgd echo "Reboot failed; help!"
40 1.1 cgd exit 1
41 1.1 cgd ;;
42 1.1 cgd 8)
43 1.38 cgd echo "Automatic file system check failed; help!"
44 1.1 cgd exit 1
45 1.1 cgd ;;
46 1.1 cgd 12)
47 1.38 cgd echo "Boot interrupted."
48 1.1 cgd exit 1
49 1.1 cgd ;;
50 1.1 cgd 130)
51 1.1 cgd # interrupt before catcher installed
52 1.1 cgd exit 1
53 1.1 cgd ;;
54 1.1 cgd *)
55 1.38 cgd echo "Unknown error; help!"
56 1.1 cgd exit 1
57 1.1 cgd ;;
58 1.1 cgd esac
59 1.1 cgd fi
60 1.1 cgd
61 1.38 cgd trap "echo 'Boot interrupted.'; exit 1" 3
62 1.1 cgd
63 1.1 cgd swapon -a
64 1.1 cgd
65 1.1 cgd umount -a >/dev/null 2>&1
66 1.1 cgd mount -a -t nonfs
67 1.1 cgd rm -f /fastboot # XXX (root now writeable)
68 1.40 cgd
69 1.63 mrg if [ -s /etc/rc.conf ]; then
70 1.63 mrg . /etc/rc.conf
71 1.63 mrg fi
72 1.63 mrg
73 1.40 cgd # set flags on ttys. (do early, in case they use tty for SLIP in netstart)
74 1.40 cgd echo 'setting tty flags'
75 1.40 cgd ttyflags -a
76 1.1 cgd
77 1.63 mrg # load any kernel modules specified in /etc/lkm.conf
78 1.67 mycroft if [ "$lkm_init" != NO ] && [ -f /etc/rc.lkm ]; then
79 1.63 mrg . /etc/rc.lkm
80 1.63 mrg fi
81 1.63 mrg
82 1.1 cgd # set hostname, turn on network
83 1.1 cgd echo 'starting network'
84 1.1 cgd . /etc/netstart
85 1.1 cgd
86 1.26 deraadt mount /usr >/dev/null 2>&1
87 1.42 mycroft mount /var >/dev/null 2>&1
88 1.26 deraadt
89 1.41 jtc # clean up left-over files
90 1.41 jtc rm -f /etc/nologin
91 1.41 jtc rm -f /var/spool/lock/LCK.*
92 1.41 jtc rm -f /var/spool/uucp/STST/*
93 1.45 cgd (cd /var/run && { rm -rf -- *; install -c -m 664 -g utmp /dev/null utmp; })
94 1.41 jtc
95 1.63 mrg # start the system logger first, so that all messages
96 1.63 mrg # from daemons are logged, and the name server next.
97 1.63 mrg
98 1.67 mycroft if [ "$syslogd_flags" != NO ]; then
99 1.67 mycroft if [ "$syslogd_flags" = DEFAULT ]; then
100 1.67 mycroft syslogd_flags=""
101 1.67 mycroft fi
102 1.63 mrg echo 'starting system logger'
103 1.63 mrg rm -f /dev/log
104 1.63 mrg syslogd $syslogd_flags
105 1.63 mrg fi
106 1.63 mrg
107 1.67 mycroft if [ "$named_flags" != NO ]; then
108 1.67 mycroft if [ "$named_flags" = DEFAULT ]; then
109 1.67 mycroft named_flags=""
110 1.67 mycroft fi
111 1.63 mrg echo 'starting name server'; named $named_flags
112 1.63 mrg fi
113 1.63 mrg
114 1.63 mrg # now start the rpc servers, for YP server/client, NFS.
115 1.63 mrg echo -n 'starting rpc daemons:'
116 1.63 mrg
117 1.63 mrg # note that portmap is generally required for all other rpc services.
118 1.67 mycroft if [ "$portmap" != NO ]; then
119 1.63 mrg echo -n ' portmap'; portmap
120 1.63 mrg fi
121 1.63 mrg
122 1.67 mycroft if [ "$ypserv_flags" != NO ]; then
123 1.67 mycroft if [ "$ypserv_flags" = DEFAULT ]; then
124 1.67 mycroft ypserv_flags="-d"
125 1.67 mycroft fi
126 1.63 mrg echo -n ' ypserv'; ypserv $ypserv_flags
127 1.63 mrg fi
128 1.63 mrg
129 1.67 mycroft if [ "$ypbind_flags" != NO ]; then
130 1.67 mycroft if [ "$ypbind_flags" = DEFAULT ]; then
131 1.67 mycroft ypbind_flags=""
132 1.67 mycroft fi
133 1.63 mrg echo -n ' ypbind'; ypbind $ypbind_flags
134 1.63 mrg fi
135 1.63 mrg
136 1.67 mycroft if [ "$yppasswdd_flags" != NO ]; then
137 1.67 mycroft if [ "$yppasswdd_flags" = DEFAULT ]; then
138 1.67 mycroft yppasswdd_flags=""
139 1.67 mycroft fi
140 1.63 mrg echo -n ' rpc.yppasswdd'; rpc.yppasswdd $yppasswdd_flags
141 1.63 mrg fi
142 1.63 mrg
143 1.67 mycroft if [ "$bootparamd_flags" != NO ] && [ -r /etc/bootparams ]; then
144 1.67 mycroft if [ "$bootparamd_flags" = DEFAULT ]; then
145 1.67 mycroft bootparamd_flags=""
146 1.67 mycroft fi
147 1.63 mrg echo -n ' rpc.bootparamd'; rpc.bootparamd $bootparamd_flags
148 1.63 mrg fi
149 1.63 mrg
150 1.67 mycroft nfs_locking=NO
151 1.67 mycroft
152 1.67 mycroft if [ "$nfs_server" = YES ] && [ -r /etc/exports ]; then
153 1.67 mycroft if [ "$nfsd_flags" = DEFAULT ]; then
154 1.63 mrg nfsd_flags="-tun 4"
155 1.63 mrg fi
156 1.63 mrg rm -f /var/db/mountdtab
157 1.63 mrg echo -n > /var/db/mountdtab
158 1.63 mrg echo -n ' mountd'; mountd $mountd_flags
159 1.63 mrg echo -n ' nfsd'; nfsd $nfsd_flags
160 1.67 mycroft nfs_locking=MAYBE
161 1.1 cgd fi
162 1.63 mrg
163 1.67 mycroft if [ "$nfs_client" = YES ]; then
164 1.67 mycroft if [ "$nfsiod_flags" = DEFAULT ]; then
165 1.63 mrg nfsiod_flags="-n 4"
166 1.63 mrg fi
167 1.63 mrg echo -n ' nfsiod'; nfsiod $nfsiod_flags
168 1.67 mycroft nfs_locking=MAYBE
169 1.66 scottr fi
170 1.66 scottr
171 1.67 mycroft if [ "$nfs_locking" != NO ]; then
172 1.67 mycroft if [ "$statd_flags" != NO ]; then
173 1.67 mycroft if [ "$statd_flags" = DEFAULT ]; then
174 1.67 mycroft statd_flags=""
175 1.67 mycroft fi
176 1.66 scottr echo ' statd'; rpc.statd $statd_flags
177 1.66 scottr fi
178 1.66 scottr
179 1.67 mycroft if [ "$lockd_flags" != NO ]; then
180 1.67 mycroft if [ "$lockd_flags" = DEFAULT ]; then
181 1.67 mycroft lockd_flags=""
182 1.67 mycroft fi
183 1.66 scottr echo ' lockd'; rpc.lockd $lockd_flags
184 1.66 scottr fi
185 1.63 mrg fi
186 1.63 mrg
187 1.67 mycroft if [ "$amd_flags" != NO ] && [ -d "$amd_dir" -a -r "$amd_master" ]; then
188 1.67 mycroft if [ "$amd_flags" = DEFAULT ]; then
189 1.67 mycroft amd_flags="-l syslog -x error,noinfo,nostats"
190 1.67 mycroft fi
191 1.63 mrg echo -n ' amd'
192 1.63 mrg amd $amd_flags -p -a $amd_dir `cat $amd_master` > /var/run/amd.pid
193 1.63 mrg fi
194 1.63 mrg
195 1.1 cgd echo '.'
196 1.63 mrg mount -a -t nfs
197 1.63 mrg
198 1.63 mrg if [ -f /sbin/ldconfig ]; then
199 1.63 mrg echo 'creating runtime link editor directory cache.'
200 1.63 mrg if [ -s /etc/ld.so.conf ]; then
201 1.63 mrg ldconfig `cat /etc/ld.so.conf`
202 1.63 mrg else
203 1.63 mrg ldconfig
204 1.63 mrg fi
205 1.63 mrg fi
206 1.1 cgd
207 1.1 cgd # /var/crash should be a directory or a symbolic link
208 1.1 cgd # to the crash directory if core dumps are to be saved.
209 1.67 mycroft if [ "$savecore_flags" != NO ] && [ -d /var/crash ]; then
210 1.67 mycroft if [ "$savecore_flags" = DEFAULT ]; then
211 1.67 mycroft savecore_flags=""
212 1.67 mycroft fi
213 1.1 cgd echo checking for core dump...
214 1.63 mrg savecore $savecore_flags /var/crash
215 1.1 cgd fi
216 1.1 cgd
217 1.47 deraadt echo -n 'checking quotas:'
218 1.47 deraadt quotacheck -a
219 1.47 deraadt echo ' done.'
220 1.47 deraadt quotaon -a
221 1.1 cgd
222 1.1 cgd # build ps databases
223 1.2 cgd echo 'building databases...'
224 1.11 cgd kvm_mkdb /netbsd
225 1.1 cgd dev_mkdb
226 1.1 cgd
227 1.1 cgd chmod 666 /dev/tty[pqrs]*
228 1.1 cgd
229 1.1 cgd # check the password temp/lock file
230 1.1 cgd if [ -f /etc/ptmp ]
231 1.1 cgd then
232 1.1 cgd logger -s -p auth.err \
233 1.1 cgd 'password file may be incorrect -- /etc/ptmp exists'
234 1.1 cgd fi
235 1.1 cgd
236 1.32 mycroft virecovery=/var/tmp/vi.recover/recover.*
237 1.32 mycroft if [ "$virecovery" != "/var/tmp/vi.recover/recover.*" ]; then
238 1.32 mycroft echo preserving editor files
239 1.32 mycroft for i in $virecovery; do
240 1.32 mycroft sendmail -t < $i
241 1.32 mycroft done
242 1.32 mycroft fi
243 1.1 cgd
244 1.1 cgd echo clearing /tmp
245 1.1 cgd
246 1.65 mikel # Prune quickly with one rm, then use find to clean up /tmp/[lq]* (this
247 1.65 mikel # is not needed with mfs /tmp, but doesn't hurt anything).
248 1.1 cgd (cd /tmp && rm -rf [a-km-pr-zA-Z]* &&
249 1.46 deraadt find . ! -name . ! -name lost+found ! -name quota.user \
250 1.46 deraadt ! -name quota.group -exec rm -rf -- {} \; -type d -prune)
251 1.1 cgd
252 1.34 cgd if [ -f /var/account/acct ]; then
253 1.34 cgd echo 'turning on accounting'; accton /var/account/acct
254 1.34 cgd fi
255 1.1 cgd
256 1.1 cgd echo -n standard daemons:
257 1.1 cgd echo -n ' update'; update
258 1.31 jtc echo -n ' cron'; cron
259 1.1 cgd echo '.'
260 1.1 cgd
261 1.63 mrg # now start all the other daemons
262 1.1 cgd echo -n starting network daemons:
263 1.1 cgd
264 1.67 mycroft if [ "$gated_flags" != NO ] && [ -r /etc/gated.conf ]; then
265 1.67 mycroft if [ "$gated_flags" = DEFAULT ]; then
266 1.67 mycroft gated_flags=""
267 1.67 mycroft fi
268 1.48 mycroft echo -n ' gated'; gated $gated_flags
269 1.67 mycroft elif [ "$routed_flags" != NO ]; then
270 1.67 mycroft if [ "$routed_flags" = DEFAULT ]; then
271 1.67 mycroft routed_flags="-q"
272 1.67 mycroft fi
273 1.48 mycroft echo -n ' routed'; routed $routed_flags
274 1.1 cgd fi
275 1.1 cgd
276 1.67 mycroft if [ "$mrouted_flags" != NO ]; then
277 1.67 mycroft if [ "$mrouted_flags" = DEFAULT ]; then
278 1.67 mycroft mrouted_flags=""
279 1.67 mycroft fi
280 1.55 thorpej echo -n ' mrouted'; mrouted $mrouted_flags
281 1.55 thorpej fi
282 1.55 thorpej
283 1.67 mycroft if [ "$timed_flags" != NO ]; then
284 1.67 mycroft if [ "$timed_flags" = DEFAULT ]; then
285 1.67 mycroft timed_flags=""
286 1.67 mycroft fi
287 1.67 mycroft echo -n ' timed'; timed $timed_flags
288 1.63 mrg fi
289 1.63 mrg
290 1.67 mycroft if [ "$xntpd_flags" != NO ]; then
291 1.67 mycroft if [ "$xntpd_flags" = DEFAULT ]; then
292 1.67 mycroft xntpd_flags=""
293 1.67 mycroft fi
294 1.67 mycroft echo -n ' xntpd'; xntpd $xntpd_flags
295 1.61 mrg fi
296 1.61 mrg
297 1.67 mycroft if [ "$dhcpd_flags" != NO ] && [ -r /etc/dhcpd.conf ]; then
298 1.67 mycroft if [ "$dhcpd_flags" = DEFAULT ]; then
299 1.67 mycroft dhcpd_flags=""
300 1.67 mycroft fi
301 1.61 mrg echo -n ' dhcpd'; dhcpd $dhcpd_flags
302 1.29 mycroft fi
303 1.29 mycroft
304 1.67 mycroft if [ "$rwhod" = YES ]; then
305 1.48 mycroft echo -n ' rwhod'; rwhod
306 1.1 cgd fi
307 1.1 cgd
308 1.67 mycroft if [ "$lpd_flags" != NO ]; then
309 1.67 mycroft if [ "$lpd_flags" = DEFAULT ]; then
310 1.67 mycroft lpd_flags=""
311 1.67 mycroft fi
312 1.63 mrg echo -n ' printer'; lpd $lpd_flags
313 1.60 tls fi
314 1.60 tls
315 1.63 mrg # We call sendmail with a full path so that SIGHUP works.
316 1.67 mycroft if [ "$sendmail_flags" != NO ] && [ -r /etc/sendmail.cf ]; then
317 1.67 mycroft if [ "$sendmail_flags" = DEFAULT ]; then
318 1.67 mycroft sendmail_flags="-bd -q30m"
319 1.67 mycroft fi
320 1.63 mrg echo -n ' sendmail'; /usr/sbin/sendmail $sendmail_flags
321 1.60 tls fi
322 1.60 tls
323 1.67 mycroft if [ "$rarpd_flags" != NO ] && [ -r /etc/ethers ]; then
324 1.67 mycroft if [ "$rarpd_flags" = DEFAULT ]; then
325 1.67 mycroft rarpd_flags="-a"
326 1.67 mycroft fi
327 1.63 mrg echo -n ' rarpd'; rarpd $rarpd_flags
328 1.60 tls fi
329 1.60 tls
330 1.67 mycroft if [ "$rbootd_flags" != NO ] && [ -r /etc/rbootd.conf ]; then
331 1.67 mycroft if [ "$rbootd_flags" = DEFAULT ]; then
332 1.67 mycroft rbootd_flags=""
333 1.67 mycroft fi
334 1.63 mrg echo -n ' rbootd'; rbootd $rbootd_flags
335 1.52 thorpej fi
336 1.52 thorpej
337 1.67 mycroft if [ "$inetd_flags" != NO ] && [ -r /etc/inetd.conf ]; then
338 1.67 mycroft if [ "$inetd_flags" = DEFAULT ]; then
339 1.67 mycroft inetd_flags=""
340 1.67 mycroft fi
341 1.63 mrg echo -n ' inetd'; inetd $inetd_flags
342 1.30 mycroft fi
343 1.30 mycroft
344 1.1 cgd echo '.'
345 1.1 cgd
346 1.25 mycroft . /etc/rc.local
347 1.1 cgd
348 1.1 cgd date
349 1.1 cgd exit 0
350