Skip to content

Commit

Permalink
build: Skip initialization of Guacamole if not needed
Browse files Browse the repository at this point in the history
The Initialization raised several errors when the corresponding tables
did already exist. We ignored those errors, but they are confusing for administrators.

Therefore, skip initialization if already done.
  • Loading branch information
MoritzWeber0 committed Jun 25, 2024
1 parent bef9037 commit 8149673
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -161,12 +161,17 @@ wait:
@kill %%

provision-guacamole:
@echo "Waiting for guacamole container, before we can initialize the database..."
echo "Waiting for guacamole container, before we can initialize the database..."
@kubectl get --context k3d-$(CLUSTER_NAME) -n $(NAMESPACE) --watch pods &
@sleep 2
sleep 2
@kubectl wait --for=condition=Ready pods --timeout=$(TIMEOUT) --context k3d-$(CLUSTER_NAME) -n $(NAMESPACE) -l id=$(RELEASE)-deployment-guacamole-guacamole
@kubectl wait --for=condition=Ready pods --timeout=$(TIMEOUT) --context k3d-$(CLUSTER_NAME) -n $(NAMESPACE) -l id=$(RELEASE)-deployment-guacamole-postgres
@kill %%
TABLE_EXISTS=$$(kubectl exec --context k3d-$(CLUSTER_NAME) -n $(NAMESPACE) --container $(RELEASE)-guacamole-postgres deployment/$(RELEASE)-guacamole-postgres -- psql -U guacamole -tAc "SELECT EXISTS(SELECT 1 FROM information_schema .tables WHERE table_name='guacamole_user');")
if [[ $$TABLE_EXISTS == "t" ]]; then
echo "Guacamole database already initialized. Skipping initialization.";
exit 0;
fi
@kubectl exec --context k3d-$(CLUSTER_NAME) --namespace $(NAMESPACE) --container $(RELEASE)-guacamole-guacamole deployment/$(RELEASE)-guacamole-guacamole -- /opt/guacamole/bin/initdb.sh --postgresql | \
kubectl exec -i --context k3d-$(CLUSTER_NAME) --namespace $(NAMESPACE) deployment/$(RELEASE)-guacamole-postgres -- psql -U guacamole guacamole
@echo "Guacamole database initialized sucessfully.";
Expand Down

0 comments on commit 8149673

Please sign in to comment.