#!/usr/bin/env bash set -euo pipefail # Apply direct Blockscout route configuration # Updates NPMplus to use direct route: explorer.d-bis.org → 192.168.11.140:4000 # Usage: ./apply-direct-blockscout-route.sh set -e SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" PROJECT_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)" echo "==========================================" echo "Apply Direct Blockscout Route" echo "==========================================" echo "This will update NPMplus configuration" echo "to route explorer.d-bis.org directly to" echo "Blockscout on port 4000 (bypassing nginx)" echo "==========================================" echo "" # Check if Node.js is available if ! command -v node &> /dev/null; then echo "❌ Node.js is not installed" echo " Please install Node.js to run the NPMplus update script" exit 1 fi # Check if Playwright is installed if [ ! -d "$PROJECT_ROOT/node_modules/playwright" ]; then echo "⚠️ Playwright not found, installing dependencies..." cd "$PROJECT_ROOT" if [ -f "package.json" ]; then npm install else echo "❌ package.json not found" echo " Please install dependencies manually" exit 1 fi fi echo "✅ Dependencies ready" echo "" # Run the NPMplus update script echo "=== Updating NPMplus Configuration ===" cd "$PROJECT_ROOT/scripts/nginx-proxy-manager" if [ -f "update-explorer-direct-route.js" ]; then echo "Running NPMplus update script..." node update-explorer-direct-route.js UPDATE_SUCCESS=$? else echo "⚠️ update-explorer-direct-route.js not found" echo " Creating it now..." # The script should have been created by configure-direct-blockscout-route.sh # If not, we'll use the main configure script with updated settings echo " Using main configuration script with direct route..." node configure-npmplus-domains.js UPDATE_SUCCESS=$? fi echo "" if [ $UPDATE_SUCCESS -eq 0 ]; then echo "==========================================" echo "✅ Configuration Updated Successfully" echo "==========================================" echo "" echo "Changes Applied:" echo " Domain: explorer.d-bis.org" echo " Old Route: http://192.168.11.140:80 (via nginx)" echo " New Route: http://192.168.11.140:4000 (direct)" echo "" echo "Next Steps:" echo " 1. Wait 10-30 seconds for NPMplus to reload" echo " 2. Test the API:" echo " curl -I https://explorer.d-bis.org/api/v2/stats" echo " 3. Check browser console for any errors" echo "" else echo "==========================================" echo "⚠️ Configuration Update Had Issues" echo "==========================================" echo "" echo "You may need to manually update NPMplus:" echo " 1. Log into: https://192.168.0.166:81" echo " 2. Find 'explorer.d-bis.org' proxy host" echo " 3. Update Forward Host: 192.168.11.140" echo " 4. Update Forward Port: 4000" echo " 5. Save changes" echo "" fi echo "=========================================="