You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

30 lines
658 B

#! /usr/bin/env bash
# Vultr Add DNS Record
api_url="https://api.vultr.com/v2"
api_key=${VULTR_API_KEY:-''}
domain="$1"
challenge="$2"
root=$(echo "$domain" | awk -F\. '{print $(NF-1) FS $NF}')
subdomain="_acme-challenge.${domain%.$root}"
if [[ -z "$VULTR_API_KEY" ]]; then
echo "VULTR_API_KEY variable not set"
exit 1
fi
function create {
curl "${api_url}/domains/$1/records" -s -o /dev/null -X POST -H "Authorization: Bearer ${VULTR_API_KEY}" -H "Content-Type: application/json" \
--data "{
\"name\" : \"$2\",
\"type\" : \"TXT\",
\"data\" : \"${challenge}\",
\"ttl\" : 300,
\"priority\" : 0
}"
}
create $root $subdomain