#!/usr/bin/env bash
# Update migration script to use thin1 storage instead of local-lvm
# Since pve/pve2 have thin1 storage configured and available

set -euo pipefail

SCRIPT_FILE="/home/intlc/projects/proxmox/scripts/rename-and-migrate-chain138-containers.sh"

# Colors
GREEN='\033[0;32m'
BLUE='\033[0;34m'
NC='\033[0m'

log_info() { echo -e "${BLUE}[INFO]${NC} $1"; }
log_success() { echo -e "${GREEN}[✓]${NC} $1"; }

log_info "Updating migration script to use thin1 storage..."
log_info "pve and pve2 have thin1 storage configured and available"
log_info "This is compatible for migrations from ml110's local-lvm"

# Update storage variables in the script
sed -i 's/STORAGE_PVE="${STORAGE_PVE:-local}"/STORAGE_PVE="${STORAGE_PVE:-thin1}"/' "$SCRIPT_FILE"
sed -i 's/STORAGE_PVE2="${STORAGE_PVE2:-local}"/STORAGE_PVE2="${STORAGE_PVE2:-thin1}"/' "$SCRIPT_FILE"

log_success "Migration script updated to use thin1 storage"
log_info "Storage configuration:"
log_info "  • pve: thin1"
log_info "  • pve2: thin1"

cat << 'EOF'

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✅ STORAGE CONFIGURATION UPDATE
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

✅ Migration script updated to use thin1 storage

📝 Storage configuration:
   • pve: thin1 (already configured and active)
   • pve2: thin1 (already configured and active)
   • Source (ml110): local-lvm

✅ thin1 storage is available and configured on both pve and pve2
✅ This storage can accept migrations from ml110's local-lvm

🎯 Next step: Run migration script
   ./scripts/rename-and-migrate-chain138-containers.sh

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
EOF

