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