rc revision 88676
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 88676 2001-12-29 19:42:55Z 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# Set up the list of network filesystem types for which mounting should be
271# delayed until after network initialization.
272networkfs_types='nfs:NFS smbfs:SMB portalfs:PORTAL'
273case ${extra_netfs_types} in
274[Nn][Oo])
275	;;
276*)
277	networkfs_types="${networkfs_types} ${extra_netfs_types}"
278	;;
279esac
280
281# Mount everything except nfs filesystems.
282mount_excludes='no'
283for i in ${networkfs_types}; do
284	fstype=${i%:*}
285	mount_excludes="${mount_excludes}${fstype},"
286done
287mount_excludes=${mount_excludes%,}
288mount -a -t ${mount_excludes}
289
290case $? in
2910)
292	;;
293*)
294	echo 'Mounting /etc/fstab filesystems failed, startup aborted'
295	exit 1
296	;;
297esac
298
299# Run custom disk mounting function here
300#
301if [ -n "${diskless_mount}" -a -r "${diskless_mount}" ]; then
302		sh ${diskless_mount}
303fi
304
305# Reseed /dev/random with previously stored entropy.
306case ${entropy_dir} in
307[Nn][Oo])
308	;;
309*)
310	entropy_dir=${entropy_dir:-/var/db/entropy}
311	if [ -d "${entropy_dir}" ]; then
312		if [ -w /dev/random ]; then
313			for seedfile in ${entropy_dir}/*; do
314				feed_dev_random "${seedfile}"
315			done
316		fi
317	fi
318	;;
319esac
320
321case ${entropy_file} in
322[Nn][Oo] | '')
323	;;
324*)
325	if [ -w /dev/random ]; then
326		feed_dev_random "${entropy_file}"
327	fi
328	;;
329esac
330
331adjkerntz -i
332
333purgedir() {
334	local dir file
335
336	if [ $# -eq 0 ]; then
337		purgedir .
338	else
339		for dir
340		do
341		(
342			cd "$dir" && for file in .* *
343			do
344				[ ."$file" = .. -o ."$file" = ... ] && continue
345				if [ -d "$file" -a ! -L "$file" ]
346				then
347					purgedir "$file"
348				else
349					rm -f -- "$file"
350				fi
351			done
352		)
353		done
354	fi
355}
356
357clean_var() {
358	if [ -d /var/run -a ! -f /var/run/clean_var ]; then
359		purgedir /var/run
360		# Keep a copy of the boot messages around
361		dmesg >/var/run/dmesg.boot
362		# And an initial utmp file
363		(cd /var/run && cp /dev/null utmp && chmod 644 utmp;)
364		>/var/run/clean_var
365	fi
366	if [ -d /var/spool/lock -a ! -f /var/spool/lock/clean_var ]; then
367		purgedir /var/spool/lock
368		>/var/spool/lock/clean_var
369	fi
370	rm -rf /var/spool/uucp/.Temp/*
371}
372
373# network_pass1() *may* end up writing stuff to /var - we don't want to
374# remove it immediately afterwards - *nor* do we want to fail to clean
375# an NFS-mounted /var.
376rm -f /var/run/clean_var /var/spool/lock/clean_var
377clean_var
378
379# Add additional swapfile, if configured.
380#
381case ${swapfile} in
382[Nn][Oo] | '')
383	;;
384*)
385	if [ -w "${swapfile}" -a -c /dev/mdctl ]; then
386		echo "Adding ${swapfile} as additional swap"
387		mdev=`mdconfig -a -t vnode -f ${swapfile}` && swapon /dev/${mdev}
388	fi
389	;;
390esac
391
392# Set sysctl variables as early as we can
393#
394if [ -r /etc/rc.sysctl ]; then
395	. /etc/rc.sysctl
396fi
397
398# Configure serial devices
399#
400if [ -r /etc/rc.serial ]; then
401	. /etc/rc.serial
402fi
403
404# Start up PC-card configuration
405#
406if [ -r /etc/rc.pccard ]; then
407	. /etc/rc.pccard
408fi
409
410# Start up the initial network configuration.
411#
412if [ -r /etc/rc.network ]; then
413	. /etc/rc.network	# We only need to do this once.
414	network_pass1
415fi
416
417case ${ipv6_enable} in
418[Yy][Ee][Ss])
419	if [ -r /etc/rc.network6 ]; then
420		. /etc/rc.network6	# We only need to do this once also.
421		network6_pass1
422	fi
423	;;
424esac
425
426# Mount NFS filesystems if present in /etc/fstab
427#
428# XXX When the vfsload() issues with nfsclient support and related sysctls
429# have been resolved, this block can be removed, and the condition that
430# skips nfs in the following block (for "other network filesystems") can
431# be removed.
432case "`mount -d -a -t nfs 2> /dev/null`" in
433*mount_nfs*)
434	# Handle absent nfs client support
435	nfsclient_in_kernel=0
436	if sysctl vfs.nfs >/dev/null 2>&1; then
437		nfsclient_in_kernel=1
438	else
439		kldload nfsclient && nfsclient_in_kernel=1
440	fi
441
442	case ${nfsclient_in_kernel} in
443	1)
444		echo -n 'Mounting NFS file systems:'
445		mount -a -t nfs
446		echo '.'
447		;;
448	*)
449		echo 'Warning: nfs mount requested, but no nfs client in kernel'
450		;;
451	esac
452	;;
453esac
454
455# Mount other network filesystems if present in /etc/fstab
456for i in ${networkfs_types}; do
457	fstype=${i%:*}
458	fsdecr=${i#*:}
459
460	if [ "${fstype}" = "nfs" ]; then
461		continue
462	fi
463	case "`mount -d -a -t ${fstype}`" in
464	*mount_${fstype}*)
465	       echo -n "Mounting ${fsdecr} file systems:"
466	       mount -a -t ${fstype}
467	       echo '.'
468	       ;;
469	esac
470done
471
472# Whack the pty perms back into shape.
473#
474if ls /dev/tty[pqrsPQRS]* > /dev/null 2>&1; then
475	chflags 0 /dev/tty[pqrsPQRS]*
476	chmod 666 /dev/tty[pqrsPQRS]*
477	chown root:wheel /dev/tty[pqrsPQRS]*
478fi
479
480# Clean up left-over files
481#
482clean_var			# If it hasn't already been done
483rm /var/run/clean_var /var/spool/lock/clean_var
484
485# Clearing /tmp at boot-time seems to have a long tradition.  It doesn't
486# help in any way for long-living systems, and it might accidentally
487# clobber files you would rather like to have preserved after a crash
488# (if not using mfs /tmp anyway).
489#
490# See also the example of another cleanup policy in /etc/periodic/daily.
491#
492case ${clear_tmp_enable} in
493[Yy][Ee][Ss])
494	echo -n 'Clearing /tmp:'
495	# prune quickly with one rm, then use find to clean up /tmp/[lq]*
496	# (not needed with mfs /tmp, but doesn't hurt there...)
497	(cd /tmp && rm -rf [a-km-pr-zA-Z]* &&
498		find -d . ! -name . ! -name lost+found ! -name quota.user \
499		! -name quota.group -exec rm -rf -- {} \;)
500	echo '.'
501	;;
502esac
503
504# Remove X lock files, since they will prevent you from restarting X11
505# after a system crash.
506#
507rm -f /tmp/.X*-lock /tmp/.X11-unix/*
508
509# Snapshot any kernel -c changes back to disk here <someday>.
510# This has changed with ELF and /kernel.config.
511
512echo -n 'Additional daemons:'
513
514# Start system logging and name service.  Named needs to start before syslogd
515# if you don't have a /etc/resolv.conf.
516#
517case ${syslogd_enable} in
518[Yy][Ee][Ss])
519	# Transitional symlink (for the next couple of years :) until all
520	# binaries have had a chance to move towards /var/run/log.
521	if [ ! -L /dev/log ]; then
522		# might complain for r/o root f/s
523		ln -sf /var/run/log /dev/log
524	fi
525
526	rm -f /var/run/log
527	echo -n ' syslogd';
528	${syslogd_program:-/usr/sbin/syslogd} ${syslogd_flags}
529	;;
530esac
531
532echo '.'
533
534# Build device name databases if we are not using DEVFS
535#
536if sysctl vfs.devfs.generation > /dev/null 2>&1 ; then
537	rm -f /var/run/dev.db
538else
539	dev_mkdb
540fi
541
542# Enable dumpdev so that savecore can see it.
543# /var/crash should be a directory or a symbolic link
544# to the crash directory if core dumps are to be saved.
545#
546case ${dumpdev} in
547[Nn][Oo] | '')
548	;;
549*)
550	case ${dumpdir} in
551	'')
552		dumpdir='/var/crash'
553		;;
554	esac
555
556	if [ -e "${dumpdev}" -a -d "${dumpdir}" ]; then
557		/sbin/dumpon -v ${dumpdev}
558		echo -n 'Checking for core dump: '
559		/sbin/savecore ${savecore_flags} "${dumpdir}"
560	fi
561	;;
562esac
563
564if [ -n "${network_pass1_done}" ]; then
565	network_pass2
566fi
567
568# Enable/Check the quotas (must be after ypbind if using NIS)
569#
570case ${enable_quotas} in
571[Yy][Ee][Ss])
572	case ${check_quotas} in
573	[Yy][Ee][Ss])
574		echo -n 'Checking quotas:'
575		quotacheck -a
576		echo ' done.'
577		;;
578	esac
579
580	echo -n 'Enabling quotas:'
581	quotaon -a
582	echo ' done.'
583	;;
584esac
585
586if [ -n "${network_pass2_done}" ]; then
587	network_pass3
588fi
589
590# Check the password temp/lock file
591#
592if [ -e /etc/ptmp ]; then
593	logger -s -p auth.err \
594	"password file may be incorrect -- /etc/ptmp exists"
595fi
596
597case ${accounting_enable} in
598[Yy][Ee][Ss])
599	if [ -d /var/account ]; then
600		echo 'Turning on accounting:'
601		if [ ! -e /var/account/acct ]; then
602			touch /var/account/acct
603		fi
604		accton /var/account/acct
605	fi
606	;;
607esac
608
609# Make shared lib searching a little faster.  Leave /usr/lib first if you
610# add your own entries or you may come to grief.
611#
612ldconfig="/sbin/ldconfig"
613case ${ldconfig_insecure} in
614[Yy][Ee][Ss])
615	ldconfig="${ldconfig} -i"
616	;;
617esac
618if [ -x /sbin/ldconfig ]; then
619	case `/usr/bin/objformat` in
620	elf)
621		_LDC=/usr/lib
622		for i in ${ldconfig_paths}; do
623			if [ -d "${i}" ]; then
624				_LDC="${_LDC} ${i}"
625			fi
626		done
627		echo 'ELF ldconfig path:' ${_LDC}
628		${ldconfig} -elf ${_LDC}
629		;;
630	esac
631
632	# Legacy aout support for i386 only
633	case `sysctl -n hw.machine` in
634	i386)
635		# Default the a.out ldconfig path.
636		: ${ldconfig_paths_aout=${ldconfig_paths}}
637		_LDC=/usr/lib/aout
638		for i in ${ldconfig_paths_aout}; do
639			if [ -d "${i}" ]; then
640				_LDC="${_LDC} ${i}"
641			fi
642		done
643		echo 'a.out ldconfig path:' ${_LDC}
644		${ldconfig} -aout ${_LDC}
645		;;
646	esac
647fi
648
649# Now start up miscellaneous daemons that don't belong anywhere else
650#
651echo -n 'Starting standard daemons:'
652case ${inetd_enable} in
653[Nn][Oo])
654	;;
655*)
656	echo -n ' inetd'; ${inetd_program:-/usr/sbin/inetd} ${inetd_flags}
657	;;
658esac
659
660case ${cron_enable} in
661[Nn][Oo])
662	;;
663*)
664	echo -n ' cron';	${cron_program:-/usr/sbin/cron} ${cron_flags}
665	;;
666esac
667
668case ${lpd_enable} in
669[Yy][Ee][Ss])
670	echo -n ' printer';	${lpd_program:-/usr/sbin/lpd} ${lpd_flags}
671	;;
672esac
673
674case ${sshd_enable} in
675[Yy][Ee][Ss])
676	if [ -x ${sshd_program:-/usr/sbin/sshd} ]; then
677		echo -n ' sshd';
678		${sshd_program:-/usr/sbin/sshd} ${sshd_flags}
679	fi
680	;;
681esac
682
683case ${usbd_enable} in
684[Yy][Ee][Ss])
685	echo -n ' usbd';	/usr/sbin/usbd ${usbd_flags}
686	;;
687esac
688
689if [ -r /etc/mail/sendmail.cf ]; then
690	case ${sendmail_enable} in
691	[Yy][Ee][Ss])
692		echo -n ' sendmail'
693		/usr/sbin/sendmail ${sendmail_flags}
694		;;
695	*)
696		case ${sendmail_outbound_enable} in
697		[Yy][Ee][Ss])
698			echo -n ' sendmail'
699			/usr/sbin/sendmail ${sendmail_outbound_flags}
700			;;
701		esac
702		;;
703	esac
704fi
705
706echo '.'
707
708# Recover vi editor files.
709find /var/tmp/vi.recover ! -type f -a ! -type d -delete
710vibackup=`echo /var/tmp/vi.recover/vi.*`
711if [ "${vibackup}" != '/var/tmp/vi.recover/vi.*' ]; then
712	echo -n 'Recovering vi editor sessions:'
713	for i in /var/tmp/vi.recover/vi.*; do
714		# Only test files that are readable.
715		if [ ! -r "${i}" ]; then
716			continue
717		fi
718
719		# Unmodified nvi editor backup files either have the
720		# execute bit set or are zero length.  Delete them.
721		if [ -x "${i}" -o ! -s "${i}" ]; then
722			rm -f "${i}"
723		fi
724	done
725
726	# It is possible to get incomplete recovery files, if the editor
727	# crashes at the right time.
728	virecovery=`echo /var/tmp/vi.recover/recover.*`
729	if [ "${virecovery}" != "/var/tmp/vi.recover/recover.*" ]; then
730		for i in /var/tmp/vi.recover/recover.*; do
731			# Only test files that are readable.
732			if [ ! -r "${i}" ]; then
733				continue
734			fi
735
736			# Delete any recovery files that are zero length,
737			# corrupted, or that have no corresponding backup file.
738			# Else send mail to the user.
739			recfile=`awk '/^X-vi-recover-path:/{print $2}' < "${i}"`
740			if [ -n "${recfile}" -a -s "${recfile}" ]; then
741				sendmail -t < "${i}"
742			else
743				rm -f "${i}"
744			fi
745		done
746	fi
747	echo '.'
748fi
749
750# Make a bounds file for msgs(1) if there isn't one already
751#
752if [ -d /var/msgs -a ! -f /var/msgs/bounds -a ! -L /var/msgs/bounds ]; then
753	echo 0 > /var/msgs/bounds
754fi
755
756case ${update_motd} in
757[Nn][Oo] | '')
758	;;
759*)
760	if T=`mktemp /tmp/_motd.XXXXXX`; then
761		uname -v | sed -e 's,^\([^#]*\) #\(.* [1-2][0-9][0-9][0-9]\).*/\([^\]*\) $,\1 (\3) #\2,' > ${T}
762		awk '{if (NR == 1) {if ($1 == "FreeBSD") {next} else {print "\n"$0}} else {print}}' < /etc/motd >> ${T}
763		cmp -s ${T} /etc/motd || {
764			cp ${T} /etc/motd
765			chmod 644 /etc/motd
766		}
767		rm -f ${T}
768	fi
769	;;
770esac
771
772# Run rc.devfs if readable to customize devfs
773#
774if [ -r /etc/rc.devfs ]; then
775	sh /etc/rc.devfs
776fi
777
778# Configure implementation specific stuff
779#
780arch=`uname -m`
781if [ -r /etc/rc.${arch} ]; then
782	. /etc/rc.${arch}
783fi
784
785# Configure the system console
786#
787if [ -r /etc/rc.syscons ]; then
788	. /etc/rc.syscons
789fi
790
791echo -n 'Additional ABI support:'
792
793# Load the SysV IPC API if requested.
794case ${sysvipc_enable} in
795[Yy][Ee][Ss])
796	echo -n ' sysvipc'
797	kldload sysvmsg >/dev/null 2>&1
798	kldload sysvsem >/dev/null 2>&1
799	kldload sysvshm >/dev/null 2>&1
800	;;
801esac
802
803# Start the Linux binary compatibility if requested.
804#
805case ${linux_enable} in
806[Yy][Ee][Ss])
807	echo -n ' linux'
808	if ! kldstat -v | grep -E 'linux(aout|elf)' > /dev/null; then
809		kldload linux > /dev/null 2>&1
810	fi
811	if [ -x /compat/linux/sbin/ldconfig ]; then
812		/compat/linux/sbin/ldconfig
813	fi
814	;;
815esac
816
817# Start the SysVR4 binary emulation if requested.
818#
819case ${svr4_enable} in
820[Yy][Ee][Ss])
821	echo -n ' svr4';	kldload svr4 > /dev/null 2>&1
822	;;
823esac
824
825echo '.'
826
827# Do traditional (but rather obsolete) rc.local file if it exists.  If you
828# use this file and want to make it programmatic, source /etc/defaults/rc.conf
829# in /etc/rc.local and add your custom variables to /etc/rc.conf, as
830# shown below.  Please do not put local extensions into /etc/rc itself.
831# Use /etc/rc.local
832#
833# ---- rc.local ----
834#	if [ -r /etc/defaults/rc.conf ]; then
835#		. /etc/defaults/rc.conf
836#		source_rc_confs
837#	elif [ -r /etc/rc.conf ]; then
838#		. /etc/rc.conf
839#	fi
840#
841#	... additional startup conditionals ...
842# ---- rc.local ----
843#
844if [ -r /etc/rc.local ]; then
845	echo -n 'Starting local daemons:'
846	sh /etc/rc.local
847	echo '.'
848fi
849
850# For each valid dir in $local_startup, search for init scripts matching *.sh
851#
852case ${local_startup} in
853[Nn][Oo] | '')
854	;;
855*)
856	echo -n 'Local package initialization:'
857	slist=""
858	if [ -z "${script_name_sep}" ]; then
859		script_name_sep=" "
860	fi
861	for dir in ${local_startup}; do
862		if [ -d "${dir}" ]; then
863			for script in ${dir}/*.sh; do
864				slist="${slist}${script_name_sep}${script}"
865			done
866		fi
867	done
868	script_save_sep="$IFS"
869	IFS="${script_name_sep}"
870	for script in ${slist}; do
871		if [ -x "${script}" ]; then
872			(set -T
873			trap 'exit 1' 2
874			${script} start)
875		elif [ -f "${script}" -o -L "${script}" ]; then
876			echo -n " (skipping ${script##*/}, not executable)"
877		fi
878	done
879	IFS="${script_save_sep}"
880	echo '.'
881	;;
882esac
883
884if [ -n "${network_pass3_done}" ]; then
885	network_pass4
886fi
887
888# Raise kernel security level.  This should be done only after `fsck' has
889# repaired local file systems if you want the securelevel to be greater than 1.
890#
891case ${kern_securelevel_enable} in
892[Yy][Ee][Ss])
893	if [ "${kern_securelevel}" -ge 0 ]; then
894		echo 'Raising kernel security level: '
895		sysctl kern.securelevel=${kern_securelevel}
896	fi
897	;;
898esac
899
900# Start background fsck checks if necessary
901case ${background_fsck} in
902[Yy][Ee][Ss])
903	echo 'Starting background filesystem checks'
904	nice -4 fsck -B -p 2>&1 | logger -p daemon.notice &
905	;;
906esac
907
908echo ''
909
910date
911
912exit 0
913
914