Files
proxmox/scripts/nginx-proxy-manager/run-npmplus-migration.sh.bak
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

174 lines
6.6 KiB
Bash
Executable File
Raw Permalink Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/bin/bash
set -euo pipefail
# Complete NPMplus migration - runs all steps automatically
# This script orchestrates the entire migration process
set -e
PROXMOX_HOST="192.168.11.11"
TZ="America/New_York"
ACME_EMAIL="nsatoshi2007@hotmail.com"
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 105 -- 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 105 -- 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 if NPMplus is already installed
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"
read -p " Use existing container? (y/n): " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
NEW_CONTAINER_ID="$EXISTING_CT"
echo " ✅ Using existing container: $NEW_CONTAINER_ID"
else
NEW_CONTAINER_ID=""
fi
else
NEW_CONTAINER_ID=""
fi
# Step 3: Install NPMplus if needed
if [ -z "$NEW_CONTAINER_ID" ]; then
echo "📦 Step 3: Installing NPMplus..."
echo " ⚠️ The Proxmox helper script requires interactive input."
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: $TZ"
echo " - ACME Email: $ACME_EMAIL"
echo ""
read -p " Press Enter after NPMplus is installed and you have the container ID..."
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
else
echo "📦 Step 3: Using existing NPMplus container"
fi
# Step 4: Get container information
echo ""
echo "📦 Step 4: 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?"
exit 1
fi
echo " ✅ Container IP: $CONTAINER_IP"
# Get 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
'" || 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 5: Migrate configurations
echo ""
echo "📦 Step 5: Migrating configurations..."
bash scripts/nginx-proxy-manager/migrate-configs-to-npmplus.sh \
"$PROXMOX_HOST" \
"$NEW_CONTAINER_ID" \
"https://$CONTAINER_IP:81" <<< "$ADMIN_PASSWORD" || {
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 6: Update network configuration info
echo ""
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo "📋 Step 6: Network Configuration Update Required"
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo ""
echo "⚠️ Manual Step Required: 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 7: Test migration
echo ""
echo "📦 Step 7: 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: 105"
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 ""