Skip to content

Instantly share code, notes, and snippets.

@dfar-io
Created January 12, 2022 14:41
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 dfar-io/0ecb34c1a4c4f7410d20a5016b67c64f to your computer and use it in GitHub Desktop.
Save dfar-io/0ecb34c1a4c4f7410d20a5016b67c64f to your computer and use it in GitHub Desktop.
#!/bin/bash
# Adds the appropriate TXT record for creating a Let's Encrypt certificate.
# exit when any command fails
set -e
if [ "$1" == "" ] || [ "$2" == "" ]
then
echo "GODADDY_API_KEY and GODADDY_API_SECRET arguments required."
exit 1
fi
# split domain provided
IFS='.' read -ra domain <<< "$CERTBOT_DOMAIN"
curl --request PATCH \
--url "https://api.godaddy.com/v1/domains/${domain[1]}.${domain[2]}/records" \
--header "Authorization: sso-key $1:$2" \
--header 'Content-Type: application/json' \
--data '[
{
"data": "'$CERTBOT_VALIDATION'",
"name": "_acme-challenge.'${domain[0]}'",
"port": 65535,
"priority": 0,
"protocol": "string",
"service": "string",
"ttl": 600,
"type": "TXT",
"weight": 0
}
]'
sleep 25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment