]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
more shell scripting fixes in 10.interface
authorAndrew Tridgell <tridge@samba.org>
Thu, 13 Sep 2007 01:57:42 +0000 (11:57 +1000)
committerAndrew Tridgell <tridge@samba.org>
Thu, 13 Sep 2007 01:57:42 +0000 (11:57 +1000)
(This used to be ctdb commit 4ee2230b3f2ae7437a9d0cf973eb4645d276accd)

ctdb/config/events.d/10.interface

index 9df8d2e31124292f956e8f9e4c271202bc2f5499..aee7d62176428718dcce86e5fbe18113f4cab72d 100755 (executable)
@@ -25,8 +25,10 @@ shift
 kill_tcp_connections() {
     _IP="$1"    
     _failed=0
+
     _killcount=0
-    netstat -tn |egrep "^tcp.*\s+$_IP:.*ESTABLISHED" | awk '{print $4" "$5}' | 
+    connfile="/etc/ctdb/state/connections.$_IP"
+    netstat -tn |egrep "^tcp.*\s+$_IP:.*ESTABLISHED" | awk '{print $4" "$5}' > $connfile
     while read dest src; do
        srcip=`echo $src | cut -d: -f1`
        srcport=`echo $src | cut -d: -f2`
@@ -34,11 +36,15 @@ kill_tcp_connections() {
        destport=`echo $dest | cut -d: -f2`
        ctdb killtcp $srcip:$srcport $destip:$destport >/dev/null 2>&1 || _failed=1
        _killcount=`expr $_killcount + 1`
-    done
+    done < $connfile
+    /bin/rm -f $connfile
     [ $_failed = 0 ] || {
        echo "`date` Failed to send killtcp control"
        return;
     }
+    [ $_killcount -gt 0 ] || {
+       return;
+    }
     _count=0
     while netstat -tn |egrep "^tcp.*\s+$_IP:.*ESTABLISHED" > /dev/null; do
        sleep 1