From 842d9aab4e4c9531a3ac5c0376405339b7025b36 Mon Sep 17 00:00:00 2001 From: Ronnie Sahlberg Date: Tue, 12 Oct 2010 02:49:11 +1100 Subject: move extracting the config from config.tdb for public addresses into its own function (This used to be ctdb commit 2d478a39ed8303b0371112d61630660d12b7db2c) --- ctdb/config/events.d/00.ctdb | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) (limited to 'ctdb/config/events.d/00.ctdb') diff --git a/ctdb/config/events.d/00.ctdb b/ctdb/config/events.d/00.ctdb index 8ff6488e5f..1389ae4060 100755 --- a/ctdb/config/events.d/00.ctdb +++ b/ctdb/config/events.d/00.ctdb @@ -12,6 +12,24 @@ . $CTDB_BASE/functions loadconfig +update_config_from_tdb() { + # Pull optional ctdb configuration data out of config.tdb + PUBLICADDRESSESKEY='public-addresses:node#'`ctdb -t 1 xpnn|sed -e "s/.*://"` + rm -f $CTDB_VARDIR/state/public_addresses + ctdb pfetch config.tdb $PUBLICADDRESSESKEY $CTDB_VARDIR/state/public_addresses + [ "$?" = "0" ] && [ `stat --format="%s" /etc/ctdb/state/public_addresses` != "0" ] && [ ! -z "$CTDB_PUBLIC_ADDRESSES" ] && { + diff $CTDB_VARDIR/state/public_addresses $CTDB_PUBLIC_ADDRESSES >/dev/null 2>/dev/null + [ $? = "0" ] || { + echo CTDB public address configuration had been updated. + echo Extracting new configuration from database. + diff $CTDB_VARDIR/state/public_addresses $CTDB_PUBLIC_ADDRESSES + cp $CTDB_VARDIR/state/public_addresses $CTDB_PUBLIC_ADDRESSES + echo Restarting CTDB + service ctdb restart & + } + } +} + case "$1" in init) # make sure we have a blank state directory for the scripts to work with @@ -35,21 +53,7 @@ case "$1" in ;; startup) - # Pull optional ctdb configuration data out of config.tdb - PUBLICADDRESSESKEY='public-addresses:node#'`ctdb -t 1 xpnn|sed -e "s/.*://"` - rm -f $CTDB_VARDIR/state/public_addresses - ctdb pfetch config.tdb $PUBLICADDRESSESKEY $CTDB_VARDIR/state/public_addresses - [ "$?" = "0" ] && [ `stat --format="%s" /etc/ctdb/state/public_addresses` != "0" ] && [ ! -z "$CTDB_PUBLIC_ADDRESSES" ] && { - diff $CTDB_VARDIR/state/public_addresses $CTDB_PUBLIC_ADDRESSES >/dev/null 2>/dev/null - [ $? = "0" ] || { - echo CTDB public address configuration had been updated. - echo Extracting new configuration from database. - diff $CTDB_VARDIR/state/public_addresses $CTDB_PUBLIC_ADDRESSES - cp $CTDB_VARDIR/state/public_addresses $CTDB_PUBLIC_ADDRESSES - echo Restarting CTDB - service ctdb restart & - } - } + update_config_from_tdb & ;; monitor) # We should never enter swap, so SwapTotal == SwapFree. -- cgit