Created
June 18, 2019 11:47
-
-
Save gabriel-samfira/11d98e121222bc26a23283c79553ce8d to your computer and use it in GitHub Desktop.
quick and dirty dynamic DNS updater for digital ocean
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 python3 | |
import requests | |
import digitalocean | |
import sys | |
TOKEN="your secret goes gere" | |
DOMAIN="example.com" | |
RECORD="my-record" | |
myIP = requests.get("https://simplestreams.samfira.com/ip").text.rstrip("\n") | |
dom = digitalocean.Domain(token=TOKEN) | |
dom.name = DOMAIN | |
records = dom.get_records() | |
for rec in records: | |
if rec.name == RECORD and rec.type == "A": | |
if rec.data == myIP: | |
sys.exit(0) | |
rec.data = myIP | |
rec.save() | |
sys.exit(0) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment