This allows other scripts to use the given options for a particular
event script. One interesting example is that the ctdb_natgw tool
should look for configuration in events.d/11.natgw.options.
In the future this will be something like
events/failover/11.natgw.options, so require the component to be
specified even though it isn't yet used.
Test support is also updated.
Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
fi
}
+# load_script_options [ component script ]
+# script is an event script name relative to a component
+# component is currently ignored
load_script_options ()
{
+ if [ $# -eq 2 ] ; then
+ _script="$2"
+ elif [ $# -eq 0 ] ; then
+ _script=""
+ else
+ die "usage: load_script_options [ component script ]"
+ fi
+
loadconfig
_options="${CTDB_BASE}/script.options"
. "$_options"
fi
- _options="${0%.script}.options"
+ if [ -n "$_script" ] ; then
+ _s="${CTDB_BASE}/events.d/${_script}"
+ else
+ _s="${0%.script}"
+ fi
+ _options="${_s}.options"
if [ -r "$_options" ] ; then
. "$_options"
# General setup fakery
-# The current implementation just assumes each non-comment line of
-# input is a variable assignment and evals it with export prepended.
+# Default is to use script name with ".options" appended. With
+# arguments, this can specify an alternate script name (and
+# component).
setup_script_options ()
{
- _options="${script_dir}/${script%.script}.options"
+ if [ $# -eq 2 ] ; then
+ _script="$2"
+ elif [ $# -eq 0 ] ; then
+ _script=""
+ else
+ die "usage: setup_script_options [ component script ]"
+ fi
+
+ if [ -n "$_script" ] ; then
+ _options="${CTDB_BASE}/events.d/${_script}.options"
+ else
+ _options="${script_dir}/${script%.script}.options"
+ fi
cat >>"$_options"