[PATCH] Don't test if a service is enabled when it's required

Jilles Tjoelker jilles at stack.nl
Fri Aug 26 21:44:59 UTC 2011


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


More information about the freebsd-rc mailing list