Forked from kenmickles/update-digitial-ocean-dns.sh
Created
September 13, 2018 14:37
-
-
Save banasiak/b1363d5aabdbf279db5c8f7c1bd5e1fa 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