Setting rc scripts default values

Brooks Davis brooks at freebsd.org
Fri Feb 23 06:56:46 UTC 2007


On Fri, Feb 23, 2007 at 08:34:28AM +0200, Vasil Dimov wrote:
> On Thu, Feb 22, 2007 at 16:25:26 -0600, Brooks Davis wrote:
> > On Thu, Feb 22, 2007 at 07:26:58PM +0200, Vasil Dimov wrote:
> > > Hi,
> > > 
> > > Is there any special reason to write the rc scripts this way:
> > > 
> > > load_rc_config "$name"
> > > : ${rsyncd_enable="NO"}
> > > 
> > > instead of this way:
> > > 
> > > rsyncd_enable="NO"
> > > load_rc_config "$name"
> > > 
> > > apache does it this way:
> > > 
> > > apache_enable=${apache_enable-"NO"}
> > > load_rc_config $name
> > > 
> > > but I think it can safely be changed to
> > > 
> > > apache_enable="NO"
> > > load_rc_config $name
> > > 
> > > What did I miss...
> > 
> > load_rc_config doesn't reread /etc/rc.conf every time.
> 
> Hmmz, I see that load_rc_config() does not reread /etc/rc.conf only if
> _rc_conf_loaded is set. The only place where _rc_conf_loaded is set is
> in load_rc_config() itself after it reads /etc/rc.conf. load_rc_config()
> is not called anywhere in rc.subr [1].
> 
> Can you show me a scenario where this code:
> 
> . /etc/rc.subr
> rcvar=`set_rcvar`
> foo_enable="NO"
> load_rc_config ${name}  # foo_enable="YES" is in /etc/rc.conf
> 
> ends up with foo_enable="NO"?
> 
> Thanks.

load_rc_config is called from /etc/rc before any scripts are run on
startup.  If that doesn't result in _rc_conf_loaded being set in the
script, the code is useless and should be ripped out (I'm not entierly
sure it isn't useless, but it's late here and I'm not going to test it
now).

-- Brooks
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 187 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-rc/attachments/20070223/74a9616f/attachment.pgp


More information about the freebsd-rc mailing list