diff --git a/CLManager/CLManagerMain.py b/CLManager/CLManagerMain.py
new file mode 100644
index 000000000..6a58cbb64
--- /dev/null
+++ b/CLManager/CLManagerMain.py
@@ -0,0 +1,191 @@
+import threading as multi
+from plogical.acl import ACLManager
+import plogical.CyberCPLogFileWriter as logging
+from plogical.processUtilities import ProcessUtilities
+from django.shortcuts import render
+import os
+from serverStatus.serverStatusUtil import ServerStatusUtil
+import json
+from django.shortcuts import HttpResponse
+from math import ceil
+from websiteFunctions.models import Websites
+from .models import CLPackages
+
+
+class CLManagerMain(multi.Thread):
+
+ def __init__(self, request=None, templateName=None, function=None, data=None):
+ multi.Thread.__init__(self)
+ self.request = request
+ self.templateName = templateName
+ self.function = function
+ self.data = data
+
+ def run(self):
+ try:
+ if self.function == 'submitCageFSInstall':
+ self.submitCageFSInstall()
+ elif self.function == 'enableOrDisable':
+ self.enableOrDisable()
+
+ except BaseException, msg:
+ logging.CyberCPLogFileWriter.writeToFile(str(msg) + ' [ContainerManager.run]')
+
+ def renderC(self):
+
+ userID = self.request.session['userID']
+ currentACL = ACLManager.loadedACL(userID)
+
+ if currentACL['admin'] == 1:
+ pass
+ else:
+ return ACLManager.loadError()
+
+ data = {}
+ data['CL'] = 0
+ data['CAGEFS'] = 0
+ CLPath = '/etc/sysconfig/cloudlinux'
+ CageFSPath = '/usr/sbin/cagefsctl'
+
+ if os.path.exists(CLPath):
+ data['CL'] = 1
+
+ if os.path.exists(CageFSPath):
+ data['CAGEFS'] = 1
+
+ if data['CL'] == 0:
+ return render(self.request, 'CLManager/notAvailable.html', data)
+ elif data['CAGEFS'] == 0:
+ return render(self.request, 'CLManager/notAvailable.html', data)
+ else:
+ return render(self.request, self.templateName, self.data)
+
+ def submitCageFSInstall(self):
+ try:
+ userID = self.request.session['userID']
+ currentACL = ACLManager.loadedACL(userID)
+
+ if currentACL['admin'] == 1:
+ pass
+ else:
+ logging.CyberCPLogFileWriter.statusWriter(ServerStatusUtil.lswsInstallStatusPath,
+ 'Not authorized to install container packages. [404].',
+ 1)
+ return 0
+
+ execPath = "sudo python /usr/local/CyberCP/CLManager/CageFS.py"
+ execPath = execPath + " --function submitCageFSInstall"
+ ProcessUtilities.outputExecutioner(execPath)
+
+ except BaseException, msg:
+ logging.CyberCPLogFileWriter.statusWriter(ServerStatusUtil.lswsInstallStatusPath, str(msg) + ' [404].', 1)
+
+ def findWebsitesJson(self, currentACL, userID, pageNumber):
+ finalPageNumber = ((pageNumber * 10)) - 10
+ endPageNumber = finalPageNumber + 10
+ websites = ACLManager.findWebsiteObjects(currentACL, userID)[finalPageNumber:endPageNumber]
+
+ json_data = "["
+ checker = 0
+
+ command = '/usr/sbin/cagefsctl --list-enabled'
+ Enabled = ProcessUtilities.outputExecutioner(command)
+
+ for items in websites:
+ if Enabled.find(items.externalApp) > -1:
+ status = 1
+ else:
+ status = 0
+ dic = {'domain': items.domain, 'externalApp': items.externalApp, 'status': status}
+
+ if checker == 0:
+ json_data = json_data + json.dumps(dic)
+ checker = 1
+ else:
+ json_data = json_data + ',' + json.dumps(dic)
+
+ json_data = json_data + ']'
+
+ return json_data
+
+ def websitePagination(self, currentACL, userID):
+ websites = ACLManager.findAllSites(currentACL, userID)
+
+ pages = float(len(websites)) / float(10)
+ pagination = []
+
+ if pages <= 1.0:
+ pages = 1
+ pagination.append('
')
+ else:
+ pages = ceil(pages)
+ finalPages = int(pages) + 1
+
+ for i in range(1, finalPages):
+ pagination.append('' + str(i) + ' ')
+
+ return pagination
+
+ def getFurtherAccounts(self, userID=None, data=None):
+ try:
+ currentACL = ACLManager.loadedACL(userID)
+ pageNumber = int(data['page'])
+ json_data = self.findWebsitesJson(currentACL, userID, pageNumber)
+ pagination = self.websitePagination(currentACL, userID)
+
+ cageFSPath = '/home/cyberpanel/cagefs'
+
+ if os.path.exists(cageFSPath):
+ default = 'On'
+ else:
+ default = 'Off'
+
+ final_dic = {'status': 1, 'listWebSiteStatus': 1, 'error_message': "None", "data": json_data,
+ 'pagination': pagination, 'default': default}
+ final_json = json.dumps(final_dic)
+ return HttpResponse(final_json)
+ except BaseException, msg:
+ dic = {'status': 1, 'listWebSiteStatus': 0, 'error_message': str(msg)}
+ json_data = json.dumps(dic)
+ return HttpResponse(json_data)
+
+ def enableOrDisable(self):
+ try:
+ websites = Websites.objects.all()
+ if self.data['mode'] == 1:
+ for items in websites:
+ command = '/usr/sbin/cagefsctl --enable %s' % (items.externalApp)
+ ProcessUtilities.executioner(command)
+ else:
+ for items in websites:
+ command = '/usr/sbin/cagefsctl --disable %s' % (items.externalApp)
+ ProcessUtilities.executioner(command)
+ except BaseException, msg:
+ logging.CyberCPLogFileWriter.writeToFile(str(msg))
+
+ def fetchPackages(self, currentACL):
+
+ if currentACL['admin'] == 1:
+ pass
+ else:
+ return ACLManager.loadErrorJson()
+
+ json_data = "["
+ checker = 0
+
+ for items in CLPackages.objects.all():
+ dic = {'name': items.name, 'SPEED': items.speed, 'VMEM': items.vmem, 'PMEM': items.pmem, 'IO': items.io, 'IOPS': items.iops, 'EP': items.ep,
+ 'NPROC': items.nproc, 'inodessoft': items.inodessoft, 'inodeshard': items.inodeshard}
+
+ if checker == 0:
+ json_data = json_data + json.dumps(dic)
+ checker = 1
+ else:
+ json_data = json_data + ',' + json.dumps(dic)
+
+ json_data = json_data + ']'
+
+ final_dic = {'status': 1, 'error_message': "None", "data": json_data}
+ final_json = json.dumps(final_dic)
+ return HttpResponse(final_json)
+
diff --git a/CLManager/CLPackages.py b/CLManager/CLPackages.py
new file mode 100755
index 000000000..951acbee7
--- /dev/null
+++ b/CLManager/CLPackages.py
@@ -0,0 +1,82 @@
+#!/usr/local/CyberCP/bin/python2
+import os
+import os.path
+import sys
+import django
+sys.path.append('/usr/local/CyberCP')
+os.environ.setdefault("DJANGO_SETTINGS_MODULE", "CyberCP.settings")
+django.setup()
+import argparse
+from websiteFunctions.models import Websites
+from CLManager.models import CLPackages
+import pwd
+
+class CLinuxPackages:
+
+ @staticmethod
+ def listAll():
+ for items in Websites.objects.all():
+ itemPackage = items.package
+ try:
+ clPackage = CLPackages.objects.get(owner=itemPackage)
+ statement = '%s %s' % (pwd.getpwnam(items.externalApp).pw_uid, clPackage.name)
+ print statement
+ except:
+ pass
+
+
+ @staticmethod
+ def listPackages():
+ for items in CLPackages.objects.all():
+ print items.name
+
+ @staticmethod
+ def userIDPackage(user):
+ website = Websites.objects.get(externalApp=user)
+ itemPackage = website.package
+ try:
+ clPackage = CLPackages.objects.get(owner=itemPackage)
+ print clPackage
+ except:
+ pass
+
+
+ @staticmethod
+ def packageForUser(package):
+ for items in Websites.objects.all():
+ itemPackage = items.package
+ try:
+ clPackage = CLPackages.objects.get(owner=itemPackage)
+ if clPackage.name == package:
+ print pwd.getpwnam(items.externalApp).pw_uid
+ except:
+ pass
+
+def main():
+
+ parser = argparse.ArgumentParser(description='CyberPanel Container Manager')
+ parser.add_argument('--userid', help='User ID')
+ parser.add_argument('--package', help='Package')
+ parser.add_argument('--function', help='Function')
+ parser.add_argument('--list-all', help='List all users/packages.', action='store_true')
+ parser.add_argument('--list-packages', help='List all packages.', action='store_true')
+
+
+ args = vars(parser.parse_args())
+
+ if args['userid']:
+ CLinuxPackages.userIDPackage(args['userid'])
+ elif args['package']:
+ CLinuxPackages.packageForUser(args['package'])
+ elif args['list_all']:
+ CLinuxPackages.listAll()
+ elif args['list_packages']:
+ CLinuxPackages.listPackages()
+
+
+
+
+
+if __name__ == "__main__":
+ main()
+
diff --git a/CLManager/CageFS.py b/CLManager/CageFS.py
new file mode 100644
index 000000000..1fb87ff24
--- /dev/null
+++ b/CLManager/CageFS.py
@@ -0,0 +1,60 @@
+#!/usr/local/CyberCP/bin/python2
+import sys
+sys.path.append('/usr/local/CyberCP')
+import plogical.CyberCPLogFileWriter as logging
+import argparse
+from plogical.mailUtilities import mailUtilities
+from serverStatus.serverStatusUtil import ServerStatusUtil
+
+
+class CageFS:
+ packages = ['talksho']
+ users = ['5001']
+
+ @staticmethod
+ def submitCageFSInstall():
+ try:
+
+ mailUtilities.checkHome()
+
+ statusFile = open(ServerStatusUtil.lswsInstallStatusPath, 'w')
+
+ logging.CyberCPLogFileWriter.statusWriter(ServerStatusUtil.lswsInstallStatusPath,
+ "Starting Packages Installation..\n", 1)
+
+ command = 'sudo yum install cagefs -y'
+ ServerStatusUtil.executioner(command, statusFile)
+
+ command = 'sudo /usr/sbin/cagefsctl --init'
+ ServerStatusUtil.executioner(command, statusFile)
+
+ command = 'sudo /usr/sbin/cagefsctl --update-etc'
+ ServerStatusUtil.executioner(command, statusFile)
+
+ command = 'sudo /usr/sbin/cagefsctl --force-update'
+ ServerStatusUtil.executioner(command, statusFile)
+
+ logging.CyberCPLogFileWriter.statusWriter(ServerStatusUtil.lswsInstallStatusPath,
+ "Packages successfully installed.[200]\n", 1)
+
+ except BaseException, msg:
+ logging.CyberCPLogFileWriter.statusWriter(ServerStatusUtil.lswsInstallStatusPath, str(msg) + ' [404].', 1)
+
+def main():
+
+ parser = argparse.ArgumentParser(description='CyberPanel CageFS Manager')
+ parser.add_argument('--function', help='Function')
+
+
+ args = vars(parser.parse_args())
+
+ if args["function"] == "submitCageFSInstall":
+ CageFS.submitCageFSInstall()
+
+
+
+
+
+if __name__ == "__main__":
+ main()
+
diff --git a/CLManager/__init__.py b/CLManager/__init__.py
new file mode 100644
index 000000000..e69de29bb
diff --git a/CLManager/admin.py b/CLManager/admin.py
new file mode 100644
index 000000000..13be29d96
--- /dev/null
+++ b/CLManager/admin.py
@@ -0,0 +1,6 @@
+# -*- coding: utf-8 -*-
+from __future__ import unicode_literals
+
+from django.contrib import admin
+
+# Register your models here.
diff --git a/CLManager/apps.py b/CLManager/apps.py
new file mode 100644
index 000000000..1f97e1e94
--- /dev/null
+++ b/CLManager/apps.py
@@ -0,0 +1,8 @@
+# -*- coding: utf-8 -*-
+from __future__ import unicode_literals
+
+from django.apps import AppConfig
+
+
+class ClmanagerConfig(AppConfig):
+ name = 'CLManager'
diff --git a/CLManager/migrations/__init__.py b/CLManager/migrations/__init__.py
new file mode 100644
index 000000000..e69de29bb
diff --git a/CLManager/models.py b/CLManager/models.py
new file mode 100644
index 000000000..cdbab13b0
--- /dev/null
+++ b/CLManager/models.py
@@ -0,0 +1,20 @@
+# -*- coding: utf-8 -*-
+from __future__ import unicode_literals
+
+from django.db import models
+from packages.models import Package
+
+# Create your models here.
+
+class CLPackages(models.Model):
+ owner = models.ForeignKey(Package)
+ name = models.CharField(max_length=50,unique=True)
+ speed = models.CharField(max_length=50)
+ vmem = models.CharField(max_length=50)
+ pmem = models.CharField(max_length=50)
+ io = models.CharField(max_length=50)
+ iops = models.CharField(max_length=50)
+ ep = models.CharField(max_length=50)
+ nproc = models.CharField(max_length=50)
+ inodessoft = models.CharField(max_length=50)
+ inodeshard = models.CharField(max_length=50)
\ No newline at end of file
diff --git a/CLManager/static/CLManager/CLManager.js b/CLManager/static/CLManager/CLManager.js
new file mode 100644
index 000000000..547a407d5
--- /dev/null
+++ b/CLManager/static/CLManager/CLManager.js
@@ -0,0 +1,934 @@
+app.controller('installCageFS', function ($scope, $http, $timeout, $window) {
+
+ $scope.installDockerStatus = true;
+ $scope.installBoxGen = true;
+ $scope.dockerInstallBTN = false;
+
+ $scope.submitCageFSInstall = function () {
+
+ $scope.installDockerStatus = false;
+ $scope.installBoxGen = true;
+ $scope.dockerInstallBTN = true;
+
+ url = "/CloudLinux/submitCageFSInstall";
+
+ var data = {};
+ var config = {
+ headers: {
+ 'X-CSRFToken': getCookie('csrftoken')
+ }
+ };
+
+
+ $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
+
+
+ function ListInitialDatas(response) {
+ $scope.cyberPanelLoading = true;
+ if (response.data.status === 1) {
+ $scope.installBoxGen = false;
+ getRequestStatus();
+ } else {
+ new PNotify({
+ title: 'Operation Failed!',
+ text: response.data.error_message,
+ type: 'error'
+ });
+ }
+
+ }
+
+ function cantLoadInitialDatas(response) {
+ $scope.cyberPanelLoading = true;
+ new PNotify({
+ title: 'Operation Failed!',
+ text: 'Could not connect to server, please refresh this page',
+ type: 'error'
+ });
+ }
+
+ };
+
+ function getRequestStatus() {
+ $scope.cyberPanelLoading = false;
+
+ url = "/serverstatus/switchTOLSWSStatus";
+
+ var data = {};
+
+ var config = {
+ headers: {
+ 'X-CSRFToken': getCookie('csrftoken')
+ }
+ };
+
+
+ $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
+
+
+ function ListInitialDatas(response) {
+ if (response.data.abort === 0) {
+ $scope.requestData = response.data.requestStatus;
+ $timeout(getRequestStatus, 1000);
+ } else {
+ // Notifications
+ $scope.cyberPanelLoading = true;
+ $timeout.cancel();
+ $scope.requestData = response.data.requestStatus;
+ if (response.data.installed === 1) {
+ $timeout(function () {
+ $window.location.reload();
+ }, 3000);
+ }
+
+ }
+ }
+
+ function cantLoadInitialDatas(response) {
+ $scope.cyberPanelLoading = true;
+ new PNotify({
+ title: 'Operation Failed!',
+ text: 'Could not connect to server, please refresh this page',
+ type: 'error'
+ });
+
+
+ }
+
+ }
+});
+
+app.controller('listWebsitesCage', function ($scope, $http) {
+
+ var globalPageNumber;
+ $scope.getFurtherWebsitesFromDB = function (pageNumber) {
+ $scope.cyberPanelLoading = false;
+ globalPageNumber = pageNumber;
+
+ var config = {
+ headers: {
+ 'X-CSRFToken': getCookie('csrftoken')
+ }
+ };
+
+ var data = {page: pageNumber};
+
+
+ dataurl = "/CloudLinux/submitWebsiteListing";
+
+ $http.post(dataurl, data, config).then(ListInitialData, cantLoadInitialData);
+
+
+ function ListInitialData(response) {
+ $scope.cyberPanelLoading = true;
+ if (response.data.listWebSiteStatus === 1) {
+ var finalData = JSON.parse(response.data.data);
+ $scope.WebSitesList = finalData;
+ $scope.pagination = response.data.pagination;
+ $scope.default = response.data.default;
+ $("#listFail").hide();
+ } else {
+ $("#listFail").fadeIn();
+ $scope.errorMessage = response.data.error_message;
+ console.log(response.data);
+
+ }
+ }
+
+ function cantLoadInitialData(response) {
+ $scope.cyberPanelLoading = true;
+ console.log("not good");
+ }
+
+
+ };
+ $scope.getFurtherWebsitesFromDB(1);
+
+ $scope.cyberPanelLoading = true;
+
+ $scope.searchWebsites = function () {
+
+ $scope.cyberPanelLoading = false;
+
+ var config = {
+ headers: {
+ 'X-CSRFToken': getCookie('csrftoken')
+ }
+ };
+
+ var data = {
+ patternAdded: $scope.patternAdded
+ };
+
+ dataurl = "/websites/searchWebsites";
+
+ $http.post(dataurl, data, config).then(ListInitialData, cantLoadInitialData);
+
+
+ function ListInitialData(response) {
+ $scope.cyberPanelLoading = true;
+ if (response.data.listWebSiteStatus === 1) {
+
+ var finalData = JSON.parse(response.data.data);
+ $scope.WebSitesList = finalData;
+ $("#listFail").hide();
+ } else {
+ new PNotify({
+ title: 'Operation Failed!',
+ text: response.data.error_message,
+ type: 'error'
+ });
+
+ }
+ }
+
+ function cantLoadInitialData(response) {
+ $scope.cyberPanelLoading = true;
+ new PNotify({
+ title: 'Operation Failed!',
+ text: 'Connect disrupted, refresh the page.',
+ type: 'error'
+ });
+ }
+
+
+ };
+
+ $scope.enableOrDisable = function (domain, all, mode, toggle = 0) {
+ $scope.cyberPanelLoading = false;
+
+ url = "/CloudLinux/enableOrDisable";
+
+ var data = {
+ domain: domain,
+ all: all,
+ mode: mode,
+ toggle: toggle
+ };
+ var config = {
+ headers: {
+ 'X-CSRFToken': getCookie('csrftoken')
+ }
+ };
+
+
+ $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
+
+
+ function ListInitialDatas(response) {
+ $scope.cyberPanelLoading = true;
+ if (response.data.status === 1) {
+ new PNotify({
+ title: 'Success',
+ text: response.data.success,
+ type: 'success'
+ });
+
+ if (all === 0) {
+ $scope.getFurtherWebsitesFromDB(globalPageNumber);
+ }
+ } else {
+ new PNotify({
+ title: 'Operation Failed!',
+ text: response.data.error_message,
+ type: 'error'
+ });
+ }
+
+ }
+
+ function cantLoadInitialDatas(response) {
+ $scope.cyberPanelLoading = true;
+ new PNotify({
+ title: 'Operation Failed!',
+ text: 'Could not connect to server, please refresh this page',
+ type: 'error'
+ });
+ }
+
+ };
+
+ $scope.refreshStatus = function () {
+ $scope.getFurtherWebsitesFromDB(globalPageNumber);
+ }
+
+
+});
+
+app.controller('createCLPackage', function ($scope, $http) {
+
+ $scope.cyberPanelLoading = true;
+ $scope.modifyPackageForm = true;
+ $scope.toggleView = function () {
+ $scope.modifyPackageForm = false;
+ };
+
+ $scope.createPackage = function () {
+ $scope.cyberPanelLoading = false;
+
+ url = "/CloudLinux/submitCreatePackage";
+
+ var data = {
+ selectedPackage: $scope.selectedPackage,
+ name: $scope.name,
+ SPEED: $scope.SPEED,
+ VMEM: $scope.VMEM,
+ PMEM: $scope.PMEM,
+ IO: $scope.IO,
+ IOPS: $scope.IOPS,
+ EP: $scope.EP,
+ NPROC: $scope.NPROC,
+ INODESsoft: $scope.INODESsoft,
+ INODEShard: $scope.INODEShard,
+ };
+ var config = {
+ headers: {
+ 'X-CSRFToken': getCookie('csrftoken')
+ }
+ };
+
+
+ $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
+
+
+ function ListInitialDatas(response) {
+ $scope.cyberPanelLoading = true;
+ if (response.data.status === 1) {
+ new PNotify({
+ title: 'Success',
+ text: 'Successfully created.',
+ type: 'success'
+ });
+ } else {
+ new PNotify({
+ title: 'Operation Failed!',
+ text: response.data.error_message,
+ type: 'error'
+ });
+ }
+
+ }
+
+ function cantLoadInitialDatas(response) {
+ $scope.cyberPanelLoading = true;
+ new PNotify({
+ title: 'Operation Failed!',
+ text: 'Could not connect to server, please refresh this page',
+ type: 'error'
+ });
+ }
+
+ };
+
+});
+
+app.controller('listCloudLinuxPackages', function ($scope, $http) {
+
+ $scope.cyberPanelLoading = true;
+
+ $scope.fetchPackageas = function () {
+ $scope.cyberPanelLoading = false;
+
+ var config = {
+ headers: {
+ 'X-CSRFToken': getCookie('csrftoken')
+ }
+ };
+
+ var data = {};
+
+
+ dataurl = "/CloudLinux/fetchPackages";
+
+ $http.post(dataurl, data, config).then(ListInitialData, cantLoadInitialData);
+
+
+ function ListInitialData(response) {
+ $scope.cyberPanelLoading = true;
+ if (response.data.status === 1) {
+ $scope.packages = JSON.parse(response.data.data);
+ } else {
+ new PNotify({
+ title: 'Operation Failed!',
+ text: response.data.error_message,
+ type: 'error'
+ });
+ }
+ }
+
+ function cantLoadInitialData(response) {
+ $scope.cyberPanelLoading = true;
+ new PNotify({
+ title: 'Operation Failed!',
+ text: 'Could not connect to server, please refresh this page',
+ type: 'error'
+ });
+ }
+
+
+ };
+ $scope.fetchPackageas();
+
+ $scope.deleteCLPackage = function (name) {
+ $scope.cyberPanelLoading = false;
+
+ url = "/CloudLinux/deleteCLPackage";
+
+ var data = {
+ name: name
+ };
+ var config = {
+ headers: {
+ 'X-CSRFToken': getCookie('csrftoken')
+ }
+ };
+
+
+ $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
+
+
+ function ListInitialDatas(response) {
+ $scope.cyberPanelLoading = true;
+ if (response.data.status === 1) {
+ new PNotify({
+ title: 'Success',
+ text: 'Successfully deleted.',
+ type: 'success'
+ });
+ $scope.fetchPackageas();
+ } else {
+ new PNotify({
+ title: 'Operation Failed!',
+ text: response.data.error_message,
+ type: 'error'
+ });
+ }
+
+ }
+
+ function cantLoadInitialDatas(response) {
+ $scope.cyberPanelLoading = true;
+ new PNotify({
+ title: 'Operation Failed!',
+ text: 'Could not connect to server, please refresh this page',
+ type: 'error'
+ });
+ }
+
+ };
+ $scope.populatePackage = function (name, speed, vmem, pmem, io, iops, ep, nproc, inodessoft, inodeshard) {
+ $scope.name = name;
+ $scope.SPEED = speed;
+ $scope.VMEM = vmem;
+ $scope.PMEM = pmem;
+ $scope.IO = io;
+ $scope.IOPS = iops;
+ $scope.EP = ep;
+ $scope.NPROC = nproc;
+ $scope.inodessoft = inodessoft;
+ $scope.inodeshard = inodeshard;
+
+ };
+
+ $scope.saveSettings = function () {
+ $scope.cyberPanelLoading = false;
+
+ url = "/CloudLinux/saveSettings";
+
+ var data = {
+ name: $scope.name,
+ SPEED: $scope.SPEED,
+ VMEM: $scope.VMEM,
+ PMEM: $scope.PMEM,
+ IO: $scope.IO,
+ IOPS: $scope.IOPS,
+ EP: $scope.EP,
+ NPROC: $scope.NPROC,
+ INODESsoft: $scope.inodessoft,
+ INODEShard: $scope.inodeshard,
+ };
+ var config = {
+ headers: {
+ 'X-CSRFToken': getCookie('csrftoken')
+ }
+ };
+
+
+ $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
+
+
+ function ListInitialDatas(response) {
+ $scope.cyberPanelLoading = true;
+ if (response.data.status === 1) {
+ new PNotify({
+ title: 'Success',
+ text: 'Changes successfully applied.',
+ type: 'success'
+ });
+ $scope.fetchPackageas();
+ } else {
+ new PNotify({
+ title: 'Operation Failed!',
+ text: response.data.error_message,
+ type: 'error'
+ });
+ }
+
+ }
+
+ function cantLoadInitialDatas(response) {
+ $scope.cyberPanelLoading = true;
+ new PNotify({
+ title: 'Operation Failed!',
+ text: 'Could not connect to server, please refresh this page',
+ type: 'error'
+ });
+ }
+
+ };
+
+});
+
+
+app.controller('websiteContainerLimitCL', function ($scope, $http, $timeout, $window) {
+
+
+ // Get CPU Usage of User
+
+ var cpu = [];
+ var dataset;
+ var totalPoints = 100;
+ var updateInterval = 1000;
+ var now = new Date().getTime();
+
+ var options = {
+ series: {
+ lines: {
+ lineWidth: 1.2
+ },
+ bars: {
+ align: "center",
+ fillColor: {colors: [{opacity: 1}, {opacity: 1}]},
+ barWidth: 500,
+ lineWidth: 1
+ }
+ },
+ xaxis: {
+ mode: "time",
+ tickSize: [5, "second"],
+ tickFormatter: function (v, axis) {
+ var date = new Date(v);
+
+ if (date.getSeconds() % 20 == 0) {
+ var hours = date.getHours() < 10 ? "0" + date.getHours() : date.getHours();
+ var minutes = date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes();
+ var seconds = date.getSeconds() < 10 ? "0" + date.getSeconds() : date.getSeconds();
+
+ return hours + ":" + minutes + ":" + seconds;
+ } else {
+ return "";
+ }
+ },
+ axisLabel: "Time",
+ axisLabelUseCanvas: true,
+ axisLabelFontSizePixels: 12,
+ axisLabelFontFamily: 'Verdana, Arial',
+ axisLabelPadding: 10
+ },
+ yaxes: [
+ {
+ min: 0,
+ max: 100,
+ tickSize: 5,
+ tickFormatter: function (v, axis) {
+ if (v % 10 == 0) {
+ return v + "%";
+ } else {
+ return "";
+ }
+ },
+ axisLabel: "CPU loading",
+ axisLabelUseCanvas: true,
+ axisLabelFontSizePixels: 12,
+ axisLabelFontFamily: 'Verdana, Arial',
+ axisLabelPadding: 6
+ }, {
+ max: 5120,
+ position: "right",
+ axisLabel: "Disk",
+ axisLabelUseCanvas: true,
+ axisLabelFontSizePixels: 12,
+ axisLabelFontFamily: 'Verdana, Arial',
+ axisLabelPadding: 6
+ }
+ ],
+ legend: {
+ noColumns: 0,
+ position: "nw"
+ },
+ grid: {
+ backgroundColor: {colors: ["#ffffff", "#EDF5FF"]}
+ }
+ };
+
+ function initData() {
+ for (var i = 0; i < totalPoints; i++) {
+ var temp = [now += updateInterval, 0];
+
+ cpu.push(temp);
+ }
+ }
+
+ function GetData() {
+
+ var data = {
+ domain: $("#domain").text()
+ };
+ $.ajaxSetup({cache: false});
+
+ $.ajax({
+ url: "/CloudLinux/getUsageData",
+ dataType: 'json',
+ success: update,
+ type: "POST",
+ headers: {'X-CSRFToken': getCookie('csrftoken')},
+ contentType: "application/json",
+ data: JSON.stringify(data), // Our valid JSON string
+ error: function () {
+ setTimeout(GetData, updateInterval);
+ }
+ });
+ }
+
+ var temp;
+
+ function update(_data) {
+ cpu.shift();
+
+ now += updateInterval;
+
+ temp = [now, _data.cpu];
+ cpu.push(temp);
+
+
+ dataset = [
+ {label: "CPU:" + _data.cpu + "%", data: cpu, lines: {fill: true, lineWidth: 1.2}, color: "#00FF00"}
+ ];
+
+ $.plot($("#flot-placeholder1"), dataset, options);
+ setTimeout(GetData, updateInterval);
+ }
+
+ // Memory Usage of User
+
+ var memory = [];
+ var datasetMemory;
+ var totalPointsMemory = 100;
+ var updateIntervalMemory = 1000;
+ var nowMemory = new Date().getTime();
+
+ var optionsMemory = {
+ series: {
+ lines: {
+ lineWidth: 1.2
+ },
+ bars: {
+ align: "center",
+ fillColor: {colors: [{opacity: 1}, {opacity: 1}]},
+ barWidth: 500,
+ lineWidth: 1
+ }
+ },
+ xaxis: {
+ mode: "time",
+ tickSize: [5, "second"],
+ tickFormatter: function (v, axis) {
+ var date = new Date(v);
+
+ if (date.getSeconds() % 20 == 0) {
+ var hours = date.getHours() < 10 ? "0" + date.getHours() : date.getHours();
+ var minutes = date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes();
+ var seconds = date.getSeconds() < 10 ? "0" + date.getSeconds() : date.getSeconds();
+
+ return hours + ":" + minutes + ":" + seconds;
+ } else {
+ return "";
+ }
+ },
+ axisLabel: "Time",
+ axisLabelUseCanvas: true,
+ axisLabelFontSizePixels: 12,
+ axisLabelFontFamily: 'Verdana, Arial',
+ axisLabelPadding: 10
+ },
+ yaxes: [
+ {
+ min: 0,
+ max: $scope.memory,
+ tickSize: 5,
+ tickFormatter: function (v, axis) {
+ if (v % 10 == 0) {
+ return v + "MB";
+ } else {
+ return "";
+ }
+ },
+ axisLabel: "CPU loading",
+ axisLabelUseCanvas: true,
+ axisLabelFontSizePixels: 12,
+ axisLabelFontFamily: 'Verdana, Arial',
+ axisLabelPadding: 6
+ }, {
+ max: 5120,
+ position: "right",
+ axisLabel: "Disk",
+ axisLabelUseCanvas: true,
+ axisLabelFontSizePixels: 12,
+ axisLabelFontFamily: 'Verdana, Arial',
+ axisLabelPadding: 6
+ }
+ ],
+ legend: {
+ noColumns: 0,
+ position: "nw"
+ },
+ grid: {
+ backgroundColor: {colors: ["#ffffff", "#EDF5FF"]}
+ }
+ };
+
+ function initDataMemory() {
+ for (var i = 0; i < totalPointsMemory; i++) {
+ var temp = [nowMemory += updateIntervalMemory, 0];
+
+ memory.push(temp);
+ }
+ }
+
+ function GetDataMemory() {
+
+ var data = {
+ domain: $("#domain").text(),
+ type: 'memory'
+ };
+ $.ajaxSetup({cache: false});
+
+ $.ajax({
+ url: "/CloudLinux/getUsageData",
+ dataType: 'json',
+ headers: {'X-CSRFToken': getCookie('csrftoken')},
+ success: updateMemory,
+ type: "POST",
+ contentType: "application/json",
+ data: JSON.stringify(data), // Our valid JSON string
+ error: function () {
+ setTimeout(GetDataMemory, updateIntervalMemory);
+ }
+ });
+ }
+
+ var tempMemory;
+
+ function updateMemory(_data) {
+ memory.shift();
+
+ nowMemory += updateIntervalMemory;
+
+ tempMemory = [nowMemory, _data.memory];
+ memory.push(tempMemory);
+
+
+ datasetMemory = [
+ {
+ label: "Memory:" + _data.memory + "MB",
+ data: memory,
+ lines: {fill: true, lineWidth: 1.2},
+ color: "#00FF00"
+ }
+ ];
+
+ $.plot($("#memoryUsage"), datasetMemory, optionsMemory);
+ setTimeout(GetDataMemory, updateIntervalMemory);
+ }
+
+ // Disk Usage
+
+ var readRate = [], writeRate = [];
+ var datasetDisk;
+ var totalPointsDisk = 100;
+ var updateIntervalDisk = 5000;
+ var now = new Date().getTime();
+
+ var optionsDisk = {
+ series: {
+ lines: {
+ lineWidth: 1.2
+ },
+ bars: {
+ align: "center",
+ fillColor: {colors: [{opacity: 1}, {opacity: 1}]},
+ barWidth: 500,
+ lineWidth: 1
+ }
+ },
+ xaxis: {
+ mode: "time",
+ tickSize: [30, "second"],
+ tickFormatter: function (v, axis) {
+ var date = new Date(v);
+
+ if (date.getSeconds() % 20 == 0) {
+ var hours = date.getHours() < 10 ? "0" + date.getHours() : date.getHours();
+ var minutes = date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes();
+ var seconds = date.getSeconds() < 10 ? "0" + date.getSeconds() : date.getSeconds();
+
+ return hours + ":" + minutes + ":" + seconds;
+ } else {
+ return "";
+ }
+ },
+ axisLabel: "Time",
+ axisLabelUseCanvas: true,
+ axisLabelFontSizePixels: 12,
+ axisLabelFontFamily: 'Verdana, Arial',
+ axisLabelPadding: 10
+ },
+ yaxes: [
+ {
+ min: 0,
+ max: $scope.networkSpeed,
+ tickSize: 5,
+ tickFormatter: function (v, axis) {
+ if (v % 10 == 0) {
+ return v + "mb/sec";
+ } else {
+ return "";
+ }
+ },
+ axisLabel: "CPU loading",
+ axisLabelUseCanvas: true,
+ axisLabelFontSizePixels: 12,
+ axisLabelFontFamily: 'Verdana, Arial',
+ axisLabelPadding: 6
+ }, {
+ max: 5120,
+ position: "right",
+ axisLabel: "Disk",
+ axisLabelUseCanvas: true,
+ axisLabelFontSizePixels: 12,
+ axisLabelFontFamily: 'Verdana, Arial',
+ axisLabelPadding: 6
+ }
+ ],
+ legend: {
+ noColumns: 0,
+ position: "nw"
+ },
+ grid: {
+ backgroundColor: {colors: ["#ffffff", "#EDF5FF"]}
+ }
+ };
+
+ function initDataDisk() {
+ for (var i = 0; i < totalPointsDisk; i++) {
+ var temp = [now += updateIntervalDisk, 0];
+
+ readRate.push(temp);
+ writeRate.push(temp);
+ }
+ }
+
+ function GetDataDisk() {
+
+ var data = {
+ domain: $("#domain").text(),
+ type: 'io'
+ };
+
+ $.ajaxSetup({cache: false});
+
+ $.ajax({
+ url: "/CloudLinux/getUsageData",
+ dataType: 'json',
+ headers: {'X-CSRFToken': getCookie('csrftoken')},
+ success: updateDisk,
+ type: "POST",
+ contentType: "application/json",
+ data: JSON.stringify(data), // Our valid JSON string
+ error: function () {
+ setTimeout(GetDataMemory, updateIntervalMemory);
+ }
+ });
+ }
+
+ var tempDisk;
+
+ function updateDisk(_data) {
+ readRate.shift();
+ writeRate.shift();
+
+ now += updateIntervalDisk;
+
+ tempDisk = [now, _data.readRate];
+ readRate.push(tempDisk);
+
+ tempDisk = [now, _data.readRate];
+ writeRate.push(tempDisk);
+
+ datasetDisk = [
+ {
+ label: "Read IO/s " + _data.readRate + " mb/s ",
+ data: readRate,
+ lines: {fill: true, lineWidth: 1.2},
+ color: "#00FF00"
+ },
+ {
+ label: "Write IO/s " + _data.writeRate + " mb/s ",
+ data: writeRate,
+ lines: {lineWidth: 1.2},
+ color: "#FF0000"
+ }
+ ];
+
+ $.plot($("#diskUsage"), datasetDisk, optionsDisk);
+ setTimeout(GetDataDisk, updateIntervalDisk);
+ }
+
+
+ $(document).ready(function () {
+
+ // Report Memory Usage
+
+ initDataMemory();
+
+ datasetMemory = [
+ {label: "Memory", data: memory, lines: {fill: true, lineWidth: 1.2}, color: "#00FF00"}
+ ];
+
+ $.plot($("#memoryUsage"), datasetMemory, optionsMemory);
+ setTimeout(GetDataMemory, updateIntervalMemory);
+
+ // Report CPU Usage
+
+ initData();
+
+ dataset = [
+ {label: "CPU", data: cpu, lines: {fill: true, lineWidth: 1.2}, color: "#00FF00"}
+ ];
+
+ $.plot($("#flot-placeholder1"), dataset, options);
+ setTimeout(GetData, updateInterval);
+
+ // Report Disk Usage
+
+ initDataDisk();
+
+ datasetDisk = [
+ {label: "Read IO/s: ", data: readRate, lines: {fill: true, lineWidth: 1.2}, color: "#00FF00"},
+ {label: "Write IO/s: ", data: writeRate, color: "#0044FF", bars: {show: true}, yaxis: 2}
+ ];
+
+ $.plot($("#diskUsage"), datasetDisk, optionsDisk);
+ setTimeout(GetDataDisk, updateIntervalDisk);
+ });
+});
\ No newline at end of file
diff --git a/CLManager/templates/CLManager/createPackage.html b/CLManager/templates/CLManager/createPackage.html
new file mode 100755
index 000000000..e7e0c2fba
--- /dev/null
+++ b/CLManager/templates/CLManager/createPackage.html
@@ -0,0 +1,146 @@
+{% extends "baseTemplate/index.html" %}
+{% load i18n %}
+{% block title %}{% trans "Create Cloud Linux Package - CyberPanel" %}{% endblock %}
+{% block content %}
+
+ {% load static %}
+
+
+
{% trans "Create CloudLinux Package." %}
+
{% trans "Each CloudLinux package have one associated (owner) CyberPanel package. During website creation associated CloudLinux package will be assigned to website user." %}
+
+
+
+
+
+
+
+{% endblock %}
diff --git a/CLManager/templates/CLManager/listPackages.html b/CLManager/templates/CLManager/listPackages.html
new file mode 100755
index 000000000..c7442359c
--- /dev/null
+++ b/CLManager/templates/CLManager/listPackages.html
@@ -0,0 +1,236 @@
+{% extends "baseTemplate/index.html" %}
+{% load i18n %}
+{% block title %}{% trans "Manage CloudLinux Packages - CyberPanel" %}{% endblock %}
+{% block content %}
+
+ {% load static %}
+ {% get_current_language as LANGUAGE_CODE %}
+
+
+
+
+
+
+
{% trans "Manage CloudLinux Packages" %}
+
{% trans "Manage/Delete CloudLinux Packages." %}
+
+
+
+
+
+
+
+
+
+ Name
+ SPEED
+ VMEM
+ PMEM
+ IO
+ IOPS
+ EP
+ NPROC
+ INODES soft
+ INODES hard
+ Actions
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Delete
+ Edit
+
+
+
+
+
+
+
+
+
{% trans "Cannot list websites. Error message:" %} {$ errorMessage $}
+
+
+
+
+
+
+
+
+
+
+
+
+{% endblock %}
\ No newline at end of file
diff --git a/CLManager/templates/CLManager/listWebsites.html b/CLManager/templates/CLManager/listWebsites.html
new file mode 100755
index 000000000..cd0e24528
--- /dev/null
+++ b/CLManager/templates/CLManager/listWebsites.html
@@ -0,0 +1,117 @@
+{% extends "baseTemplate/index.html" %}
+{% load i18n %}
+{% block title %}{% trans "CageFS - CyberPanel" %}{% endblock %}
+{% block content %}
+
+ {% load static %}
+ {% get_current_language as LANGUAGE_CODE %}
+
+
+
+
+
+
+
{% trans "List Websites" %}
+
{% trans "Enable/Disable and view CageFS status for websites." %}
+
+
+
+
+
+
+
+
+
+
+ Domain
+ User
+ Actions
+
+
+
+
+
+
+
+
+ Disable
+ Enable
+
+
+
+
+
+
+
+
{% trans "Cannot list websites. Error message:" %} {$ errorMessage $}
+
+
+
+
+
+
+
+
+
+
+
+
+{% endblock %}
\ No newline at end of file
diff --git a/CLManager/templates/CLManager/monitorUsage.html b/CLManager/templates/CLManager/monitorUsage.html
new file mode 100755
index 000000000..8eccc09b8
--- /dev/null
+++ b/CLManager/templates/CLManager/monitorUsage.html
@@ -0,0 +1,87 @@
+{% extends "baseTemplate/index.html" %}
+{% load i18n %}
+{% block title %}{% trans "Monitor Usage - CyberPanel" %}{% endblock %}
+{% block content %}
+
+ {% load static %}
+ {% get_current_language as LANGUAGE_CODE %}
+
+
+
+
+
+
+
{% trans "List Websites" %}
+
{% trans "Monitor usage of your websites." %}
+
+
+
+
+
+ {% trans "Websites" %}
+
+
+
+
+
+
+ Domain
+ Launch
+ IP Address
+ Package
+ Owner
+ State
+ Email
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
{% trans "Cannot list websites. Error message:" %} {$ errorMessage $}
+
+
+
+
+
+
+
+
+
+
+
+
+{% endblock %}
\ No newline at end of file
diff --git a/CLManager/templates/CLManager/notAvailable.html b/CLManager/templates/CLManager/notAvailable.html
new file mode 100755
index 000000000..c597c3827
--- /dev/null
+++ b/CLManager/templates/CLManager/notAvailable.html
@@ -0,0 +1,67 @@
+{% extends "baseTemplate/index.html" %}
+{% load i18n %}
+{% block title %}{% trans "Not available - CyberPanel" %}{% endblock %}
+{% block content %}
+
+ {% load static %}
+ {% get_current_language as LANGUAGE_CODE %}
+
+
+
+
+
+
{% trans "Not available" %}
+
{% trans "Either CageFS is not installed or you are not on CloudLinux OS." %}
+
+
+ {% if not CL %}
+
+
+
+
+
{% trans "CageFS is only available with CloudLinux OS. " %} Click
+ Here {% trans " for conversion details." %}
+
+
+
+
+ {% else %}
+
+
+
+
+ {% trans "Install Packages" %}
+
+
+
+
{% trans "CageFS is not installed on this server. Please proceed to installation." %}
+
+
+
+
+
+
+
+
Install Now
+
+
+
+
+
+ {% endif %}
+
+
+{% endblock %}
+
diff --git a/CLManager/templates/CLManager/websiteContainerLimit.html b/CLManager/templates/CLManager/websiteContainerLimit.html
new file mode 100755
index 000000000..13fac7c7b
--- /dev/null
+++ b/CLManager/templates/CLManager/websiteContainerLimit.html
@@ -0,0 +1,52 @@
+{% extends "baseTemplate/index.html" %}
+{% load i18n %}
+{% block title %}{{ domain }}{% trans " usage - CyberPanel" %}{% endblock %}
+{% block content %}
+
+ {% load static %}
+ {% get_current_language as LANGUAGE_CODE %}
+
+
+
+
+
+
+
{% trans "Usage" %}
+
{% trans "View CPU, Memory and Disk usage for " %} {{ domain }}
+
+
+
+
+
+ {% trans "CPU Usage of" %} {{ domain }}
+
+
+
+
+
+ {% trans "Memory Usage of" %} {{ domain }}
+
+
+
+
+
+ {% trans "Disk Usage of" %} {{ domain }}
+
+
+
+
+
+
+
+
+
+{% endblock %}
\ No newline at end of file
diff --git a/CLManager/tests.py b/CLManager/tests.py
new file mode 100644
index 000000000..5982e6bcd
--- /dev/null
+++ b/CLManager/tests.py
@@ -0,0 +1,6 @@
+# -*- coding: utf-8 -*-
+from __future__ import unicode_literals
+
+from django.test import TestCase
+
+# Create your tests here.
diff --git a/CLManager/urls.py b/CLManager/urls.py
new file mode 100644
index 000000000..d7a531c43
--- /dev/null
+++ b/CLManager/urls.py
@@ -0,0 +1,18 @@
+from django.conf.urls import url
+import views
+
+urlpatterns = [
+ url(r'^CageFS$', views.CageFS, name='CageFS'),
+ url(r'^submitCageFSInstall$', views.submitCageFSInstall, name='submitCageFSInstall'),
+ url(r'^submitWebsiteListing$', views.getFurtherAccounts, name='submitWebsiteListing'),
+ url(r'^enableOrDisable$', views.enableOrDisable, name='enableOrDisable'),
+ url(r'^CreatePackage$', views.CreatePackage, name='CreatePackageCL'),
+ url(r'^submitCreatePackage$', views.submitCreatePackage, name='submitCreatePackageCL'),
+ url(r'^listPackages$', views.listPackages, name='listPackagesCL'),
+ url(r'^fetchPackages$', views.fetchPackages, name='fetchPackagesCL'),
+ url(r'^deleteCLPackage$', views.deleteCLPackage, name='deleteCLPackage'),
+ url(r'^saveSettings$', views.saveSettings, name='saveSettings'),
+ url(r'^monitorUsage$', views.monitorUsage, name='monitorUsage'),
+ url(r'^manage/(?P(.*))$', views.websiteContainerLimit, name='websiteContainerLimitCL'),
+ url(r'^getUsageData$', views.getUsageData, name='getUsageData'),
+]
\ No newline at end of file
diff --git a/CLManager/views.py b/CLManager/views.py
new file mode 100644
index 000000000..e02a3a040
--- /dev/null
+++ b/CLManager/views.py
@@ -0,0 +1,358 @@
+# -*- coding: utf-8 -*-
+from __future__ import unicode_literals
+
+from django.shortcuts import redirect, HttpResponse
+from loginSystem.views import loadLoginPage
+from plogical.acl import ACLManager
+from CLManagerMain import CLManagerMain
+import json
+from websiteFunctions.models import Websites
+from plogical.processUtilities import ProcessUtilities
+import os
+from packages.models import Package
+from .models import CLPackages
+import subprocess
+import multiprocessing
+import pwd
+from plogical.CyberCPLogFileWriter import CyberCPLogFileWriter as logging
+# Create your views here.
+
+def CageFS(request):
+ try:
+ templateName = 'CLManager/listWebsites.html'
+ c = CLManagerMain(request, templateName)
+ return c.renderC()
+ except KeyError:
+ return redirect(loadLoginPage)
+
+def submitCageFSInstall(request):
+ try:
+
+ userID = request.session['userID']
+ currentACL = ACLManager.loadedACL(userID)
+
+ if currentACL['admin'] == 1:
+ pass
+ else:
+ return ACLManager.loadErrorJson()
+
+ c = CLManagerMain(request, None, 'submitCageFSInstall')
+ c.start()
+
+ 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)
+
+def getFurtherAccounts(request):
+ try:
+ userID = request.session['userID']
+ wm = CLManagerMain()
+ return wm.getFurtherAccounts(userID, json.loads(request.body))
+ except KeyError:
+ return redirect(loadLoginPage)
+
+def enableOrDisable(request):
+ try:
+
+ userID = request.session['userID']
+ currentACL = ACLManager.loadedACL(userID)
+
+ if currentACL['admin'] == 1:
+ pass
+ else:
+ return ACLManager.loadErrorJson()
+
+ data = json.loads(request.body)
+
+ if data['toggle'] == 1:
+ cageFSPath = '/home/cyberpanel/cagefs'
+ if os.path.exists(cageFSPath):
+ os.remove(cageFSPath)
+ else:
+ writeToFile = open(cageFSPath, 'w')
+ writeToFile.writelines('enable')
+ writeToFile.close()
+
+ data_ret = {'status': 1, 'error_message': 'None', 'success': 'Default status successfully changed changed.'}
+ json_data = json.dumps(data_ret)
+ return HttpResponse(json_data)
+
+ if data['all'] == 0:
+ if data['mode'] == 1:
+ website = Websites.objects.get(domain=data['domain'])
+ command = '/usr/sbin/cagefsctl --enable %s' % (website.externalApp)
+ else:
+ website = Websites.objects.get(domain=data['domain'])
+ command = '/usr/sbin/cagefsctl --disable %s' % (website.externalApp)
+
+ ProcessUtilities.executioner(command)
+ data_ret = {'status': 1, 'error_message': 'None', 'success': 'Changes successfully applied.'}
+ json_data = json.dumps(data_ret)
+ return HttpResponse(json_data)
+ else:
+ c = CLManagerMain(request, None, 'enableOrDisable', data)
+ c.start()
+
+ data_ret = {'status': 1, 'error_message': 'None', 'success': 'Job started in background, refresh in few seconds to see the status.'}
+ 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)
+
+def CreatePackage(request):
+ try:
+ userID = request.session['userID']
+ currentACL = ACLManager.loadedACL(userID)
+ templateName = 'CLManager/createPackage.html'
+ packageList = ACLManager.loadPackages(userID, currentACL)
+ data = {}
+ data['packList'] = packageList
+ c = CLManagerMain(request, templateName, None, data)
+ return c.renderC()
+ except KeyError:
+ return redirect(loadLoginPage)
+
+def submitCreatePackage(request):
+ try:
+
+ userID = request.session['userID']
+ currentACL = ACLManager.loadedACL(userID)
+
+ if currentACL['admin'] == 1:
+ pass
+ else:
+ return ACLManager.loadErrorJson()
+
+ data = json.loads(request.body)
+
+ selectedPackage = data['selectedPackage']
+
+ package = Package.objects.get(packageName=selectedPackage)
+
+ if package.clpackages_set.all().count() == 1:
+ data_ret = {'status': 0, 'error_message': 'This package already have one associated CloudLinux Package.'}
+ json_data = json.dumps(data_ret)
+ return HttpResponse(json_data)
+
+ name = data['name']
+ SPEED = data['SPEED']
+ VMEM = data['VMEM']
+ PMEM = data['PMEM']
+ IO = data['IO']
+ IOPS = data['IOPS']
+ EP = data['EP']
+ NPROC = data['NPROC']
+ INODESsoft = data['INODESsoft']
+ INODEShard = data['INODEShard']
+
+ clPackage = CLPackages(name=name, owner=package, speed=SPEED, vmem=VMEM, pmem=PMEM, io=IO, iops=IOPS, ep=EP, nproc=NPROC, inodessoft=INODESsoft, inodeshard=INODEShard)
+ clPackage.save()
+
+ command = 'sudo lvectl package-set %s --speed=%s --pmem=%s --io=%s --nproc=%s --iops=%s --vmem=%s --ep=%s' % (name, SPEED, PMEM, IO, NPROC, IOPS, VMEM, EP)
+ ProcessUtilities.executioner(command)
+
+ command = 'sudo lvectl apply all'
+ ProcessUtilities.popenExecutioner(command)
+
+ data_ret = {'status': 1}
+ 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)
+
+def listPackages(request):
+ try:
+ templateName = 'CLManager/listPackages.html'
+ c = CLManagerMain(request, templateName)
+ return c.renderC()
+ except KeyError:
+ return redirect(loadLoginPage)
+
+def fetchPackages(request):
+ try:
+ userID = request.session['userID']
+ wm = CLManagerMain()
+ return wm.fetchPackages(ACLManager.loadedACL(userID))
+ except KeyError:
+ return redirect(loadLoginPage)
+
+def deleteCLPackage(request):
+ try:
+
+ userID = request.session['userID']
+ currentACL = ACLManager.loadedACL(userID)
+
+ if currentACL['admin'] == 1:
+ pass
+ else:
+ return ACLManager.loadErrorJson()
+
+ data = json.loads(request.body)
+
+ name = data['name']
+
+ clPackage = CLPackages.objects.get(name=name)
+ clPackage.delete()
+
+ data_ret = {'status': 1}
+ 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)
+
+def saveSettings(request):
+ try:
+
+ userID = request.session['userID']
+ currentACL = ACLManager.loadedACL(userID)
+
+ if currentACL['admin'] == 1:
+ pass
+ else:
+ return ACLManager.loadErrorJson()
+
+ data = json.loads(request.body)
+
+ name = data['name']
+ SPEED = data['SPEED']
+ VMEM = data['VMEM']
+ PMEM = data['PMEM']
+ IO = data['IO']
+ IOPS = data['IOPS']
+ EP = data['EP']
+ NPROC = data['NPROC']
+ INODESsoft = data['INODESsoft']
+ INODEShard = data['INODEShard']
+
+ clPackage = CLPackages.objects.get(name=name)
+ clPackage.speed = SPEED
+ clPackage.vmem = VMEM
+ clPackage.pmem = PMEM
+ clPackage.io = IO
+ clPackage.iops = IOPS
+ clPackage.ep = EP
+ clPackage.nproc = NPROC
+ clPackage.inodessoft = INODESsoft
+ clPackage.inodeshard = INODEShard
+ clPackage.save()
+
+ command = 'sudo lvectl package-set %s --speed=%s --pmem=%s --io=%s --nproc=%s --iops=%s --vmem=%s --ep=%s' % (
+ name, SPEED, PMEM, IO, NPROC, IOPS, VMEM, EP)
+ ProcessUtilities.executioner(command)
+
+ command = 'sudo lvectl apply all'
+ ProcessUtilities.popenExecutioner(command)
+
+ data_ret = {'status': 1}
+ 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)
+
+def monitorUsage(request):
+ try:
+ templateName = 'CLManager/monitorUsage.html'
+ c = CLManagerMain(request, templateName)
+ return c.renderC()
+ except KeyError:
+ return redirect(loadLoginPage)
+
+def websiteContainerLimit(request, domain):
+ try:
+ templateName = 'CLManager/websiteContainerLimit.html'
+ data = {}
+ data['domain'] = domain
+ c = CLManagerMain(request, templateName, None, data)
+ return c.renderC()
+ except KeyError:
+ return redirect(loadLoginPage)
+
+def getUsageData(request):
+ try:
+
+ userID = request.session['userID']
+ currentACL = ACLManager.loadedACL(userID)
+
+ if currentACL['admin'] == 1:
+ pass
+ else:
+ return ACLManager.loadErrorJson()
+
+ data = json.loads(request.body)
+ domain = data['domain']
+ website = Websites.objects.get(domain=domain)
+ uid = pwd.getpwnam(website.externalApp).pw_uid
+
+ try:
+ type = data['type']
+ finalData = {}
+ finalData['status'] = 1
+
+ try:
+ if type == 'memory':
+
+ command = 'sudo lveps -o id:10,mem:10'
+ output = ProcessUtilities.outputExecutioner(command).splitlines()
+ for items in output:
+ if items.find(website.externalApp) > -1:
+ finalData['memory'] = int(items.split(' ')[-1])
+ break
+
+ elif type == 'io':
+
+ finalData['readRate'] = 0
+ finalData['writeRate'] = 0
+
+ command = 'sudo lveps -o id:10,iops:10'
+ output = ProcessUtilities.outputExecutioner(command).splitlines()
+ for items in output:
+ if items.find(website.externalApp) > -1:
+ finalData['readRate'] = int(items.split(' ')[-1])
+ break
+
+ except:
+ finalData['memory'] = '0'
+ finalData['readRate'] = 0
+ finalData['writeRate'] = 0
+ except:
+
+ finalData = {}
+ finalData['status'] = 1
+
+ command = 'sudo lveps -o id:10,cpu:10 -d'
+ output = ProcessUtilities.outputExecutioner(command).splitlines()
+
+ for items in output:
+ if items.find(website.externalApp) > -1:
+ finalData['cpu'] = int(items.split(' ')[-1].rstrip('%'))
+ break
+
+ final_json = json.dumps(finalData)
+ return HttpResponse(final_json)
+
+ except BaseException, msg:
+ data_ret = {'status': 0, 'error_message': str(msg), 'cpu': 0, 'memory':0}
+ json_data = json.dumps(data_ret)
+ return HttpResponse(json_data)
\ No newline at end of file
diff --git a/CyberCP/secMiddleware.py b/CyberCP/secMiddleware.py
index 9c8a0923d..e1ade8a9c 100755
--- a/CyberCP/secMiddleware.py
+++ b/CyberCP/secMiddleware.py
@@ -8,6 +8,18 @@ class secMiddleware:
self.get_response = get_response
def __call__(self, request):
+ try:
+ uID = request.session['userID']
+ if request.session['ipAddr'] == request.META.get('REMOTE_ADDR'):
+ pass
+ else:
+ logging.writeToFile(request.META.get('REMOTE_ADDR'))
+ final_dic = {'error_message': "Session reuse detected, IPAddress logged.",
+ "errorMessage": "Session reuse detected, IPAddress logged."}
+ final_json = json.dumps(final_dic)
+ return HttpResponse(final_json)
+ except:
+ pass
if request.method == 'POST':
try:
#logging.writeToFile(request.body)
@@ -28,17 +40,23 @@ class secMiddleware:
else:
continue
- if request.build_absolute_uri().find('filemanager') > -1:
+ if request.build_absolute_uri().find('cloudAPI') > -1 or request.build_absolute_uri().find('filemanager') > -1 or request.build_absolute_uri().find('verifyLogin') > -1 or request.build_absolute_uri().find('submitUserCreation') > -1:
continue
- if key == 'emailMessage' or key == 'configData' or key == 'rewriteRules' or key == 'modSecRules' or key == 'recordContentTXT' or key == 'SecAuditLogRelevantStatus' or key == 'fileContent':
+ if key == 'passwordByPass' or key == 'cronCommand' or key == 'emailMessage' or key == 'configData' or key == 'rewriteRules' or key == 'modSecRules' or key == 'recordContentTXT' or key == 'SecAuditLogRelevantStatus' or key == 'fileContent':
continue
- if value.find(';') > -1 or value.find('&&') > -1 or value.find('|') > -1 or value.find('...') > -1:
+ if value.find(';') > -1 or value.find('&&') > -1 or value.find('|') > -1 or value.find('...') > -1 \
+ or value.find("`") > -1 or value.find("$") > -1 or value.find("(") > -1 or value.find(")") > -1 \
+ or value.find("'") > -1 or value.find("[") > -1 or value.find("]") > -1 or value.find("{") > -1 or value.find("}") > -1\
+ or value.find(":") > -1 or value.find("<") > -1 or value.find(">") > -1:
logging.writeToFile(request.body)
final_dic = {'error_message': "Data supplied is not accepted.",
"errorMessage": "Data supplied is not accepted."}
final_json = json.dumps(final_dic)
return HttpResponse(final_json)
- if key.find(';') > -1 or key.find('&&') > -1 or key.find('|') > -1 or key.find('...') > -1:
+ if key.find(';') > -1 or key.find('&&') > -1 or key.find('|') > -1 or key.find('...') > -1 \
+ or key.find("`") > -1 or key.find("$") > -1 or key.find("(") > -1 or key.find(")") > -1 \
+ or key.find("'") > -1 or key.find("[") > -1 or key.find("]") > -1 or key.find("{") > -1 or key.find("}") > -1\
+ or key.find(":") > -1 or key.find("<") > -1 or key.find(">") > -1:
logging.writeToFile(request.body)
final_dic = {'error_message': "Data supplied is not accepted.", "errorMessage": "Data supplied is not accepted."}
final_json = json.dumps(final_dic)
diff --git a/CyberCP/settings.py b/CyberCP/settings.py
index 6892a9d23..77a7aeecd 100755
--- a/CyberCP/settings.py
+++ b/CyberCP/settings.py
@@ -63,7 +63,8 @@ INSTALLED_APPS = [
'highAvailability',
's3Backups',
'dockerManager',
- 'containerization'
+ 'containerization',
+ 'CLManager'
]
MIDDLEWARE = [
@@ -71,6 +72,7 @@ MIDDLEWARE = [
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.locale.LocaleMiddleware',
'django.middleware.common.CommonMiddleware',
+ 'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
@@ -157,7 +159,6 @@ USE_L10N = True
USE_TZ = True
-
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.11/howto/static-files/
diff --git a/CyberCP/urls.py b/CyberCP/urls.py
index fdfd5addc..48f0ff276 100755
--- a/CyberCP/urls.py
+++ b/CyberCP/urls.py
@@ -42,4 +42,5 @@ urlpatterns = [
url(r'^cloudAPI/', include('cloudAPI.urls')),
url(r'^docker/', include('dockerManager.urls')),
url(r'^container/', include('containerization.urls')),
+ url(r'^CloudLinux/', include('CLManager.urls')),
]
diff --git a/api/views.py b/api/views.py
index 88ad396e7..3be35b466 100755
--- a/api/views.py
+++ b/api/views.py
@@ -14,15 +14,13 @@ import os
from baseTemplate.models import version
from plogical.mailUtilities import mailUtilities
from plogical.website import WebsiteManager
-from loginSystem.models import ACL
-from plogical.acl import ACLManager
-from firewall.models import FirewallRules
from s3Backups.s3Backups import S3Backups
from plogical.CyberCPLogFileWriter import CyberCPLogFileWriter as logging
from plogical.processUtilities import ProcessUtilities
+from django.views.decorators.csrf import csrf_exempt
# Create your views here.
-
+@csrf_exempt
def verifyConn(request):
try:
if request.method == 'POST':
@@ -52,6 +50,7 @@ def verifyConn(request):
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
+@csrf_exempt
def createWebsite(request):
data = json.loads(request.body)
adminUser = data['adminUser']
@@ -66,6 +65,7 @@ def createWebsite(request):
wm = WebsiteManager()
return wm.createWebsiteAPI(json.loads(request.body))
+@csrf_exempt
def getUserInfo(request):
try:
if request.method == 'POST':
@@ -111,6 +111,7 @@ def getUserInfo(request):
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
+@csrf_exempt
def changeUserPassAPI(request):
try:
if request.method == 'POST':
@@ -155,6 +156,7 @@ def changeUserPassAPI(request):
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
+@csrf_exempt
def changePackageAPI(request):
try:
if request.method == 'POST':
@@ -199,6 +201,7 @@ def changePackageAPI(request):
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
+@csrf_exempt
def deleteWebsite(request):
try:
if request.method == 'POST':
@@ -243,6 +246,7 @@ def deleteWebsite(request):
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
+@csrf_exempt
def submitWebsiteStatus(request):
try:
if request.method == 'POST':
@@ -273,6 +277,7 @@ def submitWebsiteStatus(request):
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
+@csrf_exempt
def loginAPI(request):
try:
username = request.POST['username']
@@ -296,6 +301,7 @@ def loginAPI(request):
json_data = json.dumps(data)
return HttpResponse(json_data)
+@csrf_exempt
def fetchSSHkey(request):
try:
if request.method == "POST":
@@ -313,7 +319,7 @@ def fetchSSHkey(request):
if hashPassword.check_password(admin.password, password):
pubKey = os.path.join("/root",".ssh",'cyberpanel.pub')
- execPath = "sudo cat " + pubKey
+ execPath = "cat " + pubKey
data = ProcessUtilities.outputExecutioner(execPath)
data_ret = {
@@ -338,6 +344,7 @@ def fetchSSHkey(request):
json_data = json.dumps(data)
return HttpResponse(json_data)
+@csrf_exempt
def remoteTransfer(request):
try:
if request.method == "POST":
@@ -372,7 +379,7 @@ def remoteTransfer(request):
## Accounts to transfer is a path to file, containing accounts.
- execPath = "sudo python " + virtualHostUtilities.cyberPanel + "/plogical/remoteTransferUtilities.py"
+ execPath = "python " + virtualHostUtilities.cyberPanel + "/plogical/remoteTransferUtilities.py"
execPath = execPath + " remoteTransfer --ipAddress " + ipAddress + " --dir " + dir + " --accountsToTransfer " + path
ProcessUtilities.popenExecutioner(execPath)
@@ -389,6 +396,7 @@ def remoteTransfer(request):
json_data = json.dumps(data)
return HttpResponse(json_data)
+@csrf_exempt
def fetchAccountsFromRemoteServer(request):
try:
if request.method == "POST":
@@ -438,6 +446,7 @@ def fetchAccountsFromRemoteServer(request):
json_data = json.dumps(data)
return HttpResponse(json_data)
+@csrf_exempt
def FetchRemoteTransferStatus(request):
try:
if request.method == "POST":
@@ -455,7 +464,7 @@ def FetchRemoteTransferStatus(request):
dir = "/home/backup/transfer-"+str(data['dir'])+"/backup_log"
try:
- command = "sudo cat "+ dir
+ command = "cat "+ dir
status = ProcessUtilities.outputExecutioner(command)
@@ -478,6 +487,7 @@ def FetchRemoteTransferStatus(request):
json_data = json.dumps(data)
return HttpResponse(json_data)
+@csrf_exempt
def cancelRemoteTransfer(request):
try:
if request.method == "POST":
@@ -500,13 +510,13 @@ def cancelRemoteTransfer(request):
path = dir + "/pid"
- command = "sudo cat " + path
+ command = "cat " + path
pid = ProcessUtilities.outputExecutioner(command)
- command = "sudo kill -KILL " + pid
+ command = "kill -KILL " + pid
ProcessUtilities.executioner(command)
- command = "sudo rm -rf " + dir
+ command = "rm -rf " + dir
ProcessUtilities.executioner(command)
data = {'cancelStatus': 1, 'error_message': "None"}
@@ -524,6 +534,7 @@ def cancelRemoteTransfer(request):
json_data = json.dumps(data)
return HttpResponse(json_data)
+@csrf_exempt
def cyberPanelVersion(request):
try:
if request.method == 'POST':
@@ -570,6 +581,7 @@ def cyberPanelVersion(request):
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
+@csrf_exempt
def runAWSBackups(request):
try:
diff --git a/backup/backupManager.py b/backup/backupManager.py
index 7bfdd4231..9ad618a1a 100755
--- a/backup/backupManager.py
+++ b/backup/backupManager.py
@@ -21,6 +21,7 @@ import time
import plogical.backupUtilities as backupUtil
import requests
from plogical.processUtilities import ProcessUtilities
+from multiprocessing import Process
class BackupManager:
def __init__(self, domain = None, childDomain = None):
@@ -85,6 +86,11 @@ class BackupManager:
else:
return ACLManager.loadErrorJson('fetchStatus', 0)
+ if ACLManager.checkOwnership(backupDomain, admin, currentACL) == 1:
+ pass
+ else:
+ return ACLManager.loadErrorJson()
+
website = Websites.objects.get(domain=backupDomain)
backups = website.backups_set.all()
@@ -141,11 +147,9 @@ class BackupManager:
## /home/example.com/backup/backup-example-06-50-03-Thu-Feb-2018
tempStoragePath = os.path.join(backupPath, backupName)
- execPath = "sudo nice -n 10 python " + virtualHostUtilities.cyberPanel + "/plogical/backupUtilities.py"
- execPath = execPath + " submitBackupCreation --tempStoragePath " + tempStoragePath + " --backupName " \
- + backupName + " --backupPath " + backupPath + ' --backupDomain ' + backupDomain
- ProcessUtilities.popenExecutioner(execPath)
+ p = Process(target=backupUtil.submitBackupCreation, args=(tempStoragePath, backupName, backupPath,backupDomain))
+ p.start()
time.sleep(2)
@@ -166,11 +170,13 @@ class BackupManager:
backupFileNamePath = os.path.join("/home", backupDomain, "backup/backupFileName")
pid = os.path.join("/home", backupDomain, "backup/pid")
+ domain = Websites.objects.get(domain=backupDomain)
+
## read file name
try:
command = "sudo cat " + backupFileNamePath
- fileName = ProcessUtilities.outputExecutioner(command)
+ fileName = ProcessUtilities.outputExecutioner(command, domain.externalApp)
except:
fileName = "Fetching.."
@@ -178,20 +184,20 @@ class BackupManager:
if os.path.exists(status):
command = "sudo cat " + status
- status = ProcessUtilities.outputExecutioner(command)
+ status = ProcessUtilities.outputExecutioner(command, domain.externalApp)
if status.find("Completed") > -1:
### Removing Files
command = 'sudo rm -f ' + status
- ProcessUtilities.executioner(command)
+ ProcessUtilities.executioner(command, domain.externalApp)
command = 'sudo rm -f ' + backupFileNamePath
- ProcessUtilities.executioner(command)
+ ProcessUtilities.executioner(command, domain.externalApp)
command = 'sudo rm -f ' + pid
- ProcessUtilities.executioner(command)
+ ProcessUtilities.executioner(command, domain.externalApp)
final_json = json.dumps(
{'backupStatus': 1, 'error_message': "None", "status": status, "abort": 1,
@@ -202,13 +208,13 @@ class BackupManager:
## removing status file, so that backup can re-run
try:
command = 'sudo rm -f ' + status
- ProcessUtilities.executioner(command)
+ ProcessUtilities.executioner(command, domain.externalApp)
command = 'sudo rm -f ' + backupFileNamePath
- ProcessUtilities.executioner(command)
+ ProcessUtilities.executioner(command, domain.externalApp)
command = 'sudo rm -f ' + pid
- ProcessUtilities.executioner(command)
+ ProcessUtilities.executioner(command, domain.externalApp)
backupObs = Backups.objects.filter(fileName=fileName)
for items in backupObs:
@@ -243,9 +249,7 @@ class BackupManager:
fileName = data['fileName']
execPath = "sudo python " + virtualHostUtilities.cyberPanel + "/plogical/backupUtilities.py"
-
execPath = execPath + " cancelBackupCreation --backupCancellationDomain " + backupCancellationDomain + " --fileName " + fileName
-
subprocess.call(shlex.split(execPath))
try:
@@ -268,6 +272,12 @@ class BackupManager:
backup = Backups.objects.get(id=backupID)
domainName = backup.website.domain
+ currentACL = ACLManager.loadedACL(userID)
+ admin = Administrator.objects.get(pk=userID)
+ if ACLManager.checkOwnership(domainName, admin, currentACL) == 1:
+ pass
+ else:
+ return ACLManager.loadErrorJson()
path = "/home/" + domainName + "/backup/" + backup.fileName + ".tar.gz"
command = 'sudo rm -f ' + path
@@ -283,7 +293,7 @@ class BackupManager:
return HttpResponse(final_json)
- def submitRestore(self, data = None):
+ def submitRestore(self, data = None, userID = None):
try:
backupFile = data['backupFile']
originalFile = "/home/backup/" + backupFile
@@ -293,6 +303,12 @@ class BackupManager:
else:
dir = "CyberPanelRestore"
+ currentACL = ACLManager.loadedACL(userID)
+ if currentACL['admin'] == 1:
+ pass
+ else:
+ return ACLManager.loadErrorJson()
+
execPath = "sudo nice -n 10 python " + virtualHostUtilities.cyberPanel + "/plogical/backupUtilities.py"
execPath = execPath + " submitRestore --backupFile " + backupFile + " --dir " + dir
ProcessUtilities.popenExecutioner(execPath)
diff --git a/backup/views.py b/backup/views.py
index b4796c76a..20b645ea5 100755
--- a/backup/views.py
+++ b/backup/views.py
@@ -27,6 +27,7 @@ def backupSite(request):
except KeyError:
return redirect(loadLoginPage)
+
def restoreSite(request):
try:
userID = request.session['userID']
@@ -35,6 +36,7 @@ def restoreSite(request):
except KeyError:
return redirect(loadLoginPage)
+
def getCurrentBackups(request):
try:
userID = request.session['userID']
@@ -43,9 +45,10 @@ def getCurrentBackups(request):
except KeyError:
return redirect(loadLoginPage)
+
def submitBackupCreation(request):
try:
- userID = 1
+ userID = request.session['userID']
result = pluginManager.preSubmitBackupCreation(request)
if result != 200:
@@ -59,6 +62,7 @@ def submitBackupCreation(request):
except KeyError:
return redirect(loadLoginPage)
+
def backupStatus(request):
try:
userID = 1
@@ -67,6 +71,7 @@ def backupStatus(request):
except KeyError:
return redirect(loadLoginPage)
+
def cancelBackupCreation(request):
try:
userID = request.session['userID']
@@ -75,6 +80,7 @@ def cancelBackupCreation(request):
except KeyError:
return redirect(loadLoginPage)
+
def deleteBackup(request):
try:
userID = request.session['userID']
@@ -95,19 +101,22 @@ def deleteBackup(request):
except KeyError:
return redirect(loadLoginPage)
+
def submitRestore(request):
try:
+ userID = request.session['userID']
result = pluginManager.preSubmitRestore(request)
if result != 200:
return result
wm = BackupManager()
- coreResult = wm.submitRestore(json.loads(request.body))
+ coreResult = wm.submitRestore(json.loads(request.body), userID)
return coreResult
except KeyError:
return redirect(loadLoginPage)
+
def restoreStatus(request):
try:
wm = BackupManager()
@@ -115,6 +124,7 @@ def restoreStatus(request):
except KeyError:
return redirect(loadLoginPage)
+
def backupDestinations(request):
try:
userID = request.session['userID']
@@ -123,6 +133,7 @@ def backupDestinations(request):
except KeyError:
return redirect(loadLoginPage)
+
def submitDestinationCreation(request):
try:
userID = request.session['userID']
diff --git a/baseTemplate/static/baseTemplate/custom-js/system-status.js b/baseTemplate/static/baseTemplate/custom-js/system-status.js
index 134e67021..1bf3b0d8f 100755
--- a/baseTemplate/static/baseTemplate/custom-js/system-status.js
+++ b/baseTemplate/static/baseTemplate/custom-js/system-status.js
@@ -23,7 +23,7 @@ function getCookie(name) {
}
function randomPassword(length) {
- var chars = "abcdefghijklmnopqrstuvwxyz!@#$%^*()-+<>ABCDEFGHIJKLMNOP1234567890";
+ var chars = "abcdefghijklmnopqrstuvwxyz!@#%^*-+ABCDEFGHIJKLMNOP1234567890";
var pass = "";
for (var x = 0; x < length; x++) {
var i = Math.floor(Math.random() * chars.length);
diff --git a/baseTemplate/templates/baseTemplate/index.html b/baseTemplate/templates/baseTemplate/index.html
index df0c301af..c8e870de7 100755
--- a/baseTemplate/templates/baseTemplate/index.html
+++ b/baseTemplate/templates/baseTemplate/index.html
@@ -606,6 +606,34 @@
+
+
+
+ {% trans "CloudLinux" %}
+ {% trans "NEW" %}
+
+
+
+
+
@@ -756,6 +784,9 @@
{% trans "CSF" %}
+ {% trans "CageFS" %}
+
@@ -870,6 +901,7 @@
+