Created
February 9, 2017 04:23
-
-
Save noeljackson/d7dedfdb5514903c57f66e2ab4806819 to your computer and use it in GitHub Desktop.
Pure Cloudflare cache for a domain via the shell
This file contains 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
#!/bin/bash | |
CFKEY=apikeygoeshere | |
[email protected] | |
CFDOMAIN=yourdomain.com | |
CFZONE=$(curl -X GET "https://api.cloudflare.com/client/v4/zones?name=$CFDOMAIN&status=active&page=1&per_page=20&order=status&direction=desc&match=all" \ | |
-H "X-Auth-Email: $CFUSER" \ | |
-H "X-Auth-Key: $CFKEY" \ | |
-H "Content-Type: application/json" \ | |
| grep -Eo '"result\"\:\[\{"id":"([^"]+)"' \ | |
| awk '{gsub("\"","");print $1}' \ | |
| awk '{gsub("result:\\[\\{id:","");print $1}') | |
curl -X DELETE "https://api.cloudflare.com/client/v4/zones/$CFZONE/purge_cache" \ | |
-H "X-Auth-Email: $CFUSER" \ | |
-H "X-Auth-Key: $CFKEY" \ | |
-H "Content-Type: application/json" \ | |
--data '{"purge_everything":true}' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment