case "$1" in
init)
# make sure we have a blank state directory for the scripts to work with
- rm -rf $CTDB_VARDIR/state
- mkdir -p $CTDB_VARDIR/state || {
- ret=$?
- echo "mkdir -p $CTDB_VARDIR/state - failed - $ret"
- exit $ret
- }
+ rm -rf "$CTDB_SCRIPT_VARDIR"
+ mkdir -p "$CTDB_SCRIPT_VARDIR" || \
+ die "mkdir -p ${CTDB_SCRIPT_VARDIR} - failed - ${ret}" $?
if select_tdb_checker ; then
check_persistent_databases || exit $?
# utility functions for ctdb event scripts
+CTDB_VARDIR="/usr/local/var/lib/ctdb"
+
# Only (and always) override these variables in test code
-if [ -z "$CTDB_VARDIR" ] ; then
- CTDB_VARDIR="/usr/local/var/lib/ctdb"
+if [ -z "$CTDB_SCRIPT_VARDIR" ] ; then
+ CTDB_SCRIPT_VARDIR="/usr/local/var/lib/ctdb/state"
fi
if [ -z "$CTDB_ETCDIR" ] ; then
# This sets $pnn - this avoid an unnecessary subprocess.
ctdb_get_pnn ()
{
- _pnn_file="$CTDB_VARDIR/state/my-pnn"
+ _pnn_file="${CTDB_SCRIPT_VARDIR}/my-pnn"
if [ ! -f "$_pnn_file" ] ; then
ctdb pnn | sed -e 's@.*:@@' >"$_pnn_file"
fi
_ctdb_check_tcp_common ()
{
assert_service_name
- _d="${CTDB_VARDIR}/state/failcount"
+ _d="${CTDB_SCRIPT_VARDIR}/failcount"
_ctdb_service_started_file="${_d}/${service_name}.started"
}
# Simple counters
_ctdb_counter_common () {
_service_name="${1:-${service_name:-${script_name}}}"
- _counter_file="${CTDB_VARDIR}/state/failcount/${_service_name}"
+ _counter_file="${CTDB_SCRIPT_VARDIR}/failcount/${_service_name}"
mkdir -p "${_counter_file%/*}" # dirname
}
ctdb_counter_init () {
ctdb_setup_service_state_dir ()
{
- service_state_dir="$CTDB_VARDIR/state/service_state/${1:-${service_name}}"
+ service_state_dir="${CTDB_SCRIPT_VARDIR}/service_state/${1:-${service_name}}"
mkdir -p "$service_state_dir" || {
echo "Error creating state dir \"$service_state_dir\""
exit 1
_ctdb_managed_common ()
{
- _ctdb_managed_file="${CTDB_VARDIR}/state/managed_history/${service_name}"
+ _ctdb_managed_file="${CTDB_SCRIPT_VARDIR}/managed_history/${service_name}"
}
ctdb_service_managed ()
_ctdb_service_reconfigure_common ()
{
- _d="${CTDB_VARDIR}/state/service_status/${service_name}"
+ _d="${CTDB_SCRIPT_VARDIR}/service_status/${service_name}"
mkdir -p "$_d"
_ctdb_service_reconfigure_flag="$_d/reconfigure"
}
{
_port="$1"
- tickledir="$CTDB_VARDIR/state/tickles"
+ tickledir="${CTDB_SCRIPT_VARDIR}/tickles"
mkdir -p "$tickledir"
ctdb_get_pnn
</listitem>
</varlistentry>
- <varlistentry>
- <term>CTDB_VARDIR=<parameter>DIRECTORY</parameter></term>
- <listitem>
- <para>
- DIRECTORY containing CTDB files that are modified at
- runtime.
- </para>
- <para>
- Defaults to <filename>/usr/local/var/lib/ctdb</filename>.
- </para>
- </listitem>
- </varlistentry>
-
-
</variablelist>
</refsect1>
</listitem>
</varlistentry>
+ <varlistentry>
+ <term>CTDB_VARDIR=<parameter>DIRECTORY</parameter></term>
+ <listitem>
+ <para>
+ DIRECTORY containing CTDB files that are modified at
+ runtime.
+ </para>
+ <para>
+ Defaults to <filename>/usr/local/var/lib/ctdb</filename>.
+ </para>
+ </listitem>
+ </varlistentry>
+
</variablelist>
</refsect1>
rm -r "$EVENTSCRIPTS_TESTS_VAR_DIR"
fi
mkdir -p "$EVENTSCRIPTS_TESTS_VAR_DIR"
-export CTDB_VARDIR="$EVENTSCRIPTS_TESTS_VAR_DIR/ctdb"
+export CTDB_SCRIPT_VARDIR="$EVENTSCRIPTS_TESTS_VAR_DIR/script-state"
export CTDB_LOGGING="file:${EVENTSCRIPTS_TESTS_VAR_DIR}/log.ctdb"
touch "${CTDB_LOGGING#file:}" || \
die "Unable to setup logging for \"$CTDB_LOGGING\""
-if [ -d "${TEST_SUBDIR}/etc" ] ; then
+if [ -d "${TEST_SUBDIR}/etc" ] ; then
cp -a "${TEST_SUBDIR}/etc" "$EVENTSCRIPTS_TESTS_VAR_DIR"
export CTDB_ETCDIR="${EVENTSCRIPTS_TESTS_VAR_DIR}/etc"
else
export FAKE_CTDB_PNN="$1"
echo "Setting up PNN ${FAKE_CTDB_PNN}"
- export CTDB_VARDIR="$EVENTSCRIPTS_TESTS_VAR_DIR/ctdb/${FAKE_CTDB_PNN}"
- mkdir -p "$CTDB_VARDIR"
+ export CTDB_SCRIPT_VARDIR="$EVENTSCRIPTS_TESTS_VAR_DIR/script-state/${FAKE_CTDB_PNN}"
+ mkdir -p "$CTDB_SCRIPT_VARDIR"
}
setup_ctdb ()