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>
224 lines
8.7 KiB
Bash
Executable File
224 lines
8.7 KiB
Bash
Executable File
#!/bin/bash
|
||
set -euo pipefail
|
||
|
||
# Migrate configurations to NPMplus after installation
|
||
# Run this after NPMplus is installed and running
|
||
|
||
set -e
|
||
|
||
PROXMOX_HOST="${1:-192.168.11.11}"
|
||
CONTAINER_ID="${2}"
|
||
NPM_URL="${3}"
|
||
|
||
if [ -z "$CONTAINER_ID" ] || [ -z "$NPM_URL" ]; then
|
||
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
||
echo "🔄 NPMplus Configuration Migration"
|
||
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
||
echo ""
|
||
echo "Usage: $0 [PROXMOX_HOST] [CONTAINER_ID] [NPM_URL]"
|
||
echo ""
|
||
echo "Example:"
|
||
echo " $0 192.168.11.11 106 https://192.168.11.27:81"
|
||
echo ""
|
||
echo "Or run interactively:"
|
||
read -p "Proxmox Host [192.168.11.11]: " PROXMOX_HOST
|
||
PROXMOX_HOST="${PROXMOX_HOST:-192.168.11.11}"
|
||
read -p "NPMplus Container ID: " CONTAINER_ID
|
||
read -p "NPMplus URL (https://IP:81): " NPM_URL
|
||
echo ""
|
||
fi
|
||
|
||
EMAIL="admin@example.org"
|
||
read -sp "NPMplus Admin Password: " PASSWORD
|
||
echo ""
|
||
|
||
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
||
echo "🔐 Authenticating to NPMplus..."
|
||
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
||
|
||
# Create migration script to run inside container
|
||
MIGRATE_SCRIPT=$(cat << 'MIGRATE_EOF'
|
||
#!/bin/bash
|
||
set -e
|
||
|
||
NPM_URL="${1}"
|
||
EMAIL="${2}"
|
||
PASSWORD="${3}"
|
||
|
||
echo "🔐 Authenticating..."
|
||
TOKEN_RESPONSE=$(curl -s -k -X POST "$NPM_URL/api/tokens" \
|
||
-H "Content-Type: application/json" \
|
||
-d "{\"identity\":\"$EMAIL\",\"secret\":\"$PASSWORD\"}")
|
||
|
||
TOKEN=$(echo "$TOKEN_RESPONSE" | jq -r '.token // empty' 2>/dev/null || echo "")
|
||
|
||
if [ -z "$TOKEN" ] || [ "$TOKEN" = "null" ]; then
|
||
ERROR_MSG=$(echo "$TOKEN_RESPONSE" | jq -r '.error.message // "Unknown error"' 2>/dev/null || echo "$TOKEN_RESPONSE")
|
||
echo "❌ Authentication failed: $ERROR_MSG"
|
||
exit 1
|
||
fi
|
||
|
||
echo "✅ Authentication successful"
|
||
echo ""
|
||
|
||
# Function to create proxy host
|
||
create_proxy_host() {
|
||
local domain=$1
|
||
local scheme=$2
|
||
local hostname=$3
|
||
local port=$4
|
||
local websocket=$5
|
||
|
||
echo "📋 Processing $domain..."
|
||
|
||
# Check if exists
|
||
EXISTING=$(curl -s -k -X GET "$NPM_URL/api/nginx/proxy-hosts" \
|
||
-H "Authorization: Bearer $TOKEN" | jq -r ".result[] | select(.domain_names[] == \"$domain\") | .id" 2>/dev/null || echo "")
|
||
|
||
local HOST_ID
|
||
if [ -n "$EXISTING" ] && [ "$EXISTING" != "null" ]; then
|
||
echo " ℹ️ Already exists (ID: $EXISTING)"
|
||
HOST_ID=$EXISTING
|
||
else
|
||
# Create new
|
||
echo " ➕ Creating proxy host..."
|
||
RESPONSE=$(curl -s -k -X POST "$NPM_URL/api/nginx/proxy-hosts" \
|
||
-H "Authorization: Bearer $TOKEN" \
|
||
-H "Content-Type: application/json" \
|
||
-d "{
|
||
\"domain_names\": [\"$domain\"],
|
||
\"forward_scheme\": \"$scheme\",
|
||
\"forward_hostname\": \"$hostname\",
|
||
\"forward_port\": $port,
|
||
\"allow_websocket_upgrade\": $websocket,
|
||
\"block_exploits\": true,
|
||
\"cache_enabled\": false,
|
||
\"ssl_forced\": true,
|
||
\"http2_support\": true,
|
||
\"hsts_enabled\": true,
|
||
\"hsts_subdomains\": true,
|
||
\"access_list_id\": 0,
|
||
\"certificate_id\": 0
|
||
}")
|
||
|
||
HOST_ID=$(echo "$RESPONSE" | jq -r '.id // empty' 2>/dev/null || echo "")
|
||
|
||
if [ -z "$HOST_ID" ] || [ "$HOST_ID" = "null" ]; then
|
||
ERROR=$(echo "$RESPONSE" | jq -r '.error.message // .error // "Unknown error"' 2>/dev/null || echo "$RESPONSE")
|
||
echo " ❌ Failed: $ERROR"
|
||
return 1
|
||
fi
|
||
|
||
echo " ✅ Created (ID: $HOST_ID)"
|
||
fi
|
||
|
||
# Request SSL certificate
|
||
echo " 🔒 Requesting SSL certificate..."
|
||
CERT_RESPONSE=$(curl -s -k -X POST "$NPM_URL/api/nginx/certificates" \
|
||
-H "Authorization: Bearer $TOKEN" \
|
||
-H "Content-Type: application/json" \
|
||
-d "{
|
||
\"domain_names\": [\"$domain\"],
|
||
\"provider\": \"letsencrypt\",
|
||
\"letsencrypt_email\": \"nsatoshi2007@hotmail.com\",
|
||
\"letsencrypt_agree\": true
|
||
}")
|
||
|
||
CERT_ID=$(echo "$CERT_RESPONSE" | jq -r '.id // empty' 2>/dev/null || echo "")
|
||
|
||
if [ -z "$CERT_ID" ] || [ "$CERT_ID" = "null" ]; then
|
||
ERROR=$(echo "$CERT_RESPONSE" | jq -r '.error.message // .error // "Check manually"' 2>/dev/null || echo "$CERT_RESPONSE")
|
||
echo " ⚠️ Certificate request: $ERROR"
|
||
echo " ℹ️ Certificate may be processing or domain may need DNS verification"
|
||
else
|
||
echo " ✅ Certificate requested (ID: $CERT_ID)"
|
||
|
||
# Update proxy host with certificate
|
||
if [ -n "$CERT_ID" ] && [ "$CERT_ID" != "null" ] && [ "$CERT_ID" != "0" ]; then
|
||
sleep 2 # Wait a moment for certificate to be processed
|
||
UPDATE_RESPONSE=$(curl -s -k -X PUT "$NPM_URL/api/nginx/proxy-hosts/$HOST_ID" \
|
||
-H "Authorization: Bearer $TOKEN" \
|
||
-H "Content-Type: application/json" \
|
||
-d "{
|
||
\"certificate_id\": $CERT_ID,
|
||
\"ssl_forced\": true
|
||
}")
|
||
|
||
echo " ✅ SSL configured for $domain"
|
||
fi
|
||
fi
|
||
|
||
return 0
|
||
}
|
||
|
||
# Configure all 19 domains
|
||
echo "🚀 Starting domain configuration (19 domains)..."
|
||
echo ""
|
||
|
||
SUCCESS=0
|
||
FAILED=0
|
||
|
||
# sankofa.nexus (5 domains)
|
||
create_proxy_host "sankofa.nexus" "http" "192.168.11.140" "80" "false" && ((SUCCESS++)) || ((FAILED++))
|
||
create_proxy_host "www.sankofa.nexus" "http" "192.168.11.140" "80" "false" && ((SUCCESS++)) || ((FAILED++))
|
||
create_proxy_host "phoenix.sankofa.nexus" "http" "192.168.11.140" "80" "false" && ((SUCCESS++)) || ((FAILED++))
|
||
create_proxy_host "www.phoenix.sankofa.nexus" "http" "192.168.11.140" "80" "false" && ((SUCCESS++)) || ((FAILED++))
|
||
create_proxy_host "the-order.sankofa.nexus" "http" "192.168.11.140" "80" "false" && ((SUCCESS++)) || ((FAILED++))
|
||
|
||
# d-bis.org (9 domains)
|
||
create_proxy_host "explorer.d-bis.org" "http" "192.168.11.140" "80" "false" && ((SUCCESS++)) || ((FAILED++))
|
||
create_proxy_host "rpc-http-pub.d-bis.org" "https" "192.168.11.252" "443" "true" && ((SUCCESS++)) || ((FAILED++))
|
||
create_proxy_host "rpc-ws-pub.d-bis.org" "https" "192.168.11.252" "443" "true" && ((SUCCESS++)) || ((FAILED++))
|
||
create_proxy_host "rpc-http-prv.d-bis.org" "https" "192.168.11.251" "443" "true" && ((SUCCESS++)) || ((FAILED++))
|
||
create_proxy_host "rpc-ws-prv.d-bis.org" "https" "192.168.11.251" "443" "true" && ((SUCCESS++)) || ((FAILED++))
|
||
create_proxy_host "dbis-admin.d-bis.org" "http" "192.168.11.130" "80" "false" && ((SUCCESS++)) || ((FAILED++))
|
||
create_proxy_host "dbis-api.d-bis.org" "http" "192.168.11.155" "3000" "false" && ((SUCCESS++)) || ((FAILED++))
|
||
create_proxy_host "dbis-api-2.d-bis.org" "http" "192.168.11.156" "3000" "false" && ((SUCCESS++)) || ((FAILED++))
|
||
create_proxy_host "secure.d-bis.org" "http" "192.168.11.130" "80" "false" && ((SUCCESS++)) || ((FAILED++))
|
||
|
||
# mim4u.org (4 domains)
|
||
create_proxy_host "mim4u.org" "http" "192.168.11.36" "80" "false" && ((SUCCESS++)) || ((FAILED++))
|
||
create_proxy_host "www.mim4u.org" "http" "192.168.11.36" "80" "false" && ((SUCCESS++)) || ((FAILED++))
|
||
create_proxy_host "secure.mim4u.org" "http" "192.168.11.36" "80" "false" && ((SUCCESS++)) || ((FAILED++))
|
||
create_proxy_host "training.mim4u.org" "http" "192.168.11.36" "80" "false" && ((SUCCESS++)) || ((FAILED++))
|
||
|
||
# defi-oracle.io (1 domain)
|
||
create_proxy_host "rpc.public-0138.defi-oracle.io" "https" "192.168.11.252" "443" "true" && ((SUCCESS++)) || ((FAILED++))
|
||
|
||
echo ""
|
||
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
||
echo "📊 Configuration Summary"
|
||
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
||
echo "✅ Successful: $SUCCESS"
|
||
echo "⚠️ Failed: $FAILED"
|
||
echo "📋 Total: 19"
|
||
echo ""
|
||
echo "⏳ SSL certificates may take 1-2 minutes to be issued"
|
||
MIGRATE_EOF
|
||
)
|
||
|
||
# Write script to temp file and copy to container
|
||
TEMP_SCRIPT="/tmp/migrate-npmplus-$$.sh"
|
||
echo "$MIGRATE_SCRIPT" > "$TEMP_SCRIPT"
|
||
chmod +x "$TEMP_SCRIPT"
|
||
|
||
# Copy to Proxmox host
|
||
scp "$TEMP_SCRIPT" root@"$PROXMOX_HOST":/tmp/migrate-npmplus.sh
|
||
|
||
# Run inside container
|
||
echo "🚀 Running migration script in NPMplus container..."
|
||
ssh root@"$PROXMOX_HOST" "pct exec $CONTAINER_ID -- bash /tmp/migrate-npmplus.sh '$NPM_URL' '$EMAIL' '$PASSWORD'"
|
||
|
||
# Cleanup
|
||
rm -f "$TEMP_SCRIPT"
|
||
ssh root@"$PROXMOX_HOST" "rm -f /tmp/migrate-npmplus.sh"
|
||
|
||
echo ""
|
||
echo "✅ Migration complete!"
|
||
echo ""
|
||
echo "📋 Next steps:"
|
||
echo " 1. Update UDM Pro port forwarding to new container IP"
|
||
echo " 2. Test all domains: bash scripts/check-east-west-ssl-status.sh"
|
||
echo " 3. Verify SSL certificates are issued"
|
||
echo ""
|