fix: remove stale wg0 interface before container start
Some checks failed
Build and Push Docker Images / Сборка сервера (multi-arch) (push) Has been cancelled
Build and Push Docker Images / Сборка клиента (multi-arch) (push) Has been cancelled

- 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
This commit is contained in:
Deploy Bot
2026-07-30 01:36:56 +01:00
parent 9e59e4c5a1
commit 1dc0238c66

View File

@@ -337,6 +337,9 @@ start_container() {
header "Starting ${role} container: ${host}" 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" " ssh_remote "$host" "$pass" "
cd ${target} cd ${target}
docker compose -f ${compose_file} up -d --remove-orphans 2>&1 docker compose -f ${compose_file} up -d --remove-orphans 2>&1
@@ -349,19 +352,21 @@ start_container() {
force_stop() { force_stop() {
header "Force-stopping existing containers" header "Force-stopping existing containers"
info "Stopping VPS container..." info "Stopping VPS container and cleaning up..."
ssh_remote "$VPS_HOST" "$VPS_PASS" " ssh_remote "$VPS_HOST" "$VPS_PASS" "
cd /opt/wireguard-vps-tunnel 2>/dev/null || exit 0 cd /opt/wireguard-vps-tunnel 2>/dev/null || exit 0
docker compose -f docker-compose.server.yml down --remove-orphans 2>/dev/null || true docker compose -f docker-compose.server.yml down --remove-orphans 2>/dev/null || true
ip link del wg0 2>/dev/null || true
" || true " || true
info "Stopping client container..." info "Stopping client container and cleaning up..."
ssh_remote "$CLIENT_HOST" "$CLIENT_PASS" " ssh_remote "$CLIENT_HOST" "$CLIENT_PASS" "
cd /opt/wireguard-vps-tunnel 2>/dev/null || exit 0 cd /opt/wireguard-vps-tunnel 2>/dev/null || exit 0
docker compose -f docker-compose.client.yml down --remove-orphans 2>/dev/null || true docker compose -f docker-compose.client.yml down --remove-orphans 2>/dev/null || true
ip link del wg0 2>/dev/null || true
" || true " || true
success "Existing containers stopped" success "Existing containers stopped and interfaces cleaned"
} }
# ── Wait for healthy containers ───────────────────────────────────────────── # ── Wait for healthy containers ─────────────────────────────────────────────