Skip to content

Commit

Permalink
bug fix: #346
Browse files Browse the repository at this point in the history
  • Loading branch information
usmannasir committed May 22, 2020
1 parent d71b304 commit ca1d507
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 19 deletions.
16 changes: 9 additions & 7 deletions manageServices/serviceManager.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ def managePDNS(self):
ipsString = ipsString.rstrip(' ')
ipStringNoSubnet = ipStringNoSubnet.rstrip(' ')



tempPath = "/home/cyberpanel/" + str(randint(1000, 9999))
writeToFile = open(tempPath, 'w')

for items in data:
if items.find('allow-axfr-ips') > -1:
Expand All @@ -49,14 +49,14 @@ def managePDNS(self):
if items.find('slave') > -1:
continue

counter = counter + 1
if items.find('master') > -1:
continue

tempPath = "/home/cyberpanel/" + str(randint(1000, 9999))
writeToFile = open(tempPath, 'w')
counter = counter + 1

for items in data:
writeToFile.writelines(items + '\n')


writeToFile.writelines('allow-axfr-ips=' + ipsString + '\n')
writeToFile.writelines('also-notify=' + ipStringNoSubnet + '\n')
writeToFile.writelines('daemon=no\n')
Expand All @@ -82,6 +82,9 @@ def managePDNS(self):
if items.find('slave') > -1:
continue

if items.find('slave=yes') > 1:
return 0

counter = counter + 1

tempPath = "/home/cyberpanel/" + str(randint(1000, 9999))
Expand Down Expand Up @@ -112,6 +115,5 @@ def managePDNS(self):
Supermasters(ip=self.extraArgs['masterServerIP'], nameserver=self.extraArgs['slaveServerNS'], account='').save()

command = 'sudo mv ' + tempPath + ' ' + path
#subprocess.call(shlex.split(command))
ProcessUtilities.executioner(command)

18 changes: 9 additions & 9 deletions manageServices/templates/manageServices/managePowerDNS.html
Original file line number Diff line number Diff line change
Expand Up @@ -51,57 +51,57 @@ <h3 class="content-box-header">

<div ng-hide="masterServerHD" class="form-group">
<label class="col-sm-3 control-label">{% trans "Slave Server" %}</label>
<div class="col-sm-6">
<div ng-init="slaveServerNS='{{ slaveServerNS }}'" class="col-sm-6">
<input type="text" class="form-control" ng-model="slaveServerNS" required>
</div>
</div>

<div ng-hide="masterServerHD" class="form-group">
<label class="col-sm-3 control-label">{% trans "Master Server IP" %}</label>
<div class="col-sm-6">
<div ng-init="masterServerIP='{{ masterServerIP }}'" class="col-sm-6">
<input type="text" class="form-control" ng-model="masterServerIP" required>
</div>
</div>

<div ng-hide="slaveIPs" class="form-group">
<label class="col-sm-3 control-label">{% trans "Slave Server 1" %}</label>
<div class="col-sm-6">
<div ng-init="slaveServer='{{ slaveServer }}'" class="col-sm-6">
<input type="text" class="form-control" ng-model="slaveServer" required>
</div>
</div>

<div ng-hide="slaveIPs" class="form-group">
<label class="col-sm-3 control-label">{% trans "Slave Server IP" %}</label>
<div class="col-sm-6">
<div ng-init="slaveServerIP='{{ slaveServerIP }}'" class="col-sm-6">
<input type="text" class="form-control" ng-model="slaveServerIP" required>
</div>
</div>

<div ng-hide="slaveIPs" class="form-group">
<label class="col-sm-3 control-label">{% trans "Slave Server 2 (Optional)" %}</label>
<div class="col-sm-6">
<div ng-init="slaveServer2='{{ slaveServer2 }}'" class="col-sm-6">
<input type="text" class="form-control" ng-model="slaveServer2" required>
</div>
</div>

<div ng-hide="slaveIPs" class="form-group">
<label class="col-sm-3 control-label">{% trans "Slave Server IP 2 (Optional)" %}</label>
<div class="col-sm-6">
<div ng-init="slaveServerIP2='{{ slaveServerIP2 }}'" class="col-sm-6">
<input type="text" class="form-control" ng-model="slaveServerIP2" required>
</div>
</div>

<div ng-hide="slaveIPs" class="form-group">
<label class="col-sm-3 control-label">{% trans "Slave Server 3 (Optional)" %}</label>
<div class="col-sm-6">
<div ng-init="slaveServer3='{{ slaveServer3 }}'" class="col-sm-6">
<input type="text" class="form-control" ng-model="slaveServer3" required>
</div>
</div>

<div ng-hide="slaveIPs" class="form-group">
<label class="col-sm-3 control-label">{% trans "Slave Server IP 3 (Optional)" %}</label>
<div class="col-sm-6">
<input type="text" class="form-control" ng-model="slaveIPData" required>
<div ng-init="slaveServerIP3='{{ slaveServerIP3 }}'" class="col-sm-6">
<input type="text" class="form-control" ng-model="slaveServerIP3" required>
</div>
</div>

Expand Down
27 changes: 24 additions & 3 deletions manageServices/views.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# -*- coding: utf-8 -*-


from django.shortcuts import render
from django.shortcuts import HttpResponse, redirect
import plogical.CyberCPLogFileWriter as logging
Expand All @@ -14,19 +13,41 @@
from plogical.processUtilities import ProcessUtilities
# Create your views here.


def managePowerDNS(request):
try:
userID = request.session['userID']
currentACL = ACLManager.loadedACL(userID)


if currentACL['admin'] == 1:
pass
else:
return ACLManager.loadError()
try:
return render(request, 'manageServices/managePowerDNS.html', {"status": 1})

data = {}
data['status'] = 1

pdnsStatus = PDNSStatus.objects.get(pk=1)

if pdnsStatus.type == 'MASTER':
counter = 1

for items in SlaveServers.objects.all():

if counter == 1:
data['slaveServer'] = items.slaveServer
data['slaveServerIP'] = items.slaveServerIP
else:
data['slaveServer%s' % (str(counter))] = items.slaveServer
data['slaveServerIP%s' % (str(counter))] = items.slaveServerIP

counter = counter + 1
else:
data['slaveServerNS'] = pdnsStatus.masterServer
data['masterServerIP'] = pdnsStatus.masterIP

return render(request, 'manageServices/managePowerDNS.html', data)
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg))
return HttpResponse("See CyberCP main log file.")
Expand Down

0 comments on commit ca1d507

Please sign in to comment.