Order of items in rc.d scripts such as quota
Doug Barton
dougb at FreeBSD.org
Wed Jun 29 00:02:48 UTC 2011
On 06/28/2011 14:45, Jilles Tjoelker wrote:
> This message is about a style issue of little relevance to correctness;
> however, consistency in this regard is useful.
>
> The conventional order of items in rc.d scripts appears to be
> * comments and keywords
> * source /etc/rc.subr and the like
> * set variables like name, rcvar, start_cmd, stop_cmd
> * define functions
> * load_rc_config $name
> * run_rc_command "$1"
>
> A problem occurs when the variables to be set need rc.conf information.
> In the case of start_cmd and stop_cmd this can always be avoided by
> having them call a function (which could be done but was not done in the
> recently fixed /etc/rc.d/quota, r223644, conf/157687), but this does not
> work for some other variables like command_args (e.g. in
> /etc/rc.d/ypxfrd).
>
> A nasty thing about this is that /etc/rc.conf variables work even before
> load_rc_config when the script is started from /etc/rc (initial boot and
> shutdown) but not when the script is started directly or via service(8).
> Variables from /etc/rc.conf.d or defaults work in neither case.
>
> It would be safer to place load_rc_config directly below the name and
> rcvar settings and any set_rcvar and set_rcvar_obsolete calls. This is
> in fact exactly what r223644 does for /etc/rc.d/quota so this change
> seems good even if it is somewhat different from many other rc.d
> scripts.
I agree. It's long been necessary to move load_rc_config up in ports
scripts, e.g.,
http://www.freebsd.org/doc/en_US.ISO8859-1/books/porters-handbook/rc-scripts.html
The current ordering was adopted wholesale from the NetBSD import, and
is fine for trivial scripts, but as you point out here it causes more
problems than it solves for anything even moderately complex. I've
struggled with it in rc.d/named many times in fact.
Assuming no one objects, how do you plan to make the change? My
preference is towards doing it en masse in HEAD prior to 9-release, and
MFC'ing to RELENG_8 prior to 8.3. I'm willing to do what I can to help
here, albeit with a currently small supply of 'tuits.
Doug
--
Nothin' ever doesn't change, but nothin' changes much.
-- OK Go
Breadth of IT experience, and depth of knowledge in the DNS.
Yours for the right price. :) http://SupersetSolutions.com/
More information about the freebsd-rc
mailing list