Added path-vars

master
Ruakij 3 years ago
parent 37f946305d
commit 5674bf339c

@ -163,7 +163,7 @@ def updateNsData(zone):
hasToDelete = True hasToDelete = True
adaptFileForRequire(zone, dumpFile) adaptFileForRequire(zone, HOSTS_PATH, dumpFile)
if dnscontrolPush(zone) != 0: if dnscontrolPush(zone) != 0:
raise Exception("Pushing data failed!") raise Exception("Pushing data failed!")
@ -173,7 +173,7 @@ def updateNsData(zone):
log.warning(f'{adaptedZone} |\tUpdating NS-Data failed!') log.warning(f'{adaptedZone} |\tUpdating NS-Data failed!')
if(hasToDelete): if(hasToDelete):
deleteFile(dumpFile) deleteFile(os.path.join(HOSTS_PATH, dumpFile))
def adaptZoneName(zone): def adaptZoneName(zone):
if config['zone']['public-suffix'] != "" and zone.endswith(config['zone']['public-suffix']): if config['zone']['public-suffix'] != "" and zone.endswith(config['zone']['public-suffix']):
@ -190,17 +190,19 @@ def deleteFile(file):
os.remove(file) os.remove(file)
ignoreLinesRexp = r"^\s*(var|D\(|DnsProvider\(|DefaultTTL\()" ignoreLinesRexp = r"^\s*(var|D\(|DnsProvider\(|DefaultTTL\()"
def adaptFileForRequire(zone, dumpFile): def adaptFileForRequire(zone, path, dumpFile):
log.debug(f"{zone} |\tRewriting file '{dumpFile}'..") log.debug(f"{zone} |\tRewriting file '{dumpFile}'..")
with open(f"{HOSTS_PATH}/{dumpFile}", 'r') as fin: dumpFilePath = os.path.join(path, dumpFile)
with open(f"{HOSTS_PATH}/{dumpFile}.tmp", 'w+') as fout:
with open(dumpFilePath, 'r') as fin:
with open(f"{dumpFilePath}.tmp", 'w+') as fout:
fout.write(f'D_EXTEND("{zone}",\n') fout.write(f'D_EXTEND("{zone}",\n')
for line in fin: for line in fin:
if not re.match(ignoreLinesRexp, line): if not re.match(ignoreLinesRexp, line):
fout.write(line) fout.write(line)
os.replace(f"{HOSTS_PATH}/{dumpFile}.tmp", dumpFile) os.replace(f"{dumpFilePath}.tmp", dumpFilePath)
def dnscontrolPush(zone): def dnscontrolPush(zone):
log.debug(f'{zone} |\tPushing..') log.debug(f'{zone} |\tPushing..')

Loading…
Cancel
Save