Confused about /etc/rc.d and apache - BSD

This is a discussion on Confused about /etc/rc.d and apache - BSD ; I'm new to *BSD (well, actually I've been away for about 15 years), and I haven't got my head around how particular things in /etc/rc.d are selected to be started. Let me first explain what I think is going on ...

+ Reply to Thread
Results 1 to 12 of 12

Thread: Confused about /etc/rc.d and apache

  1. Confused about /etc/rc.d and apache

    I'm new to *BSD (well, actually I've been away for about 15 years), and
    I haven't got my head around how particular things in /etc/rc.d are
    selected to be started.

    Let me first explain what I think is going on so I can better articulate
    my confusion.

    First
    /etc/rc
    is run, figuring out what kind of boot this is and sourcing

    /etc/rc.subr
    which contains the shell sub routines that do the bulk of the work and
    then sourcing

    /etc/defaults/rc.conf
    and
    /etc/rc.conf

    which set shell variables, many of which are used to determine which
    services should be started.

    and (after working out a proper order for the things in rc.d calls
    run_rc_script()
    for each file.

    So unlike SysV still init.d, each and every start up script is run, each
    script determines for itself whether it should actually do anything.
    These scripts do this by looking to see whether script-name_enable has
    been set to YES (usually from one of the .conf files). This check is
    done via the set_rcvar() routine defined in rc.subr.

    I installed the apache22 port using pkg_add. That told me to add the line

    apache22_enable="YES"

    to /etc/rc.conf

    which I did. However, nothing seems to have been added to /etc/rc.d.
    And a grep for apache or http in /etc/rc.d turns up nothing.

    Yet when I rebooted (for other reasons) apache did start. How?

    Also if I want to start a service manually (and not at boot) is there
    some equivalent to what I would do under linux? eg something like

    /etc/init.d/apache

    This leads to a someone broader question. Is there a good document out
    there for helping people familiar with linux or other unicies to get get
    used to doing things the BSD way?

    -j

    --
    Jeffrey Goldberg http://www.goldmark.org/jeff/
    I rarely read top-posted, over-quoted or HTML posts
    My Reply-To address is valid.

  2. Re: Confused about /etc/rc.d and apache

    Jeffrey Goldberg wrote:

    > I installed the apache22 port using pkg_add. That told me to add the line
    >
    > apache22_enable="YES"
    >
    > to /etc/rc.conf
    >
    > which I did. However, nothing seems to have been added to /etc/rc.d.
    > And a grep for apache or http in /etc/rc.d turns up nothing.
    >
    > Yet when I rebooted (for other reasons) apache did start. How?


    Never mind. Within two minutes of posting, I discovered /usr/local/etc

    But that still leaves me with my other more general questions which I'll
    repeat here:

    > Also if I want to start a service manually (and not at boot) is there
    > some equivalent to what I would do under linux? eg something like
    >
    > /etc/init.d/apache
    >
    > This leads to a someone broader question. Is there a good document out
    > there for helping people familiar with linux or other unicies to get get
    > used to doing things the BSD way?



    --
    Jeffrey Goldberg http://www.goldmark.org/jeff/
    I rarely read top-posted, over-quoted or HTML posts
    My Reply-To address is valid.

  3. Re: Confused about /etc/rc.d and apache

    Jeffrey Goldberg wrote:

    [snip]
    > So unlike SysV still init.d, each and every start up script is run, each
    > script determines for itself whether it should actually do anything.
    > These scripts do this by looking to see whether script-name_enable has
    > been set to YES (usually from one of the .conf files). This check is
    > done via the set_rcvar() routine defined in rc.subr.


    I believe, IIRC, that the rc_subr startup system was imported from NetBSD.

    > I installed the apache22 port using pkg_add. That told me to add the line
    >
    > apache22_enable="YES"
    >
    > to /etc/rc.conf
    >
    > which I did. However, nothing seems to have been added to /etc/rc.d.
    > And a grep for apache or http in /etc/rc.d turns up nothing.
    >
    > Yet when I rebooted (for other reasons) apache did start. How?


    Look in /usr/local/etc for the rc.d directory. FreeBSD places startup
    scripts for third party applications such as Apache here. For example, on
    my system there is an apache22.sh which starts Apache. Of course scripts
    here need to have their execute bit(s) set. You will also find the .conf
    files for third party apps under /usr/local/etc as well.

    > Also if I want to start a service manually (and not at boot) is there
    > some equivalent to what I would do under linux? eg something like
    >
    > /etc/init.d/apache


    Generally speaking you can type /usr/local/etc/rc.d/somestartup.sh start or
    stop to run or stop a process. Apache in particular has a control program
    called apachectl which will start, stop, or restart Apache. Some other
    applications mau also have such a control program, the one that readily
    comes to my mind is Resin.

    > This leads to a someone broader question. Is there a good document out
    > there for helping people familiar with linux or other unicies to get get
    > used to doing things the BSD way?
    >


    My favorite starting point is the very excellent Handbook, which can be
    found here:

    http://www.freebsd.org/doc/en_US.ISO...ook/index.html

    as well as locally available under /usr/share/doc. Also while you're poking
    around in there notice the /usr/share/examples. This has some commented
    examples of typical configration files. When I first began with FreeBSD I
    started with the book "The Complete FreeBSD" by Greg Lehey. There is
    another book similar to this one, but I can't recall the name right now.

    -Jason





  4. Re: Confused about /etc/rc.d and apache

    On 2007-02-10, Jeffrey Goldberg wrote:
    > Jeffrey Goldberg wrote:
    >
    > Never mind. Within two minutes of posting, I discovered /usr/local/etc
    >
    > But that still leaves me with my other more general questions which I'll
    > repeat here:
    >
    >> Also if I want to start a service manually (and not at boot) is there
    >> some equivalent to what I would do under linux? eg something like
    >>
    >> /etc/init.d/apache
    >>


    Then just remove Apache entry from rc.conf, and the you can always run it
    manually with:

    # sh /usr/local/etc/rc.d/apache forcestart

    >> This leads to a someone broader question. Is there a good document out
    >> there for helping people familiar with linux or other unicies to get get
    >> used to doing things the BSD way?

    >


    www.freebsd.org/handbook?

    --
    Piotr Smyrak

  5. Re: Confused about /etc/rc.d and apache

    On Sat, 10 Feb 2007 14:50:52 -0600
    Jeffrey Goldberg wrote:

    > Jeffrey Goldberg wrote:
    > Never mind. Within two minutes of posting, I discovered /usr/local/etc




    > But that still leaves me with my other more general questions which I'll
    > repeat here:
    >
    > > Also if I want to start a service manually (and not at boot) is there
    > > some equivalent to what I would do under linux? eg something like
    > >
    > > /etc/init.d/apache


    /etc/rc.d/ start
    and to stop it
    /etc/rc.d/ stop

    Or you might want /usr/local/etc/rc.d/

    But note that it will not start unless the enabling variable is set
    in rc.conf.

    --
    C:>WIN | Directable Mirror Arrays
    The computer obeys and wins. | A better way to focus the sun
    You lose and Bill collects. | licences available see
    | http://www.sohara.org/

  6. Re: Confused about /etc/rc.d and apache

    Piotr Smyrak wrote:

    >>> Also if I want to start a service manually (and not at boot) is there
    >>> some equivalent to what I would do under linux? eg something like
    >>>
    >>> /etc/init.d/apache
    >>>

    >
    > Then just remove Apache entry from rc.conf, and the you can always run it
    > manually with:
    >
    > # sh /usr/local/etc/rc.d/apache forcestart


    Thank you.

    >>> This leads to a someone broader question. Is there a good document out
    >>> there for helping people familiar with linux or other unicies to get get
    >>> used to doing things the BSD way?

    >
    > www.freebsd.org/handbook?


    I have gone through the handbook and have found it very helpful.
    (Though I still don't grok the "ports" stuff yet). But if the answer to
    my above question was in the handbook or FAQ I apologize for missing. I
    have looked through both. I also suppose that other similar questions
    will come up. I guess the document I'm looking for is yet to be written.

    Cheers,

    -j



    --
    Jeffrey Goldberg http://www.goldmark.org/jeff/
    I rarely read top-posted, over-quoted or HTML posts
    My Reply-To address is valid.

  7. Re: Confused about /etc/rc.d and apache

    In our last episode, <12ssbtdk50iirb5@news.supernews.com>, the lovely and
    talented Jeffrey Goldberg broadcast on comp.unix.bsd.freebsd.misc:

    > Jeffrey Goldberg wrote:


    >> Also if I want to start a service manually (and not at boot) is there
    >> some equivalent to what I would do under linux? eg something like
    >>
    >> /etc/init.d/apache
    >>
    >> This leads to a someone broader question. Is there a good document out
    >> there for helping people familiar with linux or other unicies to get get
    >> used to doing things the BSD way?


    for apache see man apachectl.
    for other services you can run the appropriate script from
    /usr/local/etc/rc.d such as

    /usr/local/etc/rc.d/mysql-server start

    As should be obvious from this example, you have to investigate each
    one for required parameters or switches.

    --
    Lars Eighner
    Countdown: 709 days to go.

  8. Re: Confused about /etc/rc.d and apache

    On 02/11/2007 05:12 AM, Lars Eighner wrote:
    > In our last episode, <12ssbtdk50iirb5@news.supernews.com>, the lovely and
    > talented Jeffrey Goldberg broadcast on comp.unix.bsd.freebsd.misc:
    >
    >> Jeffrey Goldberg wrote:

    >
    >>> Also if I want to start a service manually (and not at boot) is there
    >>> some equivalent to what I would do under linux? eg something like
    >>>
    >>> /etc/init.d/apache
    >>>
    >>> This leads to a someone broader question. Is there a good document out
    >>> there for helping people familiar with linux or other unicies to get get
    >>> used to doing things the BSD way?

    >
    > for apache see man apachectl.
    > for other services you can run the appropriate script from
    > /usr/local/etc/rc.d such as
    >
    > /usr/local/etc/rc.d/mysql-server start
    >
    > As should be obvious from this example, you have to investigate each
    > one for required parameters or switches.


    Almost all the rc scripts inherit properties from /etc/rc.conf, so you
    still need to adjust your /etc/rc.conf even for the
    /usr/local/etc/rc.d/* scripts.

    The /usr/local/etc/rc.d/apache contains:

    apache_enable=${apache_enable-"NO"}

    so either to need to set it to YES in the /etc/rc.conf or provide it
    temporarily:

    # export apache_enable="YES" # bash
    # apache_enable="YES"; export export apache_enable # sh

    and try:

    # /usr/local/etc/rc.d/apache start

    Hope that helps!
    --
    Dr Balwinder S "bsd" Dheeman Registered Linux User: #229709
    Anu's Linux@HOME Machines: #168573, 170593, 259192
    Chandigarh, UT, 160062, India Distros: Ubuntu, Fedora, Knoppix
    Home: http://cto.homelinux.net/~bsd/ Visit: http://counter.li.org/

  9. Re: Confused about /etc/rc.d and apache

    On 2007-02-10, Steve O'Hara-Smith wrote:
    > On Sat, 10 Feb 2007 14:50:52 -0600
    > Jeffrey Goldberg wrote:
    >
    >> But that still leaves me with my other more general questions which I'll
    >> repeat here:
    >>
    >> > Also if I want to start a service manually (and not at boot) is there
    >> > some equivalent to what I would do under linux? eg something like
    >> >
    >> > /etc/init.d/apache

    >
    > /etc/rc.d/ start
    > and to stop it
    > /etc/rc.d/ stop


    Note, that that locations sports only base system startup scripts,
    3rd party apps from ports are not going in here. Apache is one of them.

    > Or you might want /usr/local/etc/rc.d/
    >
    > But note that it will not start unless the enabling variable is set
    > in rc.conf.


    One can always use:

    # /etc/rc.d/ force(start|stop)

    That will start/stop the service even without the knob set in rc.conf.*

    --
    Piotr Smyrak

  10. Re: Confused about /etc/rc.d and apache

    On 2007-02-10, Jeffrey Goldberg wrote:
    > Piotr Smyrak wrote:
    >
    >>>> This leads to a someone broader question. Is there a good document out
    >>>> there for helping people familiar with linux or other unicies to get get
    >>>> used to doing things the BSD way?

    >>
    >> www.freebsd.org/handbook?

    >
    > I have gone through the handbook and have found it very helpful.
    > (Though I still don't grok the "ports" stuff yet).


    What is that you do not understand?

    > But if the answer to
    > my above question was in the handbook or FAQ I apologize for missing. I
    > have looked through both. I also suppose that other similar questions
    > will come up. I guess the document I'm looking for is yet to be written.


    Try man rc for start, that will give you more insight on the
    booting process, and running services. You will get pointers
    to other manuals, too.

    --
    Piotr Smyrak

  11. Re: Confused about /etc/rc.d and apache

    In article <12ssbedngs55ac2@news.supernews.com>,
    Jeffrey Goldberg wrote:

    Just one little comment - the rest is snipped [ wjv ]

    >So unlike SysV still init.d, each and every start up script is
    >run, each script determines for itself whether it should actually
    >do anything. These scripts do this by looking to see whether
    >script-name_enable has been set to YES (usually from one of the
    >.conf files). This check is done via the set_rcvar() routine
    >defined in rc.subr.


    Actually the laster SysV systems also looked at another file to
    determine whether they should be run. On Irix the file that
    told things to start or not was a simple text file with the
    application name, and then a column that had either yes or no.

    Just thought I'd clarify that - SysV changed a lot during it
    evolution from V.2 to V.3 to V.4 - and during the process seemed to
    grow exponentially :-(

    Bill
    --
    Bill Vermillion - bv @ wjv . com

  12. Re: Confused about /etc/rc.d and apache

    Piotr Smyrak wrote:
    > On 2007-02-10, Jeffrey Goldberg wrote:


    >> I have gone through the handbook and have found it very helpful.
    >> (Though I still don't grok the "ports" stuff yet).

    >
    > What is that you do not understand?


    Actually, I think I have a better handle on it now.

    >> I guess the document I'm looking for is yet to be written.


    > Try man rc for start, that will give you more insight on the
    > booting process, and running services. You will get pointers
    > to other manuals, too.


    Thank you. And more importantly, the information that I had asked for
    here was in the Handbook after all (including information about
    /usr/local/etc) So I apologize for complaining that it wasn't. My only
    excuses are that I was reading the handbook with links (which takes some
    getting used to) and information overload.

    Anyway, thanks for everyone's help.

    Cheers,

    -j

    --
    Jeffrey Goldberg http://www.goldmark.org/jeff/
    I rarely read top-posted, over-quoted or HTML posts
    My Reply-To address is valid.

+ Reply to Thread