#!/usr/bin/env bash # Wave 0: run from host on LAN. Runs W0-1 (NPMplus RPC fix) and W0-3 (NPMplus backup). # W0-2 (sendCrossChain real): run scripts/bridge/run-send-cross-chain.sh without --dry-run when ready. # # Usage: bash scripts/run-wave0-from-lan.sh [--dry-run] [--skip-backup|--skip-rpc-fix] set -euo pipefail SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" PROJECT_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)" cd "$PROJECT_ROOT" DRY_RUN=false SKIP_BACKUP=false SKIP_RPC_FIX=false for a in "$@"; do [[ "$a" == "--dry-run" ]] && DRY_RUN=true [[ "$a" == "--skip-backup" ]] && SKIP_BACKUP=true [[ "$a" == "--skip-rpc-fix" ]] && SKIP_RPC_FIX=true done log_info() { echo -e "\033[0;34m[INFO]\033[0m $1"; } log_ok() { echo -e "\033[0;32m[✓]\033[0m $1"; } log_warn() { echo -e "\033[0;33m[⚠]\033[0m $1"; } log_err() { echo -e "\033[0;31m[✗]\033[0m $1"; } echo "" echo "Wave 0 (from LAN): NPMplus RPC fix + Backup" echo "" # Ensure jq (required by update-npmplus-proxy-hosts-api.sh) on remote host if ! command -v jq &>/dev/null; then log_info "Installing jq..." if command -v apt-get &>/dev/null; then apt-get update -qq && apt-get install -y -qq jq >/dev/null 2>&1 || { log_err "Could not install jq. Install manually: apt-get install jq"; exit 1; } else log_err "jq is required. Install it (e.g. apt-get install jq) and re-run." exit 1 fi fi if [[ "$SKIP_RPC_FIX" != true ]]; then log_info "W0-1: NPMplus RPC fix..." if [[ "$DRY_RUN" == true ]]; then echo " [DRY-RUN] bash scripts/nginx-proxy-manager/update-npmplus-proxy-hosts-api.sh" else bash "$SCRIPT_DIR/nginx-proxy-manager/update-npmplus-proxy-hosts-api.sh" && log_ok "W0-1 done" || { log_err "W0-1 failed"; exit 1; } fi else log_warn "W0-1 skipped" fi if [[ "$SKIP_BACKUP" != true ]]; then log_info "W0-3: NPMplus backup..." if [[ "$DRY_RUN" == true ]]; then echo " [DRY-RUN] bash scripts/verify/backup-npmplus.sh" else bash "$SCRIPT_DIR/verify/backup-npmplus.sh" && log_ok "W0-3 done" || log_warn "W0-3 failed (container may be stopped)" fi else log_warn "W0-3 skipped" fi echo "" log_info "W0-2 (sendCrossChain real): bash scripts/bridge/run-send-cross-chain.sh [recipient] # omit --dry-run" log_ok "Wave 0 script finished." echo ""