From owner-freebsd-rc@FreeBSD.ORG Tue Jun 28 21:45:42 2011 Return-Path: Delivered-To: freebsd-rc@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 4777E1065673 for ; Tue, 28 Jun 2011 21:45:42 +0000 (UTC) (envelope-from jilles@stack.nl) Received: from mx1.stack.nl (relay02.stack.nl [IPv6:2001:610:1108:5010::104]) by mx1.freebsd.org (Postfix) with ESMTP id D9E268FC0C for ; Tue, 28 Jun 2011 21:45:41 +0000 (UTC) Received: from turtle.stack.nl (turtle.stack.nl [IPv6:2001:610:1108:5010::132]) by mx1.stack.nl (Postfix) with ESMTP id 61603359385 for ; Tue, 28 Jun 2011 23:45:40 +0200 (CEST) Received: by turtle.stack.nl (Postfix, from userid 1677) id 596441740A; Tue, 28 Jun 2011 23:45:40 +0200 (CEST) Date: Tue, 28 Jun 2011 23:45:40 +0200 From: Jilles Tjoelker To: freebsd-rc@freebsd.org Message-ID: <20110628214540.GA6258@stack.nl> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) Subject: Order of items in rc.d scripts such as quota 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: Tue, 28 Jun 2011 21:45:42 -0000 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