Add function to remove new VM on failure
This commit is contained in:
parent
be78536fed
commit
8e7de734f4
@ -16,6 +16,7 @@ function error_exit() {
|
|||||||
local REASON="\e[97m${1:-$DEFAULT}\e[39m"
|
local REASON="\e[97m${1:-$DEFAULT}\e[39m"
|
||||||
local FLAG="\e[91m[ERROR] \e[93m$EXIT@$LINE"
|
local FLAG="\e[91m[ERROR] \e[93m$EXIT@$LINE"
|
||||||
msg "$FLAG $REASON"
|
msg "$FLAG $REASON"
|
||||||
|
[ ! -z ${VMID-} ] && cleanup_vmid
|
||||||
exit $EXIT
|
exit $EXIT
|
||||||
}
|
}
|
||||||
function info() {
|
function info() {
|
||||||
@ -27,6 +28,14 @@ function msg() {
|
|||||||
local TEXT="$1"
|
local TEXT="$1"
|
||||||
echo -e "$TEXT"
|
echo -e "$TEXT"
|
||||||
}
|
}
|
||||||
|
function cleanup_vmid() {
|
||||||
|
if $(qm status $VMID &>/dev/null); then
|
||||||
|
if [ "$(qm status $VMID | awk '{print $2}')" == "running" ]; then
|
||||||
|
qm stop $VMID
|
||||||
|
fi
|
||||||
|
qm destroy $VMID
|
||||||
|
fi
|
||||||
|
}
|
||||||
function cleanup() {
|
function cleanup() {
|
||||||
popd >/dev/null
|
popd >/dev/null
|
||||||
rm -rf $TEMP_DIR
|
rm -rf $TEMP_DIR
|
||||||
|
Loading…
Reference in New Issue
Block a user