-
Notifications
You must be signed in to change notification settings - Fork 0
/
vm
executable file
·47 lines (38 loc) · 1.14 KB
/
vm
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
41
42
43
44
45
46
47
#!/bin/bash
#set -x
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}
domain=$1
if [[ -z $domain ]]; then
echo "USAGE:vm <name>"
echo " where name is a the name of one of your existing vms:"
$pre virsh list --all | grep -v $base
echo " You can use vmnew to create a new one from the base."
echo " Base vm is $base ... you should not use this one directly"
exit -1
fi
# set background to black
#echo -e "\033]11;#000000\007"
# set foreground to red
#echo -e "\033]10;#FFFFF\007"
if ! $pretty virsh console --force $domain; then
$pre virsh start $domain
if ! $pretty virsh console --force $domain; then
echo "WTF: can't seem to start or attach to kele console" > /dev/stderr
exit -1
fi
fi