-
Notifications
You must be signed in to change notification settings - Fork 0
/
vmssh
executable file
·40 lines (32 loc) · 946 Bytes
/
vmssh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/bin/bash
#set -x
vmtooldir=$(dirname $(readlink -f $0))
scriptdir=$(dirname $(realpath $0))
configdir=$scriptdir/config
[[ -z $VMARCH ]] && [[ -a $configdir/VMARCH ]] \
&& VMARCH=$(cat $configdir/VMARCH)
[[ -z $VMHOST ]] && [[ -a $configdir/${VMARCH}.host ]] \
&& VMHOST=$(cat $configdir/${VMARCH}.host)
vmhost=${VMHOST}
if [[ $vmhost != $(hostname) ]]; then
pre="ssh -x $vmhost"
pretty="ssh -x -t $vmhost"
else
unset pre
unset pretty
fi
arch=${VMARCH:-$($pre uname -i)}
base=${VMBASEVM:-basevm-$arch}
user=${VMUSER:-user}
domain=$1
if [[ -z $domain ]]; then
echo "USAGE:vm <name>"
echo " where name is a the name of one of your existing kele vms:"
$pre virsh list --all | grep -v $base
echo " You can use newkele to create a new one from the base."
echo " Base vm is $base ... you should avoid using this one"
exit -1
fi
ip=$($vmtooldir/vmip $domain)
shift
$pretty ssh $user@$ip $@