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 ─────────────────────────────────────────────