install required components only

This commit is contained in:
Usman Nasir
2019-06-27 13:07:47 +05:00
parent c02cd2c6c4
commit 26153007e6
12 changed files with 282 additions and 153 deletions

View File

@@ -5,7 +5,7 @@ from loginSystem.models import Administrator
class Domains(models.Model):
admin = models.ForeignKey(Administrator,on_delete=models.CASCADE, default=1)
admin = models.ForeignKey(Administrator,on_delete=models.CASCADE, null=True)
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)
@@ -18,7 +18,7 @@ class Domains(models.Model):
class Records(models.Model):
domainOwner = models.ForeignKey(Domains, on_delete=models.CASCADE)
domainOwner = models.ForeignKey(Domains, on_delete=models.CASCADE, null=True)
id = models.BigAutoField(primary_key=True)
domain_id = models.IntegerField(blank=True, null=True)
name = models.CharField(max_length=255, blank=True, null=True)

View File

@@ -604,8 +604,8 @@ class InstallCyberPanel:
'Install PowerDNS',
1, 1, os.EX_OSERR)
command = 'curl -o /etc/yum.repos.d/powerdns-auth-master.repo ' \
'https://repo.powerdns.com/repo-files/centos-auth-master.repo'
command = 'curl -o /etc/yum.repos.d/powerdns-auth-42.repo ' \
'https://repo.powerdns.com/repo-files/centos-auth-42.repo'
install.preFlightsChecks.call(command, self.distro, '[installPowerDNS]',
'Install PowerDNS',
1, 1, os.EX_OSERR)

View File

