-
-
Save jcarley/1cd960b7d1dd6764f751 to your computer and use it in GitHub Desktop.
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
#!/usr/bin/env bash | |
set -x | |
# Domain you wish to update | |
DOMAIN="example.com" | |
# Get the v4/v6 addresses from icanhazip.com [pretty reliable!] | |
IPV4_ADDR=`wget -4 -q -O - icanhazip.com` | |
IPV6_ADDR=`wget -6 -q -O - icanhazip.com` | |
# Get your v2 API token from here: https://cloud.digitalocean.com/settings/tokens/new | |
TOKEN="..." | |
# Add the record IDs you wish to update here | |
V4_RECORDS=(123 ...) | |
V6_RECORDS=(678 ...) | |
for RECORD in $V4_RECORDS | |
do | |
wget \ | |
-O - \ | |
--quiet \ | |
--no-check-certificate \ | |
--method="PUT" \ | |
--header="Content-Type: application/json" \ | |
--header="Authorization: Bearer $TOKEN" \ | |
--body-data="{\"data\":\"$IPV4_ADDR\"}" "https://api.digitalocean.com/v2/domains/$DOMAIN/records/$RECORD" | |
done | |
for RECORD in $V6_RECORDS | |
do | |
wget \ | |
-O - \ | |
--quiet \ | |
--no-check-certificate \ | |
--method="PUT" \ | |
--header="Content-Type: application/json" \ | |
--header="Authorization: Bearer $TOKEN" \ | |
--body-data="{\"data\":\"$IPV6_ADDR\"}" "https://api.digitalocean.com/v2/domains/$DOMAIN/records/$RECORD" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment