Compare commits
No commits in common. "238bd37d40ee001b42abcf662f469eedd5aae687" and "96f5766349620fc07ea8f7133cd531c6d8b6a8e2" have entirely different histories.
238bd37d40
...
96f5766349
19
daemon.py
19
daemon.py
@ -4,10 +4,6 @@ import shutil, os, re, _thread, socket, sys, re, yaml, logging as log
|
|||||||
|
|
||||||
import dnslib as dns
|
import dnslib as dns
|
||||||
|
|
||||||
DATA_PATH="/data"
|
|
||||||
APP_PATH="/app"
|
|
||||||
HOSTS_PATH="/app/hosts"
|
|
||||||
|
|
||||||
config = None
|
config = None
|
||||||
def main(args):
|
def main(args):
|
||||||
setupLogging(True)
|
setupLogging(True)
|
||||||
@ -15,26 +11,23 @@ def main(args):
|
|||||||
setupEnvironment()
|
setupEnvironment()
|
||||||
|
|
||||||
global config
|
global config
|
||||||
config = readConfig(os.path.join(DATA_PATH, "config.yml"))
|
config = readConfig("/data/config.yml")
|
||||||
|
|
||||||
s = setupSocket(config['socket']['address'], config['socket']['port'])
|
s = setupSocket(config['socket']['address'], config['socket']['port'])
|
||||||
|
|
||||||
startListen(s)
|
startListen(s)
|
||||||
|
|
||||||
def setupEnvironment():
|
def setupEnvironment():
|
||||||
if not os.path.exists(DATA_PATH):
|
if not os.path.exists('/data'):
|
||||||
os.mkdir(DATA_PATH)
|
os.mkdir("/data")
|
||||||
|
|
||||||
(all, some) = copyAllFiles(f"{APP_PATH}/data/", DATA_PATH)
|
(all, some) = copyAllFiles("data/", "/data")
|
||||||
if all:
|
if all:
|
||||||
log.warning("Configuration-files were created!")
|
log.warning("Configuration-files were created!")
|
||||||
log.warning(" Make sure to change them according to your setup")
|
log.warning(" Make sure to change them according to your setup")
|
||||||
elif some:
|
elif some:
|
||||||
log.warning("Some configuration-files were recreated, because they were missing")
|
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):
|
def copyAllFiles(src, dst, overwrite=False):
|
||||||
all=True
|
all=True
|
||||||
some=False
|
some=False
|
||||||
@ -183,7 +176,7 @@ def adaptZoneName(zone):
|
|||||||
|
|
||||||
def dumpZoneData(zone, dumpFile):
|
def dumpZoneData(zone, dumpFile):
|
||||||
log.debug(f"{zone} |\tDumping to '{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):
|
def deleteFile(file):
|
||||||
log.debug(f"Deleting file '{file}'")
|
log.debug(f"Deleting file '{file}'")
|
||||||
@ -204,7 +197,7 @@ def adaptFileForRequire(zone, dumpFile):
|
|||||||
|
|
||||||
def dnscontrolPush(zone):
|
def dnscontrolPush(zone):
|
||||||
log.debug(f'{zone} |\tPushing..')
|
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__":
|
if __name__ == "__main__":
|
||||||
sys.exit(main(sys.argv))
|
sys.exit(main(sys.argv))
|
||||||
|
@ -20,4 +20,4 @@ D('example.com', REG_NONE, DnsProvider(cloudflare));
|
|||||||
|
|
||||||
// Include
|
// Include
|
||||||
// (Do not touch unless you know what you are doing!)
|
// (Do not touch unless you know what you are doing!)
|
||||||
require_glob("/app/hosts/");
|
require_glob(""); // TODO: determine correct location to include
|
||||||
|
Loading…
x
Reference in New Issue
Block a user