From owner-freebsd-questions@FreeBSD.ORG Tue Sep 21 09:37:20 2004 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 50EB916A4CE for ; Tue, 21 Sep 2004 09:37:20 +0000 (GMT) Received: from aiolos.otenet.gr (aiolos.otenet.gr [195.170.0.23]) by mx1.FreeBSD.org (Postfix) with ESMTP id C6ED943D1D for ; Tue, 21 Sep 2004 09:37:10 +0000 (GMT) (envelope-from keramida@ceid.upatras.gr) Received: from orion.daedalusnetworks.priv (host5.bedc.ondsl.gr [62.103.39.229])i8L9awvn016144; Tue, 21 Sep 2004 12:37:00 +0300 Received: from orion.daedalusnetworks.priv (orion [127.0.0.1]) i8L9amUW004862; Tue, 21 Sep 2004 12:36:48 +0300 (EEST) (envelope-from keramida@ceid.upatras.gr) Received: (from keramida@localhost)i8L9alXx004861; Tue, 21 Sep 2004 12:36:47 +0300 (EEST) (envelope-from keramida@ceid.upatras.gr) Date: Tue, 21 Sep 2004 12:36:47 +0300 From: Giorgos Keramidas To: Markie Message-ID: <20040921093647.GC4451@orion.daedalusnetworks.priv> References: <01bb01c49f69$48c66300$f800000a@laptop> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <01bb01c49f69$48c66300$f800000a@laptop> cc: freebsd-questions@freebsd.org Subject: Re: reload rc.conf during boot process X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 21 Sep 2004 09:37:20 -0000 On 2004-09-21 00:26, Markie 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 ''