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