testing: Enable ssh connection to second IP by name (e.g. moon1)
authorTobias Brunner <tobias@strongswan.org>
Mon, 4 Mar 2013 17:01:10 +0000 (18:01 +0100)
committerTobias Brunner <tobias@strongswan.org>
Tue, 5 Mar 2013 16:40:13 +0000 (17:40 +0100)
testing/ssh

index 0de44d0..4777cfb 100755 (executable)
@@ -16,7 +16,15 @@ then
        # assume we got an ip address
        ip=$host
 else
-       ip="`echo $HOSTNAMEIPV4 | sed -n -e "s/^.*${host},//gp" | awk -F, '{ print $1 }' | awk '{ print $1 }'`"
+       pos='$1'
+       echo "$host" | grep -q ".*1$"
+       if [ $? -eq 0 ]
+       then
+               # {host}1, use second address
+               pos='$2'
+               host=`echo "$host" | sed -n -e "s/1$//p"`
+       fi
+       ip="`echo $HOSTNAMEIPV4 | sed -n -e "s/^.*${host},//gp" | awk -F, "{ print ${pos} }" | awk '{ print $1 }'`"
        if [ -z $ip ]
        then
                echo "Host '$host' unknown"