[SCM] Samba Shared Repository - branch master updated
Michael Adam
obnox at samba.org
Tue Sep 15 09:58:03 UTC 2015
The branch, master has been updated
via 3ddd351 ctdb-build: Install pre-built manpages when xsltproc not available
via f1bb641 ctdb-doc: Update out-of-date documentation for CTDB socket options
via b933b91 ctdb-scripts: Update important installed files to use build-time defaults
via 56fd37b ctdb-tools: Drop vacuum.log from ctdb_diagnostics
via 121d1a8 ctdb-scripts: Rename variable CTDB_ETCDIR to CTDB_SYS_ETCDIR
via 014a1eb ctdb-scripts: CTDB_BASE must be set when including functions file
via c58d582 ctdb-scripts: Factor out possible creation of rt_tables file
via 6774676 ctdb-scripts: Move remaining state files into CTDB_SCRIPT_VARDIR
via 3aa11b1 ctdb-scripts: New internal variable CTDB_SCRIPT_VARDIR
via d064620 ctdb-scripts: Properly set CTDB_VARDIR in scripts at install time
via bd77a97 ctdb-build: Add missing manual pages to pre-generate list for tarball
via 36a1473 ctdb-docs: Update "ctdb reloadnodes" documentation
via e7a139b ctdb-scripts: Drop internal file-level variables referencing $CTDB_VARDIR
via 143ec9e ctdb-scripts: Drop file removal involving $ctdb_managed_dir
via 353c27d ctdb-scripts: Drop functions ctdb_checkstatus() and ctdb_setstatus()
via 8c2948e ctdb-scripts: Drop 62.cnfs eventscript
from 9d49dfa ctdb-scripts: New internal variable CTDB_NFS_CALLOUT_STATE_DIR
https://git.samba.org/?p=samba.git;a=shortlog;h=master
- Log -----------------------------------------------------------------
commit 3ddd35142ab86de431d00f93de2fb6a2b371317d
Author: Martin Schwenke <martin at meltin.net>
Date: Fri Sep 11 13:08:38 2015 +1000
ctdb-build: Install pre-built manpages when xsltproc not available
At the moment they are not installed at all if xsltproc is not
available.
They can still be filtered to have the paths match what was
configured.
Signed-off-by: Martin Schwenke <martin at meltin.net>
Reviewed-by: Amitay Isaacs <amitay at gmail.com>
Reviewed-by: Jose A. Rivera <jarrpa at samba.org>
Reviewed-by: Michael Adam <obnox at samba.org>
Autobuild-User(master): Michael Adam <obnox at samba.org>
Autobuild-Date(master): Tue Sep 15 11:57:44 CEST 2015 on sn-devel-104
commit f1bb641a3a0f923faa594937db55437caf446343
Author: Martin Schwenke <martin at meltin.net>
Date: Mon Aug 17 21:09:06 2015 +1000
ctdb-doc: Update out-of-date documentation for CTDB socket options
These still say /tmp/ctdb.socket, which is very out-dated. Update
with build-time location.
Signed-off-by: Martin Schwenke <martin at meltin.net>
Reviewed-by: Amitay Isaacs <amitay at gmail.com>
Reviewed-by: Jose A. Rivera <jarrpa at samba.org>
Reviewed-by: Michael Adam <obnox at samba.org>
commit b933b91a0b03969eea73bb986f94e6c1d2e4887c
Author: Martin Schwenke <martin at meltin.net>
Date: Mon Aug 17 20:47:58 2015 +1000
ctdb-scripts: Update important installed files to use build-time defaults
In this case: ctdbd_wrapper, onnode, ctdb_diagnostics, ctdb.sudoers.
Set sensible defaults from configure options.
Update documentation to match, trying to fix up anything that has been
missed before.
The onnode unit tests need a symlink to the functions file.
The simple integration tests need to set CTDB_BASE and also
need symlinks to functions/nodes.
Signed-off-by: Martin Schwenke <martin at meltin.net>
Reviewed-by: Amitay Isaacs <amitay at gmail.com>
Reviewed-by: Jose A. Rivera <jarrpa at samba.org>
Reviewed-by: Michael Adam <obnox at samba.org>
fixup
Signed-off-by: Martin Schwenke <martin at meltin.net>
commit 56fd37ba0dc26f14261dee5e12f1dbcddf8b6779
Author: Martin Schwenke <martin at meltin.net>
Date: Sat Aug 22 20:14:09 2015 +1000
ctdb-tools: Drop vacuum.log from ctdb_diagnostics
This hasn't existed for a long time.
Signed-off-by: Martin Schwenke <martin at meltin.net>
Reviewed-by: Amitay Isaacs <amitay at gmail.com>
Reviewed-by: Jose A. Rivera <jarrpa at samba.org>
Reviewed-by: Michael Adam <obnox at samba.org>
commit 121d1a8571a36636ba6efda778d01ec8c9d1e671
Author: Martin Schwenke <martin at meltin.net>
Date: Mon Aug 17 14:12:15 2015 +1000
ctdb-scripts: Rename variable CTDB_ETCDIR to CTDB_SYS_ETCDIR
This variable points to /etc/ by default.
This distinguishes it from the different variable from wscript, which
points to /etc/ctdb/.
Signed-off-by: Martin Schwenke <martin at meltin.net>
Reviewed-by: Amitay Isaacs <amitay at gmail.com>
Reviewed-by: Jose A. Rivera <jarrpa at samba.org>
Reviewed-by: Michael Adam <obnox at samba.org>
commit 014a1eb54008fc36890c8bcd4103fbd8053002e2
Author: Martin Schwenke <martin at meltin.net>
Date: Mon Aug 17 14:01:40 2015 +1000
ctdb-scripts: CTDB_BASE must be set when including functions file
Also fix an unused test to set CTDB_BASE.
Signed-off-by: Martin Schwenke <martin at meltin.net>
Reviewed-by: Amitay Isaacs <amitay at gmail.com>
Reviewed-by: Jose A. Rivera <jarrpa at samba.org>
Reviewed-by: Michael Adam <obnox at samba.org>
commit c58d582ffb8c03f67b6799a9783fe8061b404d5e
Author: Martin Schwenke <martin at meltin.net>
Date: Mon Aug 17 13:39:10 2015 +1000
ctdb-scripts: Factor out possible creation of rt_tables file
Signed-off-by: Martin Schwenke <martin at meltin.net>
Reviewed-by: Amitay Isaacs <amitay at gmail.com>
Reviewed-by: Jose A. Rivera <jarrpa at samba.org>
Reviewed-by: Michael Adam <obnox at samba.org>
commit 677467682a8866096e696191c4ac93249c9fb991
Author: Martin Schwenke <martin at meltin.net>
Date: Thu Aug 13 15:57:52 2015 +1000
ctdb-scripts: Move remaining state files into CTDB_SCRIPT_VARDIR
Signed-off-by: Martin Schwenke <martin at meltin.net>
Reviewed-by: Amitay Isaacs <amitay at gmail.com>
Reviewed-by: Jose A. Rivera <jarrpa at samba.org>
Reviewed-by: Michael Adam <obnox at samba.org>
commit 3aa11b175ac2a09af292e187929212cfad4e0839
Author: Martin Schwenke <martin at meltin.net>
Date: Thu Aug 13 15:54:20 2015 +1000
ctdb-scripts: New internal variable CTDB_SCRIPT_VARDIR
Clearly identifies where all state files from scripts should go and
allows that location to be easily changed. This patch should not
change any behaviour (outside of eventscript unit tests, where a
clearer location is now used).
CTDB_VARDIR should no longer be overridden. Continue to set
CTDB_DBDIR and similar to override database location in unit tests.
Signed-off-by: Martin Schwenke <martin at meltin.net>
Reviewed-by: Amitay Isaacs <amitay at gmail.com>
Reviewed-by: Jose A. Rivera <jarrpa at samba.org>
Reviewed-by: Michael Adam <obnox at samba.org>
commit d064620f51f572b925e901feddb3ed649320fea7
Author: Martin Schwenke <martin at meltin.net>
Date: Thu Aug 13 15:17:51 2015 +1000
ctdb-scripts: Properly set CTDB_VARDIR in scripts at install time
Have wscript do path substitution.
No need to export this and CTDB_ETCDIR here, but test scripts will
still need to do so.
Signed-off-by: Martin Schwenke <martin at meltin.net>
Reviewed-by: Amitay Isaacs <amitay at gmail.com>
Reviewed-by: Jose A. Rivera <jarrpa at samba.org>
Reviewed-by: Michael Adam <obnox at samba.org>
commit bd77a9797fc24587309b5c2873bd5f2b144f3ae6
Author: Martin Schwenke <martin at meltin.net>
Date: Fri Aug 21 21:19:55 2015 +1000
ctdb-build: Add missing manual pages to pre-generate list for tarball
Signed-off-by: Martin Schwenke <martin at meltin.net>
Reviewed-by: Amitay Isaacs <amitay at gmail.com>
Reviewed-by: Jose A. Rivera <jarrpa at samba.org>
Reviewed-by: Michael Adam <obnox at samba.org>
commit 36a14730f18ef5a87f3d9095693cab0f06062414
Author: Martin Schwenke <martin at meltin.net>
Date: Fri Aug 21 16:07:21 2015 +1000
ctdb-docs: Update "ctdb reloadnodes" documentation
Format instructions for adding/deleting nodes with appropriate XML and
simplify wording.
Signed-off-by: Martin Schwenke <martin at meltin.net>
Reviewed-by: Amitay Isaacs <amitay at gmail.com>
Reviewed-by: Jose A. Rivera <jarrpa at samba.org>
Reviewed-by: Michael Adam <obnox at samba.org>
commit e7a139bffe80b7111d8392bf25a50d528d5e42e7
Author: Martin Schwenke <martin at meltin.net>
Date: Mon Aug 10 16:11:18 2015 +1000
ctdb-scripts: Drop internal file-level variables referencing $CTDB_VARDIR
Using $CTDB_VARDIR at file scope is dangerous because it doesn't
respect the configuration. Uses of these variables are simple so just
drop the variables and use $CTDB_VARDIR inside functions where it is
safe.
Signed-off-by: Martin Schwenke <martin at meltin.net>
Reviewed-by: Amitay Isaacs <amitay at gmail.com>
Reviewed-by: Jose A. Rivera <jarrpa at samba.org>
Reviewed-by: Michael Adam <obnox at samba.org>
commit 143ec9e4c2963039d08d4cd9835474412c5eb6c8
Author: Martin Schwenke <martin at meltin.net>
Date: Mon Aug 10 16:33:42 2015 +1000
ctdb-scripts: Drop file removal involving $ctdb_managed_dir
This directory has been under $CTDB_VARDIR for a long time, so is
already removed. The command is also potentially dangerous if
$ctdb_managed_dir is not set.
Signed-off-by: Martin Schwenke <martin at meltin.net>
Reviewed-by: Amitay Isaacs <amitay at gmail.com>
Reviewed-by: Jose A. Rivera <jarrpa at samba.org>
Reviewed-by: Michael Adam <obnox at samba.org>
commit 353c27deab30a86c94d76f0b8197fb84ce260d99
Author: Martin Schwenke <martin at meltin.net>
Date: Mon Aug 10 16:03:05 2015 +1000
ctdb-scripts: Drop functions ctdb_checkstatus() and ctdb_setstatus()
They're not used outside of ctdb_standard_event_helper().
As a consequence, make ctdb_standard_event_helper() do nothing. It is
harder to remove because it is used in many places, perhaps by
external eventscripts where it has been copied from existing scripts.
Signed-off-by: Martin Schwenke <martin at meltin.net>
Reviewed-by: Amitay Isaacs <amitay at gmail.com>
Reviewed-by: Jose A. Rivera <jarrpa at samba.org>
Reviewed-by: Michael Adam <obnox at samba.org>
commit 8c2948eba59d4ee24af1154c774c9fa79939bd91
Author: Martin Schwenke <martin at meltin.net>
Date: Mon Aug 10 15:34:29 2015 +1000
ctdb-scripts: Drop 62.cnfs eventscript
To get a similar effect just do something like this:
mmaddcallback ctdb-disable-on-quorumLoss \
--command /usr/bin/ctdb \
--event quorumLoss --parms "disable"
mmaddcallback ctdb-enable-on-quorumReached \
--command /usr/bin/ctdb \
--event quorumReached --parms "enable"
Signed-off-by: Martin Schwenke <martin at meltin.net>
Reviewed-by: Amitay Isaacs <amitay at gmail.com>
Reviewed-by: Jose A. Rivera <jarrpa at samba.org>
Reviewed-by: Michael Adam <obnox at samba.org>
-----------------------------------------------------------------------
Summary of changes:
ctdb/config/ctdb.sudoers | 4 +-
ctdb/config/ctdbd_wrapper | 8 +-
ctdb/config/debug-hung-script.sh | 2 +-
ctdb/config/debug_locks.sh | 3 +-
ctdb/config/events.d/00.ctdb | 13 +-
ctdb/config/events.d/13.per_ip_routing | 44 +++----
ctdb/config/events.d/62.cnfs | 78 ------------
ctdb/config/events.d/README | 2 +-
ctdb/config/functions | 117 ++++++------------
ctdb/doc/ctdb.1.xml | 158 +++++++++++++++---------
ctdb/doc/ctdb.7.xml | 26 ++--
ctdb/doc/ctdbd.1.xml | 31 +++--
ctdb/doc/ctdbd.conf.5.xml | 85 +++++++------
ctdb/doc/onnode.1.xml | 37 +++---
ctdb/packaging/RPM/ctdb.spec.in | 1 -
ctdb/tests/eventscripts/50.samba.monitor.110.sh | 2 +-
ctdb/tests/eventscripts/50.samba.monitor.111.sh | 2 +-
ctdb/tests/eventscripts/scripts/local.sh | 16 +--
ctdb/tests/eventscripts/stubs/testparm | 4 +-
ctdb/tests/onnode/functions | 1 +
ctdb/tests/simple/functions | 1 +
ctdb/tests/simple/scripts/local.bash | 5 +
ctdb/tests/test_check_tcp_ports.sh | 3 +-
ctdb/tools/ctdb_diagnostics | 17 ++-
ctdb/tools/onnode | 17 ++-
ctdb/wscript | 106 ++++++++++++----
26 files changed, 388 insertions(+), 395 deletions(-)
delete mode 100755 ctdb/config/events.d/62.cnfs
create mode 120000 ctdb/tests/onnode/functions
create mode 120000 ctdb/tests/simple/functions
Changeset truncated at 500 lines:
diff --git a/ctdb/config/ctdb.sudoers b/ctdb/config/ctdb.sudoers
index 1c6619b..1c23818 100644
--- a/ctdb/config/ctdb.sudoers
+++ b/ctdb/config/ctdb.sudoers
@@ -1,3 +1,3 @@
-Defaults!/etc/ctdb/statd-callout !requiretty
+Defaults!/usr/local/etc/ctdb/statd-callout !requiretty
-rpcuser ALL=(ALL) NOPASSWD: /etc/ctdb/statd-callout
+rpcuser ALL=(ALL) NOPASSWD: /usr/local/etc/ctdb/statd-callout
diff --git a/ctdb/config/ctdbd_wrapper b/ctdb/config/ctdbd_wrapper
index c5fe004..66d88c9 100755
--- a/ctdb/config/ctdbd_wrapper
+++ b/ctdb/config/ctdbd_wrapper
@@ -15,14 +15,16 @@ action="$2"
############################################################
-[ -n "$CTDB_BASE" ] || export CTDB_BASE="/etc/ctdb"
+if [ -z "$CTDB_BASE" ] ; then
+ export CTDB_BASE="/usr/local/etc/ctdb"
+fi
. "${CTDB_BASE}/functions"
loadconfig "ctdb"
[ -n "$CTDB_SOCKET" ] && export CTDB_SOCKET
-ctdbd="${CTDBD:-/usr/sbin/ctdbd}"
+ctdbd="${CTDBD:-/usr/local/sbin/ctdbd}"
############################################################
@@ -184,7 +186,7 @@ start()
if [ -n "$CTDB_VALGRIND" -a "$CTDB_VALGRIND" != "no" ] ; then
if [ "$CTDB_VALGRIND" = "yes" ] ; then
- ctdbd="valgrind -q --log-file=/var/log/ctdb_valgrind ${ctdbd}"
+ ctdbd="valgrind -q --log-file=/usr/local/var/log/ctdb_valgrind ${ctdbd}"
else
ctdbd="${CTDB_VALGRIND} ${ctdbd}"
fi
diff --git a/ctdb/config/debug-hung-script.sh b/ctdb/config/debug-hung-script.sh
index 3f800fc..9bde684 100755
--- a/ctdb/config/debug-hung-script.sh
+++ b/ctdb/config/debug-hung-script.sh
@@ -56,4 +56,4 @@ fi
mv "$tmp" "$CTDB_DEBUG_HUNG_SCRIPT_LOGFILE"
fi
-) 9>"${CTDB_VARDIR}/debug-hung-script.lock"
+) 9>"${CTDB_SCRIPT_VARDIR}/debug-hung-script.lock"
diff --git a/ctdb/config/debug_locks.sh b/ctdb/config/debug_locks.sh
index 33bf3e6..3b66b6a 100755
--- a/ctdb/config/debug_locks.sh
+++ b/ctdb/config/debug_locks.sh
@@ -62,7 +62,6 @@ loadconfig ctdb
fi
echo "===== End of debug locks PID=$$ ====="
-
-) 9>"${CTDB_VARDIR}/debug_locks.lock" | script_log "ctdbd-lock"
+)9>"${CTDB_SCRIPT_VARDIR}/debug_locks.lock" | script_log "ctdbd-lock"
exit 0
diff --git a/ctdb/config/events.d/00.ctdb b/ctdb/config/events.d/00.ctdb
index da7186f..99a0c71 100755
--- a/ctdb/config/events.d/00.ctdb
+++ b/ctdb/config/events.d/00.ctdb
@@ -120,17 +120,12 @@ set_ctdb_variables ()
ctdb_check_args "$@"
-case "$1" in
+case "$1" in
init)
# make sure we have a blank state directory for the scripts to work with
- rm -rf $CTDB_VARDIR/state
- # Look at the pattern - this should not be -rf!!!
- rm -f $ctdb_managed_dir/*
- 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 $?
diff --git a/ctdb/config/events.d/13.per_ip_routing b/ctdb/config/events.d/13.per_ip_routing
index cd0020e..56dfc34 100755
--- a/ctdb/config/events.d/13.per_ip_routing
+++ b/ctdb/config/events.d/13.per_ip_routing
@@ -93,6 +93,19 @@ ipv4_host_addr_to_net ()
######################################################################
+ensure_rt_tables ()
+{
+ rt_tables="$CTDB_SYS_ETCDIR/iproute2/rt_tables"
+
+ # This file should always exist. Even if this didn't exist on the
+ # system, adding a route will have created it. What if we startup
+ # and immediately shutdown? Let's be sure.
+ if [ ! -f "$rt_tables" ] ; then
+ mkdir -p "${rt_tables%/*}" # dirname
+ touch "$rt_tables"
+ fi
+}
+
# Setup a table id to use for the given IP. We don't need to know it,
# it just needs to exist in /etc/iproute2/rt_tables. Fail if no free
# table id could be found in the configured range.
@@ -100,12 +113,7 @@ ensure_table_id_for_ip ()
{
_ip=$1
- _f="$CTDB_ETCDIR/iproute2/rt_tables"
- # This file should always exist, but...
- if [ ! -f "$_f" ] ; then
- mkdir -p $(dirname "$_f")
- touch "$_f"
- fi
+ ensure_rt_tables
# Maintain a table id for each IP address we've ever seen in
# rt_tables. We use a "ctdb." prefix on the label.
@@ -117,7 +125,7 @@ ensure_table_id_for_ip ()
(
# Note that die() just gets us out of the subshell...
flock --timeout 30 0 || \
- die "ensure_table_id_for_ip: failed to lock file $_f"
+ die "ensure_table_id_for_ip: failed to lock file $rt_tables"
_new=$CTDB_PER_IP_ROUTING_TABLE_ID_LOW
while read _t _l ; do
@@ -140,44 +148,38 @@ ensure_table_id_for_ip ()
# If the new table id is legal then add it to the file and
# print it.
if [ $_new -le $CTDB_PER_IP_ROUTING_TABLE_ID_HIGH ] ; then
- printf "%d\t%s\n" "$_new" "$_label" >>"$_f"
+ printf "%d\t%s\n" "$_new" "$_label" >>"$rt_tables"
return 0
else
return 1
fi
- ) <"$_f"
+ ) <"$rt_tables"
}
# Clean up all the table ids that we might own.
clean_up_table_ids ()
{
- _f="$CTDB_ETCDIR/iproute2/rt_tables"
- # Even if this didn't exist on the system, adding a route will
- # have created it. What if we startup and immediately shutdown?
- if [ ! -f "$_f" ] ; then
- mkdir -p $(dirname "$_f")
- touch "$_f"
- fi
+ ensure_rt_tables
(
# Note that die() just gets us out of the subshell...
flock --timeout 30 0 || \
- die "clean_up_table_ids: failed to lock file $_f"
+ die "clean_up_table_ids: failed to lock file $rt_tables"
# Delete any items from the file that have a table id in our
# range or a label matching our label. Preserve comments.
- _tmp="${_f}.$$.ctdb"
+ _tmp="${rt_tables}.$$.ctdb"
awk -v min="$CTDB_PER_IP_ROUTING_TABLE_ID_LOW" \
-v max="$CTDB_PER_IP_ROUTING_TABLE_ID_HIGH" \
-v pre="$table_id_prefix" \
'/^#/ || \
!(min <= $1 && $1 <= max) && \
!(index($2, pre) == 1) \
- { print $0 }' "$_f" >"$_tmp"
+ { print $0 }' "$rt_tables" >"$_tmp"
- mv "$_tmp" "$_f"
+ mv "$_tmp" "$rt_tables"
# The lock is gone - don't do anything else here
- ) <"$_f"
+ ) <"$rt_tables"
}
######################################################################
diff --git a/ctdb/config/events.d/62.cnfs b/ctdb/config/events.d/62.cnfs
deleted file mode 100755
index 339eaef..0000000
--- a/ctdb/config/events.d/62.cnfs
+++ /dev/null
@@ -1,78 +0,0 @@
-#!/bin/sh
-# event script to integrate with gpfs cnfs
-
-[ -n "$CTDB_BASE" ] || \
- export CTDB_BASE=$(cd -P $(dirname "$0") ; dirname "$PWD")
-
-. $CTDB_BASE/functions
-
-loadconfig
-
-ctdb_setup_service_state_dir "gpfs"
-
-check_if_healthy() {
- mkdir -p "$service_state_dir/fs"
-
- [ -f "$service_state_dir/gpfsnoquorum" ] && {
- logger No GPFS quorum. Node is UNHEALTHY
- $CTDB_BASE/events.d/62.cnfs unhealthy "No GPFS quorum. Nodfe is UNHEALTHY."
- exit 0
- }
-
- logger All required GPFS resources are available. CNFS part is healthy.
- $CTDB_BASE/events.d/62.cnfs healthy
-}
-
-case "$1" in
- startup)
- check_if_healthy
- ;;
-
-
- gpfsquorumreached)
- rm -f "$service_state_dir/gpfsnoquorum"
- logger "GPFS quorum has been reached."
- check_if_healthy
- ;;
-
- gpfsquorumloss)
- touch "$service_state_dir/gpfsnoquorum"
- logger "GPFS quorum has been lost."
- $CTDB_BASE/events.d/62.cnfs unhealthy "GPFS quorum was lost! Marking node as UNHEALTHY."
- ;;
-
- unhealthy)
- # Mark the node as UNHEALTHY which means all public addresses
- # will be migrated off the node.
- shift
- echo "$*" | ctdb_setstatus unhealthy -
-
- # force a monitor event so we pick up immediately that this script
- # will now fail and make the node unhealthy.
- ctdb eventscript monitor
-
- # Wait until we no longer serve any ip addresses at all
- ctdb_get_pnn
- while ctdb -X ip | grep -q "^|.*|${pnn}|\$" ; do
- sleep 1
- done
- ;;
-
- healthy)
- # mark the node as healthy
- ctdb_setstatus healthy
- ;;
-
-
- monitor)
- ctdb_checkstatus
- exit $?
- ;;
-
- *)
- ctdb_standard_event_handler "$@"
- ;;
-esac
-
-exit 0
-
diff --git a/ctdb/config/events.d/README b/ctdb/config/events.d/README
index ea9048f..c7c3dea 100644
--- a/ctdb/config/events.d/README
+++ b/ctdb/config/events.d/README
@@ -31,7 +31,7 @@ init
and prepare the basic setup.
At this stage 'ctdb' commands won't work.
- Example: 00.ctdb cleans up $CTDB_VARDIR/state
+ Example: 00.ctdb cleans up $CTDB_SCRIPT_VARDIR
setup
This event does not take any additional arguments.
diff --git a/ctdb/config/functions b/ctdb/config/functions
index 42b467b..49bed98 100755
--- a/ctdb/config/functions
+++ b/ctdb/config/functions
@@ -2,16 +2,22 @@
# utility functions for ctdb event scripts
-[ -z "$CTDB_VARDIR" ] && {
- if [ -d "/var/lib/ctdb" ] ; then
- export CTDB_VARDIR="/var/lib/ctdb"
- else
- export CTDB_VARDIR="/var/ctdb"
- fi
-}
-[ -z "$CTDB_ETCDIR" ] && {
- export CTDB_ETCDIR="/etc"
-}
+if [ -z "$CTDB_BASE" ] ; then
+ echo 'CTDB_BASE unset in CTDB functions file'
+ exit 1
+fi
+
+CTDB_VARDIR="/usr/local/var/lib/ctdb"
+
+# Only (and always) override these variables in test code
+
+if [ -z "$CTDB_SCRIPT_VARDIR" ] ; then
+ CTDB_SCRIPT_VARDIR="/usr/local/var/lib/ctdb/state"
+fi
+
+if [ -z "$CTDB_SYS_ETCDIR" ] ; then
+ CTDB_SYS_ETCDIR="/etc"
+fi
#######################################
# pull in a system config file, if any
@@ -33,10 +39,10 @@ _loadconfig() {
return
fi
- if [ -f $CTDB_ETCDIR/sysconfig/$1 ]; then
- . $CTDB_ETCDIR/sysconfig/$1
- elif [ -f $CTDB_ETCDIR/default/$1 ]; then
- . $CTDB_ETCDIR/default/$1
+ if [ -f $CTDB_SYS_ETCDIR/sysconfig/$1 ]; then
+ . $CTDB_SYS_ETCDIR/sysconfig/$1
+ elif [ -f $CTDB_SYS_ETCDIR/default/$1 ]; then
+ . $CTDB_SYS_ETCDIR/default/$1
elif [ -f $CTDB_BASE/sysconfig/$1 ]; then
. $CTDB_BASE/sysconfig/$1
fi
@@ -95,7 +101,7 @@ script_log ()
if [ -n "$CTDB_LOGGING" ] ; then
_file="${CTDB_LOGGING#file:}"
else
- _file="/var/log/log.ctdb"
+ _file="/usr/local/var/log/log.ctdb"
fi
{
if [ -n "$*" ] ; then
@@ -177,10 +183,10 @@ _service ()
$_nice /sbin/service "$_service_name" "$_op"
elif [ -x /usr/sbin/service ]; then
$_nice /usr/sbin/service "$_service_name" "$_op"
- elif [ -x $CTDB_ETCDIR/init.d/$_service_name ]; then
- $_nice $CTDB_ETCDIR/init.d/$_service_name "$_op"
- elif [ -x $CTDB_ETCDIR/rc.d/init.d/$_service_name ]; then
- $_nice $CTDB_ETCDIR/rc.d/init.d/$_service_name "$_op"
+ elif [ -x $CTDB_SYS_ETCDIR/init.d/$_service_name ]; then
+ $_nice $CTDB_SYS_ETCDIR/init.d/$_service_name "$_op"
+ elif [ -x $CTDB_SYS_ETCDIR/rc.d/init.d/$_service_name ]; then
+ $_nice $CTDB_SYS_ETCDIR/rc.d/init.d/$_service_name "$_op"
fi
}
@@ -204,7 +210,7 @@ nice_service()
# 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 at .*:@@' >"$_pnn_file"
fi
@@ -307,7 +313,8 @@ ctdb_check_directories()
_ctdb_check_tcp_common ()
{
assert_service_name
- _ctdb_service_started_file="$ctdb_fail_dir/$service_name.started"
+ _d="${CTDB_SCRIPT_VARDIR}/failcount"
+ _ctdb_service_started_file="${_d}/${service_name}.started"
}
ctdb_check_tcp_init ()
@@ -610,7 +617,7 @@ flush_route_cache ()
# Simple counters
_ctdb_counter_common () {
_service_name="${1:-${service_name:-${script_name}}}"
- _counter_file="$ctdb_fail_dir/$_service_name"
+ _counter_file="${CTDB_SCRIPT_VARDIR}/failcount/${_service_name}"
mkdir -p "${_counter_file%/*}" # dirname
}
ctdb_counter_init () {
@@ -659,12 +666,9 @@ ctdb_check_counter () {
########################################################
-ctdb_status_dir="$CTDB_VARDIR/state/service_status"
-ctdb_fail_dir="$CTDB_VARDIR/state/failcount"
-
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
@@ -674,17 +678,15 @@ ctdb_setup_service_state_dir ()
########################################################
# Managed status history, for auto-start/stop
-ctdb_managed_dir="$CTDB_VARDIR/state/managed_history"
-
_ctdb_managed_common ()
{
- _ctdb_managed_file="$ctdb_managed_dir/$service_name"
+ _ctdb_managed_file="${CTDB_SCRIPT_VARDIR}/managed_history/${service_name}"
}
ctdb_service_managed ()
{
_ctdb_managed_common
- mkdir -p "$ctdb_managed_dir"
+ mkdir -p "${_ctdb_managed_file%/*}" # dirname
touch "$_ctdb_managed_file"
}
@@ -700,49 +702,12 @@ is_ctdb_previously_managed_service ()
[ -f "$_ctdb_managed_file" ]
}
-########################################################
-# Check and set status
-
-log_status_cat ()
-{
- echo "node is \"$1\", \"${script_name}\" reports problem: $(cat $2)"
-}
-
-ctdb_checkstatus ()
-{
- if [ -r "$ctdb_status_dir/$script_name/unhealthy" ] ; then
- log_status_cat "unhealthy" "$ctdb_status_dir/$script_name/unhealthy"
- return 1
- elif [ -r "$ctdb_status_dir/$script_name/banned" ] ; then
- log_status_cat "banned" "$ctdb_status_dir/$script_name/banned"
- return 2
- else
- return 0
- fi
-}
-
-ctdb_setstatus ()
-{
- d="$ctdb_status_dir/$script_name"
- case "$1" in
- unhealthy|banned)
- mkdir -p "$d"
- cat "$2" >"$d/$1"
- ;;
- *)
- for i in "banned" "unhealthy" ; do
- rm -f "$d/$i"
- done
- ;;
- esac
-}
-
##################################################################
# Reconfigure a service on demand
_ctdb_service_reconfigure_common ()
{
- _d="$ctdb_status_dir/${service_name}"
+ _d="${CTDB_SCRIPT_VARDIR}/service_status/${service_name}"
mkdir -p "$_d"
_ctdb_service_reconfigure_flag="$_d/reconfigure"
}
@@ -1031,17 +996,7 @@ service_stop ()
ctdb_standard_event_handler ()
{
- case "$1" in
- status)
- ctdb_checkstatus
- exit
- ;;
- setstatus)
- shift
- ctdb_setstatus "$@"
- exit
- ;;
- esac
+ :
}
iptables_wrapper ()
@@ -1054,7 +1009,7 @@ iptables_wrapper ()
fi
# iptables doesn't like being re-entered, so flock-wrap it.
--
Samba Shared Repository
More information about the samba-cvs
mailing list