added script that updates my dns settings
This commit is contained in:
parent
b310e2ca32
commit
1f2e9ef043
|
@ -0,0 +1,56 @@
|
||||||
|
#!/bin/python3
|
||||||
|
# @Author skiqqy
|
||||||
|
import requests
|
||||||
|
import os
|
||||||
|
import json
|
||||||
|
|
||||||
|
f = open("secret/godaddy_key", "r")
|
||||||
|
|
||||||
|
secret = ""
|
||||||
|
key = ""
|
||||||
|
for line in f:
|
||||||
|
line = line.replace("\n","")
|
||||||
|
parse = line.split(":")
|
||||||
|
if parse[0] == "secret":
|
||||||
|
secret = parse[1]
|
||||||
|
elif parse[0] == "key":
|
||||||
|
key = parse[1]
|
||||||
|
|
||||||
|
if secret == "" or key == "":
|
||||||
|
print("No key or secret set")
|
||||||
|
exit(1)
|
||||||
|
|
||||||
|
url="https://api.godaddy.com/"
|
||||||
|
|
||||||
|
header={
|
||||||
|
"content-type":"application/json",
|
||||||
|
"Authorization":"sso-key " + key + ":" + secret
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# Domains and subdomains
|
||||||
|
domains = {
|
||||||
|
"skiqqy.xyz":[
|
||||||
|
{"name": "git", "type": "A"},
|
||||||
|
{"name": "irc", "type": "A"},
|
||||||
|
{"name": "proj", "type": "A"},
|
||||||
|
{"name": "pay", "type": "A"},
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
# Get current public ip
|
||||||
|
ip = os.popen('curl ifconfig.me').read()
|
||||||
|
|
||||||
|
# Construct the post data
|
||||||
|
for domain in domains:
|
||||||
|
post = [{}]
|
||||||
|
for sub in domains[domain]:
|
||||||
|
post[0]["type"] = sub["type"]
|
||||||
|
post[0]["name"] = sub["name"]
|
||||||
|
post[0]["data"] = ip
|
||||||
|
post[0]["ttl"] = 3600
|
||||||
|
|
||||||
|
# Do the put
|
||||||
|
req_url = url + "v1/domains/" + domain + "/records/" + sub["type"] + "/" + sub["name"]
|
||||||
|
r = requests.put(req_url, headers=header, json=post)
|
||||||
|
print(r)
|
Loading…
Reference in New Issue