diff --git a/manageServices/serviceManager.py b/manageServices/serviceManager.py index 877c30472..27917605a 100755 --- a/manageServices/serviceManager.py +++ b/manageServices/serviceManager.py @@ -6,6 +6,8 @@ from manageServices.models import SlaveServers class ServiceManager: + slaveConfPath = '/home/cyberpanel/slaveConf' + def __init__(self, extraArgs): self.extraArgs = extraArgs @@ -64,50 +66,55 @@ class ServiceManager: writeToFile.writelines('master=yes\n') writeToFile.close() else: - counter = 0 + import os - for items in data: - if items.find('allow-axfr-ips') > -1: - continue + if not os.path.exists(ServiceManager.slaveConfPath): - if items.find('also-notify') > -1: - continue + writeToFile = open(ServiceManager.slaveConfPath, 'w') + writeToFile.write('configured') + writeToFile.close() - if items.find('daemon=') > -1: - continue + counter = 0 - if items.find('disable-axfr') > -1: - continue + for items in data: + if items.find('allow-axfr-ips') > -1: + continue - if items.find('slave') > -1: - continue + if items.find('also-notify') > -1: + continue - if items.find('slave=yes') > 1: - return 0 + if items.find('daemon=') > -1: + continue - counter = counter + 1 + if items.find('disable-axfr') > -1: + continue - tempPath = "/home/cyberpanel/" + str(randint(1000, 9999)) - writeToFile = open(tempPath, 'w') + if items.find('slave') > -1: + continue - for items in data: - writeToFile.writelines(items + '\n') + counter = counter + 1 - slaveData = """slave=yes -daemon=yes -disable-axfr=yes -guardian=yes -local-address=0.0.0.0 -local-port=53 -master=no -slave-cycle-interval=60 -setgid=pdns -setuid=pdns -superslave=yes -""" + tempPath = "/home/cyberpanel/" + str(randint(1000, 9999)) + writeToFile = open(tempPath, 'w') - writeToFile.writelines(slaveData) - writeToFile.close() + for items in data: + writeToFile.writelines(items + '\n') + + slaveData = """slave=yes + daemon=yes + disable-axfr=yes + guardian=yes + local-address=0.0.0.0 + local-port=53 + master=no + slave-cycle-interval=60 + setgid=pdns + setuid=pdns + superslave=yes + """ + + writeToFile.writelines(slaveData) + writeToFile.close() for items in Supermasters.objects.all(): items.delete()