mirror of
https://github.com/usmannasir/cyberpanel.git
synced 2025-11-08 06:16:08 +01:00
pdns replication
This commit is contained in:
@@ -182,6 +182,10 @@ app.controller('adminController', function($scope,$http,$timeout) {
|
|||||||
|
|
||||||
// DNS Management
|
// DNS Management
|
||||||
|
|
||||||
|
if(!Boolean(response.data.dnsAsWhole)){
|
||||||
|
$('.dnsAsWhole').hide();
|
||||||
|
}
|
||||||
|
|
||||||
if(!Boolean(response.data.createNameServer)){
|
if(!Boolean(response.data.createNameServer)){
|
||||||
$('.createNameServer').hide();
|
$('.createNameServer').hide();
|
||||||
}
|
}
|
||||||
@@ -200,6 +204,10 @@ app.controller('adminController', function($scope,$http,$timeout) {
|
|||||||
|
|
||||||
// Email Management
|
// Email Management
|
||||||
|
|
||||||
|
if(!Boolean(response.data.emailAsWhole)){
|
||||||
|
$('.emailAsWhole').hide();
|
||||||
|
}
|
||||||
|
|
||||||
if(!Boolean(response.data.createEmail)){
|
if(!Boolean(response.data.createEmail)){
|
||||||
$('.createEmail').hide();
|
$('.createEmail').hide();
|
||||||
}
|
}
|
||||||
@@ -223,6 +231,10 @@ app.controller('adminController', function($scope,$http,$timeout) {
|
|||||||
|
|
||||||
// FTP Management
|
// FTP Management
|
||||||
|
|
||||||
|
if(!Boolean(response.data.ftpAsWhole)){
|
||||||
|
$('.ftpAsWhole').hide();
|
||||||
|
}
|
||||||
|
|
||||||
if(!Boolean(response.data.createFTPAccount)){
|
if(!Boolean(response.data.createFTPAccount)){
|
||||||
$('.createFTPAccount').hide();
|
$('.createFTPAccount').hide();
|
||||||
}
|
}
|
||||||
@@ -273,6 +285,19 @@ app.controller('adminController', function($scope,$http,$timeout) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}else{
|
||||||
|
|
||||||
|
if(!Boolean(response.data.emailAsWhole)){
|
||||||
|
$('.emailAsWhole').hide();
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!Boolean(response.data.ftpAsWhole)){
|
||||||
|
$('.ftpAsWhole').hide();
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!Boolean(response.data.dnsAsWhole)){
|
||||||
|
$('.dnsAsWhole').hide();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -475,7 +475,7 @@
|
|||||||
</div><!-- .sidebar-submenu -->
|
</div><!-- .sidebar-submenu -->
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
<li>
|
<li class="dnsAsWhole">
|
||||||
<a title="{% trans 'DNS' %}">
|
<a title="{% trans 'DNS' %}">
|
||||||
<i class="glyph-icon icon-sitemap"></i>
|
<i class="glyph-icon icon-sitemap"></i>
|
||||||
<span>{% trans "DNS" %}</span>
|
<span>{% trans "DNS" %}</span>
|
||||||
@@ -500,7 +500,7 @@
|
|||||||
</div><!-- .sidebar-submenu -->
|
</div><!-- .sidebar-submenu -->
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
<li>
|
<li class="emailAsWhole">
|
||||||
<a href="{% url 'loadEmailHome' %}" title="{% trans 'Email' %}">
|
<a href="{% url 'loadEmailHome' %}" title="{% trans 'Email' %}">
|
||||||
<i class="glyph-icon icon-paper-plane"></i>
|
<i class="glyph-icon icon-paper-plane"></i>
|
||||||
<span>{% trans "Email" %}</span>
|
<span>{% trans "Email" %}</span>
|
||||||
@@ -531,7 +531,7 @@
|
|||||||
</div><!-- .sidebar-submenu -->
|
</div><!-- .sidebar-submenu -->
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
<li>
|
<li class="ftpAsWhole">
|
||||||
<a href="{% url 'packagesHome' %}" title="{% trans 'FTP' %}">
|
<a href="{% url 'packagesHome' %}" title="{% trans 'FTP' %}">
|
||||||
<i class="glyph-icon icon-cloud-upload"></i>
|
<i class="glyph-icon icon-cloud-upload"></i>
|
||||||
<span>{% trans "FTP" %}</span>
|
<span>{% trans "FTP" %}</span>
|
||||||
@@ -761,7 +761,7 @@
|
|||||||
</div><!-- .sidebar-submenu -->
|
</div><!-- .sidebar-submenu -->
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
<li class="serverACL">
|
<li class="emailAsWhole" class="serverACL">
|
||||||
<a href="#" title="{% trans 'Mail Settings' %}">
|
<a href="#" title="{% trans 'Mail Settings' %}">
|
||||||
<i class="glyph-icon icon-envelope"></i>
|
<i class="glyph-icon icon-envelope"></i>
|
||||||
<span>{% trans "Mail Settings" %}</span>
|
<span>{% trans "Mail Settings" %}</span>
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ import shlex
|
|||||||
import os
|
import os
|
||||||
import plogical.CyberCPLogFileWriter as logging
|
import plogical.CyberCPLogFileWriter as logging
|
||||||
from plogical.acl import ACLManager
|
from plogical.acl import ACLManager
|
||||||
|
from manageServices.models import PDNSStatus
|
||||||
# Create your views here.
|
# Create your views here.
|
||||||
|
|
||||||
|
|
||||||
@@ -41,6 +42,26 @@ def getAdminStatus(request):
|
|||||||
val = request.session['userID']
|
val = request.session['userID']
|
||||||
currentACL = ACLManager.loadedACL(val)
|
currentACL = ACLManager.loadedACL(val)
|
||||||
|
|
||||||
|
if os.path.exists('/home/cyberpanel/postfix'):
|
||||||
|
currentACL['emailAsWhole'] = 1
|
||||||
|
else:
|
||||||
|
currentACL['emailAsWhole'] = 0
|
||||||
|
|
||||||
|
if os.path.exists('/home/cyberpanel/pureftpd'):
|
||||||
|
currentACL['ftpAsWhole'] = 1
|
||||||
|
else:
|
||||||
|
currentACL['ftpAsWhole'] = 0
|
||||||
|
|
||||||
|
try:
|
||||||
|
pdns = PDNSStatus.objects.get(pk=1)
|
||||||
|
currentACL['dnsAsWhole'] = pdns.serverStatus
|
||||||
|
except:
|
||||||
|
if os.path.exists('/etc/pdns'):
|
||||||
|
PDNSStatus(serverStatus=1).save()
|
||||||
|
currentACL['dnsAsWhole'] = 1
|
||||||
|
else:
|
||||||
|
currentACL['dnsAsWhole'] = 0
|
||||||
|
|
||||||
json_data = json.dumps(currentACL)
|
json_data = json.dumps(currentACL)
|
||||||
return HttpResponse(json_data)
|
return HttpResponse(json_data)
|
||||||
except KeyError:
|
except KeyError:
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ from loginSystem.models import Administrator
|
|||||||
|
|
||||||
|
|
||||||
class Domains(models.Model):
|
class Domains(models.Model):
|
||||||
admin = models.ForeignKey(Administrator,on_delete=models.CASCADE)
|
admin = models.ForeignKey(Administrator,on_delete=models.CASCADE, default=1)
|
||||||
name = models.CharField(unique=True, max_length=255)
|
name = models.CharField(unique=True, max_length=255)
|
||||||
master = models.CharField(max_length=128, blank=True, null=True)
|
master = models.CharField(max_length=128, blank=True, null=True)
|
||||||
last_check = models.IntegerField(blank=True, null=True)
|
last_check = models.IntegerField(blank=True, null=True)
|
||||||
|
|||||||
@@ -3611,14 +3611,21 @@ def main():
|
|||||||
import installCyberPanel
|
import installCyberPanel
|
||||||
|
|
||||||
if ent == 0:
|
if ent == 0:
|
||||||
installCyberPanel.Main(cwd, mysql, distro, ent, None, port)
|
installCyberPanel.Main(cwd, mysql, distro, ent, None, port, args.ftp, args.powerdns)
|
||||||
else:
|
else:
|
||||||
installCyberPanel.Main(cwd, mysql, distro, ent, serial, port)
|
installCyberPanel.Main(cwd, mysql, distro, ent, serial, port, args.ftp, args.powerdns)
|
||||||
|
|
||||||
|
|
||||||
checks.setupPHPAndComposer()
|
checks.setupPHPAndComposer()
|
||||||
checks.fix_selinux_issue()
|
checks.fix_selinux_issue()
|
||||||
checks.install_psmisc()
|
checks.install_psmisc()
|
||||||
|
|
||||||
|
if args.postfix != None:
|
||||||
|
checks.install_postfix_davecot()
|
||||||
|
checks.setup_email_Passwords(installCyberPanel.InstallCyberPanel.mysqlPassword, mysql)
|
||||||
|
checks.setup_postfix_davecot_config(mysql)
|
||||||
|
else:
|
||||||
|
if args.postfix == 'On':
|
||||||
checks.install_postfix_davecot()
|
checks.install_postfix_davecot()
|
||||||
checks.setup_email_Passwords(installCyberPanel.InstallCyberPanel.mysqlPassword, mysql)
|
checks.setup_email_Passwords(installCyberPanel.InstallCyberPanel.mysqlPassword, mysql)
|
||||||
checks.setup_postfix_davecot_config(mysql)
|
checks.setup_postfix_davecot_config(mysql)
|
||||||
|
|||||||
@@ -18,13 +18,15 @@ class InstallCyberPanel:
|
|||||||
mysql_Root_password = ""
|
mysql_Root_password = ""
|
||||||
mysqlPassword = ""
|
mysqlPassword = ""
|
||||||
|
|
||||||
def __init__(self, rootPath, cwd, distro, ent, serial = None, port = None):
|
def __init__(self, rootPath, cwd, distro, ent, serial = None, port = None, ftp = None, dns = None):
|
||||||
self.server_root_path = rootPath
|
self.server_root_path = rootPath
|
||||||
self.cwd = cwd
|
self.cwd = cwd
|
||||||
self.distro = distro
|
self.distro = distro
|
||||||
self.ent = ent
|
self.ent = ent
|
||||||
self.serial = serial
|
self.serial = serial
|
||||||
self.port = port
|
self.port = port
|
||||||
|
self.ftp = None
|
||||||
|
self.dns = dns
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def stdOut(message, log=0, exit=0, code=os.EX_OK):
|
def stdOut(message, log=0, exit=0, code=os.EX_OK):
|
||||||
@@ -686,7 +688,7 @@ class InstallCyberPanel:
|
|||||||
logging.InstallLog.writeToFile(str(msg) + " [startPowerDNS]")
|
logging.InstallLog.writeToFile(str(msg) + " [startPowerDNS]")
|
||||||
|
|
||||||
|
|
||||||
def Main(cwd, mysql, distro, ent, serial = None, port = "8090"):
|
def Main(cwd, mysql, distro, ent, serial = None, port = "8090", ftp = None, dns = None):
|
||||||
|
|
||||||
InstallCyberPanel.mysqlPassword = randomPassword.generate_pass()
|
InstallCyberPanel.mysqlPassword = randomPassword.generate_pass()
|
||||||
InstallCyberPanel.mysql_Root_password = randomPassword.generate_pass()
|
InstallCyberPanel.mysql_Root_password = randomPassword.generate_pass()
|
||||||
@@ -706,7 +708,7 @@ def Main(cwd, mysql, distro, ent, serial = None, port = "8090"):
|
|||||||
else:
|
else:
|
||||||
InstallCyberPanel.mysqlPassword = InstallCyberPanel.mysql_Root_password
|
InstallCyberPanel.mysqlPassword = InstallCyberPanel.mysql_Root_password
|
||||||
|
|
||||||
installer = InstallCyberPanel("/usr/local/lsws/",cwd, distro, ent, serial, port)
|
installer = InstallCyberPanel("/usr/local/lsws/",cwd, distro, ent, serial, port, ftp, dns)
|
||||||
|
|
||||||
installer.installLiteSpeed()
|
installer.installLiteSpeed()
|
||||||
if ent == 0:
|
if ent == 0:
|
||||||
@@ -727,10 +729,22 @@ def Main(cwd, mysql, distro, ent, serial = None, port = "8090"):
|
|||||||
|
|
||||||
mysqlUtilities.createDatabase("cyberpanel","cyberpanel",InstallCyberPanel.mysqlPassword)
|
mysqlUtilities.createDatabase("cyberpanel","cyberpanel",InstallCyberPanel.mysqlPassword)
|
||||||
|
|
||||||
|
if ftp == None:
|
||||||
|
installer.installPureFTPD()
|
||||||
|
installer.installPureFTPDConfigurations(mysql)
|
||||||
|
installer.startPureFTPD()
|
||||||
|
else:
|
||||||
|
if ftp == 'On':
|
||||||
installer.installPureFTPD()
|
installer.installPureFTPD()
|
||||||
installer.installPureFTPDConfigurations(mysql)
|
installer.installPureFTPDConfigurations(mysql)
|
||||||
installer.startPureFTPD()
|
installer.startPureFTPD()
|
||||||
|
|
||||||
|
if dns == None:
|
||||||
|
installer.installPowerDNS()
|
||||||
|
installer.installPowerDNSConfigurations(InstallCyberPanel.mysqlPassword, mysql)
|
||||||
|
installer.startPowerDNS()
|
||||||
|
else:
|
||||||
|
if dns == 'On':
|
||||||
installer.installPowerDNS()
|
installer.installPowerDNS()
|
||||||
installer.installPowerDNSConfigurations(InstallCyberPanel.mysqlPassword, mysql)
|
installer.installPowerDNSConfigurations(InstallCyberPanel.mysqlPassword, mysql)
|
||||||
installer.startPowerDNS()
|
installer.startPowerDNS()
|
||||||
@@ -8,5 +8,10 @@ from django.db import models
|
|||||||
class PDNSStatus(models.Model):
|
class PDNSStatus(models.Model):
|
||||||
serverStatus = models.IntegerField(default=1)
|
serverStatus = models.IntegerField(default=1)
|
||||||
type = models.CharField(max_length=6, default='NATIVE')
|
type = models.CharField(max_length=6, default='NATIVE')
|
||||||
allow_axfr_ips = models.CharField(max_length=500, default='')
|
masterServer = models.CharField(max_length=200, default='')
|
||||||
also_notify = models.CharField(max_length=500, default='')
|
masterIP = models.CharField(max_length=200, default='')
|
||||||
|
|
||||||
|
|
||||||
|
class SlaveServers(models.Model):
|
||||||
|
slaveServer = models.CharField(max_length=200, default='NATIVE')
|
||||||
|
slaveServerIP = models.CharField(max_length=200, default='NATIVE')
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
import subprocess, shlex
|
import subprocess, shlex
|
||||||
from random import randint
|
from random import randint
|
||||||
from plogical.processUtilities import ProcessUtilities
|
from plogical.processUtilities import ProcessUtilities
|
||||||
|
from dns.models import Supermasters
|
||||||
|
from manageServices.models import SlaveServers
|
||||||
|
|
||||||
class ServiceManager:
|
class ServiceManager:
|
||||||
|
|
||||||
@@ -8,17 +10,27 @@ class ServiceManager:
|
|||||||
self.extraArgs = extraArgs
|
self.extraArgs = extraArgs
|
||||||
|
|
||||||
def managePDNS(self):
|
def managePDNS(self):
|
||||||
return 0
|
|
||||||
type = self.extraArgs['type']
|
type = self.extraArgs['type']
|
||||||
path = '/etc/pdns/pdns.conf'
|
path = '/etc/pdns/pdns.conf'
|
||||||
|
|
||||||
data = subprocess.check_output(shlex.split('sudo cat ' + path)).splitlines()
|
data = ProcessUtilities.outputExecutioner('sudo cat ' + path).splitlines()
|
||||||
|
#data = subprocess.check_output(shlex.split('sudo cat ' + path)).splitlines()
|
||||||
|
|
||||||
|
|
||||||
if type == 'MASTER':
|
if type == 'MASTER':
|
||||||
counter = 0
|
counter = 0
|
||||||
|
|
||||||
slaveIPData = self.extraArgs['slaveIPData']
|
ipsString = ''
|
||||||
ipsString = slaveIPData.replace(',', '/32,')
|
ipStringNoSubnet = ''
|
||||||
|
|
||||||
|
for items in SlaveServers.objects.all():
|
||||||
|
ipsString = ipsString + '%s/32 ' % (items.slaveServerIP)
|
||||||
|
ipStringNoSubnet = ipStringNoSubnet + '%s ' % (items.slaveServerIP)
|
||||||
|
|
||||||
|
ipsString = ipsString.rstrip(' ')
|
||||||
|
ipStringNoSubnet = ipStringNoSubnet.rstrip(' ')
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
for items in data:
|
for items in data:
|
||||||
@@ -46,7 +58,7 @@ class ServiceManager:
|
|||||||
writeToFile.writelines(items + '\n')
|
writeToFile.writelines(items + '\n')
|
||||||
|
|
||||||
writeToFile.writelines('allow-axfr-ips=' + ipsString + '\n')
|
writeToFile.writelines('allow-axfr-ips=' + ipsString + '\n')
|
||||||
writeToFile.writelines('also-notify=' + slaveIPData + '\n')
|
writeToFile.writelines('also-notify=' + ipStringNoSubnet + '\n')
|
||||||
writeToFile.writelines('daemon=no\n')
|
writeToFile.writelines('daemon=no\n')
|
||||||
writeToFile.writelines('disable-axfr=no\n')
|
writeToFile.writelines('disable-axfr=no\n')
|
||||||
writeToFile.writelines('master=yes\n')
|
writeToFile.writelines('master=yes\n')
|
||||||
@@ -82,6 +94,12 @@ class ServiceManager:
|
|||||||
writeToFile.writelines('daemon=no\n')
|
writeToFile.writelines('daemon=no\n')
|
||||||
writeToFile.close()
|
writeToFile.close()
|
||||||
|
|
||||||
|
for items in Supermasters.objects.all():
|
||||||
|
items.delete()
|
||||||
|
|
||||||
|
Supermasters(ip=self.extraArgs['masterServerIP'], nameserver=self.extraArgs['slaveServerNS'], account='').save()
|
||||||
|
|
||||||
command = 'sudo mv ' + tempPath + ' ' + path
|
command = 'sudo mv ' + tempPath + ' ' + path
|
||||||
|
#subprocess.call(shlex.split(command))
|
||||||
ProcessUtilities.executioner(command)
|
ProcessUtilities.executioner(command)
|
||||||
|
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ app.controller('powerDNS', function ($scope, $http, $timeout, $window) {
|
|||||||
$scope.couldNotConnect = true;
|
$scope.couldNotConnect = true;
|
||||||
$scope.changesApplied = true;
|
$scope.changesApplied = true;
|
||||||
$scope.slaveIPs = true;
|
$scope.slaveIPs = true;
|
||||||
|
$scope.masterServerHD = true;
|
||||||
|
|
||||||
var pdnsStatus = false;
|
var pdnsStatus = false;
|
||||||
|
|
||||||
@@ -90,7 +91,14 @@ app.controller('powerDNS', function ($scope, $http, $timeout, $window) {
|
|||||||
status: pdnsStatus,
|
status: pdnsStatus,
|
||||||
service: service,
|
service: service,
|
||||||
dnsMode: $scope.dnsMode,
|
dnsMode: $scope.dnsMode,
|
||||||
slaveIPData: $scope.slaveIPData
|
slaveServerNS: $scope.slaveServerNS,
|
||||||
|
masterServerIP: $scope.masterServerIP,
|
||||||
|
slaveServer: $scope.slaveServer,
|
||||||
|
slaveServerIP: $scope.slaveServerIP,
|
||||||
|
slaveServer2: $scope.slaveServer2,
|
||||||
|
slaveServerIP2: $scope.slaveServerIP2,
|
||||||
|
slaveServer3: $scope.slaveServer3,
|
||||||
|
slaveServerIP3: $scope.slaveServerIP3,
|
||||||
};
|
};
|
||||||
}else {
|
}else {
|
||||||
var data = {
|
var data = {
|
||||||
@@ -142,9 +150,11 @@ app.controller('powerDNS', function ($scope, $http, $timeout, $window) {
|
|||||||
$scope.modeChange = function () {
|
$scope.modeChange = function () {
|
||||||
if ($scope.dnsMode === 'MASTER') {
|
if ($scope.dnsMode === 'MASTER') {
|
||||||
$scope.slaveIPs = false;
|
$scope.slaveIPs = false;
|
||||||
|
$scope.masterServerHD = true;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
$scope.slaveIPs = true;
|
$scope.slaveIPs = true;
|
||||||
|
$scope.masterServerHD = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -49,10 +49,59 @@
|
|||||||
<div class="current-pack">{% trans 'Default is Slave Mode' %}</div>
|
<div class="current-pack">{% trans 'Default is Slave Mode' %}</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div ng-hide="slaveIPs" class="form-group">
|
<div ng-hide="masterServerHD" class="form-group">
|
||||||
<label class="col-sm-3 control-label">{% trans "Slave IPs" %}</label>
|
<label class="col-sm-3 control-label">{% trans "Slave Server" %}</label>
|
||||||
<div class="col-sm-6">
|
<div class="col-sm-6">
|
||||||
<input placeholder="Comma separated listed of Slave Server IPs." type="text" class="form-control" ng-model="slaveIPData" required>
|
<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">
|
||||||
|
<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">
|
||||||
|
<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">
|
||||||
|
<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">
|
||||||
|
<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">
|
||||||
|
<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">
|
||||||
|
<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>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import os
|
|||||||
import json
|
import json
|
||||||
from plogical.mailUtilities import mailUtilities
|
from plogical.mailUtilities import mailUtilities
|
||||||
from plogical.acl import ACLManager
|
from plogical.acl import ACLManager
|
||||||
from models import PDNSStatus
|
from models import PDNSStatus, SlaveServers
|
||||||
from .serviceManager import ServiceManager
|
from .serviceManager import ServiceManager
|
||||||
from plogical.processUtilities import ProcessUtilities
|
from plogical.processUtilities import ProcessUtilities
|
||||||
# Create your views here.
|
# Create your views here.
|
||||||
@@ -96,11 +96,11 @@ def fetchStatus(request):
|
|||||||
try:
|
try:
|
||||||
pdns = PDNSStatus.objects.get(pk=1)
|
pdns = PDNSStatus.objects.get(pk=1)
|
||||||
data_ret['installCheck'] = pdns.serverStatus
|
data_ret['installCheck'] = pdns.serverStatus
|
||||||
data_ret['slaveIPData'] = pdns.also_notify
|
#data_ret['slaveIPData'] = pdns.also_notify
|
||||||
except:
|
except:
|
||||||
PDNSStatus(serverStatus=1).save()
|
PDNSStatus(serverStatus=1).save()
|
||||||
data_ret['installCheck'] = 1
|
data_ret['installCheck'] = 1
|
||||||
data_ret['slaveIPData'] = ''
|
#data_ret['slaveIPData'] = ''
|
||||||
|
|
||||||
json_data = json.dumps(data_ret)
|
json_data = json.dumps(data_ret)
|
||||||
return HttpResponse(json_data)
|
return HttpResponse(json_data)
|
||||||
@@ -161,16 +161,41 @@ def saveStatus(request):
|
|||||||
|
|
||||||
pdns = PDNSStatus.objects.get(pk=1)
|
pdns = PDNSStatus.objects.get(pk=1)
|
||||||
pdns.serverStatus = 1
|
pdns.serverStatus = 1
|
||||||
pdns.allow_axfr_ips = data['slaveIPData'].replace(',', '/32,')
|
|
||||||
pdns.also_notify = data['slaveIPData']
|
|
||||||
pdns.type = data['dnsMode']
|
pdns.type = data['dnsMode']
|
||||||
|
|
||||||
|
|
||||||
|
if data['dnsMode'] == 'SLAVE':
|
||||||
|
pdns.masterServer = data['slaveServerNS']
|
||||||
|
pdns.masterIP = data['masterServerIP']
|
||||||
|
pdns.save()
|
||||||
|
else:
|
||||||
|
pdns.masterServer = 'NONE'
|
||||||
|
pdns.masterIP = 'NONE'
|
||||||
pdns.save()
|
pdns.save()
|
||||||
|
|
||||||
extraArgs = {}
|
for items in SlaveServers.objects.all():
|
||||||
extraArgs['type'] = data['dnsMode']
|
items.delete()
|
||||||
extraArgs['slaveIPData'] = data['slaveIPData']
|
|
||||||
|
|
||||||
sm = ServiceManager(extraArgs)
|
slaveServer = SlaveServers(slaveServer=data['slaveServer'],
|
||||||
|
slaveServerIP=data['slaveServerIP'])
|
||||||
|
slaveServer.save()
|
||||||
|
|
||||||
|
try:
|
||||||
|
slaveServer = SlaveServers(slaveServer=data['slaveServer2'], slaveServerIP=data['slaveServerIP2'])
|
||||||
|
slaveServer.save()
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
|
try:
|
||||||
|
slaveServer = SlaveServers(slaveServer=data['slaveServer3'], slaveServerIP=data['slaveServerIP3'])
|
||||||
|
slaveServer.save()
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
data['type'] = data['dnsMode']
|
||||||
|
|
||||||
|
sm = ServiceManager(data)
|
||||||
sm.managePDNS()
|
sm.managePDNS()
|
||||||
|
|
||||||
command = 'sudo systemctl enable pdns'
|
command = 'sudo systemctl enable pdns'
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import subprocess
|
|||||||
import shlex
|
import shlex
|
||||||
from dns.models import Domains,Records
|
from dns.models import Domains,Records
|
||||||
from processUtilities import ProcessUtilities
|
from processUtilities import ProcessUtilities
|
||||||
from manageServices.models import PDNSStatus
|
from manageServices.models import PDNSStatus, SlaveServers
|
||||||
|
|
||||||
class DNS:
|
class DNS:
|
||||||
|
|
||||||
@@ -49,6 +49,39 @@ class DNS:
|
|||||||
|
|
||||||
zone.save()
|
zone.save()
|
||||||
|
|
||||||
|
record = Records(domainOwner=zone,
|
||||||
|
domain_id=zone.id,
|
||||||
|
name=topLevelDomain,
|
||||||
|
type="NS",
|
||||||
|
content='hostmaster.%s' % (topLevelDomain),
|
||||||
|
ttl=3600,
|
||||||
|
prio=0,
|
||||||
|
disabled=0,
|
||||||
|
auth=1)
|
||||||
|
record.save()
|
||||||
|
|
||||||
|
record = Records(domainOwner=zone,
|
||||||
|
domain_id=zone.id,
|
||||||
|
name=topLevelDomain,
|
||||||
|
type="NS",
|
||||||
|
content='ns1.%s' % (topLevelDomain),
|
||||||
|
ttl=3600,
|
||||||
|
prio=0,
|
||||||
|
disabled=0,
|
||||||
|
auth=1)
|
||||||
|
record.save()
|
||||||
|
|
||||||
|
record = Records(domainOwner=zone,
|
||||||
|
domain_id=zone.id,
|
||||||
|
name=topLevelDomain,
|
||||||
|
type="NS",
|
||||||
|
content='ns2.%s' % (topLevelDomain),
|
||||||
|
ttl=3600,
|
||||||
|
prio=0,
|
||||||
|
disabled=0,
|
||||||
|
auth=1)
|
||||||
|
record.save()
|
||||||
|
|
||||||
content = "ns1." + topLevelDomain + " hostmaster." + topLevelDomain + " 1 10800 3600 604800 3600"
|
content = "ns1." + topLevelDomain + " hostmaster." + topLevelDomain + " 1 10800 3600 604800 3600"
|
||||||
|
|
||||||
soaRecord = Records(domainOwner=zone,
|
soaRecord = Records(domainOwner=zone,
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
createWebsiteAPI#!/usr/local/CyberCP/bin/python2
|
#!/usr/local/CyberCP/bin/python2
|
||||||
import os
|
import os
|
||||||
import os.path
|
import os.path
|
||||||
import sys
|
import sys
|
||||||
|
|||||||
Reference in New Issue
Block a user