From owner-freebsd-rc@FreeBSD.ORG Sun Aug 21 13:20:46 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 CF782106564A for ; Sun, 21 Aug 2011 13:20:46 +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 73A778FC17 for ; Sun, 21 Aug 2011 13:20:46 +0000 (UTC) Received: from turtle.stack.nl (turtle.stack.nl [IPv6:2001:610:1108:5010::132]) by mx1.stack.nl (Postfix) with ESMTP id A53011DD79C; Sun, 21 Aug 2011 15:20:45 +0200 (CEST) Received: by turtle.stack.nl (Postfix, from userid 1677) id 97F57174D1; Sun, 21 Aug 2011 15:20:45 +0200 (CEST) Date: Sun, 21 Aug 2011 15:20:45 +0200 From: Jilles Tjoelker To: d@delphij.net Message-ID: <20110821132045.GA3940@stack.nl> References: <4E50B5E3.90702@delphij.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4E50B5E3.90702@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: Sun, 21 Aug 2011 13:20:46 -0000 On Sun, Aug 21, 2011 at 12:38:11AM -0700, Xin LI wrote: > Currently we do a checkyesno before doing forcestatus on a service that > is required. However, this way if a dependent service is enabled but > stopped, it would not be started. > For instance: > echo 'mountd_enable="YES"' >> /etc/rc.conf > /etc/rc.d/mountd stop > /etc/rc.d/nfsd stop > /etc/rc.d/nfsd start > Would not start mountd. > I'd like to propose the attached patch since it doesn't seem to be > necessary that we test the enable status before doing forcestatus. > Comments? > Index: amd > =================================================================== > --- amd (revision 225055) > +++ amd (working copy) > @@ -23,8 +23,7 @@ > force_depend nfsclient || return 1 > fi > > - if ! checkyesno rpcbind_enable && \ > - ! /etc/rc.d/rpcbind forcestatus 1>/dev/null 2>&1 > + if ! /etc/rc.d/rpcbind forcestatus 1>/dev/null 2>&1 > then > force_depend rpcbind || return 1 > fi [snip] I don't like that this adds a bunch of unnecessary checks to the boot. If we are booting and the appropriate variable is set, the service is running and it is not necessary to check for a process (unless it failed, in which case there is little point in trying again). Calling checkyesno is much faster than checking status (which forks several times and reads ps output byte-by-byte with the read builtin). -- Jilles Tjoelker