This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| export CF_GLOBAL_API_KEY="YOUR_GLOBAL_API" | |
| export CF_AUTH_EMAIL="user@domain.com" | |
| export FP_DOMAIN="domain.com" | |
| # Generate a Cloudflare Account API token for FlyingPress using FP_DOMAIN (requires curl and jq) | |
| api() { curl -sS -H "X-Auth-Email: $CF_AUTH_EMAIL" -H "X-Auth-Key: $CF_GLOBAL_API_KEY" -H "Content-Type: application/json" "$@" } | |
| read ZONE ACCOUNT <<< "$(api "https://api.cloudflare.com/client/v4/zones?name=$FP_DOMAIN" | jq -r '.result[0] // {} | "\(.id) \(.account.id)"')" | |
| if [ "$ZONE" = null ]; then | |
| echo "error: zone $FP_DOMAIN not found (or bad credentials)" | |
| else |