]> git.ipfire.org Git - thirdparty/strongswan.git/blob - testing/ssh
kernel-netlink: Add helper functions for nested attributes
[thirdparty/strongswan.git] / testing / ssh
1 #!/bin/bash
2
3 DIR=$(dirname `readlink -f $0`)
4 . $DIR/testing.conf
5 SSHCONF="-F $DIR/ssh_config"
6
7 if [ $# == 0 ]
8 then
9 echo "$0 <host>"
10 exit 1
11 fi
12
13 host=$1
14 echo "$host" | grep -q "^\([0-9]\+\.\|[0-9a-fA-F]\+:\).*"
15 if [ $? -eq 0 ]
16 then
17 # assume we got an ip address
18 ip=$host
19 else
20 pos='$1'
21 echo "$host" | grep -q ".*1$"
22 if [ $? -eq 0 ]
23 then
24 # {host}1, use second address
25 pos='$2'
26 host=`echo "$host" | sed -n -e "s/1$//p"`
27 fi
28 ip="`echo $HOSTNAMEIPV4 | sed -n -e "s/^.*${host},//gp" | awk -F, "{ print ${pos} }" | awk '{ print $1 }'`"
29 if [ -z $ip ]
30 then
31 echo "Host '$host' unknown"
32 exit 1
33 fi
34 fi
35
36 shift
37 exec ssh $SSHCONF -q root@$ip $@