mirror of
https://github.com/usmannasir/cyberpanel.git
synced 2025-11-07 22:06:05 +01:00
pdns replication
This commit is contained in:
@@ -182,6 +182,10 @@ app.controller('adminController', function($scope,$http,$timeout) {
|
||||
|
||||
// DNS Management
|
||||
|
||||
if(!Boolean(response.data.dnsAsWhole)){
|
||||
$('.dnsAsWhole').hide();
|
||||
}
|
||||
|
||||
if(!Boolean(response.data.createNameServer)){
|
||||
$('.createNameServer').hide();
|
||||
}
|
||||
@@ -200,6 +204,10 @@ app.controller('adminController', function($scope,$http,$timeout) {
|
||||
|
||||
// Email Management
|
||||
|
||||
if(!Boolean(response.data.emailAsWhole)){
|
||||
$('.emailAsWhole').hide();
|
||||
}
|
||||
|
||||
if(!Boolean(response.data.createEmail)){
|
||||
$('.createEmail').hide();
|
||||
}
|
||||
@@ -223,6 +231,10 @@ app.controller('adminController', function($scope,$http,$timeout) {
|
||||
|
||||
// FTP Management
|
||||
|
||||
if(!Boolean(response.data.ftpAsWhole)){
|
||||
$('.ftpAsWhole').hide();
|
||||
}
|
||||
|
||||
if(!Boolean(response.data.createFTPAccount)){
|
||||
$('.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 -->
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<li class="dnsAsWhole">
|
||||
<a title="{% trans 'DNS' %}">
|
||||
<i class="glyph-icon icon-sitemap"></i>
|
||||
<span>{% trans "DNS" %}</span>
|
||||
@@ -500,7 +500,7 @@
|
||||
</div><!-- .sidebar-submenu -->
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<li class="emailAsWhole">
|
||||
<a href="{% url 'loadEmailHome' %}" title="{% trans 'Email' %}">
|
||||
<i class="glyph-icon icon-paper-plane"></i>
|
||||
<span>{% trans "Email" %}</span>
|
||||
@@ -531,7 +531,7 @@
|
||||
</div><!-- .sidebar-submenu -->
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<li class="ftpAsWhole">
|
||||
<a href="{% url 'packagesHome' %}" title="{% trans 'FTP' %}">
|
||||
<i class="glyph-icon icon-cloud-upload"></i>
|
||||
<span>{% trans "FTP" %}</span>
|
||||
@@ -761,7 +761,7 @@
|
||||
</div><!-- .sidebar-submenu -->
|
||||
</li>
|
||||
|
||||
<li class="serverACL">
|
||||
<li class="emailAsWhole" class="serverACL">
|
||||
<a href="#" title="{% trans 'Mail Settings' %}">
|
||||
<i class="glyph-icon icon-envelope"></i>
|
||||
<span>{% trans "Mail Settings" %}</span>
|
||||
|
||||
@@ -15,6 +15,7 @@ import shlex
|
||||
import os
|
||||
import plogical.CyberCPLogFileWriter as logging
|
||||
from plogical.acl import ACLManager
|
||||
from manageServices.models import PDNSStatus
|
||||
# Create your views here.
|
||||
|
||||
|
||||
@@ -41,6 +42,26 @@ def getAdminStatus(request):
|
||||
val = request.session['userID']
|
||||
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)
|
||||
return HttpResponse(json_data)
|
||||
except KeyError:
|
||||
|
||||
@@ -5,7 +5,7 @@ from loginSystem.models import Administrator
|
||||
|
||||
|
||||
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)
|
||||
master = models.CharField(max_length=128, blank=True, null=True)
|
||||
last_check = models.IntegerField(blank=True, null=True)
|
||||
|
||||
@@ -3611,14 +3611,21 @@ def main():
|
||||
import installCyberPanel
|
||||
|
||||
if ent == 0:
|
||||
installCyberPanel.Main(cwd, mysql, distro, ent, None, port)
|
||||
installCyberPanel.Main(cwd, mysql, distro, ent, None, port, args.ftp, args.powerdns)
|
||||
else:
|
||||
installCyberPanel.Main(cwd, mysql, distro, ent, serial, port)
|
||||
installCyberPanel.Main(cwd, mysql, distro, ent, serial, port, args.ftp, args.powerdns)
|
||||
|
||||
|
||||
checks.setupPHPAndComposer()
|
||||
checks.fix_selinux_issue()
|
||||
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.setup_email_Passwords(installCyberPanel.InstallCyberPanel.mysqlPassword, mysql)
|
||||
checks.setup_postfix_davecot_config(mysql)
|
||||
|
||||
@@ -18,13 +18,15 @@ class InstallCyberPanel:
|
||||
mysql_Root_password = ""
|
||||
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.cwd = cwd
|
||||
self.distro = distro
|
||||
self.ent = ent
|
||||
self.serial = serial
|
||||
self.port = port
|
||||
self.ftp = None
|
||||
self.dns = dns
|
||||
|
||||
@staticmethod
|
||||
def stdOut(message, log=0, exit=0, code=os.EX_OK):
|
||||
@@ -686,7 +688,7 @@ class InstallCyberPanel:
|
||||
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.mysql_Root_password = randomPassword.generate_pass()
|
||||
@@ -706,7 +708,7 @@ def Main(cwd, mysql, distro, ent, serial = None, port = "8090"):
|
||||
else:
|
||||
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()
|
||||
if ent == 0:
|
||||
@@ -727,10 +729,22 @@ def Main(cwd, mysql, distro, ent, serial = None, port = "8090"):
|
||||
|
||||
mysqlUtilities.createDatabase("cyberpanel","cyberpanel",InstallCyberPanel.mysqlPassword)
|
||||
|
||||
if ftp == None:
|
||||
installer.installPureFTPD()
|
||||
installer.installPureFTPDConfigurations(mysql)
|
||||
installer.startPureFTPD()
|
||||
else:
|
||||
if ftp == 'On':
|
||||
installer.installPureFTPD()
|
||||
installer.installPureFTPDConfigurations(mysql)
|
||||
installer.startPureFTPD()
|
||||
|
||||
if dns == None:
|
||||
installer.installPowerDNS()
|
||||
installer.installPowerDNSConfigurations(InstallCyberPanel.mysqlPassword, mysql)
|
||||
installer.startPowerDNS()
|
||||
else:
|
||||
if dns == 'On':
|
||||
installer.installPowerDNS()
|
||||
installer.installPowerDNSConfigurations(InstallCyberPanel.mysqlPassword, mysql)
|
||||
installer.startPowerDNS()
|
||||
@@ -8,5 +8,10 @@ from django.db import models
|
||||
class PDNSStatus(models.Model):
|
||||
serverStatus = models.IntegerField(default=1)
|
||||
type = models.CharField(max_length=6, default='NATIVE')
|
||||
allow_axfr_ips = models.CharField(max_length=500, default='')
|
||||
also_notify = models.CharField(max_length=500, default='')
|
||||
masterServer = models.CharField(max_length=200, 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
|
||||
from random import randint
|
||||
from plogical.processUtilities import ProcessUtilities
|
||||
from dns.models import Supermasters
|
||||
from manageServices.models import SlaveServers
|
||||
|
||||
class ServiceManager:
|
||||
|
||||
@@ -8,17 +10,27 @@ class ServiceManager:
|
||||
self.extraArgs = extraArgs
|
||||
|
||||
def managePDNS(self):
|
||||
return 0
|
||||
type = self.extraArgs['type']
|
||||
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':
|
||||
counter = 0
|
||||
|
||||
slaveIPData = self.extraArgs['slaveIPData']
|
||||
ipsString = slaveIPData.replace(',', '/32,')
|
||||
ipsString = ''
|
||||
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:
|
||||
@@ -46,7 +58,7 @@ class ServiceManager:
|
||||
writeToFile.writelines(items + '\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('disable-axfr=no\n')
|
||||
writeToFile.writelines('master=yes\n')
|
||||
@@ -82,6 +94,12 @@ class ServiceManager:
|
||||
writeToFile.writelines('daemon=no\n')
|
||||
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
|
||||
#subprocess.call(shlex.split(command))
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@ app.controller('powerDNS', function ($scope, $http, $timeout, $window) {
|
||||
$scope.couldNotConnect = true;
|
||||
$scope.changesApplied = true;
|
||||
$scope.slaveIPs = true;
|
||||
$scope.masterServerHD = true;
|
||||
|
||||
var pdnsStatus = false;
|
||||
|
||||
@@ -90,7 +91,14 @@ app.controller('powerDNS', function ($scope, $http, $timeout, $window) {
|
||||
status: pdnsStatus,
|
||||
service: service,
|
||||
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 {
|
||||
var data = {
|
||||
@@ -142,9 +150,11 @@ app.controller('powerDNS', function ($scope, $http, $timeout, $window) {
|
||||
$scope.modeChange = function () {
|
||||
if ($scope.dnsMode === 'MASTER') {
|
||||
$scope.slaveIPs = false;
|
||||
$scope.masterServerHD = true;
|
||||
|
||||
} else {
|
||||
$scope.slaveIPs = true;
|
||||
$scope.masterServerHD = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -49,10 +49,59 @@
|
||||
<div class="current-pack">{% trans 'Default is Slave Mode' %}</div>
|
||||
</div>
|
||||
|
||||
<div ng-hide="slaveIPs" class="form-group">
|
||||
<label class="col-sm-3 control-label">{% trans "Slave IPs" %}</label>
|
||||
<div ng-hide="masterServerHD" class="form-group">
|
||||
<label class="col-sm-3 control-label">{% trans "Slave Server" %}</label>
|
||||
<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>
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ import os
|
||||
import json
|
||||
from plogical.mailUtilities import mailUtilities
|
||||
from plogical.acl import ACLManager
|
||||
from models import PDNSStatus
|
||||
from models import PDNSStatus, SlaveServers
|
||||
from .serviceManager import ServiceManager
|
||||
from plogical.processUtilities import ProcessUtilities
|
||||
# Create your views here.
|
||||
@@ -96,11 +96,11 @@ def fetchStatus(request):
|
||||
try:
|
||||
pdns = PDNSStatus.objects.get(pk=1)
|
||||
data_ret['installCheck'] = pdns.serverStatus
|
||||
data_ret['slaveIPData'] = pdns.also_notify
|
||||
#data_ret['slaveIPData'] = pdns.also_notify
|
||||
except:
|
||||
PDNSStatus(serverStatus=1).save()
|
||||
data_ret['installCheck'] = 1
|
||||
data_ret['slaveIPData'] = ''
|
||||
#data_ret['slaveIPData'] = ''
|
||||
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
@@ -161,16 +161,41 @@ def saveStatus(request):
|
||||
|
||||
pdns = PDNSStatus.objects.get(pk=1)
|
||||
pdns.serverStatus = 1
|
||||
pdns.allow_axfr_ips = data['slaveIPData'].replace(',', '/32,')
|
||||
pdns.also_notify = data['slaveIPData']
|
||||
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()
|
||||
|
||||
extraArgs = {}
|
||||
extraArgs['type'] = data['dnsMode']
|
||||
extraArgs['slaveIPData'] = data['slaveIPData']
|
||||
for items in SlaveServers.objects.all():
|
||||
items.delete()
|
||||
|
||||
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()
|
||||
|
||||
command = 'sudo systemctl enable pdns'
|
||||
|
||||
@@ -9,7 +9,7 @@ import subprocess
|
||||
import shlex
|
||||
from dns.models import Domains,Records
|
||||
from processUtilities import ProcessUtilities
|
||||
from manageServices.models import PDNSStatus
|
||||
from manageServices.models import PDNSStatus, SlaveServers
|
||||
|
||||
class DNS:
|
||||
|
||||
@@ -49,6 +49,39 @@ class DNS:
|
||||
|
||||
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"
|
||||
|
||||
soaRecord = Records(domainOwner=zone,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
createWebsiteAPI#!/usr/local/CyberCP/bin/python2
|
||||
#!/usr/local/CyberCP/bin/python2
|
||||
import os
|
||||
import os.path
|
||||
import sys
|
||||
|
||||
Reference in New Issue
Block a user