Cleanup bugfixes. Move vars to dedicated files
This commit is contained in:
parent
d46b475e1b
commit
6721e05387
@ -1,7 +1,7 @@
|
||||
#!/bin/bash
|
||||
|
||||
stopdls() {
|
||||
if docker ps &>/dev/null | grep -q " $DLS_CTR_NAME$"; then
|
||||
if docker ps | grep -q " $DLS_CTR_NAME$"; then
|
||||
pinfo "Stopping Direktil Local Server..."
|
||||
docker stop $DLS_CTR_NAME
|
||||
fi
|
||||
@ -28,14 +28,20 @@ cleanuppaths() {
|
||||
done
|
||||
}
|
||||
|
||||
cleanupssh() {
|
||||
for host in ${!hosts[*]}; do
|
||||
ssh-keygen -R ${hosts[$host]} &>/dev/null
|
||||
done
|
||||
}
|
||||
|
||||
cleanupnetwork() {
|
||||
if iptables -L |grep -q $QEMU_BR_NAME; then
|
||||
if iptables -L -n |grep -q $QEMU_BR_NAME; then
|
||||
pinfo "Cleaning iptables rules..."
|
||||
iptables -t nat -D POSTROUTING -j MASQUERADE -s $QEMU_BR_IP/$QEMU_BR_MASK \! -o $QEMU_BR_NAME
|
||||
iptables -D FORWARD -o $QEMU_BR_NAME -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
|
||||
iptables -D FORWARD -j ACCEPT -i $QEMU_BR_NAME
|
||||
fi
|
||||
if ip li show $QEMU_BR_NAME ; then
|
||||
if ip li show $QEMU_BR_NAME &>/dev/null; then
|
||||
pinfo "Cleaning existing interfaces..."
|
||||
ip li set $QEMU_BR_NAME down
|
||||
ip li del $QEMU_BR_NAME
|
||||
@ -50,3 +56,5 @@ declare -A hosts
|
||||
get_hosts
|
||||
destroyvms
|
||||
cleanuppaths
|
||||
cleanupssh
|
||||
cleanupnetwork
|
||||
|
@ -1,24 +1,6 @@
|
||||
#!/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"
|
||||
|
||||
source $(dirname $0)/vars
|
||||
|
||||
## Helper funcs
|
||||
|
||||
@ -57,9 +39,10 @@ check_root() {
|
||||
}
|
||||
|
||||
prereqs() {
|
||||
# set -ex
|
||||
set -e
|
||||
cd "$(dirname $0)/.."
|
||||
ctxdir="$PWD"
|
||||
source scripts/vars
|
||||
}
|
||||
|
||||
check_conf() {
|
||||
|
@ -1,11 +1,5 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Admin token to unlock the DLS store
|
||||
DLS_UNLOCK_TOKEN=changeme
|
||||
#
|
||||
#
|
||||
D2C_IMG=novit.tech/direktil/local-server:b6fa941
|
||||
DLS_IMG=novit.tech/direktil/local-server:b6fa941
|
||||
|
||||
prereqs_dls() {
|
||||
command -v docker 1>/dev/null || perror "Docker is needed, please install it and run again."
|
||||
@ -39,8 +33,8 @@ start_store() {
|
||||
|
||||
source $(dirname $0)/.common
|
||||
check_root
|
||||
prereqs_dls
|
||||
prereqs
|
||||
prereqs_dls
|
||||
dir2config
|
||||
start_store
|
||||
unlock_store
|
||||
|
@ -14,7 +14,7 @@ prereqs_qemu() {
|
||||
done
|
||||
}
|
||||
setup_network_qemu() {
|
||||
if ! ip li show $QEMU_BR_NAME ; then
|
||||
if ! ip li show $QEMU_BR_NAME &>/dev/null ; then
|
||||
ip li add name $QEMU_BR_NAME type bridge
|
||||
ip li set $QEMU_BR_NAME up
|
||||
fi
|
||||
|
@ -47,6 +47,24 @@ EOF
|
||||
done
|
||||
}
|
||||
|
||||
wait_for_apiserver() {
|
||||
vip=$(extract_var clusters public_vip)
|
||||
vip_api_port=$(extract_var clusters api_port)
|
||||
|
||||
sleep 20
|
||||
while :
|
||||
do
|
||||
pinfo "Waiting for apiserver availability ($vip:$vip_api_port). Images may still being pulled... "
|
||||
if kctl get node &>/dev/null ; then
|
||||
pinfo "API is up!"
|
||||
break
|
||||
else
|
||||
sleep 30
|
||||
fi
|
||||
done
|
||||
|
||||
}
|
||||
|
||||
install_addons() {
|
||||
body='{"Kind":"cluster","Name":"'$cluster'","Assets":["addons"]}'
|
||||
download_id=$(dls /authorize-download -d "$body"|tr -d \")
|
||||
@ -82,6 +100,7 @@ unlock_store
|
||||
declare -A hosts && get_hosts
|
||||
checkup
|
||||
start_control_plane
|
||||
wait_for_apiserver
|
||||
create_kubeconfig
|
||||
install_addons
|
||||
approve_kubelet_certificates # clients and serving certs
|
||||
|
28
scripts/vars
Normal file
28
scripts/vars
Normal file
@ -0,0 +1,28 @@
|
||||
## Vars
|
||||
|
||||
# Admin token to unlock the DLS store
|
||||
DLS_UNLOCK_TOKEN=changeme
|
||||
|
||||
# Docker container name for dir2config
|
||||
D2C_IMG=novit.tech/direktil/local-server:b6fa941
|
||||
D2C_CTR_NAME=dir2config
|
||||
|
||||
# Docker container name for direktil local server
|
||||
DLS_IMG=novit.tech/direktil/local-server:b6fa941
|
||||
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"
|
||||
|
||||
# SSH command args
|
||||
SSH_CMD="ssh -o StrictHostKeyChecking=no"
|
Loading…
Reference in New Issue
Block a user