Deleted Added
full compact
rc (114118) rc (114492)
1#!/bin/sh
2#
3# Copyright (c) 2000 The FreeBSD Project
4# All rights reserved.
5#
6# Redistribution and use in source and binary forms, with or without
7# modification, are permitted provided that the following conditions
8# are met:

--- 11 unchanged lines hidden (view full) ---

20# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25# SUCH DAMAGE.
26#
27# @(#)rc 5.27 (Berkeley) 6/5/91
1#!/bin/sh
2#
3# Copyright (c) 2000 The FreeBSD Project
4# All rights reserved.
5#
6# Redistribution and use in source and binary forms, with or without
7# modification, are permitted provided that the following conditions
8# are met:

--- 11 unchanged lines hidden (view full) ---

20# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25# SUCH DAMAGE.
26#
27# @(#)rc 5.27 (Berkeley) 6/5/91
28# $FreeBSD: head/etc/rc 114118 2003-04-27 07:08:07Z dougb $
28# $FreeBSD: head/etc/rc 114492 2003-05-02 05:27:35Z dougb $
29#
30
31# System startup script run by init on autoboot
32# or after single-user.
33# Output and error are redirected to console by init,
34# and the console is the controlling terminal.
35
36# Note that almost all of the user-configurable behavior is no longer in

--- 8 unchanged lines hidden (view full) ---

45#
46trap : 2
47trap : 3 # shouldn't be needed
48
49HOME=/
50PATH=/sbin:/bin:/usr/sbin:/usr/bin
51export HOME PATH
52
29#
30
31# System startup script run by init on autoboot
32# or after single-user.
33# Output and error are redirected to console by init,
34# and the console is the controlling terminal.
35
36# Note that almost all of the user-configurable behavior is no longer in

--- 8 unchanged lines hidden (view full) ---

