Files
proxmox/scripts/find-reserved-ip-conflicts.sh
defiQUG fbda1b4beb
Some checks failed
Deploy to Phoenix / deploy (push) Has been cancelled
docs: Ledger Live integration, contract deploy learnings, NEXT_STEPS updates
- ADD_CHAIN138_TO_LEDGER_LIVE: Ledger form done; public code review repo bis-innovations/LedgerLive; init/push commands
- CONTRACT_DEPLOYMENT_RUNBOOK: Chain 138 gas price 1 gwei, 36-addr check, TransactionMirror workaround
- CONTRACT_*: AddressMapper, MirrorManager deployed 2026-02-12; 36-address on-chain check
- NEXT_STEPS_FOR_YOU: Ledger done; steps completable now (no LAN); run-completable-tasks-from-anywhere
- MASTER_INDEX, OPERATOR_OPTIONAL, SMART_CONTRACTS_INVENTORY_SIMPLE: updates
- LEDGER_BLOCKCHAIN_INTEGRATION_COMPLETE: bis-innovations/LedgerLive reference

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-12 15:46:57 -08:00

126 lines
4.9 KiB
Bash
Executable File

#!/usr/bin/env bash
# Find all VMIDs using IPs in the reserved range (${PROXMOX_HOST_ML110:-192.168.11.10}-${IP_SERVICE_25:-${IP_SERVICE_25:-192.168.11.25}})
# These IPs are reserved for physical servers
# Usage: ./scripts/find-reserved-ip-conflicts.sh
set -euo pipefail
# Load IP configuration
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJECT_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
source "${PROJECT_ROOT}/config/ip-addresses.conf" 2>/dev/null || true
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJECT_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
# Reserved IP range for physical servers
RESERVED_START=10
RESERVED_END=25
# Proxmox hosts
declare -a PROXMOX_HOSTS=(
"${PROXMOX_HOST_ML110:-192.168.11.10}:ml110:L@kers2010"
"${PROXMOX_HOST_R630_01:-192.168.11.11}:r630-01:password"
"${PROXMOX_HOST_R630_02:-192.168.11.12}:r630-02:password"
)
# Colors
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m'
log_info() { echo -e "${BLUE}[INFO]${NC} $1"; }
log_success() { echo -e "${GREEN}[✓]${NC} $1"; }
log_warn() { echo -e "${YELLOW}[WARN]${NC} $1"; }
log_error() { echo -e "${RED}[ERROR]${NC} $1"; }
echo ""
log_info "═══════════════════════════════════════════════════════════"
log_info " FINDING VMIDs USING RESERVED IP RANGE"
log_info " Reserved Range: ${PROXMOX_HOST_ML110:-192.168.11.10} - ${IP_SERVICE_25:-${IP_SERVICE_25:-192.168.11.25}}"
log_info "═══════════════════════════════════════════════════════════"
echo ""
declare -a CONFLICTS=()
# Check each Proxmox host
for host_info in "${PROXMOX_HOSTS[@]}"; do
IFS=':' read -r ip hostname password <<< "$host_info"
log_info "Checking $hostname ($ip)..."
# Get all containers
CONTAINERS=$(ssh -o ConnectTimeout=5 -o StrictHostKeyChecking=no root@${ip} \
"pct list 2>/dev/null | tail -n +2 | awk '{print \$1}'" 2>/dev/null || echo "")
if [[ -z "$CONTAINERS" ]]; then
log_warn " No containers found or cannot access"
continue
fi
# Check each container
while IFS= read -r vmid; do
if [[ -z "$vmid" ]]; then
continue
fi
# Get IP address
ip_config=$(ssh -o ConnectTimeout=5 -o StrictHostKeyChecking=no root@${ip} \
"pct config $vmid 2>/dev/null | grep -oP 'ip=\\K[^,]+' | head -1" 2>/dev/null || echo "")
if [[ -z "$ip_config" ]] || [[ "$ip_config" == "dhcp" ]]; then
continue
fi
# Extract IP base (remove /24)
ip_base="${ip_config%/*}"
# Check if IP is in reserved range
if [[ "$ip_base" =~ ^192\.168\.11\.([0-9]+)$ ]]; then
ip_octet="${BASH_REMATCH[1]}"
if [[ $ip_octet -ge $RESERVED_START ]] && [[ $ip_octet -le $RESERVED_END ]]; then
# Get hostname
container_hostname=$(ssh -o ConnectTimeout=5 -o StrictHostKeyChecking=no root@${ip} \
"pct config $vmid 2>/dev/null | grep -oP 'hostname=\\K[^,]+' | head -1" 2>/dev/null || echo "unknown")
# Get status
status=$(ssh -o ConnectTimeout=5 -o StrictHostKeyChecking=no root@${ip} \
"pct status $vmid 2>/dev/null | awk '{print \$2}'" 2>/dev/null || echo "unknown")
log_warn " ⚠️ VMID $vmid ($container_hostname) on $hostname: $ip_base [$status]"
CONFLICTS+=("$hostname:$vmid:$container_hostname:$ip_base:$status")
fi
fi
done <<< "$CONTAINERS"
done
echo ""
log_info "═══════════════════════════════════════════════════════════"
log_info " SUMMARY"
log_info "═══════════════════════════════════════════════════════════"
echo ""
if [[ ${#CONFLICTS[@]} -eq 0 ]]; then
log_success "✅ No VMIDs found using reserved IP range"
else
log_warn "⚠️ Found ${#CONFLICTS[@]} VMID(s) using reserved IPs:"
echo ""
printf "%-12s | %-6s | %-25s | %-15s | %-8s\n" "Node" "VMID" "Hostname" "IP Address" "Status"
echo "------------|--------|---------------------------|----------------|----------"
for conflict in "${CONFLICTS[@]}"; do
IFS=':' read -r node vmid hostname ip status <<< "$conflict"
printf "%-12s | %-6s | %-25s | %-15s | %-8s\n" "$node" "$vmid" "$hostname" "$ip" "$status"
done
echo ""
log_info "These VMIDs need to be changed to IPs outside the reserved range (${IP_NGINX_LEGACY:-192.168.11.26}-99 or 192.168.11.113-139, etc.)"
fi
echo ""