From owner-freebsd-rc@FreeBSD.ORG Fri Aug 26 21:44:59 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 A8D701065676 for ; Fri, 26 Aug 2011 21:44:59 +0000 (UTC) (envelope-from jilles@stack.nl) Received: from mx1.stack.nl (relay04.stack.nl [IPv6:2001:610:1108:5010::107]) by mx1.freebsd.org (Postfix) with ESMTP id 4C05A8FC1A for ; Fri, 26 Aug 2011 21:44:59 +0000 (UTC) Received: from turtle.stack.nl (turtle.stack.nl [IPv6:2001:610:1108:5010::132]) by mx1.stack.nl (Postfix) with ESMTP id 99F7D1DD73F; Fri, 26 Aug 2011 23:44:56 +0200 (CEST) Received: by turtle.stack.nl (Postfix, from userid 1677) id 834DF174D1; Fri, 26 Aug 2011 23:44:56 +0200 (CEST) Date: Fri, 26 Aug 2011 23:44:56 +0200 From: Jilles Tjoelker To: d@delphij.net Message-ID: <20110826214456.GA41095@stack.nl> References: <4E50B5E3.90702@delphij.net> <20110821132045.GA3940@stack.nl> <4E541A49.9050207@delphij.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4E541A49.9050207@delphij.net> User-Agent: Mutt/1.5.21 (2010-09-15) Cc: freebsd-rc@FreeBSD.ORG Subject: Re: [PATCH] Don't test if a service is enabled when it's required 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: Fri, 26 Aug 2011 21:44:59 -0000 On Tue, Aug 23, 2011 at 02:23:21PM -0700, Xin LI wrote: > Thanks for Jilles' comments. I've added a new procedure called > fast_depend (poor name perhaps?) with a proposed changeset to all > these rc.d scripts that uses force_depend. > Comments? This looks like it avoids the extra forks, good. The scripts look cleaner now. > Index: etc/rc.subr > =================================================================== > --- etc/rc.subr (revision 225119) > +++ etc/rc.subr (working copy) > @@ -159,6 +159,29 @@ > } > > # > +# fast_depend script [var] [prefix] > +# Force a service to start if it's not already, regardless > +# if it's enabled. Intended for use by services > +# to resolve dependency issues. When rc_fast is set, > +# only force the dependency if var is set to "NO". It seems useful here to say why: because it will have been started anyway if var is set to "YES". > +# $1 - script name > +# $2 - variable name if the variable to test is not ${1}_enable > +# $3 - prefix path if not the default /etc/rc.d While useful, an alternate script directory cannot work because force_depend does not support it. > +# > +fast_depend() > +{ > + _script="$1" > + _variable="${2:-${1}_enable}" > + _prefix="${3:-/etc/rc.d}" > + > + if { [ -z "${rc_fast}" ] || ! checkyesno ${_variable}; } && > + ! ${_prefix}/${_script} forcestatus 1>/dev/null 2>&1 > + then > + force_depend ${_script} || return 1 > + fi > +} > + > +# > # reverse_list list > # print the list in reverse order > # -- Jilles Tjoelker