fix: full service teardown (stop+disable+remove) + port 80 wait

This commit is contained in:
Claus Lohmar 2026-07-07 14:53:00 +01:00
parent 434b23aee2
commit 533b6f4137

View file

@ -45,21 +45,38 @@ echo "[2/6] Building binary and helper tool..."
export PATH=$PATH:/usr/local/go/bin export PATH=$PATH:/usr/local/go/bin
go build -o "$BINARY_NAME" . go build -o "$BINARY_NAME" .
TOOL_DIR="$REPO_DIR/tools/nextwks-tool"
TOOL_BIN="/tmp/nextwks-tool" TOOL_BIN="/tmp/nextwks-tool"
if [ -d "$TOOL_DIR" ]; then TOOL_SRC=""
cd "$TOOL_DIR" for TRY_DIR in "$REPO_DIR/tools/nextwks-tool" "$(dirname $0)/tools/nextwks-tool"; do
go build -o "$TOOL_BIN" . 2>/dev/null && echo "[OK] Helper tool built" || echo "[WARN] Helper tool build failed" if [ -d "$TRY_DIR" ]; then
TOOL_SRC="$TRY_DIR"
break
fi
done
if [ -n "$TOOL_SRC" ]; then
cd "$TOOL_SRC"
go build -o "$TOOL_BIN" . 2>&1 && echo "[OK] Helper tool built" || echo "[WARN] Helper tool build failed"
cd "$REPO_DIR" cd "$REPO_DIR"
fi fi
# --- Greenfield path --- # --- Greenfield path ---
if [ "$GREENFIELD" = true ]; then if [ "$GREENFIELD" = true ]; then
# Step 3: Stop all services and free port 80 for ACME challenge # Step 3: Full teardown — stop, disable, remove all services
echo "[3/6] Stopping all services..." echo "[3/6] Full service teardown..."
systemctl stop $SERVICE_NAME 2>/dev/null || true systemctl stop $SERVICE_NAME 2>/dev/null || true
systemctl disable $SERVICE_NAME 2>/dev/null || true
rm -f /etc/systemd/system/$SERVICE_NAME.service
systemctl daemon-reload
podman rm -f zoraxy 2>/dev/null || true podman rm -f zoraxy 2>/dev/null || true
# Wait for port 80 to be released
for i in $(seq 1 10); do
if ! ss -tlnp | grep -q ':80 '; then
break
fi
echo " Waiting for port 80 to be released... ($i/10)"
sleep 1
done
# Wipe production directory # Wipe production directory
if [ -d "$TARGET_DIR" ]; then if [ -d "$TARGET_DIR" ]; then