From 04f89d89ec8c41abbc932fb71972895e1138b427 Mon Sep 17 00:00:00 2001 From: Chiradeep Vittal Date: Thu, 4 Nov 2010 12:45:46 -0700 Subject: [PATCH] bug 6981: merge from 2.1.x bug 6807 status 6981: resolved fixed --- scripts/network/domr/ipassoc.sh | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/scripts/network/domr/ipassoc.sh b/scripts/network/domr/ipassoc.sh index 09d58c11a95..fd6d156111f 100755 --- a/scripts/network/domr/ipassoc.sh +++ b/scripts/network/domr/ipassoc.sh @@ -122,11 +122,32 @@ remove_an_ip () { local pubIp=$2 local ipNoMask=$(echo $2 | awk -F'/' '{print $1}') local mask=$(echo $2 | awk -F'/' '{print $2}') - [ "$mask" == "" ] && mask="32" - ssh -p 3922 -o StrictHostKeyChecking=no -i $cert root@$dRIp "\ - ip addr del dev $correctVif "$ipNoMask/$mask" - " - if [ $? -gt 0 -a $? -ne 2 ] + local existingIpMask=$(ssh -p 3922 -o StrictHostKeyChecking=no -i $cert root@$dRIp " + ip addr show dev $correctVif | grep inet | awk '{print \$2}' | grep -w $ipNoMask + ") + [ "$existingIpMask" == "" ] && return 0 + local existingMask=$(echo $existingIpMask | awk -F'/' '{print $2}') + if [ "$existingMask" == "32" ] + then + ssh -p 3922 -o StrictHostKeyChecking=no -i $cert root@$dRIp " + ip addr del dev $correctVif $existingIpMask + " + result=$? + fi + if [ "$existingMask" != "32" ] + then + ssh -p 3922 -o StrictHostKeyChecking=no -i $cert root@$dRIp " + replaceIpMask=\`ip addr show dev $correctVif | grep inet | grep -v $existingIpMask | awk '{print \$2}' | sort -t/ -k2 -n|tail -1\` + ip addr del dev $correctVif $existingIpMask; + if [ -n \"\$replaceIpMask\" ]; then + ip addr del dev $correctVif \$replaceIpMask; + replaceIp=\`echo \$replaceIpMask | awk -F/ '{print \$1}'\`; + ip addr add dev $correctVif \$replaceIp/$existingMask; + fi + " + result=$? + fi + if [ $result -gt 0 -a $result -ne 2 ] then return 1 fi