fix(validation): use grep instead of rg in validate-xdc-zero-relayer-env (portable cross-checks)
Made-with: Cursor
This commit is contained in:
62
scripts/validation/validate-xdc-zero-relayer-env.sh
Executable file
62
scripts/validation/validate-xdc-zero-relayer-env.sh
Executable file
@@ -0,0 +1,62 @@
|
||||
#!/usr/bin/env bash
|
||||
# Validate XDC Zero relayer env/default example files for key presence and drift.
|
||||
# Usage: bash scripts/validation/validate-xdc-zero-relayer-env.sh
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
PROJECT_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
|
||||
|
||||
DOTENV_FILE="$PROJECT_ROOT/config/xdc-zero/xdc-relayer.dotenv.example"
|
||||
PAIR_ENV_FILE="$PROJECT_ROOT/config/xdc-zero/xdc-zero-chain138-pair.example.env"
|
||||
DEFAULTS_FILE="$PROJECT_ROOT/config/xdc-zero/xdc-zero-relayer-138-pair.example.defaults"
|
||||
SERVICE_FILE="$PROJECT_ROOT/config/systemd/xdc-zero-relayer-138-pair.example.service"
|
||||
|
||||
for f in "$DOTENV_FILE" "$PAIR_ENV_FILE" "$DEFAULTS_FILE" "$SERVICE_FILE"; do
|
||||
[[ -f "$f" ]] || { echo "ERROR: missing file: $f" >&2; exit 1; }
|
||||
done
|
||||
|
||||
require_key() {
|
||||
local file="$1"
|
||||
local key="$2"
|
||||
if ! grep -qE "^${key}=" "$file"; then
|
||||
echo "ERROR: missing ${key}= in $file" >&2
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
value_for() {
|
||||
local file="$1"
|
||||
local key="$2"
|
||||
sed -n "s/^${key}=//p" "$file" | head -n 1
|
||||
}
|
||||
|
||||
for key in RELAYER_PORT NODE_ENV SUBNET_URL PARENTNET_URL CHECKPOINT_CONTRACT MAX_FETCH_BLOCK_SIZE; do
|
||||
require_key "$DOTENV_FILE" "$key"
|
||||
require_key "$DEFAULTS_FILE" "$key"
|
||||
done
|
||||
|
||||
for key in XDC_PARENTNET_URL RPC_URL_138 PARENTNET_URL SUBNET_URL CHECKPOINT_CONTRACT_138_ON_PARENT REVERSE_CHECKPOINT_CONTRACT_PARENT_ON_138; do
|
||||
require_key "$PAIR_ENV_FILE" "$key"
|
||||
done
|
||||
|
||||
for key in RELAYER_PORT NODE_ENV PARENTNET_URL SUBNET_URL MAX_FETCH_BLOCK_SIZE; do
|
||||
v1="$(value_for "$DOTENV_FILE" "$key")"
|
||||
v2="$(value_for "$DEFAULTS_FILE" "$key")"
|
||||
if [[ "$v1" != "$v2" ]]; then
|
||||
echo "ERROR: drift for $key between $(basename "$DOTENV_FILE") and $(basename "$DEFAULTS_FILE"): '$v1' != '$v2'" >&2
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
|
||||
if ! grep -qF 'xdc-zero-relayer-138-pair.example.defaults' "$SERVICE_FILE"; then
|
||||
echo "ERROR: systemd example should reference xdc-zero-relayer-138-pair.example.defaults" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if ! grep -qE 'xdc-relayer\.dotenv\.example.*clone-local' "$PROJECT_ROOT/config/xdc-zero/README.md"; then
|
||||
echo "ERROR: config/xdc-zero/README.md should describe clone-local use of xdc-relayer.dotenv.example" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "[OK] XDC Zero relayer env/default examples are aligned"
|
||||
Reference in New Issue
Block a user