#!/usr/bin/env bash set -euo pipefail export KUBECONFIG=/Users/chrisfu/dev/knoe/knoe-k3s.kubeconfig echo "==> Removing finalizers + deleting gitea namespace..." for res in $(kubectl -n gitea get gitlabs.apps.gitlab.com --no-headers -o name 2>/dev/null || true); do kubectl -n gitea patch "$res" -p '{"metadata":{"finalizers":[]}}' --type=merge 2>/dev/null || true done kubectl get namespace gitea -o json 2>/dev/null \ | python3 -c "import sys,json; d=json.load(sys.stdin); d['spec']['finalizers']=[]; print(json.dumps(d))" \ | kubectl replace --raw /api/v1/namespaces/gitea/finalize -f - 2>&1 || true kubectl delete namespace gitea --ignore-not-found --timeout=30s 2>&1 || true echo "==> Releasing/deleting gitlab PVs..." for pv in gitlab-gitaly-synology gitlab-minio-synology; do kubectl patch pv "$pv" -p '{"spec":{"claimRef":null}}' 2>/dev/null || true kubectl delete pv "$pv" --ignore-not-found 2>/dev/null || true done echo "==> Wiping synology gitlab dirs..." kubectl -n knoe-system run gitlab-wipe \ --image=alpine:latest --restart=Never --rm --attach \ --overrides='{"spec":{"nodeName":"gandalf.knoe.org","tolerations":[{"operator":"Exists"}],"volumes":[{"name":"s","hostPath":{"path":"/synology/d005","type":"Directory"}}],"containers":[{"name":"w","image":"alpine:latest","command":["sh","-c","rm -rf /s/gitlab && echo wiped"],"volumeMounts":[{"name":"s","mountPath":"/s"}]}]}}' 2>&1 || true echo "==> Cleaning leftover ClusterRoles/Bindings from gitlab operator..." kubectl get clusterrole,clusterrolebinding -o name 2>/dev/null \ | grep -i gitlab | xargs kubectl delete --ignore-not-found 2>&1 || true echo "==> Waiting for pi.knoe.org to become Ready (up to 5min)..." for i in $(seq 1 30); do status=$(kubectl get node pi.knoe.org --no-headers 2>/dev/null | awk '{print $2}') echo " [$i/30] pi status: $status" [[ "$status" == "Ready" ]] && break sleep 10 done echo "==> Final node status:" kubectl get nodes echo "==> Clean-up done. Launching installer..." cd /Users/chrisfu/dev/knoe mkdir -p logs nohup bash install.sh --silent -c conf/service/knoe.cfg \ > logs/install_run6.log 2>&1 & echo "Installer PID $! — tail logs/install_run6.log to monitor"