Date: Fri, 5 Sep 2014 21:59:12 +0200 From: Jilles Tjoelker <jilles@stack.nl> To: Dag-Erling =?iso-8859-1?Q?Sm=F8rgrav?= <des@des.no> Cc: freebsd-rc@freebsd.org Subject: Re: rc.conf.d improvement Message-ID: <20140905195912.GC73176@stack.nl> In-Reply-To: <86a97bp27r.fsf@nine.des.no> References: <86a97bp27r.fsf@nine.des.no>
next in thread | previous in thread | raw e-mail | index | archive | help
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/<service> 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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20140905195912.GC73176>
