Date: Fri, 26 Aug 2011 23:44:56 +0200 From: Jilles Tjoelker <jilles@stack.nl> To: d@delphij.net Cc: freebsd-rc@FreeBSD.ORG Subject: Re: [PATCH] Don't test if a service is enabled when it's required Message-ID: <20110826214456.GA41095@stack.nl> In-Reply-To: <4E541A49.9050207@delphij.net> References: <4E50B5E3.90702@delphij.net> <20110821132045.GA3940@stack.nl> <4E541A49.9050207@delphij.net>
next in thread | previous in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20110826214456.GA41095>
