diff --git a/baseTemplate/static/baseTemplate/custom-js/system-status.js b/baseTemplate/static/baseTemplate/custom-js/system-status.js index 0200129db..134e67021 100755 --- a/baseTemplate/static/baseTemplate/custom-js/system-status.js +++ b/baseTemplate/static/baseTemplate/custom-js/system-status.js @@ -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,7 +285,20 @@ 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(); + } + } } function cantLoadInitialData(response) {} diff --git a/baseTemplate/templates/baseTemplate/index.html b/baseTemplate/templates/baseTemplate/index.html index 5869ec78c..df0c301af 100755 --- a/baseTemplate/templates/baseTemplate/index.html +++ b/baseTemplate/templates/baseTemplate/index.html @@ -475,7 +475,7 @@ -
  • +
  • {% trans "DNS" %} @@ -500,7 +500,7 @@
  • -
  • +
  • {% trans "Email" %} @@ -531,7 +531,7 @@
  • -
  • +
  • {% trans "FTP" %} @@ -761,7 +761,7 @@
  • -
  • +
  • {% trans "Mail Settings" %} diff --git a/baseTemplate/views.py b/baseTemplate/views.py index 94731496c..04d0c2c2f 100755 --- a/baseTemplate/views.py +++ b/baseTemplate/views.py @@ -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: diff --git a/dns/models.py b/dns/models.py index 8db112e90..db54286c4 100755 --- a/dns/models.py +++ b/dns/models.py @@ -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) diff --git a/install/install.py b/install/install.py index 016ffddb5..616451da3 100755 --- a/install/install.py +++ b/install/install.py @@ -3611,17 +3611,24 @@ 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() - checks.install_postfix_davecot() - checks.setup_email_Passwords(installCyberPanel.InstallCyberPanel.mysqlPassword, mysql) - checks.setup_postfix_davecot_config(mysql) + + 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) checks.install_unzip() checks.install_zip() diff --git a/install/installCyberPanel.py b/install/installCyberPanel.py index 49446b374..c6c291e62 100755 --- a/install/installCyberPanel.py +++ b/install/installCyberPanel.py @@ -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) - installer.installPureFTPD() - installer.installPureFTPDConfigurations(mysql) - installer.startPureFTPD() + if ftp == None: + installer.installPureFTPD() + installer.installPureFTPDConfigurations(mysql) + installer.startPureFTPD() + else: + if ftp == 'On': + installer.installPureFTPD() + installer.installPureFTPDConfigurations(mysql) + installer.startPureFTPD() - installer.installPowerDNS() - installer.installPowerDNSConfigurations(InstallCyberPanel.mysqlPassword, mysql) - installer.startPowerDNS() \ No newline at end of file + 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() \ No newline at end of file diff --git a/manageServices/models.py b/manageServices/models.py index d0e84cea8..e98e554a9 100755 --- a/manageServices/models.py +++ b/manageServices/models.py @@ -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='') \ No newline at end of file + 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') diff --git a/manageServices/serviceManager.py b/manageServices/serviceManager.py index a78dd1105..f56691bad 100755 --- a/manageServices/serviceManager.py +++ b/manageServices/serviceManager.py @@ -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) diff --git a/manageServices/static/manageServices/manageServices.js b/manageServices/static/manageServices/manageServices.js index ca700620a..bf85e23cd 100755 --- a/manageServices/static/manageServices/manageServices.js +++ b/manageServices/static/manageServices/manageServices.js @@ -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; } } diff --git a/manageServices/templates/manageServices/managePowerDNS.html b/manageServices/templates/manageServices/managePowerDNS.html index ca0b14ca5..1df94d169 100755 --- a/manageServices/templates/manageServices/managePowerDNS.html +++ b/manageServices/templates/manageServices/managePowerDNS.html @@ -49,10 +49,59 @@
    {% trans 'Default is Slave Mode' %}
    -
    - +
    +
    - + +
    +
    + +
    + +
    + +
    +
    + +
    + +
    + +
    +
    + +
    + +
    + +
    +
    + +
    + +
    + +
    +
    + +
    + +
    + +
    +
    + +
    + +
    + +
    +
    + +
    + +
    +
    diff --git a/manageServices/views.py b/manageServices/views.py index 7be89c030..d5ccd6aad 100755 --- a/manageServices/views.py +++ b/manageServices/views.py @@ -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'] - pdns.save() - extraArgs = {} - extraArgs['type'] = data['dnsMode'] - extraArgs['slaveIPData'] = data['slaveIPData'] - sm = ServiceManager(extraArgs) + if data['dnsMode'] == 'SLAVE': + pdns.masterServer = data['slaveServerNS'] + pdns.masterIP = data['masterServerIP'] + pdns.save() + else: + pdns.masterServer = 'NONE' + pdns.masterIP = 'NONE' + pdns.save() + + for items in SlaveServers.objects.all(): + items.delete() + + 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' diff --git a/plogical/dnsUtilities.py b/plogical/dnsUtilities.py index 209cd2717..a3e8dfe10 100755 --- a/plogical/dnsUtilities.py +++ b/plogical/dnsUtilities.py @@ -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, diff --git a/plogical/website.py b/plogical/website.py index 73aa58d58..c4630ee68 100755 --- a/plogical/website.py +++ b/plogical/website.py @@ -1,4 +1,4 @@ -createWebsiteAPI#!/usr/local/CyberCP/bin/python2 +#!/usr/local/CyberCP/bin/python2 import os import os.path import sys