rc revision 155866
1279377Simp#!/bin/sh 2279377Simp# 3279377Simp# Copyright (c) 2000-2004 The FreeBSD Project 4279377Simp# All rights reserved. 5279377Simp# 6279377Simp# Redistribution and use in source and binary forms, with or without 7279377Simp# modification, are permitted provided that the following conditions 8279377Simp# are met: 9279377Simp# 1. Redistributions of source code must retain the above copyright 10279377Simp# notice, this list of conditions and the following disclaimer. 11279377Simp# 2. Redistributions in binary form must reproduce the above copyright 12279377Simp# notice, this list of conditions and the following disclaimer in the 13279377Simp# documentation and/or other materials provided with the distribution. 14279377Simp# 15279377Simp# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 16279377Simp# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17279377Simp# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18279377Simp# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 19279377Simp# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20279377Simp# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 21279377Simp# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22279377Simp# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23279377Simp# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24279377Simp# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25279377Simp# SUCH DAMAGE. 26279377Simp# 27279377Simp# @(#)rc 5.27 (Berkeley) 6/5/91 28279377Simp# $FreeBSD: head/etc/rc 155866 2006-02-20 21:54:30Z dougb $ 29279377Simp# 30279377Simp 31279377Simp# System startup script run by init on autoboot 32279377Simp# or after single-user. 33279377Simp# Output and error are redirected to console by init, 34279377Simp# and the console is the controlling terminal. 35279377Simp 36279377Simp# Note that almost all of the user-configurable behavior is no longer in 37279377Simp# this file, but rather in /etc/defaults/rc.conf. Please check that file 38279377Simp# first before contemplating any changes here. If you do need to change 39279377Simp# this file for some reason, we would like to know about it. 40279377Simp 41279377Simpstty status '^T' 42279377Simp 43279377Simp# Set shell to ignore SIGINT (2), but not children; 44279377Simp# shell catches SIGQUIT (3) and returns to single user. 45279377Simp# 46279377Simptrap : 2 47279377Simptrap "echo 'Boot interrupted'; exit 1" 3 48279377Simp 49279377SimpHOME=/ 50279377SimpPATH=/sbin:/bin:/usr/sbin:/usr/bin 51279377Simpexport HOME PATH 52279377Simp 53279377Simpif [ "$1" = autoboot ]; then 54279377Simp autoboot=yes 55279377Simp _boot="faststart" 56279377Simp rc_fast=yes # run_rc_command(): do fast booting 57279377Simpelse 58279377Simp autoboot=no 59279377Simp _boot="start" 60279377Simpfi 61279377Simp 62279377Simpdlv=`/sbin/sysctl -n vfs.nfs.diskless_valid 2> /dev/null` 63279377Simpif [ ${dlv:=0} -ne 0 -o -f /etc/diskless ]; then 64279377Simp sh /etc/rc.initdiskless 65279377Simpfi 66279377Simp 67279377Simp# Run these after determining whether we are booting diskless in order 68279377Simp# to minimize the number of files that are needed on a diskless system, 69279377Simp# and to make the configuration file variables available to rc itself. 70279377Simp# 71279377Simp. /etc/rc.subr 72279377Simpecho "Loading configuration files." 73279377Simpload_rc_config 'XXX' 74279377Simp 75279377Simpskip="-s nostart" 76279377Simpif [ `/sbin/sysctl -n security.jail.jailed` -eq 1 ]; then 77279377Simp skip="$skip -s nojail" 78279377Simp if [ "$early_late_divider" = "mountcritlocal" ]; then 79279377Simp early_late_divider=NETWORKING 80279377Simp fi 81279377Simpfi 82279377Simp 83279377Simp# Do a first pass to get everything up to $early_late_divider so that 84279377Simp# we can do a second pass that includes $local_startup directories 85279377Simp# 86279377Simpfiles=`rcorder ${skip} /etc/rc.d/* 2>/dev/null` 87279377Simp 88279377Simpfor _rc_elem in ${files}; do 89279377Simp run_rc_script ${_rc_elem} ${_boot} 90279377Simp 91279377Simp case "$_rc_elem" in 92279377Simp */${early_late_divider}) break ;; 93279377Simp esac 94279377Simpdone 95279377Simp 96279377Simpunset files local_rc 97279377Simp 98279377Simp# Now that disks are mounted, for each dir in $local_startup 99279377Simp# search for init scripts that use the new rc.d semantics. 100279377Simp# 101279377Simpcase ${local_startup} in 102279377Simp[Nn][Oo] | '') ;; 103279377Simp*) find_local_scripts_new ;; 104279377Simpesac 105279377Simp 106279377Simpfiles=`rcorder ${skip} /etc/rc.d/* ${local_rc} 2>/dev/null` 107279377Simp_skip_early=1 108279377Simpfor _rc_elem in ${files}; do 109279377Simp case "$_skip_early" in 110279377Simp 1) case "$_rc_elem" in 111279377Simp */${early_late_divider}) _skip_early=0 ;; 112279377Simp esac 113279377Simp continue 114279377Simp ;; 115279377Simp esac 116279377Simp 117279377Simp run_rc_script ${_rc_elem} ${_boot} 118279377Simpdone 119279377Simp 120279377Simpecho '' 121279377Simpdate 122279377Simpexit 0 123279377Simp