mirror of
https://github.com/usmannasir/cyberpanel.git
synced 2025-11-06 21:35:55 +01:00
Enable/Disable PowerDNS Service
This commit is contained in:
@@ -58,7 +58,8 @@ INSTALLED_APPS = [
|
||||
'manageSSL',
|
||||
'api',
|
||||
'filemanager',
|
||||
'emailPremium'
|
||||
'emailPremium',
|
||||
'manageServices'
|
||||
]
|
||||
|
||||
MIDDLEWARE = [
|
||||
|
||||
Binary file not shown.
@@ -36,4 +36,5 @@ urlpatterns = [
|
||||
url(r'^api/',include('api.urls')),
|
||||
url(r'^filemanager/',include('filemanager.urls')),
|
||||
url(r'^emailPremium/',include('emailPremium.urls')),
|
||||
url(r'^manageservices/',include('manageServices.urls')),
|
||||
]
|
||||
|
||||
@@ -642,6 +642,7 @@
|
||||
<script src="{% static 'baseTemplate/bootstrap-toggle.min.js' %}"></script>
|
||||
<script src="{% static 'firewall/firewall.js' %}"></script>
|
||||
<script src="{% static 'manageSSL/manageSSL.js' %}"></script>
|
||||
<script src="{% static 'manageServices/manageServices.js' %}"></script>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -21,6 +21,20 @@
|
||||
<div class="example-box-wrapper">
|
||||
|
||||
|
||||
{% if not status %}
|
||||
|
||||
<div class="col-md-12 text-center" style="margin-bottom: 2%;">
|
||||
<h3>{% trans "PowerDNS is disabled." %}
|
||||
<a href="{% url 'managePowerDNS' %}"><button class="btn btn-alt btn-hover btn-blue-alt">
|
||||
<span>{% trans "Enable Now" %}</span>
|
||||
<i class="glyph-icon icon-arrow-right"></i>
|
||||
</button></a></h3>
|
||||
</div>
|
||||
|
||||
|
||||
{% else %}
|
||||
|
||||
|
||||
<form action="/" class="form-horizontal bordered-row">
|
||||
|
||||
|
||||
@@ -359,6 +373,8 @@
|
||||
|
||||
</form>
|
||||
|
||||
{% endif %}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -19,6 +19,17 @@
|
||||
</h3>
|
||||
<div class="example-box-wrapper">
|
||||
|
||||
{% if not status %}
|
||||
<div class="col-md-12 text-center" style="margin-bottom: 2%;">
|
||||
<h3>{% trans "PowerDNS is disabled." %}
|
||||
<a href="{% url 'managePowerDNS' %}"><button class="btn btn-alt btn-hover btn-blue-alt">
|
||||
<span>{% trans "Enable Now" %}</span>
|
||||
<i class="glyph-icon icon-arrow-right"></i>
|
||||
</button></a></h3>
|
||||
</div>
|
||||
|
||||
|
||||
{% else %}
|
||||
|
||||
<form action="/" class="form-horizontal bordered-row">
|
||||
|
||||
@@ -70,6 +81,8 @@
|
||||
|
||||
</form>
|
||||
|
||||
{% endif %}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -19,6 +19,17 @@
|
||||
</h3>
|
||||
<div class="example-box-wrapper">
|
||||
|
||||
{% if not status %}
|
||||
<div class="col-md-12 text-center" style="margin-bottom: 2%;">
|
||||
<h3>{% trans "PowerDNS is disabled." %}
|
||||
<a href="{% url 'managePowerDNS' %}"><button class="btn btn-alt btn-hover btn-blue-alt">
|
||||
<span>{% trans "Enable Now" %}</span>
|
||||
<i class="glyph-icon icon-arrow-right"></i>
|
||||
</button></a></h3>
|
||||
</div>
|
||||
|
||||
|
||||
{% else %}
|
||||
|
||||
<form action="/" class="form-horizontal bordered-row">
|
||||
|
||||
@@ -111,6 +122,9 @@
|
||||
</form>
|
||||
|
||||
|
||||
{% endif %}
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
@@ -20,6 +20,19 @@
|
||||
<div ng-controller="deleteDNSZone" class="example-box-wrapper">
|
||||
|
||||
|
||||
{% if not status %}
|
||||
<div class="col-md-12 text-center" style="margin-bottom: 2%;">
|
||||
<h3>{% trans "PowerDNS is disabled." %}
|
||||
<a href="{% url 'managePowerDNS' %}"><button class="btn btn-alt btn-hover btn-blue-alt">
|
||||
<span>{% trans "Enable Now" %}</span>
|
||||
<i class="glyph-icon icon-arrow-right"></i>
|
||||
</button></a></h3>
|
||||
</div>
|
||||
|
||||
|
||||
{% else %}
|
||||
|
||||
|
||||
<form action="/" class="form-horizontal bordered-row">
|
||||
|
||||
|
||||
@@ -75,6 +88,8 @@
|
||||
|
||||
</form>
|
||||
|
||||
{% endif %}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
29
dns/views.py
29
dns/views.py
@@ -11,6 +11,7 @@ from loginSystem.views import loadLoginPage
|
||||
from models import Domains,Records
|
||||
from re import match,I,M
|
||||
from websiteFunctions.models import Websites
|
||||
from plogical.mailUtilities import mailUtilities
|
||||
|
||||
# Create your views here.
|
||||
|
||||
@@ -31,7 +32,15 @@ def createNameserver(request):
|
||||
if admin.type == 3:
|
||||
return HttpResponse("You don't have enough priviliges to access this page.")
|
||||
|
||||
return render(request,"dns/createNameServer.html")
|
||||
mailUtilities.checkHome()
|
||||
|
||||
if os.path.exists('/home/cyberpanel/powerdns'):
|
||||
return render(request, "dns/createNameServer.html", {"status": 1})
|
||||
else:
|
||||
return render(request, "dns/createNameServer.html", {"status": 0})
|
||||
|
||||
|
||||
|
||||
except KeyError:
|
||||
return redirect(loadLoginPage)
|
||||
|
||||
@@ -202,7 +211,12 @@ def createDNSZone(request):
|
||||
try:
|
||||
userID = request.session['userID']
|
||||
admin = Administrator.objects.get(pk=userID)
|
||||
return render(request,'dns/createDNSZone.html')
|
||||
|
||||
if os.path.exists('/home/cyberpanel/powerdns'):
|
||||
return render(request,'dns/createDNSZone.html', {"status": 1})
|
||||
else:
|
||||
return render(request,'dns/createDNSZone.html', {"status": 0})
|
||||
|
||||
except KeyError:
|
||||
return redirect(loadLoginPage)
|
||||
|
||||
@@ -261,6 +275,9 @@ def addDeleteDNSRecords(request):
|
||||
admin = Administrator.objects.get(pk=val)
|
||||
domainsList = []
|
||||
|
||||
if not os.path.exists('/home/cyberpanel/powerdns'):
|
||||
return render(request,'dns/addDeleteDNSRecords.html', {"status": 0})
|
||||
|
||||
if admin.type == 1:
|
||||
domains = Domains.objects.all()
|
||||
for items in domains:
|
||||
@@ -276,7 +293,7 @@ def addDeleteDNSRecords(request):
|
||||
pass
|
||||
|
||||
|
||||
return render(request, 'dns/addDeleteDNSRecords.html',{"domainsList":domainsList})
|
||||
return render(request, 'dns/addDeleteDNSRecords.html',{"domainsList":domainsList, "status": 1})
|
||||
|
||||
except KeyError:
|
||||
return redirect(loadLoginPage)
|
||||
@@ -571,6 +588,10 @@ def deleteDNSZone(request):
|
||||
admin = Administrator.objects.get(pk=val)
|
||||
domainsList = []
|
||||
|
||||
|
||||
if not os.path.exists('/home/cyberpanel/powerdns'):
|
||||
return render(request,'dns/deleteDNSZone.html', {"status": 0})
|
||||
|
||||
if admin.type == 1:
|
||||
domains = Domains.objects.all()
|
||||
for items in domains:
|
||||
@@ -586,7 +607,7 @@ def deleteDNSZone(request):
|
||||
pass
|
||||
|
||||
|
||||
return render(request, 'dns/deleteDNSZone.html',{"domainsList":domainsList})
|
||||
return render(request, 'dns/deleteDNSZone.html',{"domainsList":domainsList, "status": 1})
|
||||
|
||||
except KeyError:
|
||||
return redirect(loadLoginPage)
|
||||
|
||||
@@ -933,7 +933,6 @@ def emailPolicyServer(request):
|
||||
except KeyError:
|
||||
return redirect(loadLoginPage)
|
||||
|
||||
|
||||
def fetchPolicyServerStatus(request):
|
||||
try:
|
||||
val = request.session['userID']
|
||||
|
||||
@@ -180,7 +180,7 @@
|
||||
<div class="modal-dialog modal-lg">
|
||||
<div class="modal-content">
|
||||
<div id="uploadBoxLabel" class="modal-header">
|
||||
<h5 class="modal-title" >{% trans "Upload File" %}</h5>
|
||||
<h5 class="modal-title" >{% trans "Upload File" %} - <a target="_blank" href="https://go.cyberpanel.net/upload-limits" title="">{% trans "Upload Limits" %}</a></h5>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
|
||||
Binary file not shown.
@@ -4,25 +4,13 @@ import views
|
||||
urlpatterns = [
|
||||
url(r'^$', views.loadPHPHome, name='loadPHPHome'),
|
||||
url(r'^installExtensions', views.installExtensions, name='installExtensions'),
|
||||
|
||||
|
||||
url(r'^getExtensionsInformation', views.getExtensionsInformation, name='getExtensionsInformation'),
|
||||
|
||||
url(r'^submitExtensionRequest', views.submitExtensionRequest, name='submitExtensionRequest'),
|
||||
|
||||
url(r'^getRequestStatus', views.getRequestStatus, name='getRequestStatus'),
|
||||
|
||||
|
||||
url(r'^editPHPConfigs', views.editPHPConfigs, name='editPHPConfigs'),
|
||||
|
||||
|
||||
url(r'^getCurrentPHPConfig', views.getCurrentPHPConfig, name='getCurrentPHPConfig'),
|
||||
|
||||
url(r'^savePHPConfigBasic', views.savePHPConfigBasic, name='savePHPConfigBasic'),
|
||||
|
||||
|
||||
url(r'^getCurrentAdvancedPHPConfig', views.getCurrentAdvancedPHPConfig, name='getCurrentAdvancedPHPConfig'),
|
||||
|
||||
url(r'^savePHPConfigAdvance', views.savePHPConfigAdvance, name='savePHPConfigAdvance'),
|
||||
|
||||
|
||||
|
||||
@@ -3,7 +3,6 @@ from __future__ import unicode_literals
|
||||
import sys
|
||||
reload(sys)
|
||||
sys.setdefaultencoding("utf-8")
|
||||
|
||||
from django.shortcuts import render,redirect
|
||||
from loginSystem.views import loadLoginPage
|
||||
from .models import PHP,installedPackages
|
||||
@@ -14,7 +13,6 @@ import os
|
||||
from plogical.installUtilities import installUtilities
|
||||
from plogical.CyberCPLogFileWriter import CyberCPLogFileWriter as logging
|
||||
import re
|
||||
import subprocess
|
||||
from loginSystem.models import Administrator
|
||||
from plogical.virtualHostUtilities import virtualHostUtilities
|
||||
import subprocess
|
||||
|
||||
0
manageServices/__init__.py
Normal file
0
manageServices/__init__.py
Normal file
BIN
manageServices/__init__.pyc
Normal file
BIN
manageServices/__init__.pyc
Normal file
Binary file not shown.
6
manageServices/admin.py
Normal file
6
manageServices/admin.py
Normal file
@@ -0,0 +1,6 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.contrib import admin
|
||||
|
||||
# Register your models here.
|
||||
BIN
manageServices/admin.pyc
Normal file
BIN
manageServices/admin.pyc
Normal file
Binary file not shown.
8
manageServices/apps.py
Normal file
8
manageServices/apps.py
Normal file
@@ -0,0 +1,8 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.apps import AppConfig
|
||||
|
||||
|
||||
class ManageservicesConfig(AppConfig):
|
||||
name = 'manageServices'
|
||||
0
manageServices/migrations/__init__.py
Normal file
0
manageServices/migrations/__init__.py
Normal file
6
manageServices/models.py
Normal file
6
manageServices/models.py
Normal file
@@ -0,0 +1,6 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import models
|
||||
|
||||
# Create your models here.
|
||||
BIN
manageServices/models.pyc
Normal file
BIN
manageServices/models.pyc
Normal file
Binary file not shown.
1094
manageServices/static/manageServices/manageServices.js
Normal file
1094
manageServices/static/manageServices/manageServices.js
Normal file
File diff suppressed because it is too large
Load Diff
81
manageServices/templates/manageServices/managePostfix.html
Normal file
81
manageServices/templates/manageServices/managePostfix.html
Normal file
@@ -0,0 +1,81 @@
|
||||
{% extends "baseTemplate/index.html" %}
|
||||
{% load i18n %}
|
||||
{% block title %}{% trans "Email Policy Server - CyberPanel" %}{% endblock %}
|
||||
{% block content %}
|
||||
|
||||
{% load static %}
|
||||
{% get_current_language as LANGUAGE_CODE %}
|
||||
<!-- Current language: {{ LANGUAGE_CODE }} -->
|
||||
|
||||
|
||||
<div class="container">
|
||||
<div id="page-title">
|
||||
<h2>{% trans "Email Policy Server Configurations!" %} - <a target="_blank" href="http://go.cyberpanel.net/emailLimits" style="height: 23px;line-height: 21px;" class="btn btn-border btn-alt border-red btn-link font-red" title=""><span>{% trans "Emai Limits Docs" %}</span></a> </h2>
|
||||
<p>{% trans "Turn ON Email Policy Server to use Email Limits Feature. " %}</p>
|
||||
</div>
|
||||
|
||||
<div ng-controller="policyServer" class="example-box-wrapper">
|
||||
<div style="border-radius: 25px;border-color:#3498db" class="content-box">
|
||||
<h3 class="content-box-header bg-blue">
|
||||
{% trans "Email Policy Server" %} <img ng-hide="policyServerLoading" src="/static/images/loading.gif">
|
||||
</h3>
|
||||
|
||||
<div class="content-box-wrapper">
|
||||
<div class="row">
|
||||
|
||||
<div style="padding: 2%" class="col-md-12">
|
||||
<form action="/" id="createPackages" class="form-horizontal bordered-row">
|
||||
|
||||
<div class="form-group">
|
||||
<label class="col-sm-4 control-label">Server Status</label>
|
||||
<div class="col-sm-6">
|
||||
<input type="checkbox" id="policServerStatus" data-toggle="toggle">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label"></label>
|
||||
<div class="col-sm-4">
|
||||
<button type="button" ng-click="savePolicServerStatus()" class="btn btn-primary btn-lg btn-block">{% trans "Save changes." %}</button>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label"></label>
|
||||
<div class="col-sm-4">
|
||||
|
||||
<div ng-hide="failedToFetch" class="alert alert-danger">
|
||||
<p>{% trans "Error message: " %} {$ errorMessage $}</p>
|
||||
</div>
|
||||
|
||||
<div ng-hide="changesApplied" class="alert alert-success">
|
||||
<p>{% trans "Changes successfully applied." %}</p>
|
||||
</div>
|
||||
|
||||
<div ng-hide="couldNotConnect" class="alert alert-danger">
|
||||
<p>{% trans "Could not connect. Please refresh this page." %} </p>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</form>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
{% endblock %}
|
||||
91
manageServices/templates/manageServices/managePowerDNS.html
Normal file
91
manageServices/templates/manageServices/managePowerDNS.html
Normal file
@@ -0,0 +1,91 @@
|
||||
{% extends "baseTemplate/index.html" %}
|
||||
{% load i18n %}
|
||||
{% block title %}{% trans "Manage PowerDNS - CyberPanel" %}{% endblock %}
|
||||
{% block content %}
|
||||
|
||||
{% load static %}
|
||||
{% get_current_language as LANGUAGE_CODE %}
|
||||
<!-- Current language: {{ LANGUAGE_CODE }} -->
|
||||
|
||||
|
||||
<div class="container">
|
||||
<div id="page-title">
|
||||
<h2>{% trans "Manage PowerDNS!" %} - <a target="_blank" href="http://go.cyberpanel.net/emailLimits" style="height: 23px;line-height: 21px;" class="btn btn-border btn-alt border-red btn-link font-red" title=""><span>{% trans "Emai Limits Docs" %}</span></a> </h2>
|
||||
<p>{% trans "Enable or disable DNS services. " %}</p>
|
||||
</div>
|
||||
|
||||
{% if status %}
|
||||
|
||||
<div ng-controller="powerDNS" class="example-box-wrapper">
|
||||
<div style="border-radius: 25px;border-color:#3498db" class="content-box">
|
||||
<h3 class="content-box-header bg-blue">
|
||||
{% trans "Manage PowerDNS" %} <img ng-hide="pdnsLoading" src="/static/images/loading.gif">
|
||||
</h3>
|
||||
|
||||
<div class="content-box-wrapper">
|
||||
<div class="row">
|
||||
|
||||
<div style="padding: 2%" class="col-md-12">
|
||||
<form action="/" id="createPackages" class="form-horizontal bordered-row">
|
||||
|
||||
<div class="form-group">
|
||||
<label class="col-sm-4 control-label">PowerDNS Status</label>
|
||||
<div class="col-sm-6">
|
||||
<input type="checkbox" id="pdnsStatus" data-toggle="toggle">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label"></label>
|
||||
<div class="col-sm-4">
|
||||
<button type="button" ng-click="saveStatus('powerdns')" class="btn btn-primary btn-lg btn-block">{% trans "Save changes." %}</button>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label"></label>
|
||||
<div class="col-sm-4">
|
||||
|
||||
<div ng-hide="failedToFetch" class="alert alert-danger">
|
||||
<p>{% trans "Error message: " %} {$ errorMessage $}</p>
|
||||
</div>
|
||||
|
||||
<div ng-hide="changesApplied" class="alert alert-success">
|
||||
<p>{% trans "Changes successfully applied." %}</p>
|
||||
</div>
|
||||
|
||||
<div ng-hide="couldNotConnect" class="alert alert-danger">
|
||||
<p>{% trans "Could not connect. Please refresh this page." %} </p>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</form>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% else %}
|
||||
|
||||
<div class="alert alert-danger">
|
||||
<p>{% trans "Only administrator can manage services." %}</p>
|
||||
</div>
|
||||
|
||||
{% endif %}
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
{% endblock %}
|
||||
6
manageServices/tests.py
Normal file
6
manageServices/tests.py
Normal file
@@ -0,0 +1,6 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.test import TestCase
|
||||
|
||||
# Create your tests here.
|
||||
8
manageServices/urls.py
Normal file
8
manageServices/urls.py
Normal file
@@ -0,0 +1,8 @@
|
||||
from django.conf.urls import url
|
||||
import views
|
||||
|
||||
urlpatterns = [
|
||||
url(r'^managePowerDNS$', views.managePowerDNS, name='managePowerDNS'),
|
||||
url(r'^fetchStatus$', views.fetchStatus, name='fetchStatus'),
|
||||
url(r'^saveStatus$', views.saveStatus, name='saveStatus'),
|
||||
]
|
||||
125
manageServices/views.py
Normal file
125
manageServices/views.py
Normal file
@@ -0,0 +1,125 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.shortcuts import render
|
||||
from loginSystem.models import Administrator
|
||||
from django.shortcuts import HttpResponse, redirect
|
||||
import plogical.CyberCPLogFileWriter as logging
|
||||
from loginSystem.views import loadLoginPage
|
||||
import os
|
||||
import json
|
||||
from plogical.mailUtilities import mailUtilities
|
||||
import subprocess, shlex
|
||||
# Create your views here.
|
||||
|
||||
|
||||
# Create your views here.
|
||||
|
||||
def managePowerDNS(request):
|
||||
try:
|
||||
val = request.session['userID']
|
||||
try:
|
||||
admin = Administrator.objects.get(pk=val)
|
||||
|
||||
if admin.type == 1:
|
||||
return render(request, 'manageServices/managePowerDNS.html', {"status": 1})
|
||||
else:
|
||||
return render(request, 'manageServices/managePowerDNS.html', {"status": 0})
|
||||
|
||||
except BaseException, msg:
|
||||
logging.CyberCPLogFileWriter.writeToFile(str(msg))
|
||||
return HttpResponse("See CyberCP main log file.")
|
||||
|
||||
except KeyError:
|
||||
return redirect(loadLoginPage)
|
||||
|
||||
|
||||
def fetchStatus(request):
|
||||
try:
|
||||
val = request.session['userID']
|
||||
admin = Administrator.objects.get(pk=val)
|
||||
try:
|
||||
if request.method == 'POST':
|
||||
|
||||
if admin.type != 1:
|
||||
dic = {'status': 0, 'error_message': "Only administrator can view this page."}
|
||||
json_data = json.dumps(dic)
|
||||
return HttpResponse(json_data)
|
||||
|
||||
mailUtilities.checkHome()
|
||||
|
||||
data = json.loads(request.body)
|
||||
service = data['service']
|
||||
|
||||
if service == 'powerdns':
|
||||
if os.path.exists('/home/cyberpanel/powerdns'):
|
||||
data_ret = {'status': 1, 'error_message': 'None', 'installCheck': 1}
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
else:
|
||||
data_ret = {'status': 1, 'error_message': 'None', 'installCheck': 0}
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
|
||||
|
||||
|
||||
except BaseException,msg:
|
||||
data_ret = {'status': 0, 'error_message': str(msg)}
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
|
||||
except KeyError,msg:
|
||||
logging.CyberCPLogFileWriter.writeToFile(str(msg))
|
||||
data_ret = {'status': 0, 'error_message': str(msg)}
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
|
||||
def saveStatus(request):
|
||||
try:
|
||||
val = request.session['userID']
|
||||
admin = Administrator.objects.get(pk=val)
|
||||
try:
|
||||
if request.method == 'POST':
|
||||
|
||||
if admin.type != 1:
|
||||
dic = {'status': 0, 'error_message': "Only administrator can view this page."}
|
||||
json_data = json.dumps(dic)
|
||||
return HttpResponse(json_data)
|
||||
|
||||
data = json.loads(request.body)
|
||||
|
||||
status = data['status']
|
||||
service = data['service']
|
||||
|
||||
mailUtilities.checkHome()
|
||||
|
||||
if service == 'powerdns':
|
||||
pdnsPath = '/home/cyberpanel/powerdns'
|
||||
if status == True:
|
||||
writeToFile = open(pdnsPath, 'w+')
|
||||
writeToFile.close()
|
||||
command = 'sudo systemctl start pdns'
|
||||
subprocess.call(shlex.split(command))
|
||||
else:
|
||||
command = 'sudo systemctl stop pdns'
|
||||
subprocess.call(shlex.split(command))
|
||||
try:
|
||||
os.remove(pdnsPath)
|
||||
except:
|
||||
pass
|
||||
|
||||
data_ret = {'status': 1, 'error_message': "None"}
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
|
||||
|
||||
except BaseException,msg:
|
||||
data_ret = {'status': 0, 'error_message': str(msg)}
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
|
||||
except KeyError,msg:
|
||||
logging.CyberCPLogFileWriter.writeToFile(str(msg))
|
||||
data_ret = {'status': 0, 'error_message': str(msg)}
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
@@ -222,6 +222,7 @@ class remoteBackup:
|
||||
|
||||
command = 'sudo rsync -avz -e "ssh -i /root/.ssh/cyberpanel -o StrictHostKeyChecking=no" ' + completedPathToSend + ' root@' + IPAddress + ':/home/backup/transfer-'+folderNumber
|
||||
subprocess.call(shlex.split(command), stdout=writeToFile)
|
||||
os.remove(completedPathToSend)
|
||||
|
||||
except BaseException, msg:
|
||||
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [startBackup]")
|
||||
|
||||
@@ -178,7 +178,7 @@ class sslUtilities:
|
||||
|
||||
try:
|
||||
logging.CyberCPLogFileWriter.writeToFile("Trying to obtain SSL for: " + virtualHostName + " and: www." + virtualHostName)
|
||||
command = "certbot certonly -n --expand --agree-tos --email " + adminEmail + " --webroot -w " + sslpath + " -d " + virtualHostName + " -d www." + virtualHostName
|
||||
command = "/usr/local/CyberCP/bin/certbot certonly -n --expand --agree-tos --email " + adminEmail + " --webroot -w " + sslpath + " -d " + virtualHostName + " -d www." + virtualHostName
|
||||
output = subprocess.check_output(shlex.split(command))
|
||||
logging.CyberCPLogFileWriter.writeToFile(
|
||||
"Successfully obtained SSL for: " + virtualHostName + " and: www." + virtualHostName)
|
||||
@@ -188,7 +188,7 @@ class sslUtilities:
|
||||
try:
|
||||
logging.CyberCPLogFileWriter.writeToFile(
|
||||
"Trying to obtain SSL for: " + virtualHostName)
|
||||
command = "certbot certonly -n --agree-tos --email " + adminEmail + " --webroot -w " + sslpath + " -d " + virtualHostName
|
||||
command = "/usr/local/CyberCP/bin/certbot certonly -n --agree-tos --email " + adminEmail + " --webroot -w " + sslpath + " -d " + virtualHostName
|
||||
output = subprocess.check_output(shlex.split(command))
|
||||
logging.CyberCPLogFileWriter.writeToFile(
|
||||
"Successfully obtained SSL for: " + virtualHostName)
|
||||
@@ -196,6 +196,8 @@ class sslUtilities:
|
||||
logging.CyberCPLogFileWriter.writeToFile('Failed to obtain SSL, issuing self-signed SSL for: ' + virtualHostName)
|
||||
return 0
|
||||
|
||||
logging.CyberCPLogFileWriter.writeToFile(command)
|
||||
|
||||
pathToStoreSSL = sslUtilities.Server_root + "/conf/vhosts/" + "SSL-" + virtualHostName
|
||||
|
||||
if not os.path.exists(pathToStoreSSL):
|
||||
@@ -260,13 +262,13 @@ class sslUtilities:
|
||||
|
||||
if serverIPAddress == ipRecordsAlias[1] and serverIPAddress == ipRecordsAlias[2]:
|
||||
|
||||
command = "certbot certonly -n --expand --agree-tos --email " + adminEmail + " --webroot -w " + sslpath + " -d " + virtualHostName + " -d www." + virtualHostName + " -d " + aliasDomain + " -d www." + aliasDomain
|
||||
command = "/usr/local/CyberCP/bin/certbot certonly -n --expand --agree-tos --email " + adminEmail + " --webroot -w " + sslpath + " -d " + virtualHostName + " -d www." + virtualHostName + " -d " + aliasDomain + " -d www." + aliasDomain
|
||||
|
||||
else:
|
||||
if serverIPAddress == ipRecordsAlias[2]:
|
||||
command = "certbot certonly -n --expand --agree-tos --email " + adminEmail + " --webroot -w " + sslpath + " -d " + virtualHostName + " -d www." + virtualHostName + " -d " + aliasDomain
|
||||
command = "/usr/local/CyberCP/bin/certbot certonly -n --expand --agree-tos --email " + adminEmail + " --webroot -w " + sslpath + " -d " + virtualHostName + " -d www." + virtualHostName + " -d " + aliasDomain
|
||||
else:
|
||||
command = "certbot certonly -n --expand --agree-tos --email " + adminEmail + " --webroot -w " + sslpath + " -d " + virtualHostName + " -d www." + virtualHostName
|
||||
command = "/usr/local/CyberCP/bin/certbot certonly -n --expand --agree-tos --email " + adminEmail + " --webroot -w " + sslpath + " -d " + virtualHostName + " -d www." + virtualHostName
|
||||
|
||||
else:
|
||||
if serverIPAddress == ipRecords[2]:
|
||||
@@ -275,13 +277,13 @@ class sslUtilities:
|
||||
|
||||
if serverIPAddress == ipRecordsAlias[1] and serverIPAddress == ipRecordsAlias[2]:
|
||||
|
||||
command = "certbot certonly -n --expand --agree-tos --email " + adminEmail + " --webroot -w " + sslpath + " -d " + virtualHostName + " -d " + aliasDomain + " -d www." + aliasDomain
|
||||
command = "/usr/local/CyberCP/bin/certbot certonly -n --expand --agree-tos --email " + adminEmail + " --webroot -w " + sslpath + " -d " + virtualHostName + " -d " + aliasDomain + " -d www." + aliasDomain
|
||||
|
||||
else:
|
||||
if serverIPAddress == ipRecordsAlias[2]:
|
||||
command = "certbot certonly -n --expand --agree-tos --email " + adminEmail + " --webroot -w " + sslpath + " -d " + virtualHostName + " -d " + aliasDomain
|
||||
command = "/usr/local/CyberCP/bin/certbot certonly -n --expand --agree-tos --email " + adminEmail + " --webroot -w " + sslpath + " -d " + virtualHostName + " -d " + aliasDomain
|
||||
else:
|
||||
command = "certbot certonly -n --expand --agree-tos --email " + adminEmail + " --webroot -w " + sslpath + " -d " + virtualHostName
|
||||
command = "/usr/local/CyberCP/bin/certbot certonly -n --expand --agree-tos --email " + adminEmail + " --webroot -w " + sslpath + " -d " + virtualHostName
|
||||
|
||||
logging.CyberCPLogFileWriter.writeToFile(
|
||||
"SSL is issued without 'www' due to DNS error for domain : " + virtualHostName)
|
||||
@@ -290,10 +292,10 @@ class sslUtilities:
|
||||
ipRecordsAlias = sslUtilities.getDNSRecords(aliasDomain)
|
||||
|
||||
if serverIPAddress == ipRecordsAlias[1] and serverIPAddress == ipRecordsAlias[2]:
|
||||
command = "certbot certonly -n --expand --agree-tos --email " + adminEmail + " --webroot -w " + sslpath + " -d " + aliasDomain + " -d www." + aliasDomain
|
||||
command = "/usr/local/CyberCP/bin/certbot certonly -n --expand --agree-tos --email " + adminEmail + " --webroot -w " + sslpath + " -d " + aliasDomain + " -d www." + aliasDomain
|
||||
else:
|
||||
if serverIPAddress == ipRecordsAlias[2]:
|
||||
command = "certbot certonly -n --expand --agree-tos --email " + adminEmail + " --webroot -w " + sslpath + " -d " + aliasDomain
|
||||
command = "/usr/local/CyberCP/bin/certbot certonly -n --expand --agree-tos --email " + adminEmail + " --webroot -w " + sslpath + " -d " + aliasDomain
|
||||
else:
|
||||
return 0
|
||||
else:
|
||||
|
||||
@@ -238,6 +238,32 @@ WantedBy=multi-user.target"""
|
||||
command = "chmod -R 777 /usr/local/lsws/Example/html/FileManager"
|
||||
subprocess.call(shlex.split(command))
|
||||
|
||||
@staticmethod
|
||||
def setupCLI():
|
||||
try:
|
||||
count = 0
|
||||
while (1):
|
||||
command = "ln -s /usr/local/CyberCP/cli/cyberPanel.py /usr/bin/cyberpanel"
|
||||
res = subprocess.call(shlex.split(command))
|
||||
|
||||
if res == 1:
|
||||
count = count + 1
|
||||
Upgrade.stdOut(
|
||||
"Trying to setup CLI, trying again, try number: " + str(count))
|
||||
if count == 3:
|
||||
Upgrade.stdOut(
|
||||
"Failed to setup CLI! [setupCLI]")
|
||||
else:
|
||||
Upgrade.stdOut("CLI setup successfull!")
|
||||
break
|
||||
|
||||
command = "chmod +x /usr/local/CyberCP/cli/cyberPanel.py"
|
||||
res = subprocess.call(shlex.split(command))
|
||||
|
||||
except OSError, msg:
|
||||
Upgrade.stdOut(str(msg) + " [setupCLI]")
|
||||
return 0
|
||||
|
||||
@staticmethod
|
||||
def staticContent():
|
||||
count = 1
|
||||
@@ -495,6 +521,7 @@ WantedBy=multi-user.target"""
|
||||
## Upgrade OpenLiteSpeed
|
||||
|
||||
Upgrade.upgradeOpenLiteSpeed()
|
||||
Upgrade.setupCLI()
|
||||
time.sleep(3)
|
||||
|
||||
## Upgrade version
|
||||
|
||||
1094
static/manageServices/manageServices.js
Normal file
1094
static/manageServices/manageServices.js
Normal file
File diff suppressed because it is too large
Load Diff
@@ -403,25 +403,21 @@ app.controller('servicesManager', function($scope,$http) {
|
||||
if(response.data.serviceAction == 1){
|
||||
setTimeout(function() {
|
||||
getServiceStatus();
|
||||
setTimeout(function() {
|
||||
$scope.ActionSuccessfull = true;
|
||||
$scope.ActionFailed = false;
|
||||
$scope.couldNotConnect = false;
|
||||
$scope.actionLoader = false;
|
||||
$scope.btnDisable = false;
|
||||
},1000)
|
||||
}, 3000);
|
||||
}
|
||||
else{
|
||||
setTimeout(function() {
|
||||
getServiceStatus();
|
||||
setTimeout(function() {
|
||||
$scope.ActionSuccessfull = false;
|
||||
$scope.ActionFailed = true;
|
||||
$scope.couldNotConnect = false;
|
||||
$scope.actionLoader = false;
|
||||
$scope.btnDisable = false;
|
||||
},1000)
|
||||
}, 5000);
|
||||
|
||||
}
|
||||
|
||||
@@ -38,9 +38,8 @@ def loadWebsitesHome(request):
|
||||
def createWebsite(request):
|
||||
try:
|
||||
val = request.session['userID']
|
||||
try:
|
||||
admin = Administrator.objects.get(pk=val)
|
||||
|
||||
try:
|
||||
if admin.type == 3:
|
||||
return HttpResponse("Not enough privileges.")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user