Last active
April 11, 2022 19:47
-
-
Save kenmickles/6746968 to your computer and use it in GitHub Desktop.
Shell script to dynamically update a Digital Ocean DNS record
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
#!/bin/bash | |
TOKEN="Get token from https://cloud.digitalocean.com/settings/applications" | |
DOMAIN=example.com | |
RECORD_ID=12345 | |
IP=`curl -s checkip.dyndns.org | grep -Eo '[0-9\.]+'` | |
# to get record id: | |
# curl -X GET -H 'Content-Type: application/json' -H "Authorization: Bearer $TOKEN" "https://api.digitalocean.com/v2/domains/$DOMAIN/records" | |
# update domain record | |
curl -s -X PUT -H 'Content-Type: application/json' -H "Authorization: Bearer $TOKEN" -d "{\"data\":\"$IP\"}" "https://api.digitalocean.com/v2/domains/$DOMAIN/records/$RECORD_ID" > /dev/null |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment