Skip to content

Instantly share code, notes, and snippets.

@marcaurele
Created February 14, 2018 07:25
Show Gist options
  • Save marcaurele/4898f5c08ec9e7dc57ef2d3ded63b172 to your computer and use it in GitHub Desktop.
Save marcaurele/4898f5c08ec9e7dc57ef2d3ded63b172 to your computer and use it in GitHub Desktop.
Certbot/Let's encrypt hook for DNS authentication using Gandi Live DNS service
#!/bin/bash
# To be used in certbot command as --manual-cleanup-hook parameter
#APIKEY=""
if [ -f /tmp/CERTBOT_$CERTBOT_DOMAIN/ZONE_RECORD_HREF ]; then
ZONE_RECORD_HREF=$(cat /tmp/CERTBOT_$CERTBOT_DOMAIN/ZONE_RECORD_HREF)
rm -f /tmp/CERTBOT_$CERTBOT_DOMAIN/ZONE_RECORD_HREF
fi
if [ -f /tmp/CERTBOT_$CERTBOT_DOMAIN/RECORD_NAME ]; then
RECORD_NAME=$(cat /tmp/CERTBOT_$CERTBOT_DOMAIN/RECORD_NAME)
rm -f /tmp/CERTBOT_$CERTBOT_DOMAIN/RECORD_NAME
fi
# Remove the challenge TXT record from the zone
if [ -n "${ZONE_RECORD_HREF}" ]; then
if [ -n "${RECORD_NAME}" ]; then
curl --silent -X DELETE "$ZONE_RECORD_HREF/$RECORD_NAME/TXT" \
-H "X-Api-Key: $APIKEY" \
-H "Content-Type: application/json"
fi
fi
@marcaurele
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment