-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathremove_vm
executable file
·50 lines (38 loc) · 1.14 KB
/
remove_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
48
49
50
#!/bin/bash -e
#dryrun="echo"
usage () {
echo "$0 <vmname>"
exit 1
}
if [ $# -ne 1 ]; then
usage
fi
. buildbot.conf
. common.sh
vmname=$1
fill_vbox_arrs
unset compiler
for ck in "${!available_compilers[@]}"; do
curvmname=${vbox_names[$ck]}
[ -z "$curvmname" ] && continue
[ "$curvmname" != "$vmname" ] && continue
if ! vboxmanage showvminfo "${vmname}" >/dev/null; then
msg_err "There is apparently no VM named $vmname."
fi
compiler=$ck
done
if [ -z "$compiler" ]; then
msg_err "Could not find compiler name of VM $vmname".
fi
echo "Compiler $compiler matches VM $vmname."
if VBoxManage list runningvms|grep -q "${vmname}"; then
$dryrun VBoxManage controlvm "$vmname" poweroff
fi
$dryrun VBoxManage unregistervm "$vmname" --delete # deletes hdd images, states, configs as well
if [ -z "${vbox_hostonlyifs[$compiler]}" ]; then
echo "No hostonlyif found belonging to VM $vmname"
else
echo "Removing hostonlyif "${vbox_hostonlyifs[$compiler]}" belonging to VM $vmname"
$dryrun VBoxManage dhcpserver remove --netname "HostInterfaceNetworking-${vbox_hostonlyifs[$compiler]}"
$dryrun VBoxManage hostonlyif remove "${vbox_hostonlyifs[$compiler]}"
fi