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
This commit is contained in:
11
deploy.sh
11
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 ─────────────────────────────────────────────
|
||||
|
||||
Reference in New Issue
Block a user