Skip to content

Instantly share code, notes, and snippets.

@uzegonemad
Created October 19, 2018 15:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save uzegonemad/6d4db16ce63b9c962f37f888c53934af to your computer and use it in GitHub Desktop.
Save uzegonemad/6d4db16ce63b9c962f37f888c53934af to your computer and use it in GitHub Desktop.
Certbot hook for iwantmyname DNS verification
/usr/local/bin/certbot-auto renew --manual-auth-hook /path/to/certbot_before.sh --renew-hook "service nginx reload"
# Note that it might take 3-4 minutes per challenge
#!/bin/bash
DOMAIN_NS="$(dig +short SOA $CERTBOT_DOMAIN | cut -d' ' -f1)"
curl -s -S -u "your@email.com:yourpassword" "https://iwantmyname.com/basicauth/ddns?hostname=_acme-challenge.$CERTBOT_DOMAIN&type=txt&value=$CERTBOT_VALIDATION"
TXT_RECORDS=""
RESULT_LEN=0
check_txt_record () {
TXT_RECORDS="$(dig +short txt _acme-challenge.$CERTBOT_DOMAIN @$DOMAIN_NS | grep $CERTBOT_VALIDATION)"
RESULT_LEN="${#TXT_RECORDS}"
}
check_txt_record
until [[ "$RESULT_LEN" -gt "0" ]]; do
check_txt_record
sleep 1
done
printf "good\n"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment