Compare commits

..

No commits in common. "238bd37d40ee001b42abcf662f469eedd5aae687" and "96f5766349620fc07ea8f7133cd531c6d8b6a8e2" have entirely different histories.

2 changed files with 7 additions and 14 deletions

View File

@ -4,10 +4,6 @@ import shutil, os, re, _thread, socket, sys, re, yaml, logging as log
import dnslib as dns
DATA_PATH="/data"
APP_PATH="/app"
HOSTS_PATH="/app/hosts"
config = None
def main(args):
setupLogging(True)
@ -15,26 +11,23 @@ def main(args):
setupEnvironment()
global config
config = readConfig(os.path.join(DATA_PATH, "config.yml"))
config = readConfig("/data/config.yml")
s = setupSocket(config['socket']['address'], config['socket']['port'])
startListen(s)
def setupEnvironment():
if not os.path.exists(DATA_PATH):
os.mkdir(DATA_PATH)
if not os.path.exists('/data'):
os.mkdir("/data")
(all, some) = copyAllFiles(f"{APP_PATH}/data/", DATA_PATH)
(all, some) = copyAllFiles("data/", "/data")
if all:
log.warning("Configuration-files were created!")
log.warning(" Make sure to change them according to your setup")
elif some:
log.warning("Some configuration-files were recreated, because they were missing")
if not os.path.exists(HOSTS_PATH):
os.mkdir(HOSTS_PATH)
def copyAllFiles(src, dst, overwrite=False):
all=True
some=False
@ -183,7 +176,7 @@ def adaptZoneName(zone):
def dumpZoneData(zone, dumpFile):
log.debug(f"{zone} |\tDumping to '{dumpFile}'..")
return os.system(f"dnscontrol get-zones --creds {DATA_PATH}/creds.json --format=js --out={HOSTS_PATH}/{dumpFile} powerdns POWERDNS {zone}")
return os.system(f"dnscontrol get-zones --creds /data/creds.json --format=js --out={dumpFile} powerdns POWERDNS {zone}")
def deleteFile(file):
log.debug(f"Deleting file '{file}'")
@ -204,7 +197,7 @@ def adaptFileForRequire(zone, dumpFile):
def dnscontrolPush(zone):
log.debug(f'{zone} |\tPushing..')
return os.system(f"dnscontrol push --config {DATA_PATH}/dnsconfig.js --creds {DATA_PATH}/creds.json --domains {zone}")
return os.system(f"dnscontrol push --config /data/dnsconfig.js --creds /data/creds.json --domains {zone}")
if __name__ == "__main__":
sys.exit(main(sys.argv))

View File

@ -20,4 +20,4 @@ D('example.com', REG_NONE, DnsProvider(cloudflare));
// Include
// (Do not touch unless you know what you are doing!)
require_glob("/app/hosts/");
require_glob(""); // TODO: determine correct location to include