Files
proxmox/scripts/cloudflare/purge-info-defi-oracle-cache.sh
defiQUG dbd517b279 Sync workspace: config, docs, scripts, CI, operator rules, and submodule pointers.
- Update dbis_core, cross-chain-pmm-lps, explorer-monorepo, metamask-integration, pr-workspace/chains
- Omit embedded publish git dirs and empty placeholders from index

Made-with: Cursor
2026-04-12 06:12:20 -07:00

32 lines
1.4 KiB
Bash
Executable File

#!/usr/bin/env bash
# Purge Cloudflare edge cache for static paths on info.defi-oracle.io (robots, sitemap, agent-hints).
# Use when the origin is correct but verify shows HTML fallback for /robots.txt etc.
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJECT_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
cd "$PROJECT_ROOT"
# shellcheck source=/dev/null
source "$PROJECT_ROOT/config/ip-addresses.conf" 2>/dev/null || true
if [[ -f "$PROJECT_ROOT/.env" ]]; then
set +u
# shellcheck source=/dev/null
source "$PROJECT_ROOT/.env" 2>/dev/null || true
set -u
fi
ZONE="${CLOUDFLARE_ZONE_ID_DEFI_ORACLE_IO:?Set CLOUDFLARE_ZONE_ID_DEFI_ORACLE_IO in .env}"
BASE="${INFO_SITE_BASE:-https://info.defi-oracle.io}"
BASE="${BASE%/}"
AUTH=()
if [[ -n "${CLOUDFLARE_API_TOKEN:-}" ]]; then
AUTH=(-H "Authorization: Bearer $CLOUDFLARE_API_TOKEN")
elif [[ -n "${CLOUDFLARE_API_KEY:-}" && -n "${CLOUDFLARE_EMAIL:-}" ]]; then
AUTH=(-H "X-Auth-Email: $CLOUDFLARE_EMAIL" -H "X-Auth-Key: $CLOUDFLARE_API_KEY")
else
echo "Need CLOUDFLARE_API_TOKEN or CLOUDFLARE_EMAIL + CLOUDFLARE_API_KEY" >&2
exit 1
fi
PAYLOAD=$(jq -n --arg b "$BASE" '{files: [$b+"/robots.txt",$b+"/sitemap.xml",$b+"/agent-hints.json",$b+"/llms.txt"]}')
curl -sS -X POST "https://api.cloudflare.com/client/v4/zones/${ZONE}/purge_cache" "${AUTH[@]}" \
-H "Content-Type: application/json" --data "$PAYLOAD" | jq -e '.success == true' >/dev/null
echo "Purged static URLs under $BASE"