Files
proxmox/scripts/nginx-proxy-manager/complete-migration.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

178 lines
7.1 KiB
Bash
Executable File

#!/bin/bash
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
# Complete NPMplus migration - handles all automated steps
# Manual steps are clearly marked
set -e
PROXMOX_HOST="${PROXMOX_HOST_R630_01}"
OLD_CONTAINER_ID="105"
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo "🔄 Complete NPMplus Migration"
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo ""
# Step 1: Backup current NPM
echo "📦 Step 1: Backing up current NPM..."
BACKUP_DIR="/tmp/npm-migration-$(date +%Y%m%d_%H%M%S)"
mkdir -p "$BACKUP_DIR"
echo " 📋 Exporting current configurations..."
ssh root@"$PROXMOX_HOST" "pct exec $OLD_CONTAINER_ID -- bash -c '
cd /app
if [ -f /data/database.sqlite ]; then
sqlite3 /data/database.sqlite \".dump\" > /tmp/npm-database.sql 2>/dev/null || echo \"Database export may have issues\"
fi
'" > "$BACKUP_DIR/backup.log" 2>&1 || echo " ⚠️ Backup may have issues, continuing..."
ssh root@"$PROXMOX_HOST" "pct exec $OLD_CONTAINER_ID -- cat /tmp/npm-database.sql" > "$BACKUP_DIR/database.sql" 2>&1 || echo "" > "$BACKUP_DIR/database.sql"
echo " ✅ Backup saved to: $BACKUP_DIR"
echo ""
# Step 2: Check for existing NPMplus
echo "📦 Step 2: Checking for existing NPMplus installation..."
EXISTING_CT=$(ssh root@"$PROXMOX_HOST" "pct list | grep -i npmplus | awk '{print \$1}' | head -1" || echo "")
if [ -n "$EXISTING_CT" ]; then
echo " ✅ Found existing NPMplus container: $EXISTING_CT"
NEW_CONTAINER_ID="$EXISTING_CT"
else
echo " ⚠️ No existing NPMplus container found"
echo ""
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo "📋 MANUAL STEP REQUIRED: Install NPMplus"
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo ""
echo "Please run this command on the Proxmox host:"
echo ""
echo " ssh root@$PROXMOX_HOST"
echo " bash -c \"\$(wget -qLO - https://github.com/community-scripts/ProxmoxVE/raw/main/ct/npmplus.sh)\""
echo ""
echo "When prompted:"
echo " • Timezone: America/New_York"
echo " • ACME Email: nsatoshi2007@hotmail.com"
echo ""
echo "After installation completes, note:"
echo " • The container ID (VMID)"
echo " • The container IP address"
echo ""
read -p "Press Enter after NPMplus is installed..."
echo ""
read -p "Enter the new NPMplus container ID (VMID): " NEW_CONTAINER_ID
if [ -z "$NEW_CONTAINER_ID" ]; then
echo " ❌ Container ID is required"
exit 1
fi
fi
# Step 3: Get container information
echo ""
echo "📦 Step 3: Getting container information..."
CONTAINER_IP=$(ssh root@"$PROXMOX_HOST" "pct exec $NEW_CONTAINER_ID -- hostname -I | awk '{print \$1}'" || echo "")
if [ -z "$CONTAINER_IP" ]; then
echo " ❌ Could not get container IP. Is the container running?"
read -p " Enter container IP manually: " CONTAINER_IP
if [ -z "$CONTAINER_IP" ]; then
exit 1
fi
fi
echo " ✅ Container IP: $CONTAINER_IP"
# Get admin password
echo " 🔑 Retrieving admin password..."
ADMIN_PASSWORD=$(ssh root@"$PROXMOX_HOST" "pct exec $NEW_CONTAINER_ID -- bash -c '
if [ -f /opt/.npm_pwd ]; then
grep -i password /opt/.npm_pwd | cut -d: -f2 | tr -d \" \"
else
docker logs npmplus 2>/dev/null | grep -i \"Creating a new user\" | tail -1 | grep -oP \"password: \K[^\s]+\" || echo \"\"
fi
'" 2>/dev/null || echo "")
if [ -z "$ADMIN_PASSWORD" ]; then
echo " ⚠️ Could not retrieve password automatically"
read -sp " Enter NPMplus admin password: " ADMIN_PASSWORD
echo ""
else
echo " ✅ Admin password retrieved"
fi
# Wait for NPMplus to be ready
echo ""
echo " ⏳ Waiting for NPMplus to be ready..."
for i in {1..30}; do
if ssh root@"$PROXMOX_HOST" "pct exec $NEW_CONTAINER_ID -- docker ps --filter 'name=npmplus' --format '{{.Status}}' 2>/dev/null" | grep -q "Up"; then
echo " ✅ NPMplus is running"
break
fi
echo " ⏳ Waiting... ($i/30)"
sleep 2
done
# Step 4: Migrate configurations
echo ""
echo "📦 Step 4: Migrating configurations..."
echo "$ADMIN_PASSWORD" | bash scripts/nginx-proxy-manager/migrate-configs-to-npmplus.sh \
"$PROXMOX_HOST" \
"$NEW_CONTAINER_ID" \
"https://$CONTAINER_IP:81" || {
echo " ⚠️ Migration script had issues. Check output above."
echo " 💡 You can run it manually:"
echo " bash scripts/nginx-proxy-manager/migrate-configs-to-npmplus.sh $PROXMOX_HOST $NEW_CONTAINER_ID https://$CONTAINER_IP:81"
}
# Step 5: Network configuration reminder
echo ""
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo "📋 Step 5: Network Configuration Update Required"
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo ""
echo "⚠️ MANUAL STEP: Update UDM Pro Port Forwarding"
echo ""
echo "1. Log into UDM Pro"
echo "2. Go to: Settings → Networks → Port Forwarding"
echo "3. Update both rules:"
echo " • HTTP (Port 80): 76.53.10.36:80 → $CONTAINER_IP:80"
echo " • HTTPS (Port 443): 76.53.10.36:443 → $CONTAINER_IP:443"
echo ""
read -p "Press Enter after updating port forwarding..."
# Step 6: Test migration
echo ""
echo "📦 Step 6: Testing migration..."
echo " ⏳ Waiting 30 seconds for SSL certificates to process..."
sleep 30
echo " 🔍 Testing SSL certificates..."
bash scripts/check-east-west-ssl-status.sh || echo " ⚠️ Some tests may have failed. Check manually."
echo ""
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo "✅ Migration Complete!"
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo ""
echo "📋 Summary:"
echo " • Old NPM Container: $OLD_CONTAINER_ID"
echo " • New NPMplus Container: $NEW_CONTAINER_ID"
echo " • NPMplus IP: $CONTAINER_IP"
echo " • Access URL: https://$CONTAINER_IP:81"
echo " • Admin Email: admin@example.org"
echo " • Backup Location: $BACKUP_DIR"
echo ""
echo "🔍 Next Steps:"
echo " 1. Verify all domains are accessible"
echo " 2. Test SSL certificates: bash scripts/check-east-west-ssl-status.sh"
echo " 3. Monitor for 24-48 hours"
echo " 4. (Optional) Stop old NPM container after verification:"
echo " ssh root@$PROXMOX_HOST \"pct stop $OLD_CONTAINER_ID\""
echo ""