Add proper Cleanup script.

Chore following such addition.
This commit is contained in:
Guillaume
2023-06-08 19:38:17 +02:00
parent 2945d21c93
commit aa18ef3224
4 changed files with 85 additions and 23 deletions

View File

@ -1,11 +1,26 @@
#!/bin/bash
## Vars
# Docker container name for dir2config
D2C_CTR_NAME=dir2config
# Docker container name for direktil local server
DLS_CTR_NAME=dls
# QEMU local bridge name. If you specificy a custom name, you may have to configure qemu bridge helper to allow it
QEMU_BR_NAME=virbr0
# QEMU VM default disk size
QEMU_DISK_SIZE=30G
# Allocated CPUs to QEMU VMs
QEMU_VM_CPU=4
# Allocated Memory to QEMU VMs
QEMU_VM_MEM=8096
################
# Token file for dls
tknfile=".dls_adm_token"
## Helper funcs
## Helper funcs
pinfo() {
echo -e "\e[32m$@\e[39m"
@ -42,7 +57,7 @@ check_root() {
}
prereqs() {
set -ex
# set -ex
cd "$(dirname $0)/.."
ctxdir="$PWD"
}
@ -86,7 +101,7 @@ get_hosts() {
ip=$(grep ip: $ctxdir/hosts/${h}.yaml|awk '{print $2}')
hosts[$h]="$ip"
done
cd -
cd - &>/dev/null
}
get_parts() {
@ -102,6 +117,15 @@ get_parts() {
done
}
destroyvms() {
for host in ${!hosts[*]}; do
host=$1
if test -f $ctxdir/data/$host/pid ; then
pinfo "Detected a pid file, killing process in case VM was already started"
kill $(cat $ctxdir/data/$host/pid) && sleep 1
fi
done
}
create_kubeconfig() {
if test -f $ctxdir/kubeconfig; then