From owner-freebsd-rc@FreeBSD.ORG Mon May 21 21:58:37 2007 Return-Path: X-Original-To: freebsd-rc@freebsd.org Delivered-To: freebsd-rc@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 6D6BD16A46C for ; Mon, 21 May 2007 21:58:37 +0000 (UTC) (envelope-from mtm@FreeBSD.Org) Received: from mx1.ethionet.et (mx1.ethionet.et [213.55.64.53]) by mx1.freebsd.org (Postfix) with ESMTP id 5256713C4C2 for ; Mon, 21 May 2007 21:58:36 +0000 (UTC) (envelope-from mtm@FreeBSD.Org) Received: from mx1.ethionet.et (localhost [127.0.0.1]) by localhost.ethionet.et (Postfix) with ESMTP id C6DDD5033; Tue, 22 May 2007 00:54:44 +0300 (EAT) Received: from rogue.navcom.lan (unknown [213.55.71.12])by mx1.ethionet.et ( Postfix) with SMTP id B6C155010;Tue, 22 May 2007 00:54:37 +0300 (EAT) Received: by rogue.navcom.lan (Postfix, from userid 1001)id 03B631438; Tue, 22 May 2007 01:03:39 +0300 (EAT) Date: Tue, 22 May 2007 01:03:39 +0300 From: Mike Makonnen To: "Brian A. Seklecki" Message-ID: <20070521220339.GA2216@rogue.navcom.lan> References: <20070124163435.F18034@arbitor.digitalfreaks.org> <4B255085-7629 -4A98-AF24-465D6E48EB41@khera.org> <20070521143034.G5929@arbitor.digitalfre aks.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20070521143034.G5929@arbitor.digitalfreaks.org> User-Agent: Mutt/1.4.2.2i X-Operating-System: FreeBSD/7.0-CURRENT (i386) X-imss-version: 2.46 X-imss-result: Passed X-imss-scores: Clean:99.90000 C:2 M:3 S:5 R:5 X-imss-settings: Baseline:3 C:2 M:2 S:3 R:2 (0.5000 0.5000) Cc: Vivek Khera , freebsd-rc@freebsd.org Subject: Re: Apache-Style Profiles for FreeBSD ports/databases/slony/* X-BeenThere: freebsd-rc@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Discussion related to /etc/rc.d design and implementation." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 21 May 2007 21:58:37 -0000 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