Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 23 Dec 2006 18:52:55 -0500
From:      Kevin Brunelle <kruptos@mlinux.org>
To:        freebsd-questions@freebsd.org
Cc:        "Michael P. Soulier" <msoulier@digitaltorque.ca>
Subject:   Re: where are /usr/local/etc/rc.d init scripts run from?
Message-ID:  <200612231852.56016.kruptos@mlinux.org>
In-Reply-To: <fb6605670612231515v7f05acdbxc0bebf5e009fd6ff@mail.gmail.com>
References:  <fb6605670612231515v7f05acdbxc0bebf5e009fd6ff@mail.gmail.com>

Next in thread | Previous in thread | Raw E-Mail | Index | Archive | Help
On Saturday 23 December 2006 18:15, Michael P. Soulier wrote:
> I was looking in /etc/rc, and it's obvious to see where the /etc/rc.d
> scripts are run from.
>
> skip="-s nostart"
> [ `/sbin/sysctl -n security.jail.jailed` -eq 1 ] && skip="$skip -s nojail"
> files=`rcorder ${skip} /etc/rc.d/* 2>/dev/null`
>
> for _rc_elem in ${files}; do
>         run_rc_script ${_rc_elem} ${_boot}
> done
>
> So rcorder is run over /etc/rc.d/*.
>
> When is the same done for /usr/local/etc/rc.d/*?
>
> Thanks,
> Mike

They are called from /etc/rc.d/localpkg if they are the old style.

The directories searched are defined with local_startup (which defaults 
to: /usr/local/etc/rc.d /usr/X11R6/etc/rc.d).

The new style scripts are found in /etc/rc as well.  You may want to look at 
the find_local_scripts_new() function in /etc/rc.subr to see how some of this 
functions.  There is some trickery here because we have to do this in more 
than one step.  Since /usr/local/etc/rc.d/ may not be on a mounted filesystem 
until we run through some of the earlier scripts.

[/etc/rc:98-118]
# Now that disks are mounted, for each dir in $local_startup
# search for init scripts that use the new rc.d semantics.
#
case ${local_startup} in
[Nn][Oo] | '') ;;
*)  find_local_scripts_new ;;
esac

files=`rcorder ${skip} /etc/rc.d/* ${local_rc} 2>/dev/null`
_skip_early=1
for _rc_elem in ${files}; do
    case "$_skip_early" in
    1)  case "$_rc_elem" in
        */${early_late_divider})    _skip_early=0 ;;
        esac
        continue
        ;;
    esac

    run_rc_script ${_rc_elem} ${_boot}
done



Want to link to this message? Use this URL: <http://docs.FreeBSD.org/cgi/mid.cgi?200612231852.56016.kruptos>