testing: ssh script accepts IP addresses instead of host names
[strongswan.git] / testing / ssh
1 #!/bin/bash
2
3 DIR=$(dirname `readlink -f $0`)
4 . $DIR/testing.conf
5
6 if [ $# == 0 ]
7 then
8         echo "$0 <host>"
9         exit 1
10 fi
11
12 host=$1
13 echo "$host" | grep -q "^\([0-9]\+\.\|[0-9a-fA-F]\+:\).*"
14 if [ $? -eq 0 ]
15 then
16         # assume we got an ip address
17         ip=$host
18 else
19         ip="`echo $HOSTNAMEIPV4 | sed -n -e "s/^.*${host},//gp" | awk -F, '{ print $1 }' | awk '{ print $1 }'`"
20         if [ -z $ip ]
21         then
22                 echo "Host '$host' unknown"
23                 exit 1
24         fi
25 fi
26
27 shift
28 exec ssh $SSHCONF -q root@$ip $@