Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 22 May 2007 01:03:39 +0300
From:      Mike Makonnen <mtm@FreeBSD.Org>
To:        "Brian A. Seklecki" <lavalamp@spiritual-machines.org>
Cc:        Vivek Khera <vivek@khera.org>, freebsd-rc@freebsd.org
Subject:   Re: Apache-Style Profiles for FreeBSD ports/databases/slony/*
Message-ID:  <20070521220339.GA2216@rogue.navcom.lan>
In-Reply-To: <20070521143034.G5929@arbitor.digitalfreaks.org>
References:  <20070124163435.F18034@arbitor.digitalfreaks.org> <4B255085-7629 -4A98-AF24-465D6E48EB41@khera.org> <20070521143034.G5929@arbitor.digitalfre aks.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Mon, May 21, 2007 at 03:24:01PM -0400, Brian A. Seklecki wrote:
> 
> Before we slip this in (I can have a clean version ready for 1.3), I had an
> architectural question about two RC variables for the -rc list.B
> 
> $[command_]flags v.s $[command_]args.  What is the architectural purpose of 
> each?  Override?  Append?  Prepend? I've looked at a bunch of scripts and 
> they're used interchangeably in many 3rd party ports scripts.
> 
> It would seem:
> 
> rc.subr(8) we run:
> 
> 	$command $rc_flags $command_args

Sometimes you may want to specify additional flags to the program from
within the rc.d script *without* clobbering any flags set in rc.conf(5).
That's what command_args is for.

> 
> I'm creating an Apache-profile-style script for Slony.  Use of profiles 
> enables some modifications to the default $command_args (appending 
> "-${profilename}" to the PID and conf file location, etc.).
> 
> However, I'd like the user/admin to be able to do *both*:
> 
> 1) Append or prepend thier own flags to the auto-generated ones
> 2) Override the auto-generated flags entirely on a per-profile basis!

I'm not familiar with what profiles are, but from a complexity
standpoint I don't think you should be doing #1. You should set sensible
defaults in your script that will work in most (normal ?) situations, but
if the user wants to override them, then the rc.conf(5) settings should
be used instead of the settings in the script.

> 
> What I was thinking I should have is:
> 
> 1) $command_args within the RC script sets the defaults for non-profile
>    config.

The command_args variable is used to append *your* flags to the command-
line without clobbering the flags set in rc.conf(5). What you should do
instead is set the default flags as so:

slon_flags="${slon_flags-'-foo'}"

This essentially serves the same purpose for a port as the flags in 
/etc/defaults/rc.conf do for programs in the base system.

> 2) $slon_flags in rc.conf(5) allows overriding of non-profile defaults
> 3) Each profile uses $slon_[profilename]_flags inherited from
>    $command_args
> 4) $slon_[profilename]_flags would normally be automatically generated
>    within RC script (adjusted PID / Conf file defaults)
> 
> --- This is where I need some guidance --
> 
> 5a) Presence of $slon_[profilename]_flags in rc.conf(5) overrides the RC
>     script auto generation.  $command_args is disregarded entirely if
>     $slon_[profilename]_flags is defined.
> 

This is probably what you should be doing (and what I would do). Basically,
put the following lines somewhere in your script:

slon_flags="${slon_flags-'-foo'}"
slon_[profilename]_flags="${slon_[profilename]_flags-'-bar'}"

[I'm assuming here that the contents of these knobs do not overlap].

> It would also seem that that I have $rc_flags at my disposal -- contains a
> string, which is eval(1)'d into another variable name for $command_flags /
> ${name}_flags.

rc_flags is for use in situations where you *want* to clobber the
flags set in rc.conf(5).

Cheers.
-- 
Mike Makonnen         | GPG-KEY: http://people.freebsd.org/~mtm/mtm.asc
mmakonnen @ gmail.com | AC7B 5672 2D11 F4D0 EBF8  5279 5359 2B82 7CD4 1F55
mtm @ FreeBSD.Org     | FreeBSD - http://www.freebsd.org



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20070521220339.GA2216>