testing: ssh script accepts IP addresses instead of host names
authorTobias Brunner <tobias@strongswan.org>
Mon, 4 Mar 2013 10:55:26 +0000 (11:55 +0100)
committerTobias Brunner <tobias@strongswan.org>
Tue, 5 Mar 2013 16:40:13 +0000 (17:40 +0100)
testing/ssh

index 9e6d49a..0de44d0 100755 (executable)
@@ -10,11 +10,18 @@ then
 fi
 
 host=$1
-ip="`echo $HOSTNAMEIPV4 | sed -n -e "s/^.*${host},//gp" | awk -F, '{ print $1 }' | awk '{ print $1 }'`"
-if [ -z $ip ]
+echo "$host" | grep -q "^\([0-9]\+\.\|[0-9a-fA-F]\+:\).*"
+if [ $? -eq 0 ]
 then
-       echo "Host '$host' unknown"
-       exit 1
+       # 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 }'`"
+       if [ -z $ip ]
+       then
+               echo "Host '$host' unknown"
+               exit 1
+       fi
 fi
 
 shift