reload rc.conf during boot process

Markie mark.cullen at dsl.pipex.com
Tue Sep 21 06:15:43 PDT 2004


----- Original Message -----
From: "Giorgos Keramidas" <keramida at ceid.upatras.gr>
To: "Markie" <mark.cullen at dsl.pipex.com>
Cc: <freebsd-questions at freebsd.org>
Sent: Tuesday, September 21, 2004 10:36 AM
Subject: Re: reload rc.conf during boot process


| On 2004-09-21 00:26, Markie <mark.cullen at dsl.pipex.com> wrote:
| > Is it possible to do this somehow?
| >
| > I was trying my hand out at C and made a cool little menu for myself.
It
| > looks for files in /etc/ which are named rc.conf.xxxxx and lists them
in
| > the menu. Then, when you select one on boot, it copies the selected
| > configuration file to rc.conf. I put my program in... the rc.d mount
| > script, so that the disk is mounted writeable at the time and my C
program
| > is able to issue cp (bad way I know) to replace rc.conf. After running
my
| > program in the rc.d mount script I then did a
| >
| > . /etc/rc.conf
| >
| > but rc.conf doesn't get reloaded. The file is being copied over, as
when I
| > reboot it starts using the copied over configuration. I am not sure if
.
| > /etc/rc.conf is supposed to load a file in? I just saw it in some other
| > script and assumed that's what it was doing.
|
| The /etc/rc script is a ``driver script'' that loads rc.conf before teh
| mount script has a chance to run.  Even if you reload rc.conf in the
| mountd script this cannot affect the parent process that runs /etc/rc.
|

Oh I think I see what you're saying, it's kind of like variable scope,
right? When I do . /etc/rc.conf in mountcritlocal that's loading the file,
but only for that script? It's not actually replacing the variables at all,
right?

| I believe a good way to do this would be to add a special script in
| /etc/rc.d that depends on mountcritlocal that can give you the rc.conf
| selection menu and then hack /etc/rc to reload rc.conf if this special
| script runs and does indeed change `/etc/rc.conf'.

Wonder why I didn't make a seperate script for the menu in the first place!
Great idea, thanks!

|
| For instance, if you called your special rc.d script that presents the
| rc.conf selection menu ``selectcf'' and saved it in /etc/rc.d, then you
| could use something like this in /etc/rc to make sure it rereads rc.conf
| if changes are made to rc.conf:
|

I saw load_rc_config 'XXX' in early.sh or something, just a minute ago!
Does the XXX do anything?

load_rc_config() {
    _command=$1

    [....]

    if [ -f /etc/rc.conf.d/"$_command" ]; then
        . /etc/rc.conf.d/"$_command"
    fi

    [....]
}

I don't actually have rc.conf.d either, as far as I can tell?

Thanks for the rc changes too! I'll give that a read and try and understand
it then give it a shot :-)
Much appreciated!

My idea was so I could try out FreeBSD on my laptop and keep it usable on
the University network, but I use NIS and NFS at home so I need some sort
of caching going on or something. No idea how to do that! Maybe something
has already been done? Searching for 'NIS password cache' only came up with
some DNS cache thing.

| % Index: rc
| % ===================================================================
| % RCS file: /home/ncvs/src/etc/rc,v
| % retrieving revision 1.333
| % diff -u -r1.333 rc
| % --- rc        24 Jul 2004 16:30:31 -0000      1.333
| % +++ rc        21 Sep 2004 09:34:08 -0000
| % @@ -71,7 +71,20 @@
| %  files=`rcorder -k ${os} ${skip} /etc/rc.d/* 2>/dev/null`
| %
| %  for _rc_elem in ${files}; do
| % -     run_rc_script ${_rc_elem} ${_boot}
| % +     case ${_rc_elem} in
| % +     /etc/rc.d/selectcf)
| % +             _sum_before=`md5 /etc/rc.conf`
| % +             run_rc_script ${_rc_elem} ${_boot}
| % +             _sum_after=`md5 /etc/rc.conf`
| % +             if [ ! "${_sum_before}" = "${_sum_after}" ]; then
| % +                     unset _rc_conf_loaded
| % +                     load_rc_config 'XXX'
| % +             fi
| % +             ;;
| % +     *)
| % +             run_rc_script ${_rc_elem} ${_boot}
| % +             ;;
| % +     esac
| %  done
| %
| %  echo ''
|



More information about the freebsd-questions mailing list