Files
proxmox/scripts/repair-corrupted-ip-replacements.sh
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

87 lines
5.4 KiB
Bash

#!/usr/bin/env bash
# Repair corrupted IP replacements from buggy fix-remaining-hardcoded-ips.sh
# Fixes ${IP_SERVICE_XX:-192.168.11.XX}N patterns to proper ${VAR:-192.168.11.XXN}
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJECT_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
# Repair patterns: broken → correct (order matters)
perl_repair() {
local f="$1"
perl -i -pe '
s/\$\{IP_SERVICE_25:-192\.168\.11\.25\}0/\${RPC_ALLTRA_1:-192.168.11.250}/g;
s/\$\{IP_SERVICE_25:-192\.168\.11\.25\}1/\${RPC_ALI_1:-192.168.11.251}/g;
s/\$\{IP_SERVICE_25:-192\.168\.11\.25\}2/\${RPC_ALI_2:-192.168.11.252}/g;
s/\$\{IP_SERVICE_25:-192\.168\.11\.25\}3/\${RPC_ALI_1_ALT:-192.168.11.253}/g;
s/\$\{IP_SERVICE_25:-192\.168\.11\.25\}4/\${RPC_ALI_2_ALT:-192.168.11.254}/g;
s/\$\{IP_SERVICE_25:-192\.168\.11\.25\}5/\${RPC_LUIS_1:-192.168.11.255}/g;
s/\$\{IP_SERVICE_25:-192\.168\.11\.25\}6/\${RPC_LUIS_2:-192.168.11.202}/g;
s/\$\{IP_SERVICE_25:-192\.168\.11\.25\}7/\${RPC_PUTU_1:-192.168.11.203}/g;
s/\$\{IP_SERVICE_25:-192\.168\.11\.25\}8/\${RPC_PUTU_2:-192.168.11.204}/g;
s/\$\{IP_SERVICE_15:-192\.168\.11\.15\}0/\${IP_BESU_RPC_0:-192.168.11.150}/g;
s/\$\{IP_SERVICE_15:-192\.168\.11\.15\}1/\${IP_BESU_RPC_1:-192.168.11.151}/g;
s/\$\{IP_SERVICE_15:-192\.168\.11\.15\}2/\${IP_BESU_RPC_2:-192.168.11.152}/g;
s/\$\{IP_SERVICE_15:-192\.168\.11\.15\}3/\${IP_BESU_RPC_3:-192.168.11.153}/g;
s/\$\{IP_SERVICE_15:-192\.168\.11\.15\}4/\${IP_BESU_SENTRY:-192.168.11.154}/g;
s/\$\{IP_SERVICE_15:-192\.168\.11\.15\}5/\${IP_DBIS_API:-192.168.11.155}/g;
s/\$\{IP_SERVICE_15:-192\.168\.11\.15\}6/\${IP_DBIS_API_2:-192.168.11.156}/g;
s/\$\{IP_SERVICE_16:-192\.168\.11\.16\}6/\${IP_NPMPLUS_ETH0:-192.168.11.166}/g;
s/\$\{IP_SERVICE_16:-192\.168\.11\.16\}7/\${IP_NPMPLUS:-192.168.11.167}/g;
s/\$\{IP_SERVICE_16:-192\.168\.11\.16\}8/\${IP_NPMPLUS_SECONDARY:-192.168.11.168}/g;
s/\$\{IP_SERVICE_22:-192\.168\.11\.22\}1/\${RPC_PUBLIC_1:-192.168.11.221}/g;
s/\$\{IP_SERVICE_23:-192\.168\.11\.23\}2/\${RPC_PRIVATE_1:-192.168.11.232}/g;
s/\$\{IP_SERVICE_24:-192\.168\.11\.24\}0/\${RPC_THIRDWEB_PRIMARY:-192.168.11.240}/g;
s/\$\{IP_SERVICE_24:-192\.168\.11\.24\}1/\${RPC_THIRDWEB_1:-192.168.11.241}/g;
s/\$\{IP_SERVICE_24:-192\.168\.11\.24\}2/\${RPC_THIRDWEB_2:-192.168.11.242}/g;
s/\$\{IP_SERVICE_24:-192\.168\.11\.24\}3/\${RPC_THIRDWEB_3:-192.168.11.243}/g;
s/\$\{IP_SERVICE_24:-192\.168\.11\.24\}4/\${IP_RPC_244:-192.168.11.244}/g;
s/\$\{IP_SERVICE_24:-192\.168\.11\.24\}5/\${IP_RPC_245:-192.168.11.245}/g;
s/\$\{IP_SERVICE_24:-192\.168\.11\.24\}6/\${IP_RPC_246:-192.168.11.246}/g;
s/\$\{IP_SERVICE_24:-192\.168\.11\.24\}7/\${IP_RPC_247:-192.168.11.247}/g;
s/\$\{IP_SERVICE_24:-192\.168\.11\.24\}8/\${IP_RPC_248:-192.168.11.248}/g;
s/\$\{IP_SERVICE_23:-192\.168\.11\.23\}3/\${RPC_NODE_233:-192.168.11.233}/g;
s/\$\{IP_SERVICE_23:-192\.168\.11\.23\}4/\${RPC_NODE_234:-192.168.11.234}/g;
s/\$\{IP_SERVICE_23:-192\.168\.11\.23\}5/\${RPC_NODE_235:-192.168.11.235}/g;
s/\$\{IP_SERVICE_23:-192\.168\.11\.23\}6/\${RPC_NODE_236:-192.168.11.236}/g;
s/\$\{IP_SERVICE_23:-192\.168\.11\.23\}7/\${IP_RPC_237:-192.168.11.237}/g;
s/\$\{IP_SERVICE_23:-192\.168\.11\.23\}8/\${IP_RPC_238:-192.168.11.238}/g;
s/\$\{IP_SERVICE_4:-192\.168\.11\.4\}0/\${IP_SERVICE_40:-192.168.11.40}/g;
s/\$\{IP_SERVICE_4:-192\.168\.11\.4\}1/\${IP_SERVICE_41:-192.168.11.41}/g;
s/\$\{IP_SERVICE_4:-192\.168\.11\.4\}2/\${IP_SERVICE_42:-192.168.11.42}/g;
s/\$\{IP_SERVICE_4:-192\.168\.11\.4\}3/\${IP_SERVICE_43:-192.168.11.43}/g;
s/\$\{IP_SERVICE_4:-192\.168\.11\.4\}4/\${ORDER_POSTGRES_PRIMARY:-192.168.11.44}/g;
s/\$\{IP_SERVICE_4:-192\.168\.11\.4\}5/\${ORDER_POSTGRES_REPLICA:-192.168.11.45}/g;
s/\$\{IP_SERVICE_4:-192\.168\.11\.4\}6/\${ORDER_REDIS_REPLICA:-192.168.11.46}/g;
s/\$\{IP_SERVICE_4:-192\.168\.11\.4\}7/\${IP_SERVICE_47:-192.168.11.47}/g;
s/\$\{IP_SERVICE_4:-192\.168\.11\.4\}8/\${IP_ORDER_OPENSEARCH:-192.168.11.48}/g;
s/\$\{IP_SERVICE_4:-192\.168\.11\.4\}9/\${IP_SERVICE_49:-192.168.11.49}/g;
s/\$\{IP_DEVICE_14:[^}]*\}0/\${IP_BLOCKSCOUT:-192.168.11.140}/g;
s/\$\{IP_SERVICE_13:[^}]*\}0/\${IP_DBIS_FRONTEND:-192.168.11.130}/g;
' "$f" 2>/dev/null || true
}
# Repair nested redundancies (collapse ${VAR:-${VAR:-...}} to ${VAR:-ip})
collapse_redundant() {
local f="$1"
# Collapse multiple levels of same var - run repeatedly until no change
perl -i -pe '
s/\$\{RPC_ALI_1:-(\$\{RPC_ALI_1:-)+\$\{RPC_ALI_1:-192\.168\.11\.251\}\}+\}/\${RPC_ALI_1:-192.168.11.251}/g;
s/\$\{RPC_ALI_2:-(\$\{RPC_ALI_2:-)+\$\{RPC_ALI_2:-192\.168\.11\.252\}\}+\}/\${RPC_ALI_2:-192.168.11.252}/g;
s/\$\{IP_BESU_RPC_0:-(\$\{IP_BESU_RPC_0:-)+\$\{IP_BESU_RPC_0:-192\.168\.11\.150\}\}+\}/\${IP_BESU_RPC_0:-192.168.11.150}/g;
' "$f" 2>/dev/null || true
}
count=0
while IFS= read -r f; do
[ -f "$f" ] || continue
[[ "$f" == *.bak ]] && continue
if grep -qE '\$\{IP_SERVICE_(4|15|16|22|23|24|25):-' "$f" 2>/dev/null; then
perl_repair "$f"
count=$((count+1))
fi
done < <(find "$PROJECT_ROOT/scripts" -name "*.sh" -type f ! -path "*/archive/*" 2>/dev/null)
echo "Repaired $count scripts"
echo "Run fix-remaining-hardcoded-ips.sh next to fix any remaining bare IPs"