Annotation of src/etc/rc, Revision 1.104
1.104 ! tron 1: # $NetBSD: rc,v 1.103 1998/04/07 04:47:33 mrg Exp $
1.73 perry 2: # originally from: @(#)rc 8.2 (Berkeley) 3/17/94
1.1 cgd 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:
9: stty 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.
13: trap : 2
14: trap : 3 # shouldn't be needed
15:
1.68 mycroft 16: export HOME=/
1.96 jonathan 17: export PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/X11R6/bin
1.50 thorpej 18:
19: # Configure ccd devices.
1.63 mrg 20: if [ -f /etc/ccd.conf ]; then
1.50 thorpej 21: ccdconfig -C
22: fi
1.1 cgd 23:
1.79 thorpej 24: # Add all block-type swap devices; these might be necessary
25: # during disk checks.
26: swapctl -A -t blk
27:
1.63 mrg 28: if [ -e /fastboot ]; then
1.38 cgd 29: echo "Fast boot: skipping disk checks."
1.68 mycroft 30: elif [ "$1" = autoboot ]; then
1.38 cgd 31: echo "Automatic boot in progress: starting file system checks."
1.1 cgd 32: fsck -p
33: case $? in
34: 0)
35: ;;
36: 2)
37: exit 1
38: ;;
39: 4)
1.35 cgd 40: echo "Rebooting..."
1.1 cgd 41: reboot
1.38 cgd 42: echo "Reboot failed; help!"
1.1 cgd 43: exit 1
44: ;;
45: 8)
1.38 cgd 46: echo "Automatic file system check failed; help!"
1.1 cgd 47: exit 1
48: ;;
49: 12)
1.38 cgd 50: echo "Boot interrupted."
1.1 cgd 51: exit 1
52: ;;
53: 130)
54: # interrupt before catcher installed
55: exit 1
56: ;;
57: *)
1.38 cgd 58: echo "Unknown error; help!"
1.1 cgd 59: exit 1
60: ;;
61: esac
62: fi
63:
1.38 cgd 64: trap "echo 'Boot interrupted.'; exit 1" 3
1.1 cgd 65:
66: umount -a >/dev/null 2>&1
1.83 drochner 67: mount /
1.1 cgd 68: rm -f /fastboot # XXX (root now writeable)
1.40 cgd 69:
1.90 veego 70: if [ -f /etc/rc.subr ]; then
71: . /etc/rc.subr
1.89 cjs 72: else
1.90 veego 73: echo "Can't read /etc/rc.subr; aborting."
1.89 cjs 74: exit 1;
75: fi
76:
1.71 mycroft 77: if [ -f /etc/rc.conf ]; then
1.63 mrg 78: . /etc/rc.conf
79: fi
80:
1.89 cjs 81: if [ "$rc_configured" != YES ]; then
82: echo "/etc/rc.conf is not configured. Multiuser boot aborted."
83: exit 1
84: fi
85:
1.40 cgd 86: # set flags on ttys. (do early, in case they use tty for SLIP in netstart)
87: echo 'setting tty flags'
88: ttyflags -a
1.1 cgd 89:
1.83 drochner 90: # load kernel modules specified in /etc/lkm.conf if the /usr filesystem
91: # is already present with "/" or can be mounted now
1.93 drochner 92: if checkyesno lkm && [ -f /etc/rc.lkm ]; then
1.83 drochner 93: mount /usr >/dev/null 2>&1
94: if [ -x /usr/bin/ld ]; then
95: lkmstage=BEFORENET
96: . /etc/rc.lkm
97: fi
1.63 mrg 98: fi
99:
1.1 cgd 100: # set hostname, turn on network
101: echo 'starting network'
1.76 scottr 102: sh /etc/netstart
103: if [ $? -ne 0 ]; then
104: exit 1
105: fi
1.1 cgd 106:
1.95 drochner 107: for fs in /usr /var $critical_filesystems; do
108: mount | (
109: ismounted=no
110: while read what _on on _type type; do
111: if [ $on = $fs ]; then
112: ismounted=yes
113: fi
114: done
115: if [ $ismounted = no ]; then
116: mount $fs >/dev/null 2>&1
117: fi
118: )
119: done
1.99 veego 120:
121: # Network Address Translation...
1.100 lukem 122: if checkyesno ipnat && [ -f /etc/ipnat.conf ]; then
1.99 veego 123: echo 'installing NAT rules ... '
1.100 lukem 124: if ! checkyesno ipfilter || [ ! -f /etc/ipf.conf ]; then
1.99 veego 125: ipf -E -Fa
126: fi
127: ipnat -F -f /etc/ipnat.conf
128: fi
1.79 thorpej 129:
130: # "Critical" file systems are now mounted. Go ahead and swap
131: # to files now, since they will be residing in the critical file
132: # systems (or, at least, better).
133: swapctl -A -t noblk
1.97 mrg 134:
135: # Check for no swap, and warn about it unless that is desired.
1.100 lukem 136: if ! checkyesno no_swap; then
1.97 mrg 137: swapctl -s | grep 'no swap devices configured' > /dev/null && \
138: echo "WARNING: no swap space configured!"
139: fi
1.26 deraadt 140:
1.41 jtc 141: # clean up left-over files
142: rm -f /etc/nologin
143: rm -f /var/spool/lock/LCK.*
144: rm -f /var/spool/uucp/STST/*
1.45 cgd 145: (cd /var/run && { rm -rf -- *; install -c -m 664 -g utmp /dev/null utmp; })
1.41 jtc 146:
1.84 veego 147: # start the system logger first, so that all messages from daemons
148: # are logged, then start savecore to get a dump on low memory systems
149: # and then start the name server.
1.63 mrg 150:
1.89 cjs 151: if checkyesno syslogd; then
1.63 mrg 152: echo 'starting system logger'
153: rm -f /dev/log
154: syslogd $syslogd_flags
1.94 lukem 155: fi
156:
157: # Enable ipmon (only useful if ipfilter is running)
158: # NOTE: requires the IPFILTER_LOG kernel option.
159: if checkyesno ipmon; then
160: echo 'starting ipmon'
161: ipmon $ipmon_flags &
1.63 mrg 162: fi
163:
1.84 veego 164: # /var/crash should be a directory or a symbolic link
165: # to the crash directory if core dumps are to be saved.
1.89 cjs 166: if checkyesno savecore; then
167: if [ -d /var/crash ]; then
168: echo checking for core dump...
169: savecore $savecore_flags /var/crash
170: else
171: logger -s "WARNING: no /var/crash directory; savecore not run."
1.84 veego 172: fi
173: fi
174:
1.89 cjs 175: if checkyesno named; then
176: echo 'starting name server'; named $named_flags
177: fi
178:
179: # set time, if requested
180: if checkyesno ntpdate; then
1.91 mikel 181: if [ -z "$ntpdate_hosts" ]; then
1.101 lukem 182: ntpdate_hosts=`awk '
183: /^server[ \t]*127.127/ {next}
184: /^server/ {print $2}
185: ' </etc/ntp.conf`
1.89 cjs 186: fi
187: if [ -n "$ntpdate_hosts" ]; then
188: echo 'Setting date via ntp.'
1.102 lukem 189: ntpdate -b -s $ntpdate_hosts
1.67 mycroft 190: fi
1.63 mrg 191: fi
192:
1.84 veego 193: # now start the rpc servers, for YP server/client.
1.63 mrg 194: echo -n 'starting rpc daemons:'
195:
196: # note that portmap is generally required for all other rpc services.
1.89 cjs 197: if checkyesno portmap; then
1.63 mrg 198: echo -n ' portmap'; portmap
199: fi
200:
1.89 cjs 201: if checkyesno ypserv; then
1.63 mrg 202: echo -n ' ypserv'; ypserv $ypserv_flags
203: fi
204:
1.89 cjs 205: if checkyesno ypbind; then
1.63 mrg 206: echo -n ' ypbind'; ypbind $ypbind_flags
207: fi
208:
1.89 cjs 209: if checkyesno yppasswdd; then
1.63 mrg 210: echo -n ' rpc.yppasswdd'; rpc.yppasswdd $yppasswdd_flags
211: fi
212:
1.89 cjs 213: if checkyesno bootparamd; then
214: if [ -r /etc/bootparams ]; then
215: echo -n ' rpc.bootparamd'; rpc.bootparamd $bootparamd_flags
216: else
217: echo
218: logger -s "WARNING: /etc/bootparams not found. " \
219: "bootparamd not started."
1.67 mycroft 220: fi
1.63 mrg 221: fi
222:
1.84 veego 223: echo '.'
224:
225: # load kernel modules specified in /etc/lkm.conf
1.89 cjs 226: if checkyesno lkm; then
227: if [ -r /etc/rc.lkm ]; then
228: lkmstage=BEFOREMOUNT
229: . /etc/rc.lkm
230: else
231: logger -s "WARNING: /etc/rc.lkm not found; LKMs not loaded."
232: fi
1.84 veego 233: fi
234:
235: mount -a
236:
237: # now start the rpc servers, for NFS server/client.
1.90 veego 238: echo -n 'starting nfs daemons:'
1.84 veego 239:
1.67 mycroft 240: nfs_locking=NO
241:
1.89 cjs 242: if checkyesno nfs_server; then
243: if [ -r /etc/exports ]; then
244: rm -f /var/db/mountdtab
245: echo -n > /var/db/mountdtab
246: echo -n ' mountd'; mountd $mountd_flags
247: echo -n ' nfsd'; nfsd $nfsd_flags
1.100 lukem 248: nfs_locking=YES
1.89 cjs 249: else
250: echo
251: logger -s "WARNING: /etc/exports not readable; " \
252: "NFS server not started."
1.69 mycroft 253: fi
1.1 cgd 254: fi
1.63 mrg 255:
1.89 cjs 256: if checkyesno nfs_client; then
1.63 mrg 257: echo -n ' nfsiod'; nfsiod $nfsiod_flags
1.100 lukem 258: nfs_locking=YES
1.66 scottr 259: fi
260:
1.100 lukem 261: if checkyesno nfs_locking; then
1.89 cjs 262: if checkyesno statd; then
1.71 mycroft 263: echo -n ' rpc.statd'; rpc.statd $statd_flags
1.66 scottr 264: fi
1.89 cjs 265: if checkyesno lockd; then
1.71 mycroft 266: echo -n ' rpc.lockd'; rpc.lockd $lockd_flags
1.66 scottr 267: fi
1.63 mrg 268: fi
269:
1.89 cjs 270: if checkyesno amd; then
271: if [ -d "$amd_dir" ]; then
272: if [ -r "$amd_master" ]; then
273: echo -n ' amd'
1.104 ! tron 274: amd $amd_flags -p -a $amd_dir \
! 275: `sed s/#.*$// <$amd_master` >/var/run/amd.pid
1.89 cjs 276: else
277: echo
278: logger -s "WARNING: \$amd_master ($amd_master)not " \
279: "readable; amd not started."
280: fi
281: else
282: echo
283: logger -s "WARNING: \$amd_dir ($amd_dir) not a directory; " \
284: "amd not started."
1.67 mycroft 285: fi
1.63 mrg 286: fi
287:
1.1 cgd 288: echo '.'
1.83 drochner 289:
1.63 mrg 290: if [ -f /sbin/ldconfig ]; then
291: echo 'creating runtime link editor directory cache.'
1.88 thorpej 292: ldconfig
1.63 mrg 293: fi
1.83 drochner 294:
295: # load kernel modules specified in /etc/lkm.conf
1.89 cjs 296: if checkyesno lkm && [ -f /etc/rc.lkm ]; then
1.83 drochner 297: lkmstage=AFTERMOUNT
298: . /etc/rc.lkm
1.1 cgd 299: fi
300:
1.89 cjs 301: echo -n 'checking quotas:'; quotacheck -a; echo ' done.'
1.47 deraadt 302: quotaon -a
1.1 cgd 303:
304: # build ps databases
1.2 cgd 305: echo 'building databases...'
1.11 cgd 306: kvm_mkdb /netbsd
1.1 cgd 307: dev_mkdb
308:
309: chmod 666 /dev/tty[pqrs]*
310:
311: # check the password temp/lock file
312: if [ -f /etc/ptmp ]
313: then
314: logger -s -p auth.err \
315: 'password file may be incorrect -- /etc/ptmp exists'
316: fi
317:
1.85 perry 318: virecovery=`echo /var/tmp/vi.recover/recover.*`
1.32 mycroft 319: if [ "$virecovery" != "/var/tmp/vi.recover/recover.*" ]; then
320: echo preserving editor files
321: for i in $virecovery; do
322: sendmail -t < $i
323: done
324: fi
1.1 cgd 325:
326: echo clearing /tmp
327:
1.65 mikel 328: # Prune quickly with one rm, then use find to clean up /tmp/[lq]* (this
329: # is not needed with mfs /tmp, but doesn't hurt anything).
1.1 cgd 330: (cd /tmp && rm -rf [a-km-pr-zA-Z]* &&
1.46 deraadt 331: find . ! -name . ! -name lost+found ! -name quota.user \
332: ! -name quota.group -exec rm -rf -- {} \; -type d -prune)
1.1 cgd 333:
1.74 perry 334: # Update kernel info in /etc/motd
335: # Must be done *before* interactive logins are possible to prevent
336: # possible race conditions.
1.89 cjs 337: if checkyesno update_motd; then
1.74 perry 338: echo 'updating motd.'
339: if [ ! -f /etc/motd ]; then
340: install -c -o root -g wheel -m 664 /dev/null /etc/motd
341: fi
342: T=/tmp/_motd
343: rm -f $T
344: sysctl -n kern.version | sed 1q > $T
345: echo "" >> $T
346: sed '1,/^$/d' < /etc/motd >> $T
347: cmp -s $T /etc/motd || cp $T /etc/motd
348: rm -f $T
349: fi
350:
1.34 cgd 351: if [ -f /var/account/acct ]; then
352: echo 'turning on accounting'; accton /var/account/acct
353: fi
1.1 cgd 354:
355: echo -n standard daemons:
1.89 cjs 356: if checkyesno update; then
1.70 mycroft 357: echo -n ' update'; update $update_flags
358: fi
1.31 jtc 359: echo -n ' cron'; cron
1.1 cgd 360: echo '.'
361:
1.63 mrg 362: # now start all the other daemons
1.1 cgd 363: echo -n starting network daemons:
364:
1.89 cjs 365: if checkyesno gated && checkyesno routed; then
366: echo
367: logger -s "WARNING: gated and routed both requested to be run: " \
368: "running only gated."
369: routed=NO
370: fi
371:
372: if checkyesno gated; then
373: if [ -r /etc/gated.conf ]; then
374: echo -n ' gated'; gated $gated_flags
375: else
376: logger -s "WARNING: no /etc/gated.conf; gated not started."
1.67 mycroft 377: fi
1.89 cjs 378: fi
379:
380: if checkyesno routed; then
1.48 mycroft 381: echo -n ' routed'; routed $routed_flags
1.1 cgd 382: fi
383:
1.89 cjs 384: if checkyesno mrouted; then
1.55 thorpej 385: echo -n ' mrouted'; mrouted $mrouted_flags
386: fi
387:
1.89 cjs 388: if checkyesno timed; then
1.67 mycroft 389: echo -n ' timed'; timed $timed_flags
1.63 mrg 390: fi
391:
1.89 cjs 392: if checkyesno xntpd; then
1.67 mycroft 393: echo -n ' xntpd'; xntpd $xntpd_flags
1.61 mrg 394: fi
395:
1.89 cjs 396: if checkyesno dhcpd; then
397: if [ -r /etc/dhcpd.conf ]; then
398: echo -n ' dhcpd'; dhcpd $dhcpd_flags
399: else
400: echo
401: logger -s "WARNING: /etc/dhcpd.conf not readable; " \
402: "dhcpd not started."
1.67 mycroft 403: fi
1.29 mycroft 404: fi
405:
1.89 cjs 406: if checkyesno rwhod; then
1.48 mycroft 407: echo -n ' rwhod'; rwhod
1.1 cgd 408: fi
409:
1.89 cjs 410: if checkyesno lpd; then
411: echo -n ' lpd'; lpd $lpd_flags
1.60 tls 412: fi
413:
1.63 mrg 414: # We call sendmail with a full path so that SIGHUP works.
1.89 cjs 415: if checkyesno sendmail; then
416: if [ -r /etc/sendmail.cf ]; then
417: echo -n ' sendmail'; /usr/sbin/sendmail $sendmail_flags
418: else
419: echo
420: logger -s "WARNING: /etc/sendmail.cf not readable; " \
421: "sendmail not started."
1.67 mycroft 422: fi
1.60 tls 423: fi
424:
1.96 jonathan 425: # Start xfs before boot daemons, so its ready before client xterminals.
426: if checkyesno xfs; then
427: echo -n ' xfs'; xfs $xfs_flags &
1.98 perry 428: sleep 2
1.96 jonathan 429: fi
430:
1.89 cjs 431: if checkyesno rarpd; then
432: if [ -r /etc/ethers ]; then
433: echo -n ' rarpd'; rarpd $rarpd_flags
434: else
435: echo
436: logger -s "WARNING: /etc/ethers not readable; " \
437: "rarpd not started."
1.67 mycroft 438: fi
1.60 tls 439: fi
440:
1.89 cjs 441: if checkyesno rbootd; then
442: if [ -r /etc/rbootd.conf ]; then
443: echo -n ' rbootd'; rbootd $rbootd_flags
444: else
445: echo
446: logger -s "WARNING: /etc/rbootd.conf not readable; " \
447: "rarpd not started."
1.67 mycroft 448: fi
1.72 cjs 449: fi
450:
1.89 cjs 451: if checkyesno mopd; then
1.72 cjs 452: echo -n ' mopd'; mopd $mopd_flags
1.86 perry 453: fi
454:
1.89 cjs 455: if checkyesno apmd; then
1.86 perry 456: echo -n ' apmd'; apmd $apmd_flags
1.103 mrg 457: fi
458:
459: if checkyesno screenblank; then
460: echo -n ' screenblank'; screenblank $screenblank_flags
1.52 thorpej 461: fi
462:
1.89 cjs 463: if checkyesno inetd; then
464: if [ -r /etc/inetd.conf ]; then
465: echo -n ' inetd'; inetd $inetd_flags
466: else
467: echo
468: logger -s "WARNING: /etc/inetd.conf not readable; " \
469: "inetd not started."
1.67 mycroft 470: fi
1.96 jonathan 471: fi
472:
473: if checkyesno xdm; then
474: echo -n ' xdm'; xdm $xdm_flags
1.30 mycroft 475: fi
476:
1.1 cgd 477: echo '.'
1.73 perry 478:
479: # Kerberos runs ONLY on the Kerberos server machine
1.89 cjs 480: if checkyesno kerberos; then
1.73 perry 481: echo -n 'starting kerberos daemons:'
482: echo -n ' kerberos'; kerberos >> /var/log/kerberos.log &
483: echo -n ' kadmind'; kadmind -n >> /var/log/kadmind.log &
484: echo '.'
485: fi
1.1 cgd 486:
1.25 mycroft 487: . /etc/rc.local
1.1 cgd 488:
489: date
490: exit 0
CVSweb <webmaster@jp.NetBSD.org>