Some checks failed
Deploy to Phoenix / deploy (push) Has been cancelled
- 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>
171 lines
6.3 KiB
Bash
Executable File
171 lines
6.3 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Fix missing storage volumes for containers on pve2
|
|
# This script checks storage config and recreates missing volumes
|
|
# Usage: ./scripts/fix-pve2-container-storage.sh [--dry-run]
|
|
|
|
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
|
|
|
|
|
|
PVE2_IP="${PROXMOX_HOST_R630_01}"
|
|
DRY_RUN=false
|
|
|
|
if [[ "${1:-}" == "--dry-run" ]]; then
|
|
DRY_RUN=true
|
|
echo "DRY RUN MODE - No changes will be made"
|
|
fi
|
|
|
|
# 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"; }
|
|
|
|
# All containers
|
|
ALL_CONTAINERS=(3000 3001 3002 3003 3500 3501 5200 6000 6400 10000 10001 10020 10030 10040 10050 10060 10070 10080 10090 10091 10092 10100 10101 10120 10130 10150 10151 10200 10201 10202 10210 10230 10232)
|
|
|
|
echo ""
|
|
log_info "Fixing container storage on pve2..."
|
|
echo ""
|
|
|
|
# Check SSH
|
|
if ! ssh -o ConnectTimeout=5 -o StrictHostKeyChecking=no root@${PVE2_IP} "echo 'OK'" &>/dev/null; then
|
|
log_error "Cannot access pve2"
|
|
exit 1
|
|
fi
|
|
|
|
FIXED=0
|
|
SKIPPED=0
|
|
FAILED=0
|
|
|
|
for vmid in "${ALL_CONTAINERS[@]}"; do
|
|
log_info "Checking CT $vmid..."
|
|
|
|
# Get storage config
|
|
rootfs_config=$(ssh -o ConnectTimeout=5 -o StrictHostKeyChecking=no root@${PVE2_IP} \
|
|
"pct config $vmid 2>/dev/null | grep '^rootfs:'" || echo "")
|
|
|
|
if [[ -z "$rootfs_config" ]]; then
|
|
log_warn " Config missing, skipping..."
|
|
((SKIPPED++))
|
|
continue
|
|
fi
|
|
|
|
# Extract storage pool and volume
|
|
storage_line=$(echo "$rootfs_config" | sed 's/^rootfs: //')
|
|
storage_pool=$(echo "$storage_line" | cut -d':' -f1)
|
|
volume_name=$(echo "$storage_line" | cut -d':' -f2 | cut -d',' -f1)
|
|
size=$(echo "$storage_line" | grep -oP 'size=\K[^,]+' || echo "")
|
|
|
|
echo " Storage: $storage_pool:$volume_name"
|
|
if [[ -n "$size" ]]; then
|
|
echo " Size: $size"
|
|
fi
|
|
|
|
# Check if volume exists
|
|
volume_exists=$(ssh -o ConnectTimeout=5 -o StrictHostKeyChecking=no root@${PVE2_IP} \
|
|
"lvs 2>/dev/null | grep -q \"^${volume_name}\" && echo 'exists' || echo 'missing'" || echo "error")
|
|
|
|
if [[ "$volume_exists" == "exists" ]]; then
|
|
log_success " ✓ Volume exists"
|
|
# Try to start
|
|
if [[ "$DRY_RUN" == "false" ]]; then
|
|
if ssh -o ConnectTimeout=5 -o StrictHostKeyChecking=no root@${PVE2_IP} \
|
|
"pct start $vmid" 2>&1 >/dev/null; then
|
|
log_success " ✓ Container started"
|
|
((FIXED++))
|
|
else
|
|
log_warn " ⚠️ Volume exists but start failed"
|
|
((FAILED++))
|
|
fi
|
|
else
|
|
log_info " [DRY RUN] Would attempt to start"
|
|
fi
|
|
else
|
|
log_warn " ⚠️ Volume missing: $volume_name"
|
|
|
|
# Check if storage pool is active
|
|
pool_status=$(ssh -o ConnectTimeout=5 -o StrictHostKeyChecking=no root@${PVE2_IP} \
|
|
"pvesm status 2>/dev/null | awk '\$1 == \"$storage_pool\" {print \$3}'" || echo "unknown")
|
|
|
|
if [[ "$pool_status" != "active" ]]; then
|
|
log_error " ❌ Storage pool '$storage_pool' is not active (status: $pool_status)"
|
|
log_info " Checking for alternative storage..."
|
|
|
|
# Find active storage
|
|
alt_storage=$(ssh -o ConnectTimeout=5 -o StrictHostKeyChecking=no root@${PVE2_IP} \
|
|
"pvesm status 2>/dev/null | grep -E 'active|available' | grep lvmthin | awk '{print \$1}' | head -1" || echo "")
|
|
|
|
if [[ -n "$alt_storage" ]]; then
|
|
log_info " Found alternative: $alt_storage"
|
|
if [[ "$DRY_RUN" == "false" ]] && [[ -n "$size" ]]; then
|
|
log_info " Updating storage config..."
|
|
new_rootfs="${alt_storage}:${volume_name},size=${size}"
|
|
if ssh -o ConnectTimeout=5 -o StrictHostKeyChecking=no root@${PVE2_IP} \
|
|
"pct set $vmid -rootfs $new_rootfs" 2>&1 >/dev/null; then
|
|
log_success " ✓ Storage config updated"
|
|
# Try to start (will create volume)
|
|
if ssh -o ConnectTimeout=5 -o StrictHostKeyChecking=no root@${PVE2_IP} \
|
|
"pct start $vmid" 2>&1 >/dev/null; then
|
|
log_success " ✓ Container started"
|
|
((FIXED++))
|
|
else
|
|
log_warn " ⚠️ Start failed after config update"
|
|
((FAILED++))
|
|
fi
|
|
else
|
|
log_error " ❌ Failed to update storage config"
|
|
((FAILED++))
|
|
fi
|
|
else
|
|
log_info " [DRY RUN] Would update to $alt_storage and start"
|
|
fi
|
|
else
|
|
log_error " ❌ No active storage found"
|
|
((FAILED++))
|
|
fi
|
|
else
|
|
log_info " Storage pool is active, volume needs to be created"
|
|
log_info " Attempting to start container (will create volume)..."
|
|
|
|
if [[ "$DRY_RUN" == "false" ]]; then
|
|
if ssh -o ConnectTimeout=5 -o StrictHostKeyChecking=no root@${PVE2_IP} \
|
|
"pct start $vmid" 2>&1 >/dev/null; then
|
|
log_success " ✓ Container started (volume created)"
|
|
((FIXED++))
|
|
else
|
|
error=$(ssh -o ConnectTimeout=5 -o StrictHostKeyChecking=no root@${PVE2_IP} \
|
|
"pct start $vmid 2>&1" || true)
|
|
log_error " ❌ Start failed:"
|
|
echo "$error" | sed 's/^/ /' | head -3
|
|
((FAILED++))
|
|
fi
|
|
else
|
|
log_info " [DRY RUN] Would attempt: pct start $vmid"
|
|
fi
|
|
fi
|
|
fi
|
|
|
|
echo ""
|
|
done
|
|
|
|
echo ""
|
|
log_info "Summary:"
|
|
log_info " Fixed: $FIXED"
|
|
log_info " Failed: $FAILED"
|
|
log_info " Skipped: $SKIPPED"
|
|
|
|
if [[ "$DRY_RUN" == "true" ]]; then
|
|
log_warn "This was a DRY RUN - no changes were made"
|
|
fi
|