#!/bin/bash
# Rollback script for IP changes
# Generated automatically - DO NOT EDIT MANUALLY

set -euo pipefail

echo "=== Rolling Back IP Changes ==="
echo ""

# Rollback VMID 3501 (ccip-monitor-1) on ml110
echo "Rolling back VMID 3501 to 192.168.11.14..."
ssh -o ConnectTimeout=10 root@192.168.11.10 "pct stop 3501" 2>/dev/null || true
sleep 2
ssh -o ConnectTimeout=10 root@192.168.11.10 "pct set 3501 --net0 bridge=vmbr0,name=eth0,ip=192.168.11.14/24,gw=192.168.11.1,type=veth" || echo "Warning: Failed to rollback 3501"
ssh -o ConnectTimeout=10 root@192.168.11.10 "pct start 3501" 2>/dev/null || true
echo ""

# Rollback VMID 3500 (oracle-publisher-1) on ml110
echo "Rolling back VMID 3500 to 192.168.11.15..."
ssh -o ConnectTimeout=10 root@192.168.11.10 "pct stop 3500" 2>/dev/null || true
sleep 2
ssh -o ConnectTimeout=10 root@192.168.11.10 "pct set 3500 --net0 bridge=vmbr0,name=eth0,ip=192.168.11.15/24,gw=192.168.11.1,type=veth" || echo "Warning: Failed to rollback 3500"
ssh -o ConnectTimeout=10 root@192.168.11.10 "pct start 3500" 2>/dev/null || true
echo ""

# Rollback VMID 103 (omada) on r630-02
echo "Rolling back VMID 103 to 192.168.11.20..."
ssh -o ConnectTimeout=10 root@192.168.11.12 "pct stop 103" 2>/dev/null || true
sleep 2
ssh -o ConnectTimeout=10 root@192.168.11.12 "pct set 103 --net0 bridge=vmbr0,name=eth0,ip=192.168.11.20/24,gw=192.168.11.1,type=veth" || echo "Warning: Failed to rollback 103"
ssh -o ConnectTimeout=10 root@192.168.11.12 "pct start 103" 2>/dev/null || true
echo ""

# Rollback VMID 104 (gitea) on r630-02
echo "Rolling back VMID 104 to 192.168.11.18..."
ssh -o ConnectTimeout=10 root@192.168.11.12 "pct stop 104" 2>/dev/null || true
sleep 2
ssh -o ConnectTimeout=10 root@192.168.11.12 "pct set 104 --net0 bridge=vmbr0,name=eth0,ip=192.168.11.18/24,gw=192.168.11.1,type=veth" || echo "Warning: Failed to rollback 104"
ssh -o ConnectTimeout=10 root@192.168.11.12 "pct start 104" 2>/dev/null || true
echo ""

# Rollback VMID 100 (proxmox-mail-gateway) on r630-02
echo "Rolling back VMID 100 to 192.168.11.4..."
ssh -o ConnectTimeout=10 root@192.168.11.12 "pct stop 100" 2>/dev/null || true
sleep 2
ssh -o ConnectTimeout=10 root@192.168.11.12 "pct set 100 --net0 bridge=vmbr0,name=eth0,ip=192.168.11.4/24,gw=192.168.11.1,type=veth" || echo "Warning: Failed to rollback 100"
ssh -o ConnectTimeout=10 root@192.168.11.12 "pct start 100" 2>/dev/null || true
echo ""

# Rollback VMID 101 (proxmox-datacenter-manager) on r630-02
echo "Rolling back VMID 101 to 192.168.11.6..."
ssh -o ConnectTimeout=10 root@192.168.11.12 "pct stop 101" 2>/dev/null || true
sleep 2
ssh -o ConnectTimeout=10 root@192.168.11.12 "pct set 101 --net0 bridge=vmbr0,name=eth0,ip=192.168.11.6/24,gw=192.168.11.1,type=veth" || echo "Warning: Failed to rollback 101"
ssh -o ConnectTimeout=10 root@192.168.11.12 "pct start 101" 2>/dev/null || true
echo ""

# Rollback VMID 102 (cloudflared) on r630-02
echo "Rolling back VMID 102 to 192.168.11.9..."
ssh -o ConnectTimeout=10 root@192.168.11.12 "pct stop 102" 2>/dev/null || true
sleep 2
ssh -o ConnectTimeout=10 root@192.168.11.12 "pct set 102 --net0 bridge=vmbr0,name=eth0,ip=192.168.11.9/24,gw=192.168.11.1,type=veth" || echo "Warning: Failed to rollback 102"
ssh -o ConnectTimeout=10 root@192.168.11.12 "pct start 102" 2>/dev/null || true
echo ""

# Rollback VMID 6200 (firefly-1) on r630-02
echo "Rolling back VMID 6200 to 192.168.11.7..."
ssh -o ConnectTimeout=10 root@192.168.11.12 "pct stop 6200" 2>/dev/null || true
sleep 2
ssh -o ConnectTimeout=10 root@192.168.11.12 "pct set 6200 --net0 bridge=vmbr0,name=eth0,ip=192.168.11.7/24,gw=192.168.11.1,type=veth" || echo "Warning: Failed to rollback 6200"
ssh -o ConnectTimeout=10 root@192.168.11.12 "pct start 6200" 2>/dev/null || true
echo ""

