forked from srvrco/getssl
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ec27405
commit a10e364
Showing
2 changed files
with
56 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#!/bin/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" -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 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#!/bin/bash | ||
# Vultr Delete DNS Record | ||
# This script requires jq to be installed on the machine running it | ||
|
||
api_url="https://api.vultr.com/v2" | ||
api_key=${VULTR_API_KEY:-''} | ||
|
||
|
||
domain="$1" | ||
|
||
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 delete { | ||
recordID=$(curl "${api_url}/domains/$1/records" -X GET -H "Authorization: Bearer ${VULTR_API_KEY}" | jq -r ".records[] | select(.name==\"$2\").id") | ||
|
||
curl "${api_url}/domains/$1/records/$recordID" -X DELETE -H "Authorization: Bearer ${VULTR_API_KEY}" | ||
} | ||
|
||
|
||
delete $root $subdomain |