From owner-freebsd-rc@FreeBSD.ORG Fri Sep 5 19:59:17 2014 Return-Path: Delivered-To: freebsd-rc@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 1579E9E3 for ; Fri, 5 Sep 2014 19:59:17 +0000 (UTC) Received: from mx1.stack.nl (relay04.stack.nl [IPv6:2001:610:1108:5010::107]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (Client CN "mailhost.stack.nl", Issuer "CA Cert Signing Authority" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id CC64615B3 for ; Fri, 5 Sep 2014 19:59:16 +0000 (UTC) Received: from snail.stack.nl (snail.stack.nl [IPv6:2001:610:1108:5010::131]) by mx1.stack.nl (Postfix) with ESMTP id B8EACB80E8; Fri, 5 Sep 2014 21:59:12 +0200 (CEST) Received: by snail.stack.nl (Postfix, from userid 1677) id A76D228494; Fri, 5 Sep 2014 21:59:12 +0200 (CEST) Date: Fri, 5 Sep 2014 21:59:12 +0200 From: Jilles Tjoelker To: Dag-Erling =?iso-8859-1?Q?Sm=F8rgrav?= Subject: Re: rc.conf.d improvement Message-ID: <20140905195912.GC73176@stack.nl> References: <86a97bp27r.fsf@nine.des.no> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <86a97bp27r.fsf@nine.des.no> User-Agent: Mutt/1.5.21 (2010-09-15) Cc: freebsd-rc@freebsd.org X-BeenThere: freebsd-rc@freebsd.org X-Mailman-Version: 2.1.18-1 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, 05 Sep 2014 19:59:17 -0000 On Mon, Aug 11, 2014 at 03:47:52PM +0200, Dag-Erling Smørgrav wrote: > The attached patch does two things: > > 1) Add /etc/rc.conf.d to BSD.root.mtree so it's created during > installation; > > 2) Modify rc.subr so that if /etc/rc.conf.d/ is a directory, > all of the files it contains are included. > Comments or objections? Conceptually it is ok, but I have a comment about the implementation of 2). > [snip] > Index: etc/rc.subr > =================================================================== > --- etc/rc.subr (revision 269808) > +++ etc/rc.subr (working copy) > @@ -1290,8 +1290,14 @@ > _rc_conf_loaded=true > fi > if [ -f /etc/rc.conf.d/"$_name" ]; then > - debug "Sourcing /etc/rc.conf.d/${_name}" > + debug "Sourcing /etc/rc.conf.d/$_name" > . /etc/rc.conf.d/"$_name" > + elif [ -d /etc/rc.conf.d/"$_name" ] ; then > + local _rc > + for _rc in $(/bin/ls /etc/rc.conf.d/"$_name") ; do > + debug "Sourcing /etc/rc.conf.d/$_name/$_rc" > + . "/etc/rc.conf.d/$_name/$_rc" > + done > fi > > # Set defaults if defined. Please don't try to parse ls output, since this introduces problems with special characters and is slower than globbing. You can do something like for _rc in /etc/rc.conf.d/"$_name"/*; do if [ -f "$_rc" ]; then debug "Sourcing $_rc" . "$_rc" fi done -- Jilles Tjoelker