Date: Tue, 28 Jun 2011 23:45:40 +0200 From: Jilles Tjoelker <jilles@stack.nl> To: freebsd-rc@freebsd.org Subject: Order of items in rc.d scripts such as quota Message-ID: <20110628214540.GA6258@stack.nl>
next in thread | raw e-mail | index | archive | help
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. -- Jilles Tjoelker
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20110628214540.GA6258>
