From 1dc0238c6614eedaf14ee99aa27adf8964d1c3e9 Mon Sep 17 00:00:00 2001 From: Deploy Bot Date: Thu, 30 Jul 2026 01:36:56 +0100 Subject: [PATCH] fix: remove stale wg0 interface before container start - deploy.sh: add 'ip link del wg0' cleanup in force_stop() for both machines - deploy.sh: add wg0 cleanup before container start (idempotent re-run) - Fixes 'wg-quick: wg0 already exists' crash on redeploy --- deploy.sh | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/deploy.sh b/deploy.sh index afb5e08..d7bd2a7 100755 --- a/deploy.sh +++ b/deploy.sh @@ -337,6 +337,9 @@ start_container() { header "Starting ${role} container: ${host}" + # Remove stale wg0 interface (leftover from previous container with host network) + ssh_remote "$host" "$pass" "ip link del wg0 2>/dev/null || true" + ssh_remote "$host" "$pass" " cd ${target} docker compose -f ${compose_file} up -d --remove-orphans 2>&1 @@ -349,19 +352,21 @@ start_container() { force_stop() { header "Force-stopping existing containers" - info "Stopping VPS container..." + info "Stopping VPS container and cleaning up..." ssh_remote "$VPS_HOST" "$VPS_PASS" " cd /opt/wireguard-vps-tunnel 2>/dev/null || exit 0 docker compose -f docker-compose.server.yml down --remove-orphans 2>/dev/null || true + ip link del wg0 2>/dev/null || true " || true - info "Stopping client container..." + info "Stopping client container and cleaning up..." ssh_remote "$CLIENT_HOST" "$CLIENT_PASS" " cd /opt/wireguard-vps-tunnel 2>/dev/null || exit 0 docker compose -f docker-compose.client.yml down --remove-orphans 2>/dev/null || true + ip link del wg0 2>/dev/null || true " || true - success "Existing containers stopped" + success "Existing containers stopped and interfaces cleaned" } # ── Wait for healthy containers ─────────────────────────────────────────────