1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-27 14:04:05 +03:00

Merge remote branch 'martins/eventscript.00.ctdb'

(This used to be ctdb commit 6c287861e780ba985e7ae7a61c1ee462b925e09e)
This commit is contained in:
Ronnie Sahlberg 2011-08-10 15:36:20 +10:00
commit 65d5c51278

View File

@ -12,28 +12,35 @@
. $CTDB_BASE/functions
loadconfig
ctdb_setup_service_state_dir "ctdb"
#
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 2>/dev/null
[ "$?" = "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 &
}
}
# Pull optional ctdb configuration data out of config.tdb
_key="public_addresses:node#$(ctdb -t 1 xpnn|sed -e 's/.*://')"
_t="$service_state_dir/public_addresses"
rm -f "$_t"
if ctdb pfetch config.tdb "$_key" "$_t" 2>/dev/null && \
[ -s "$_t" -a -n "$CTDB_PUBLIC_ADDRESSES"] && \
! cmp -s "$_t" "$CTDB_PUBLIC_ADDRESSES" ; then
echo "CTDB public address configuration has changed."
echo "Extracting new configuration from database."
diff "$_t" "$CTDB_PUBLIC_ADDRESSES"
cp "$_t" "$CTDB_PUBLIC_ADDRESSES"
echo "Restarting CTDB"
service ctdb restart &
fi
}
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"