#!/usr/bin/env bash # Build Full-Featured Blockscout Explorer UI # Creates a comprehensive explorer interface better than Etherscan 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 IP="${IP:-${IP_DEVICE_14:-${IP_DEVICE_14:-${IP_DEVICE_14:-${IP_DEVICE_14:-${IP_DEVICE_14:-192.168.11.14}}}}}0}" DOMAIN="${DOMAIN:-explorer.d-bis.org}" PASSWORD="${PASSWORD:-L@kers2010}" EXPLORER_DIR="/opt/blockscout-explorer-ui" # Colors RED='\033[0;31m' GREEN='\033[0;32m' YELLOW='\033[1;33m' BLUE='\033[0;34m' CYAN='\033[0;36m' 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"; } log_step() { echo -e "${CYAN}[STEP]${NC} $1"; } exec_container() { local cmd="$1" sshpass -p "$PASSWORD" ssh -o StrictHostKeyChecking=no root@"$IP" "bash -c '$cmd'" 2>&1 } echo "════════════════════════════════════════════════════════" echo "Build Full-Featured Blockscout Explorer UI" echo "════════════════════════════════════════════════════════" echo "" # Step 1: Create directory structure log_step "Step 1: Creating explorer UI directory..." exec_container "mkdir -p $EXPLORER_DIR && chmod 755 $EXPLORER_DIR" log_success "Directory created" # Step 2: Create comprehensive explorer HTML with all features log_step "Step 2: Creating full-featured explorer interface..." cat > /tmp/blockscout-explorer-full.html <<'HTML_EOF' Chain 138 Explorer | d-bis.org
Total Blocks
-
Total Transactions
-
Total Addresses
-
Latest Block
-

Latest Blocks

Loading blocks...

Latest Transactions

Loading transactions...

All Blocks

Loading blocks...

All Transactions

Loading transactions...

Block Details

Transaction Details

Address Details

HTML_EOF # Upload the comprehensive explorer log_step "Step 3: Uploading full explorer interface..." sshpass -p "$PASSWORD" scp -o StrictHostKeyChecking=no /tmp/blockscout-explorer-full.html root@"$IP":/var/www/html/index.html log_success "Full explorer interface uploaded" # Step 4: Update Nginx to serve the explorer log_step "Step 4: Updating Nginx configuration..." cat > /tmp/blockscout-nginx-explorer.conf <<'NGINX_EOF' # Blockscout Full Explorer UI Configuration server { listen 443 ssl http2; listen [::]:443 ssl http2; server_name explorer.d-bis.org ${IP_BLOCKSCOUT:-${IP_DEVICE_14:-${IP_DEVICE_14:-${IP_DEVICE_14:-${IP_DEVICE_14:-${IP_DEVICE_14:-192.168.11.14}}}}}0}; ssl_certificate /etc/letsencrypt/live/explorer.d-bis.org/fullchain.pem; ssl_certificate_key /etc/letsencrypt/live/explorer.d-bis.org/privkey.pem; ssl_protocols TLSv1.2 TLSv1.3; ssl_ciphers 'ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384'; ssl_prefer_server_ciphers on; ssl_session_cache shared:SSL:10m; ssl_session_timeout 10m; add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always; add_header X-Frame-Options "SAMEORIGIN" always; add_header X-Content-Type-Options "nosniff" always; add_header X-XSS-Protection "1; mode=block" always; access_log /var/log/nginx/blockscout-access.log; error_log /var/log/nginx/blockscout-error.log; root /var/www/html; index index.html; # Serve the explorer UI location = / { try_files /index.html =404; } # API endpoints - proxy to Blockscout location /api/ { proxy_pass http://127.0.0.1:4000; proxy_http_version 1.1; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; proxy_read_timeout 300s; add_header Access-Control-Allow-Origin *; add_header Access-Control-Allow-Methods "GET, POST, OPTIONS"; add_header Access-Control-Allow-Headers "Content-Type"; } # Static files location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ { expires 1y; add_header Cache-Control "public, immutable"; } # Health check location /health { access_log off; proxy_pass http://127.0.0.1:4000/api/v2/status; proxy_set_header Host $host; add_header Content-Type application/json; } } # HTTP redirect server { listen 80; listen [::]:80; server_name explorer.d-bis.org ${IP_BLOCKSCOUT:-${IP_DEVICE_14:-${IP_DEVICE_14:-${IP_DEVICE_14:-${IP_DEVICE_14:-${IP_DEVICE_14:-192.168.11.14}}}}}0}; location /.well-known/acme-challenge/ { root /var/www/html; try_files $uri =404; } location / { return 301 https://$host$request_uri; } } NGINX_EOF sshpass -p "$PASSWORD" scp -o StrictHostKeyChecking=no /tmp/blockscout-nginx-explorer.conf root@"$IP":/etc/nginx/sites-available/blockscout # Step 5: Test and reload Nginx log_step "Step 5: Testing and reloading Nginx..." exec_container "nginx -t" || { log_error "Nginx configuration test failed!" exit 1 } log_success "Nginx configuration test passed" exec_container "systemctl reload nginx" log_success "Nginx reloaded" echo "" log_success "Full-featured Blockscout Explorer UI deployed!" echo "" log_info "Features included:" log_info " ✅ Modern, responsive design" log_info " ✅ Block explorer with latest blocks" log_info " ✅ Transaction explorer" log_info " ✅ Address lookups and balances" log_info " ✅ Block detail views" log_info " ✅ Transaction detail views" log_info " ✅ Network statistics dashboard" log_info " ✅ Search functionality (address, tx hash, block number)" log_info " ✅ Real-time data from Blockscout API" log_info " ✅ Better UX than Etherscan" echo "" log_info "Access: https://explorer.d-bis.org/" echo ""