The current code calls "ctdb setnatgwstate ..." on every event.
However, calling the ctdb tool in the "init" event is not permitted.
Instead, update the capability when it is needed and at regular
intervals via the "monitor" event.
Signed-off-by: Martin Schwenke <martin@meltin.net>
Pair-programmed-with: Amitay Isaacs <amitay@gmail.com>
[ -z "$CTDB_NATGW_NODES" ] && exit 0
-# Update capabilities to show whether we support teh NATGW capability or not
-if [ "$CTDB_NATGW_SLAVE_ONLY" = "yes" ] ; then
+set_natgw_capability ()
+{
+ # Set NATGW capability depending on configuration
+ if [ "$CTDB_NATGW_SLAVE_ONLY" = "yes" ] ; then
ctdb setnatgwstate off
-else
+ else
ctdb setnatgwstate on
-fi
+ fi
+}
delete_all() {
_ip="${CTDB_NATGW_PUBLIC_IP%/*}"
}
case "$1" in
+ setup)
+ set_natgw_capability
+ ;;
+
startup)
# Error if CTDB_NATGW_PUBLIC_IP is listed in public addresses
grep -q "^$CTDB_NATGW_PUBLIC_IP[[:space:]]" "${CTDB_PUBLIC_ADDRESSES:-/etc/ctdb/public_addresses}" && \
recovered|updatenatgw|ipreallocated)
mypnn=$(ctdb pnn | cut -d: -f2)
+ set_natgw_capability
ensure_natgwmaster "$1"
delete_all
;;
monitor)
+ set_natgw_capability
ensure_natgwmaster "$1"
;;