From 0b69785eb2bd7d3f29e8ea409e5ca5437234ffaf Mon Sep 17 00:00:00 2001 From: Martin Schwenke Date: Thu, 17 Oct 2013 16:44:24 +1100 Subject: [PATCH] eventscripts: Rework the iSCSI eventscript * It should run on "ipreallocated" instead of "recovered" * Variable name NODE -> ip since that's what it is * Simplify some logic Signed-off-by: Martin Schwenke (This used to be ctdb commit 45e2bc66abf9fcfeadcc279a656ed7fd1838920a) --- ctdb/config/events.d/70.iscsi | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/ctdb/config/events.d/70.iscsi b/ctdb/config/events.d/70.iscsi index a840b4d7dac..cedaf40434e 100755 --- a/ctdb/config/events.d/70.iscsi +++ b/ctdb/config/events.d/70.iscsi @@ -20,31 +20,33 @@ is_ctdb_managed_service || exit 0 } case "$1" in - recovered) + ipreallocated) # block the iscsi port iptables -I INPUT 1 -p tcp --dport 3260 -j DROP # shut down the iscsi service killall -9 tgtd >/dev/null 2>/dev/null - THIS_NODE=`ctdb status | grep "THIS NODE" | sed -e "s/pnn://" -e "s/ .*//"` - [ -z $THIS_NODE ] && { - echo "70.iscsi: Failed to get node pnn" + this_node=$(ctdb xpnn | sed -e 's@PNN:@@') + if [ -z "$this_node" ] ; then + echo "Failed to get node pnn" exit 0 - } + fi # start the iscsi daemon tgtd >/dev/null 2>/dev/null - for NODE in `ctdb ip | grep -v "Public" | egrep " ${THIS_NODE}$" | sed -e "s/ .*//"`; do - [ -f $CTDB_START_ISCSI_SCRIPTS/${NODE}.sh ] && { - echo Starting iscsi service for public address $NODE - $CTDB_START_ISCSI_SCRIPTS/${NODE}.sh - } + ips=$(ctdb -Y ip | awk -F: -v pnn=$this_node '$3 == pnn {print $2}') + for ip in $ips ; do + script="${CTDB_START_ISCSI_SCRIPTS}/${ip}.sh" + if [ -x "$script" ] ; then + echo "Starting iscsi service for public address ${ip}" + "$script" + fi done # remove all iptables rules - while iptables -D INPUT -p tcp --dport 3260 -j DROP 2>/dev/null >/dev/null ; do + while iptables -D INPUT -p tcp --dport 3260 -j DROP >/dev/null 2>&1 ; do : done -- 2.11.4.GIT