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>
67 lines
2.6 KiB
Bash
Executable File
67 lines
2.6 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Batch update scripts for IP centralization and error handling
|
|
# Usage: ./scripts/batch-update-scripts.sh [--ip-only] [--error-only] [--both]
|
|
|
|
set -euo pipefail
|
|
|
|
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
|
|
|
|
MODE="${1:---both}"
|
|
|
|
# Colors
|
|
GREEN='\033[0;32m'
|
|
YELLOW='\033[1;33m'
|
|
BLUE='\033[0;34m'
|
|
NC='\033[0m'
|
|
|
|
log_info() { echo -e "${BLUE}[INFO]${NC} $1"; }
|
|
log_success() { echo -e "${GREEN}[✓]${NC} $1"; }
|
|
|
|
# Find scripts that need updates
|
|
if [[ "$MODE" == "--ip-only" ]] || [[ "$MODE" == "--both" ]]; then
|
|
log_info "Finding scripts with hardcoded IPs..."
|
|
IP_SCRIPTS=$(find "$PROJECT_ROOT/scripts" -name "*.sh" -type f ! -path "*/node_modules/*" ! -path "*/.git/*" ! -path "*/archive/*" -exec grep -l "192\.168\.11\." {} \; 2>/dev/null | grep -vE "(centralize|find-hardcoded|check-ip|query-missing|check-vmid)" | head -200)
|
|
|
|
for script in $IP_SCRIPTS; do
|
|
if ! grep -q "source.*ip-addresses.conf" "$script" 2>/dev/null; then
|
|
log_info "Updating IP centralization: $script"
|
|
# Add IP config loading after set -euo pipefail or at top
|
|
if grep -q "^set -euo pipefail\|^set -uo pipefail\|^set -eo pipefail" "$script"; then
|
|
sed -i '/^set -[euo]* pipefail/a\
|
|
# 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\
|
|
' "$script"
|
|
elif grep -q "^#!/" "$script"; then
|
|
# Add after shebang
|
|
sed -i '1a\
|
|
# 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\
|
|
' "$script"
|
|
fi
|
|
fi
|
|
done
|
|
fi
|
|
|
|
if [[ "$MODE" == "--error-only" ]] || [[ "$MODE" == "--both" ]]; then
|
|
log_info "Finding scripts missing error handling..."
|
|
ERROR_SCRIPTS=$(find "$PROJECT_ROOT/scripts" -name "*.sh" -type f ! -path "*/node_modules/*" ! -path "*/.git/*" ! -path "*/archive/*" -exec sh -c 'head -1 "$1" | grep -q "^#!/" && ! grep -q "set -euo pipefail\|set -uo pipefail\|set -eo pipefail" "$1" && echo "$1"' _ {} \; 2>/dev/null | head -50)
|
|
|
|
for script in $ERROR_SCRIPTS; do
|
|
log_info "Adding error handling: $script"
|
|
if grep -q "^#!/" "$script"; then
|
|
# Add after shebang, before any other code
|
|
sed -i '1a\
|
|
set -euo pipefail\
|
|
' "$script"
|
|
fi
|
|
done
|
|
fi
|
|
|
|
log_success "Batch update complete!"
|