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