This commit is contained in:
Peder Bergebakken Sundt 2022-07-06 23:04:00 +02:00
parent 8c3997cfee
commit 1dd7333798
1 changed files with 5 additions and 5 deletions

10
main.py
View File

@ -19,9 +19,9 @@ def get_pub_ip() -> str:
# https://www.domeneshop.no/admin?view=api # https://www.domeneshop.no/admin?view=api
with open("/var/lib/secrets/domeneshop.toml") as f: with open("/var/lib/secrets/domeneshop.toml") as f:
globals().update(toml.load(f)["secrets"]) c = toml.load(f)
#DOMENESHOP_TOKEN = os.environ["DOMENESHOP_TOKEN"] DOMENESHOP_TOKEN = os.environ.get("DOMENESHOP_TOKEN", c["secrets"]["DOMENESHOP_TOKEN"])
#DOMENESHOP_SECRET = os.environ["DOMENESHOP_SECRET"] DOMENESHOP_SECRET = os.environ.get("DOMENESHOP_SECRET", c["secrets"]["DOMENESHOP_SECRET"])
IP_ADDRESS = get_pub_ip() # TODO: both ipv4 and ipv6 IP_ADDRESS = get_pub_ip() # TODO: both ipv4 and ipv6
DOMAINS = { DOMAINS = {
"pbsds.net": { "pbsds.net": {
@ -39,11 +39,11 @@ for domain in client.get_domains():
if record["host"] in RECORDS \ if record["host"] in RECORDS \
and record["type"] in RECORDS[record["host"]]: and record["type"] in RECORDS[record["host"]]:
print("Found: ", end="") print("Found: ", end="")
rich.pretty.pprint(record) pprint.pprint(record)
if record["data"] != IP_ADDRESS: if record["data"] != IP_ADDRESS:
record["data"] = IP_ADDRESS record["data"] = IP_ADDRESS
print("Push: ", end="") print("Push: ", end="")
rich.pretty.pprint(record) pprint.pprint(record)
client.modify_record(domain_id=domain["id"], record_id=record.pop("id"), record=record) client.modify_record(domain_id=domain["id"], record_id=record.pop("id"), record=record)
else: else:
print("Nothing done") print("Nothing done")