@@ -35,19 +35,19 @@ class ServiceManager:
for items in data:
if items.find('allow-axfr-ips') > -1:
data[counter] = '#' + data[counter]
continue
if items.find('also-notify') > -1:
data[counter] = '#' + data[counter]
continue
if items.find('daemon=') > -1:
data[counter] = '#' + data[counter]
continue
if items.find('disable-axfr') > -1:
data[counter] = '#' + data[counter]
continue
if items.find('slave') > -1:
data[counter] = '#' + data[counter]
continue
counter = counter + 1
@@ -68,19 +68,19 @@ class ServiceManager:
for items in data:
if items.find('allow-axfr-ips') > -1:
data[counter] = '#' + data[counter]
continue
if items.find('also-notify') > -1:
data[counter] = '#' + data[counter]
continue
if items.find('daemon=') > -1:
data[counter] = '#' + data[counter]
continue
if items.find('disable-axfr') > -1:
data[counter] = '#' + data[counter]
continue
if items.find('slave') > -1:
data[counter] = '#' + data[counter]
continue
counter = counter + 1
@@ -90,8 +90,20 @@ class ServiceManager:
for items in data:
writeToFile.writelines(items + '\n')
writeToFile.writelines('slave=yes\n')
writeToFile.writelines('daemon=no\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():

View File

@@ -152,9 +152,12 @@ app.controller('powerDNS', function ($scope, $http, $timeout, $window) {
$scope.slaveIPs = false;
$scope.masterServerHD = true;
} else {
} else if($scope.dnsMode == 'SLAVE') {
$scope.slaveIPs = true;
$scope.masterServerHD = false;
}else{
$scope.slaveIPs = true;
$scope.masterServerHD = true;
}
}

View File

@@ -42,11 +42,11 @@
<label class="col-sm-3 control-label">{% trans "Select Function Mode" %}</label>
<div class="col-sm-6">
<select ng-change="modeChange()" ng-model="dnsMode" class="form-control">
<option>Default</option>
<option>MASTER</option>
<option>SLAVE</option>
</select>
</div>
<div class="current-pack">{% trans 'Default is Slave Mode' %}</div>
</div>
<div ng-hide="masterServerHD" class="form-group">

View File

@@ -168,7 +168,7 @@ def saveStatus(request):
pdns.masterServer = data['slaveServerNS']
pdns.masterIP = data['masterServerIP']
pdns.save()
else:
elif data['dnsMode'] == 'MASTER':
pdns.masterServer = 'NONE'
pdns.masterIP = 'NONE'
pdns.save()
@@ -192,7 +192,7 @@ def saveStatus(request):
except:
pass
if data['dnsMode'] != 'Default':
data['type'] = data['dnsMode']
sm = ServiceManager(data)

View File

@@ -41,6 +41,20 @@ class DNS:
pdns = PDNSStatus.objects.get(pk=1)
if pdns.type == 'MASTER':
zone = Domains(admin=admin, name=topLevelDomain, type="MASTER")
zone.save()
for items in SlaveServers.objects.all():
record = Records(domainOwner=zone,
domain_id=zone.id,
name=topLevelDomain,
type="NS",
content=items.slaveServer,
ttl=3600,
prio=0,
disabled=0,
auth=1)
record.save()
else:
zone = Domains(admin=admin, name=topLevelDomain, type="NATIVE")
except:
@@ -49,6 +63,8 @@ class DNS:
zone.save()
if zone.type == 'NATIVE':
record = Records(domainOwner=zone,
domain_id=zone.id,
name=topLevelDomain,
@@ -392,6 +408,16 @@ class DNS:
@staticmethod
def createDNSRecord(zone, name, type, value, priority, ttl):
try:
if zone.type == 'MASTER':
getSOA = Records.objects.get(domainOwner=zone, type='SOA')
soaContent = getSOA.content.split(' ')
soaContent[2] = str(int(soaContent[2]) + 1)
getSOA.content = " ".join(soaContent)
getSOA.save()
if type == 'NS':
if Records.objects.filter(name=name, type=type, content=value).count() == 0:
record = Records(domainOwner=zone,

View File

@@ -609,6 +609,19 @@ class WebsiteManager:
Data['phps'] = PHPManager.findPHPVersions()
servicePath = '/home/cyberpanel/postfix'
if os.path.exists(servicePath):
Data['email'] = 1
else:
Data['email'] = 0
servicePath = '/home/cyberpanel/pureftpd'
if os.path.exists(servicePath):
Data['ftp'] = 1
else:
Data['ftp'] = 0
return render(request, 'websiteFunctions/website.html', Data)
else:
@@ -674,6 +687,18 @@ class WebsiteManager:
Data['phps'] = PHPManager.findPHPVersions()
servicePath = '/home/cyberpanel/postfix'
if os.path.exists(servicePath):
Data['email'] = 1
else:
Data['email'] = 0
servicePath = '/home/cyberpanel/pureftpd'
if os.path.exists(servicePath):
Data['ftp'] = 1
else:
Data['ftp'] = 0
return render(request, 'websiteFunctions/launchChild.html', Data)
else:
return render(request, 'websiteFunctions/launchChild.html',

25
static/baseTemplate/custom-js/system-status.js Executable file → Normal file
View File

@@ -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();
}
}
}

17
static/manageServices/manageServices.js Executable file → Normal file
View File

@@ -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,14 @@ app.controller('powerDNS', function ($scope, $http, $timeout, $window) {
$scope.modeChange = function () {
if ($scope.dnsMode === 'MASTER') {
$scope.slaveIPs = false;
$scope.masterServerHD = true;
} else {
} else if($scope.dnsMode == 'SLAVE') {
$scope.slaveIPs = true;
$scope.masterServerHD = false;
}else{
$scope.slaveIPs = true;
$scope.masterServerHD = true;
}
}

View File

@@ -175,7 +175,8 @@
</div>
<div style="margin-bottom: 1%;" class=" col-sm-1">
<a ng-click="hidelogsbtn()" href=""><h3 class="glyph-icon icon-close text-danger mt-5"></h3></a>
<a ng-click="hidelogsbtn()" href=""><h3
class="glyph-icon icon-close text-danger mt-5"></h3></a>
</div>
<div class="col-sm-12">
<table class="table">
@@ -205,7 +206,8 @@
<div ng-hide="hideErrorLogs" class="form-group">
<div class="col-sm-2">
<input placeholder="Page Number" type="number" class="form-control" ng-model="errorPageNumber" required>
<input placeholder="Page Number" type="number" class="form-control"
ng-model="errorPageNumber" required>
</div>
<div class="col-sm-9">
@@ -217,7 +219,7 @@
<div style="margin-bottom: 1%;" class=" col-sm-1">
<a ng-click="hideErrorLogsbtn()" href="">
<h3 class="glyph-icon icon-close text-danger mt-5"></h3> </a>
<h3 class="glyph-icon icon-close text-danger mt-5"></h3></a>
</div>
<div class="col-sm-12">
@@ -275,7 +277,8 @@
<div class="col-md-3 panel-body">
<a ng-click="addSSL()" href="" title="{% trans 'Add Your Own SSL' %}" width="65" class="mr-10">
<a ng-click="addSSL()" href="" title="{% trans 'Add Your Own SSL' %}" width="65"
class="mr-10">
<img src="{% static 'images/icons/locked.png' %}" width="65" class="mr-10">
</a>
<a ng-click="addSSL()" href="" title="{% trans 'Add Your Own SSL' %}">
@@ -286,7 +289,8 @@
<div class="col-md-3 panel-body">
<a ng-click="changePHPMaster()" href="" title="{% trans 'Change PHP Version' %}" width="65" class="mr-10">
<a ng-click="changePHPMaster()" href="" title="{% trans 'Change PHP Version' %}"
width="65" class="mr-10">
<img src="{% static 'images/icons/laptop.png' %}" width="65" class="mr-10">
</a>
<a ng-click="changePHPMaster()" href="" title="{% trans 'Change PHP Version' %}">
@@ -318,7 +322,8 @@
<div ng-hide="" class="form-group">
<div style="margin-bottom: 1%;" class="col-sm-offset-11 col-sm-1">
<a ng-click="hidesslbtn()" href=""><h3 class="glyph-icon icon-close text-danger mt-5"></h3></a>
<a ng-click="hidesslbtn()" href=""><h3
class="glyph-icon icon-close text-danger mt-5"></h3></a>
</div>
<div class="col-sm-6">
<textarea placeholder="Paste Your Cert" ng-model="cert" rows="10"
@@ -382,7 +387,8 @@
<div ng-hide="fetchedConfigsData" class="form-group">
<div style="margin-bottom: 1%;" class="col-sm-offset-11 col-sm-1">
<a ng-click="hideconfigbtn()" href=""><h3 class="glyph-icon icon-close text-danger mt-5"></h3></a>
<a ng-click="hideconfigbtn()" href=""><h3
class="glyph-icon icon-close text-danger mt-5"></h3></a>
</div>
<div class="col-sm-12">
<textarea ng-model="configData" rows="20" class="form-control"></textarea>
@@ -437,7 +443,8 @@
<div ng-hide="fetchedRewriteRules" class="form-group">
<div style="margin-bottom: 1%;" class="col-sm-offset-11 col-sm-1">
<a ng-click="hideRewriteRulesbtn()" href=""><h3 class="glyph-icon icon-close text-danger mt-5"></h3></a>
<a ng-click="hideRewriteRulesbtn()" href=""><h3
class="glyph-icon icon-close text-danger mt-5"></h3></a>
</div>
<div class="col-sm-12">
<textarea ng-model="rewriteRules" rows="10" class="form-control"></textarea>
@@ -555,6 +562,7 @@
</div>
{% if ftp %}
<div class="col-md-3 panel-body">
@@ -579,6 +587,8 @@
</div>
{% endif %}
<!--- HTML To change open_basedir --->
@@ -600,7 +610,8 @@
</div>
<div style="margin-bottom: 2%;" class=" col-sm-1">
<a title="{% trans 'Cancel' %}" ng-click="hideOpenBasedir()" href=""><h3 class="glyph-icon icon-close text-danger mt-5"></h3></a>
<a title="{% trans 'Cancel' %}" ng-click="hideOpenBasedir()" href=""><h3
class="glyph-icon icon-close text-danger mt-5"></h3></a>
</div>
</div>

View File

@@ -673,7 +673,8 @@
<div ng-hide="fetchedRewriteRules" class="form-group">
<label class="col-sm-3 control-label">{% trans "Select Template" %}</label>
<div class="col-sm-6">
<select ng-change="applyRewriteTemplate()" ng-model="rewriteTemplate" class="form-control">
<select ng-change="applyRewriteTemplate()" ng-model="rewriteTemplate"
class="form-control">
<option>Force HTTP -> HTTPS</option>
<option>Force NON-WWW -> WWW</option>
</select>
@@ -810,6 +811,9 @@
</a>
</div>
{% if ftp %}
<div class="col-md-3 panel-body">
<a href="{% url 'createFTPAccount' %}" title="{% trans 'Create FTP Account' %}">
<img src="{% static 'images/icons/ftp-upload.png' %}" width="65" class="mr-10">
@@ -828,6 +832,8 @@
</a>
</div>
{% endif %}
<!--- HTML To change open_basedir --->
<div ng-hide="openBaseDirBox" class="col-md-12">
@@ -890,6 +896,8 @@
</div>
</div>
{% if email %}
{% if marketingStatus %}
<div class="example-box-wrapper my-10">
@@ -902,7 +910,8 @@
<div class="row mx-10">
<div class="col-md-3 panel-body">
<a id="emailLists" target="_blank" title="{% trans 'Create Lists' %}">
<img src="{% static 'emailMarketing/mailing.png' %}" width="65" class="mr-10">
<img src="{% static 'emailMarketing/mailing.png' %}" width="65"
class="mr-10">
</a>
<a id="emailListsChild" target="_blank" title="{% trans 'Create Lists' %}">
<span class="h4">{% trans "Create Lists" %}</span>
@@ -911,7 +920,8 @@
<div class="col-md-3 panel-body">
<a id="manageLists" target="_blank" title="{% trans 'Manage Lists' %}">
<img src="{% static 'emailMarketing/checklist.png' %}" width="65" class="mr-10">
<img src="{% static 'emailMarketing/checklist.png' %}" width="65"
class="mr-10">
</a>
<a id="manageListsChild" target="_blank" title="{% trans 'Manage Lists' %}">
<span class="h4">{% trans "Manage Lists" %}</span>
@@ -930,9 +940,11 @@
<div class="col-md-3 panel-body">
<a id="composeEmails" target="_blank" title="{% trans 'Compose Message' %}">
<img src="{% static 'emailMarketing/compose.png' %}" width="65" class="mr-10">
<img src="{% static 'emailMarketing/compose.png' %}" width="65"
class="mr-10">
</a>
<a id="composeEmailsChild" target="_blank" title="{% trans 'Compose Message' %}">
<a id="composeEmailsChild" target="_blank"
title="{% trans 'Compose Message' %}">
<span class="h4">{% trans "Compose" %}</span>
</a>
</div>
@@ -954,6 +966,8 @@
{% endif %}
{% endif %}
<div class="example-box-wrapper my-10">
<div class="panel panel-body">
<h3 class="content-box-header">