Date: Tue, 21 Sep 2004 12:36:47 +0300 From: Giorgos Keramidas <keramida@ceid.upatras.gr> To: Markie <mark.cullen@dsl.pipex.com> Cc: freebsd-questions@freebsd.org Subject: Re: reload rc.conf during boot process Message-ID: <20040921093647.GC4451@orion.daedalusnetworks.priv> In-Reply-To: <01bb01c49f69$48c66300$f800000a@laptop> References: <01bb01c49f69$48c66300$f800000a@laptop>
next in thread | previous in thread | raw e-mail | index | archive | help
On 2004-09-21 00:26, Markie <mark.cullen@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. 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'. 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: % 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 ''
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20040921093647.GC4451>