45#
46trap : 2
47trap : 3 # shouldn't be needed
48
49HOME=/
50PATH=/sbin:/bin:/usr/sbin:/usr/bin
51export HOME PATH
52
53# check_rcng() is run in a subshell solely to determine the
54# RCNG mode. We do not want to pollute our variable space
55# too soon so the procedure must be run in a subshell. An
56# exit code of 3 indicates RCNG is enabled.
57#
58check_rcng()
59{
60 if [ -r /etc/defaults/rc.conf ]; then
61 . /etc/defaults/rc.conf
62 source_rc_confs
63 elif [ -r /etc/rc.conf ]; then
64 . /etc/rc.conf
65 fi
53. /etc/rc.subr
66
54
67 # Diskless setups have to depend on a different mechanism since
68 # their config files haven't been retargeted yet.
69 #
70 [ -e /.rcng_yes ] && rc_ng="YES"
71 case ${rc_ng} in
72 [Yy][Ee][Ss])
73 exit 3
74 ;;
75 *)
76 exit 0
77 ;;
78 esac
79}
80
81( check_rcng )
82if [ $? = 3 ]; then
83 rc_ng=YES
55# Note: the system configuration files are loaded as part of
56# the RCNG system (rc.d/rccond). Do not load them here as it may
57# interfere with diskless booting.
58#
59if [ "$1" = autoboot ]; then
60 autoboot=yes
61 _boot="faststart"
62 rc_fast=yes # run_rc_command(): do fast booting
84else
63else
85 rc_ng=NO
86 echo -n  ; sleep 1 ; echo -n  ; sleep 1 ; echo -n 
87 echo ''
88 echo '**** The old versions of the rc scripts are deprecated, and'
89 echo ' will soon be removed. Make sure to update /etc and'
90 echo ' check that rc_ng is YES in /etc/defaults/rc.conf.'
91 echo ' Please report any rc problems to freebsd-rc@yahoogroups.com'
92 echo ' and/or freebsd-current@freebsd.org.'
93 echo ''
94 sleep 3
64 autoboot=no
65 _boot="start"
95fi
96
66fi
67
97case ${rc_ng} in
98YES)
99 . /etc/rc.subr
68os=`eval ${CMD_OSTYPE}`
69files=`rcorder -k ${os} -s nostart /etc/rc.d/* 2>/dev/null`
100
70
101 # Note: the system configuration files are loaded as part of
102 # the RCNG system (rc.d/rccond). Do not load them here as it may
103 # interfere with diskless booting.
104 #
105 if [ "$1" = autoboot ]; then
106 autoboot=yes
107 _boot="faststart"
108 rc_fast=yes # run_rc_command(): do fast booting
109 else
110 autoboot=no
111 _boot="start"
112 fi
113
114 os=`eval ${CMD_OSTYPE}`
115 files=`rcorder -k ${os} -s nostart /etc/rc.d/* 2>/dev/null`
116
117 for _rc_elem in ${files}; do
118 run_rc_script ${_rc_elem} ${_boot}
119 done
120
121 echo ''
122 date
123 exit 0
124 ;;
125*)
126 # fall-through to the old rc scripts
127 ;;
128esac
129
130bootmode=$1
131
132# BOOTP diskless boot. We have to run the rc file early in order to
133# retarget various config files.
134#
135if [ -r /etc/rc.diskless1 ]; then
136 dlv=`/sbin/sysctl -n vfs.nfs.diskless_valid 2> /dev/null`
137 if [ ${dlv:=0} != 0 ]; then
138 . /etc/rc.diskless1
139 fi
140fi
141
142# If there is a global system configuration file, suck it in.
143#
144if [ -r /etc/defaults/rc.conf ]; then
145 . /etc/defaults/rc.conf
146 source_rc_confs
147elif [ -r /etc/rc.conf ]; then
148 . /etc/rc.conf
149fi
150
151# XXX - Deprecated variable name support
152# for rpcbind and ntpd
153#
154[ -n "$portmap_enable" ] && rpcbind_enable="$portmap_enable"
155[ -n "$portmap_program" ] && rpcbind_program="$portmap_program"
156[ -n "$portmap_flags" ] && rpcbind_flags="$portmap_flags"
157[ -n "$single_mountd_enable" ] && mountd_enable="$single_mountd_enable"
158[ -n "$xntpd_enable" ] && ntpd_enable="$xntpd_enable"
159[ -n "$xntpd_program" ] && ntpd_program="$xntpd_program"
160[ -n "$xntpd_flags" ] && ntpd_flags="$xntpd_flags"
161
162feed_dev_random() {
163 if [ -f "${1}" -a -r "${1}" -a -s "${1}" ]; then
164# echo "Using ${1} as an entropy file"
165 cat "${1}" | dd of=/dev/random bs=8k 2>/dev/null
166 fi
167}
168
169chkdepend() {
170 svc=$1
171 svc_var=$2
172 dep=$3
173 dep_var=$4
174
175 eval svc_val=\${$svc_var}
176 eval dep_val=\${$dep_var}
177
178 case ${svc_val} in
179 [Yy][Ee][Ss])
180 case ${dep_val} in
181 [Yy][Ee][Ss])
182 ;;
183 *)
184 eval ${dep_var}="YES"
185 echo "DEPENDENCY NOTE: ${dep} will be enabled" \
186 "to support ${svc}"
187 ;;
188 esac
189 ;;
190 esac
191}
192
193chkdepend amd amd_enable rpcbind rpcbind_enable
194chkdepend amd amd_enable NFS nfs_client_enable
195chkdepend NFS nfs_server_enable rpcbind rpcbind_enable
196chkdepend NIS nis_server_enable rpcbind rpcbind_enable
197chkdepend NIS nis_client_enable rpcbind rpcbind_enable
198
199# Enable dumpdev early so that a crash during the boot process can be caught.
200#
201case ${dumpdev} in
202[Nn][Oo] | '')
203 dumpdev='NO'
204 ;;
205*)
206 /sbin/dumpon -v ${dumpdev}
207 ;;
208esac
209
210# Enable harvesting of entropy via devices. The sooner this happens the
211# better so that we can take advantage of the boot process.
212#
213echo -n 'Entropy harvesting:'
214
215case ${harvest_interrupt} in
216[Nn][Oo])
217 ;;
218*)
219 if [ -w /dev/random ]; then
220 /sbin/sysctl kern.random.sys.harvest.interrupt=1 >/dev/null
221 echo -n ' interrupts'
222 fi
223 ;;
224esac
225
226case ${harvest_ethernet} in
227[Nn][Oo])
228 ;;
229*)
230 if [ -w /dev/random ]; then
231 /sbin/sysctl kern.random.sys.harvest.ethernet=1 >/dev/null
232 echo -n ' ethernet'
233 fi
234 ;;
235esac
236
237case ${harvest_p_to_p} in
238[Nn][Oo])
239 ;;
240*)
241 if [ -w /dev/random ]; then
242 /sbin/sysctl kern.random.sys.harvest.point_to_point=1 >/dev/null
243 echo -n ' point_to_point'
244 fi
245 ;;
246esac
247
248echo '.'
249
250# First pass at reseeding /dev/random.
251#
252case ${entropy_file} in
253[Nn][Oo] | '')
254 ;;
255*)
256 if [ -w /dev/random ]; then
257 feed_dev_random "${entropy_file}"
258 fi
259 ;;
260esac
261
262# XXX temporary until we can get the entropy
263# harvesting rate up
264# Entropy below is not great,
265# but better than nothing.
266( ps -fauxww; sysctl -a; date; df -ib; dmesg; ps -fauxww; ) \
267 | dd of=/dev/random bs=8k 2>/dev/null
268cat /bin/ls | dd of=/dev/random bs=8k 2>/dev/null
269
270# Configure ccd devices.
271#
272if [ -r /etc/ccd.conf ]; then
273 ccdconfig -C
274fi
275
276case ${start_vinum} in
277[Yy][Ee][Ss])
278 vinum start
279 ;;
280esac
281
282swapon -a
283
284# Last chance to do things before potentially waiting for
285# operator to do fsck related tasks
286if [ -r /etc/rc.early ]; then
287 . /etc/rc.early
288fi
289
290case ${bootmode} in
291autoboot)
292 echo 'Automatic boot in progress...'
293 case ${background_fsck} in
294 [Yy][Ee][Ss])
295 fsck -F -p
296 ;;
297 *)
298 fsck -p
299 ;;
300 esac
301 case $? in
302 0)
303 ;;
304 2)
305 exit 1
306 ;;
307 4)
308 reboot
309 echo 'Reboot failed... help!'
310 exit 1
311 ;;
312 8)
313 case ${fsck_y_enable} in
314 [Yy][Ee][Ss])
315 echo 'File system preen failed, trying fsck -y . . .'
316 fsck -y
317 case $? in
318 0)
319 ;;
320 *)
321 echo 'Automatic filesystem check failed . . . help!'
322 exit 1
323 ;;
324 esac
325 ;;
326 *)
327 echo 'Automatic filesystem check failed . . . help!'
328 exit 1
329 ;;
330 esac
331 ;;
332 12)
333 echo 'Reboot interrupted'
334 exit 1
335 ;;
336 130)
337 # interrupt before catcher installed
338 exit 1
339 ;;
340 *)
341 echo 'Unknown error in reboot'
342 exit 1
343 ;;
344 esac
345 ;;
346*)
347 echo 'Skipping disk checks ...'
348 ;;
349esac
350
351set -T
352trap "echo 'Reboot interrupted'; exit 1" 3
353
354# root normally must be read/write, but if this is a BOOTP NFS
355# diskless boot it does not have to be.
356#
357case ${root_rw_mount} in
358[Nn][Oo] | '')
359 ;;
360*)
361 if ! mount -u -o rw / ; then
362 echo 'Mounting root filesystem rw failed, startup aborted'
363 exit 1
364 fi
365 ;;
366esac
367
368umount -a >/dev/null 2>&1
369
370# Set up the list of network filesystem types for which mounting should be
371# delayed until after network initialization.
372networkfs_types='nfs:NFS smbfs:SMB portalfs:PORTAL'
373case ${extra_netfs_types} in
374[Nn][Oo])
375 ;;
376*)
377 networkfs_types="${networkfs_types} ${extra_netfs_types}"
378 ;;
379esac
380
381# Mount everything except nfs filesystems.
382mount_excludes='no'
383for i in ${networkfs_types}; do
384 fstype=${i%:*}
385 mount_excludes="${mount_excludes}${fstype},"
71for _rc_elem in ${files}; do
72 run_rc_script ${_rc_elem} ${_boot}
386done
73done
387mount_excludes=${mount_excludes%,}
388mount -a -t ${mount_excludes}
389
74
390case $? in
3910)
392 ;;
393*)
394 echo 'Mounting /etc/fstab filesystems failed, startup aborted'
395 exit 1
396 ;;
397esac
398
399# Run custom disk mounting function here
400#
401if [ -n "${diskless_mount}" -a -r "${diskless_mount}" ]; then
402 sh ${diskless_mount}
403fi
404
405# If we booted a special kernel remove the record so we will boot
406# the default kernel next time
407rm -f /boot/nextboot.conf
408
409# Reseed /dev/random with previously stored entropy.
410case ${entropy_dir} in
411[Nn][Oo])
412 ;;
413*)
414 entropy_dir=${entropy_dir:-/var/db/entropy}
415 if [ -d "${entropy_dir}" ]; then
416 if [ -w /dev/random ]; then
417 for seedfile in ${entropy_dir}/*; do
418 feed_dev_random "${seedfile}"
419 done
420 fi
421 fi
422 ;;
423esac
424
425case ${entropy_file} in
426[Nn][Oo] | '')
427 ;;
428*)
429 if [ -w /dev/random ]; then
430 feed_dev_random "${entropy_file}"
431 fi
432 ;;
433esac
434
435adjkerntz -i
436
437purgedir() {
438 local dir file
439
440 if [ $# -eq 0 ]; then
441 purgedir .
442 else
443 for dir
444 do
445 (
446 cd "$dir" && for file in .* *
447 do
448 [ ."$file" = .. -o ."$file" = ... ] && continue
449 if [ -d "$file" -a ! -L "$file" ]
450 then
451 purgedir "$file"
452 else
453 rm -f -- "$file"
454 fi
455 done
456 )
457 done
458 fi
459}
460
461clean_var() {
462 if [ -d /var/run -a ! -f /var/run/clean_var ]; then
463 purgedir /var/run
464 # Keep a copy of the boot messages around
465 dmesg >/var/run/dmesg.boot
466 # And an initial utmp file
467 (cd /var/run && cp /dev/null utmp && chmod 644 utmp;)
468 >/var/run/clean_var
469 fi
470 if [ -d /var/spool/lock -a ! -f /var/spool/lock/clean_var ]; then
471 purgedir /var/spool/lock
472 >/var/spool/lock/clean_var
473 fi
474 rm -rf /var/spool/uucp/.Temp/*
475}
476
477# network_pass1() *may* end up writing stuff to /var - we don't want to
478# remove it immediately afterwards - *nor* do we want to fail to clean
479# an NFS-mounted /var.
480rm -f /var/run/clean_var /var/spool/lock/clean_var
481clean_var
482
483# Add additional swapfile, if configured.
484#
485case ${swapfile} in
486[Nn][Oo] | '')
487 ;;
488*)
489 if [ -w "${swapfile}" -a -c /dev/mdctl ]; then
490 echo "Adding ${swapfile} as additional swap"
491 mdev=`mdconfig -a -t vnode -f ${swapfile}` && swapon /dev/${mdev}
492 fi
493 ;;
494esac
495
496# Early pass to set the variables we can
497#
498if [ -r /etc/rc.sysctl ]; then
499 sh /etc/rc.sysctl first
500fi
501
502# Configure serial devices
503#
504if [ -r /etc/rc.serial ]; then
505 . /etc/rc.serial
506fi
507
508# Start up PC-card configuration
509#
510if [ -r /etc/rc.pccard ]; then
511 . /etc/rc.pccard
512fi
513
514# Start up the initial network configuration.
515#
516if [ -r /etc/rc.network ]; then
517 . /etc/rc.network # We only need to do this once.
518 network_pass1
519fi
520
521case ${ipv6_enable} in
522[Yy][Ee][Ss])
523 if [ -r /etc/rc.network6 ]; then
524 . /etc/rc.network6 # We only need to do this once also.
525 network6_pass1
526 fi
527 ;;
528esac
529
530# Mount NFS filesystems if present in /etc/fstab
531#
532# XXX When the vfsload() issues with nfsclient support and related sysctls
533# have been resolved, this block can be removed, and the condition that
534# skips nfs in the following block (for "other network filesystems") can
535# be removed.
536case "`mount -d -a -t nfs 2> /dev/null`" in
537*mount_nfs*)
538 # Handle absent nfs client support
539 nfsclient_in_kernel=0
540 if sysctl vfs.nfs >/dev/null 2>&1; then
541 nfsclient_in_kernel=1
542 else
543 kldload nfsclient && nfsclient_in_kernel=1
544 fi
545
546 case ${nfsclient_in_kernel} in
547 1)
548 echo -n 'Mounting NFS filesystem:'
549 mount -a -t nfs
550 echo '.'
551 ;;
552 *)
553 echo 'Warning: nfs mount requested, but no nfs client in kernel'
554 ;;
555 esac
556 ;;
557esac
558
559# Mount other network filesystems if present in /etc/fstab
560for i in ${networkfs_types}; do
561 fstype=${i%:*}
562 fsdecr=${i#*:}
563
564 if [ "${fstype}" = "nfs" ]; then
565 continue
566 fi
567 case "`mount -d -a -t ${fstype}`" in
568 *mount_${fstype}*)
569 echo -n "Mounting ${fsdecr} filesystems:"
570 mount -a -t ${fstype}
571 echo '.'
572 ;;
573 esac
574done
575
576# Whack the pty perms back into shape.
577#
578if ls /dev/tty[pqrsPQRS]* > /dev/null 2>&1; then
579 chflags 0 /dev/tty[pqrsPQRS]*
580 chmod 666 /dev/tty[pqrsPQRS]*
581 chown root:wheel /dev/tty[pqrsPQRS]*
582fi
583
584# Clean up left-over files
585#
586clean_var # If it hasn't already been done
587rm /var/run/clean_var /var/spool/lock/clean_var
588
589# Clearing /tmp at boot-time seems to have a long tradition. It doesn't
590# help in any way for long-living systems, and it might accidentally
591# clobber files you would rather like to have preserved after a crash
592# (if not using mfs /tmp anyway).
593#
594# See also the example of another cleanup policy in /etc/periodic/daily.
595#
596case ${clear_tmp_enable} in
597[Yy][Ee][Ss])
598 echo -n 'Clearing /tmp:'
599 # prune quickly with one rm, then use find to clean up /tmp/[lq]*
600 # (not needed with mfs /tmp, but doesn't hurt there...)
601 (cd /tmp && rm -rf [a-km-pr-zA-Z]* &&
602 find -d . ! -name . ! -name lost+found ! -name quota.user \
603 ! -name quota.group -exec rm -rf -- {} \;)
604 echo '.'
605 ;;
606esac
607
608# Remove X lock files, since they will prevent you from restarting X11
609# after a system crash.
610#
611rm -f /tmp/.X*-lock
612rm -fr /tmp/.X11-unix
613mkdir -m 1777 /tmp/.X11-unix
614
615# Snapshot any kernel -c changes back to disk here <someday>.
616# This has changed with ELF and /kernel.config.
617
618# Load LOMAC(4) security if wanted.
619case ${lomac_enable} in
620[Yy][Ee][Ss])
621 kldload mac_lomac >/dev/null 2>&1
622 ;;
623esac
624
625echo -n 'Additional daemons:'
626
627# Start system logging and name service. Named needs to start before syslogd
628# if you don't have a /etc/resolv.conf.
629#
630case ${syslogd_enable} in
631[Yy][Ee][Ss])
632 # Transitional symlink (for the next couple of years :) until all
633 # binaries have had a chance to move towards /var/run/log.
634 if [ ! -L /dev/log ]; then
635 # might complain for r/o root f/s
636 ln -sf /var/run/log /dev/log
637 fi
638
639 rm -f /var/run/log
640 echo -n ' syslogd';
641 ${syslogd_program:-/usr/sbin/syslogd} ${syslogd_flags}
642 ;;
643esac
644
645echo '.'
646
647# Build device name databases if we are not using DEVFS
648#
649if sysctl vfs.devfs.generation > /dev/null 2>&1 ; then
650 rm -f /var/run/dev.db
651else
652 dev_mkdb
653fi
654
655# $dumpdir should be a directory or a symbolic link
656# to the crash directory if core dumps are to be saved.
657#
658if [ "${dumpdev}" != 'NO' ]; then
659 case ${dumpdir} in
660 '')
661 dumpdir='/var/crash'
662 ;;
663 [Nn][Oo])
664 dumpdir='NO'
665 ;;
666 esac
667
668 if [ "${dumpdir}" != 'NO' ]; then
669 echo -n 'Checking for core dump: '
670 /sbin/savecore ${savecore_flags} "${dumpdir}"
671 fi
672fi
673
674if [ -n "${network_pass1_done}" ]; then
675 network_pass2
676fi
677
678# Enable/Check the quotas (must be after ypbind if using NIS)
679#
680case ${enable_quotas} in
681[Yy][Ee][Ss])
682 case ${check_quotas} in
683 [Yy][Ee][Ss])
684 echo -n 'Checking quotas:'
685 quotacheck -a
686 echo ' done.'
687 ;;
688 esac
689
690 echo -n 'Enabling quotas:'
691 quotaon -a
692 echo ' done.'
693 ;;
694esac
695
696if [ -n "${network_pass2_done}" ]; then
697 network_pass3
698fi
699
700# Check the password temp/lock file
701#
702if [ -e /etc/ptmp ]; then
703 logger -s -p auth.err \
704 "password file may be incorrect -- /etc/ptmp exists"
705fi
706
707case ${accounting_enable} in
708[Yy][Ee][Ss])
709 if [ -d /var/account ]; then
710 echo 'Turning on accounting:'
711 if [ ! -e /var/account/acct ]; then
712 touch /var/account/acct
713 fi
714 accton /var/account/acct
715 fi
716 ;;
717esac
718
719# Make shared lib searching a little faster. Leave /usr/lib first if you
720# add your own entries or you may come to grief.
721#
722ldconfig="/sbin/ldconfig"
723case ${ldconfig_insecure} in
724[Yy][Ee][Ss])
725 ldconfig="${ldconfig} -i"
726 ;;
727esac
728if [ -x /sbin/ldconfig ]; then
729 _LDC=/usr/lib
730 for i in ${ldconfig_paths}; do
731 if [ -d "${i}" ]; then
732 _LDC="${_LDC} ${i}"
733 fi
734 done
735 echo 'ELF ldconfig path:' ${_LDC}
736 ${ldconfig} ${_LDC}
737
738 # Legacy aout support for i386 only
739 case `sysctl -n hw.machine_arch` in
740 i386)
741 # Default the a.out ldconfig path.
742 : ${ldconfig_paths_aout=${ldconfig_paths}}
743 _LDC=/usr/lib/aout
744 for i in ${ldconfig_paths_aout}; do
745 if [ -d "${i}" ]; then
746 _LDC="${_LDC} ${i}"
747 fi
748 done
749 echo 'a.out ldconfig path:' ${_LDC}
750 ${ldconfig} -aout ${_LDC}
751 ;;
752 esac
753fi
754
755# Now start up miscellaneous daemons that don't belong anywhere else
756#
757echo -n 'Starting standard daemons:'
758case ${inetd_enable} in
759[Nn][Oo])
760 ;;
761*)
762 echo -n ' inetd'; ${inetd_program:-/usr/sbin/inetd} ${inetd_flags}
763 ;;
764esac
765
766case ${cron_enable} in
767[Nn][Oo])
768 ;;
769*)
770 echo -n ' cron'; ${cron_program:-/usr/sbin/cron} ${cron_flags}
771 ;;
772esac
773
774case ${lpd_enable} in
775[Yy][Ee][Ss])
776 echo -n ' printer'; ${lpd_program:-/usr/sbin/lpd} ${lpd_flags}
777 ;;
778esac
779
780case ${sshd_enable} in
781[Yy][Ee][Ss])
782 if [ -x ${sshd_program:-/usr/sbin/sshd} ]; then
783 echo -n ' sshd';
784 ${sshd_program:-/usr/sbin/sshd} ${sshd_flags}
785 fi
786 ;;
787esac
788
789case ${usbd_enable} in
790[Yy][Ee][Ss])
791 echo -n ' usbd'; /usr/sbin/usbd ${usbd_flags}
792 ;;
793esac
794
795case ${mta_start_script} in
796/*)
797 if [ -r ${mta_start_script} ]; then
798 sh ${mta_start_script}
799 fi
800 ;;
801esac
802
803echo '.'
804
805# Recover vi editor files.
806find /var/tmp/vi.recover ! -type f -a ! -type d -delete
807vibackup=`echo /var/tmp/vi.recover/vi.*`
808if [ "${vibackup}" != '/var/tmp/vi.recover/vi.*' ]; then
809 echo -n 'Recovering vi editor sessions:'
810 for i in /var/tmp/vi.recover/vi.*; do
811 # Only test files that are readable.
812 if [ ! -r "${i}" ]; then
813 continue
814 fi
815
816 # Unmodified nvi editor backup files either have the
817 # execute bit set or are zero length. Delete them.
818 if [ -x "${i}" -o ! -s "${i}" ]; then
819 rm -f "${i}"
820 fi
821 done
822
823 # It is possible to get incomplete recovery files, if the editor
824 # crashes at the right time.
825 virecovery=`echo /var/tmp/vi.recover/recover.*`
826 if [ "${virecovery}" != "/var/tmp/vi.recover/recover.*" ]; then
827 for i in /var/tmp/vi.recover/recover.*; do
828 # Only test files that are readable.
829 if [ ! -r "${i}" ]; then
830 continue
831 fi
832
833 # Delete any recovery files that are zero length,
834 # corrupted, or that have no corresponding backup file.
835 # Else send mail to the user.
836 recfile=`awk '/^X-vi-recover-path:/{print $2}' < "${i}"`
837 if [ -n "${recfile}" -a -s "${recfile}" ]; then
838 sendmail -t < "${i}"
839 else
840 rm -f "${i}"
841 fi
842 done
843 fi
844 echo '.'
845fi
846
847# Make a bounds file for msgs(1) if there isn't one already
848#
849if [ -d /var/msgs -a ! -f /var/msgs/bounds -a ! -L /var/msgs/bounds ]; then
850 echo 0 > /var/msgs/bounds
851fi
852
853case ${update_motd} in
854[Nn][Oo] | '')
855 ;;
856*)
857 if T=`mktemp /tmp/_motd.XXXXXX`; then
858 uname -v | sed -e 's,^\([^#]*\) #\(.* [1-2][0-9][0-9][0-9]\).*/\([^\]*\) $,\1 (\3) #\2,' > ${T}
859 awk '{if (NR == 1) {if ($1 == "FreeBSD") {next} else {print "\n"$0}} else {print}}' < /etc/motd >> ${T}
860 cmp -s ${T} /etc/motd || {
861 cp ${T} /etc/motd
862 chmod 644 /etc/motd
863 }
864 rm -f ${T}
865 fi
866 ;;
867esac
868
869# Run rc.devfs if readable to customize devfs
870#
871if [ -r /etc/rc.devfs ]; then
872 sh /etc/rc.devfs
873fi
874
875# Configure implementation specific stuff
876#
877arch=`uname -p`
878if [ -r /etc/rc.${arch} ]; then
879 . /etc/rc.${arch}
880fi
881
882# Configure the system console
883#
884if [ -r /etc/rc.syscons ]; then
885 . /etc/rc.syscons
886fi
887
888echo -n 'Additional ABI support:'
889
890# Load the SysV IPC API if requested.
891case ${sysvipc_enable} in
892[Yy][Ee][Ss])
893 echo -n ' sysvipc'
894 kldload sysvmsg >/dev/null 2>&1
895 kldload sysvsem >/dev/null 2>&1
896 kldload sysvshm >/dev/null 2>&1
897 ;;
898esac
899
900# Start the Linux binary compatibility if requested.
901#
902case ${linux_enable} in
903[Yy][Ee][Ss])
904 echo -n ' linux'
905 if ! kldstat -v | grep -E 'linux(aout|elf)' > /dev/null; then
906 kldload linux > /dev/null 2>&1
907 fi
908 if [ -x /compat/linux/sbin/ldconfig ]; then
909 /compat/linux/sbin/ldconfig
910 fi
911 ;;
912esac
913
914# Start the SysVR4 binary emulation if requested.
915#
916case ${svr4_enable} in
917[Yy][Ee][Ss])
918 echo -n ' svr4'; kldload svr4 > /dev/null 2>&1
919 ;;
920esac
921
922echo '.'
923
924# Do traditional (but rather obsolete) rc.local file if it exists. If you
925# use this file and want to make it programmatic, source /etc/defaults/rc.conf
926# in /etc/rc.local and add your custom variables to /etc/rc.conf, as
927# shown below. Please do not put local extensions into /etc/rc itself.
928# Use /etc/rc.local
929#
930# ---- rc.local ----
931# if [ -r /etc/defaults/rc.conf ]; then
932# . /etc/defaults/rc.conf
933# source_rc_confs
934# elif [ -r /etc/rc.conf ]; then
935# . /etc/rc.conf
936# fi
937#
938# ... additional startup conditionals ...
939# ---- rc.local ----
940#
941if [ -r /etc/rc.local ]; then
942 echo -n 'Starting local daemons:'
943 sh /etc/rc.local
944 echo '.'
945fi
946
947# For each valid dir in $local_startup, search for init scripts matching *.sh
948#
949case ${local_startup} in
950[Nn][Oo] | '')
951 ;;
952*)
953 echo -n 'Local package initialization:'
954 slist=""
955 if [ -z "${script_name_sep}" ]; then
956 script_name_sep=" "
957 fi
958 for dir in ${local_startup}; do
959 if [ -d "${dir}" ]; then
960 for script in ${dir}/*.sh; do
961 slist="${slist}${script_name_sep}${script}"
962 done
963 fi
964 done
965 script_save_sep="$IFS"
966 IFS="${script_name_sep}"
967 for script in ${slist}; do
968 if [ -x "${script}" ]; then
969 (set -T
970 trap 'exit 1' 2
971 ${script} start)
972 elif [ -f "${script}" -o -L "${script}" ]; then
973 echo -n " (skipping ${script##*/}, not executable)"
974 fi
975 done
976 IFS="${script_save_sep}"
977 echo '.'
978 ;;
979esac
980
981if [ -n "${network_pass3_done}" ]; then
982 network_pass4
983fi
984
985# Late pass to set variables we missed the first time
986#
987if [ -r /etc/rc.sysctl ]; then
988 sh /etc/rc.sysctl last
989fi
990
991# Raise kernel security level. This should be done only after `fsck' has
992# repaired local filesystems if you want the securelevel to be greater than 1.
993#
994case ${kern_securelevel_enable} in
995[Yy][Ee][Ss])
996 if [ "${kern_securelevel}" -ge 0 ]; then
997 echo 'Raising kernel security level: '
998 sysctl kern.securelevel=${kern_securelevel}
999 fi
1000 ;;
1001esac
1002
1003# Start background fsck checks if necessary
1004case ${background_fsck} in
1005[Yy][Ee][Ss])
1006 bgfsck_msg='Starting background file system checks'
1007 if [ ${background_fsck_delay:=0} -gt 0 ]; then
1008 bgfsck_msg="${bgfsck_msg} in ${background_fsck_delay} seconds"
1009 fi
1010 echo "${bgfsck_msg}."
1011
1012 (sleep ${background_fsck_delay}; nice -4 fsck -B -p) 2>&1 | \
1013 logger -p daemon.notice -t fsck &
1014 ;;
1015esac
1016
1017echo ''
75echo ''
1018
1019date
76date
1020
1021exit 0
77exit 0
1022