Files
proxmox/scripts/archive/consolidated/fix/fix-pve2-hook-issues-proper.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

135 lines
5.2 KiB
Bash

#!/usr/bin/env bash
# Fix pre-start hook issues by checking what the hook actually needs
# The hook might be failing due to missing volumes or other issues
# Usage: ./scripts/fix-pve2-hook-issues-proper.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
NODE_IP="${PROXMOX_HOST_R630_01}"
NODE_NAME=$(ssh -o ConnectTimeout=5 -o StrictHostKeyChecking=no root@${NODE_IP} "hostname" || echo "unknown")
# 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 "Fixing hook issues on $NODE_NAME ($NODE_IP)..."
echo ""
# All containers with hook issues
HOOK_ISSUE_CONTAINERS=(3000 3001 3002 3003 3500 3501 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)
FIXED=0
FAILED=0
for vmid in "${HOOK_ISSUE_CONTAINERS[@]}"; do
log_info "Processing CT $vmid..."
# Get container config
config_file="/etc/pve/nodes/${NODE_NAME}/lxc/${vmid}.conf"
rootfs=$(ssh -o ConnectTimeout=5 -o StrictHostKeyChecking=no root@${NODE_IP} \
"pct config $vmid 2>/dev/null | grep '^rootfs:'" || echo "")
if [[ -z "$rootfs" ]]; then
log_warn " Config not found, skipping..."
continue
fi
# Extract volume name
volume_name=$(echo "$rootfs" | sed 's/^rootfs: //' | cut -d':' -f2 | cut -d',' -f1)
storage_pool=$(echo "$rootfs" | sed 's/^rootfs: //' | cut -d':' -f1)
log_info " Storage: $storage_pool:$volume_name"
# Check if volume exists
volume_exists=$(ssh -o ConnectTimeout=5 -o StrictHostKeyChecking=no root@${NODE_IP} \
"lvs 2>/dev/null | grep -q \"^${volume_name}\" && echo 'exists' || echo 'missing'" || echo "error")
if [[ "$volume_exists" == "missing" ]]; then
log_warn " Volume missing, attempting to start (will create volume)..."
# Try to start - Proxmox will create the volume
if ssh -o ConnectTimeout=5 -o StrictHostKeyChecking=no root@${NODE_IP} \
"pct start $vmid" 2>&1 >/dev/null; then
log_success " ✓ Container started (volume created)"
((FIXED++))
sleep 1
continue
else
error=$(ssh -o ConnectTimeout=5 -o StrictHostKeyChecking=no root@${NODE_IP} \
"pct start $vmid 2>&1" || true)
# Check if it's still a hook error
if echo "$error" | grep -q "hook.pre-start"; then
log_info " Hook error detected, checking hook script..."
# Check the pre-start hook
hook_output=$(ssh -o ConnectTimeout=5 -o StrictHostKeyChecking=no root@${NODE_IP} \
"bash -x /usr/share/lxc/hooks/lxc-pve-prestart-hook lxc 3000 start 2>&1" || true)
# Try bypassing hook by checking container directly
log_info " Attempting direct start with debug..."
debug_output=$(ssh -o ConnectTimeout=5 -o StrictHostKeyChecking=no root@${NODE_IP} \
"lxc-start -n $vmid -F -l DEBUG -o /tmp/lxc-$vmid.log 2>&1" || true)
# For now, just try starting - the hook might work on retry
log_info " Retrying start..."
if ssh -o ConnectTimeout=5 -o StrictHostKeyChecking=no root@${NODE_IP} \
"pct start $vmid" 2>&1 >/dev/null; then
log_success " ✓ Container started on retry"
((FIXED++))
else
log_warn " ⚠️ Still failing - may need manual intervention"
((FAILED++))
fi
else
log_warn " ⚠️ Other error:"
echo "$error" | sed 's/^/ /' | head -2
((FAILED++))
fi
fi
else
log_info " Volume exists, attempting start..."
if ssh -o ConnectTimeout=5 -o StrictHostKeyChecking=no root@${NODE_IP} \
"pct start $vmid" 2>&1 >/dev/null; then
log_success " ✓ Container started"
((FIXED++))
sleep 1
else
error=$(ssh -o ConnectTimeout=5 -o StrictHostKeyChecking=no root@${NODE_IP} \
"pct start $vmid 2>&1" || true)
if echo "$error" | grep -q "already running"; then
log_success " ✓ Container already running"
((FIXED++))
elif echo "$error" | grep -q "hook.pre-start"; then
log_warn " ⚠️ Hook error - container may need manual fix"
((FAILED++))
else
log_warn " ⚠️ Start failed:"
echo "$error" | sed 's/^/ /' | head -2
((FAILED++))
fi
fi
fi
echo ""
done
echo ""
log_info "Summary: Fixed: $FIXED, Failed: $FAILED"
log_success "Done!"