Created
July 25, 2016 13:37
-
-
Save ckdake/6b199473065d48190e45ea216b566952 to your computer and use it in GitHub Desktop.
helping cloudflare and certbot get along.
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
[email protected] | |
CLOUDFLARE_KEY=probablyshoulduseyourapikeyhereinstead |
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
#Monday at 2:30am | |
30 2 * * 1 /opt/letsencrypt/certbot-auto --pre-hook "/root/cloudflare_tools/pause_all_domains.sh" --post-hook "/root/cloudflare_tools/unpause_all_domains.sh" --apache renew |
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 | |
for f in /etc/letsencrypt/renewal/*; do | |
domain=${f#/etc/letsencrypt/renewal/} | |
domain=${domain#www.} | |
domain=${domain%.conf} | |
domain=`echo ${domain} | rev | cut -d. -f 1,2 | rev` | |
echo $domain | |
done |
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 | |
cd /root/cloudflare_tools/ | |
for d in `./domains_to_renew.sh | sort | uniq`; do | |
./pause_domain.sh $d; | |
done; |
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 | |
# apt-get install jq | |
source ~/.cloudflare | |
CLOUDFLARE_ZONE_ID=`curl -X GET "https://api.cloudflare.com/client/v4/zones?name=${1}&status=active&page=1&per_page=20&order=status&direction=desc&match=all" \ | |
-H "X-Auth-Email: ${CLOUDFLARE_USER}" \ | |
-H "X-Auth-Key: ${CLOUDFLARE_KEY}" \ | |
-H "Content-Type: application/json" 2> /dev/null | jq -r ".result[0].id"` | |
RESULT=`curl -X PATCH "https://api.cloudflare.com/client/v4/zones/${CLOUDFLARE_ZONE_ID}" \ | |
-H "X-Auth-Email: ${CLOUDFLARE_USER}" \ | |
-H "X-Auth-Key: ${CLOUDFLARE_KEY}" \ | |
-H "Content-Type: application/json" \ | |
--data '{"paused":true}' 2> /dev/null | jq -r ".success, .errors, .messages"` | |
echo $RESULT |
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 | |
cd /root/cloudflare_tools/ | |
for d in `./domains_to_renew.sh | sort | uniq`; do | |
./unpause_domain.sh $d; | |
done; |
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 | |
# apt-get install jq | |
source ~/.cloudflare | |
CLOUDFLARE_ZONE_ID=`curl -X GET "https://api.cloudflare.com/client/v4/zones?name=${1}&status=active&page=1&per_page=20&order=status&direction=desc&match=all" \ | |
-H "X-Auth-Email: ${CLOUDFLARE_USER}" \ | |
-H "X-Auth-Key: ${CLOUDFLARE_KEY}" \ | |
-H "Content-Type: application/json" 2> /dev/null | jq -r ".result[0].id"` | |
RESULT=`curl -X PATCH "https://api.cloudflare.com/client/v4/zones/${CLOUDFLARE_ZONE_ID}" \ | |
-H "X-Auth-Email: ${CLOUDFLARE_USER}" \ | |
-H "X-Auth-Key: ${CLOUDFLARE_KEY}" \ | |
-H "Content-Type: application/json" \ | |
--data '{"paused":false}' 2> /dev/null | jq -r ".success, .errors, .messages"` | |
echo $RESULT |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment