File manager - Edit - /home/newsbmcs.com/public_html/static/img/logo/CLManager.tar
Back
views.py 0000644 00000026171 15027514651 0006270 0 ustar 00 # -*- coding: utf-8 -*- 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 as 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 as 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 as 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 as 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 as 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 as msg: data_ret = {'status': 0, 'error_message': str(msg), 'cpu': 0, 'memory':0} json_data = json.dumps(data_ret) return HttpResponse(json_data) __pycache__/__init__.cpython-310.pyc 0000644 00000000205 15027514651 0013217 0 ustar 00 o 8�g � @ s d S )N� r r r �(/usr/local/CyberCP/CLManager/__init__.py�<module> s __pycache__/admin.cpython-310.pyc 0000644 00000000256 15027514651 0012556 0 ustar 00 o 8�gY � @ s d dl mZ dS )� )�adminN)�django.contribr � r r �%/usr/local/CyberCP/CLManager/admin.py�<module> s __pycache__/apps.cpython-310.pyc 0000644 00000000551 15027514651 0012427 0 ustar 00 o 8�gw � @ s d dl mZ G dd� de�ZdS )� )� AppConfigc @ s e Zd ZdZdS )�ClmanagerConfig� CLManagerN)�__name__� __module__�__qualname__�name� r r �$/usr/local/CyberCP/CLManager/apps.pyr s r N)�django.appsr r r r r r �<module> s __pycache__/models.cpython-310.pyc 0000644 00000001311 15027514651 0012742 0 ustar 00 o 8�g� � @ s. d dl mZ d dlmZ G dd� dej�ZdS )� )�models)�Packagec @ s� e Zd Zejeejd�Zejddd�Z ejdd�Z ejdd�Zejdd�Zejdd�Z ejdd�Zejdd�Zejdd�Zejdd�Zejdd�ZdS )� CLPackages)� on_delete�2 T)� max_length�unique)r N)�__name__� __module__�__qualname__r � ForeignKeyr �CASCADE�owner� CharField�name�speed�vmem�pmem�io�iops�ep�nproc� inodessoft� inodeshard� r r �&/usr/local/CyberCP/CLManager/models.pyr s r N)� django.dbr �packages.modelsr �Modelr r r r r �<module> s admin.py 0000644 00000000131 15027514651 0006207 0 ustar 00 # -*- coding: utf-8 -*- from django.contrib import admin # Register your models here. CageFS.py 0000644 00000026367 15027514651 0006232 0 ustar 00 #!/usr/local/CyberCP/bin/python import sys import os import django sys.path.append('/usr/local/CyberCP') os.environ.setdefault("DJANGO_SETTINGS_MODULE", "CyberCP.settings") django.setup() import plogical.CyberCPLogFileWriter as logging import argparse from plogical.mailUtilities import mailUtilities from plogical.processUtilities import ProcessUtilities from plogical.firewallUtilities import FirewallUtilities from firewall.models import FirewallRules from serverStatus.serverStatusUtil import ServerStatusUtil class CageFS: packages = ['talksho'] users = ['5001'] @staticmethod def EnableCloudLinux(): if ProcessUtilities.decideServer() == ProcessUtilities.OLS: confPath = '/usr/local/lsws/conf/httpd_config.conf' data = open(confPath, 'r').readlines() writeToFile = open(confPath, 'w') for items in data: if items.find('priority') > -1: writeToFile.writelines(items) writeToFile.writelines('enableLVE 2\n') else: writeToFile.writelines(items) writeToFile.close() else: confPath = '/usr/local/lsws/conf/httpd_config.xml' data = open(confPath, 'r').readlines() writeToFile = open(confPath, 'w') for items in data: if items.find('<enableChroot>') > -1: writeToFile.writelines(items) writeToFile.writelines(' <enableLVE>2</enableLVE>\n') else: writeToFile.writelines(items) writeToFile.close() ProcessUtilities.restartLitespeed() @staticmethod def submitCageFSInstall(): try: mailUtilities.checkHome() statusFile = open(ServerStatusUtil.lswsInstallStatusPath, 'w') logging.CyberCPLogFileWriter.statusWriter(ServerStatusUtil.lswsInstallStatusPath, "Checking if LVE Kernel is loaded ..\n", 1) if ProcessUtilities.outputExecutioner('uname -a').find('lve') > -1 or ProcessUtilities.outputExecutioner('lsmod').find('lve') > -1: pass else: logging.CyberCPLogFileWriter.statusWriter(ServerStatusUtil.lswsInstallStatusPath, "CloudLinux is installed but kernel is not loaded, please reboot your server to load appropriate kernel. [404]\n", 1) return 0 logging.CyberCPLogFileWriter.statusWriter(ServerStatusUtil.lswsInstallStatusPath, "CloudLinux Kernel detected..\n", 1) logging.CyberCPLogFileWriter.statusWriter(ServerStatusUtil.lswsInstallStatusPath, "Enabling CloudLinux in web server ..\n", 1) CageFS.EnableCloudLinux() logging.CyberCPLogFileWriter.statusWriter(ServerStatusUtil.lswsInstallStatusPath, "CloudLinux enabled in server ..\n", 1) logging.CyberCPLogFileWriter.statusWriter(ServerStatusUtil.lswsInstallStatusPath, "Adding LVEManager port ..\n", 1) try: FirewallUtilities.addRule('tcp', '9000', '0.0.0.0/0') newFWRule = FirewallRules(name='lvemanager', proto='tcp', port='9000', ipAddress='0.0.0.0/0') newFWRule.save() except: logging.CyberCPLogFileWriter.statusWriter(ServerStatusUtil.lswsInstallStatusPath, "LVEManager port added ..\n", 1) logging.CyberCPLogFileWriter.statusWriter(ServerStatusUtil.lswsInstallStatusPath, "Reinstalling important components ..\n", 1) command = 'yum install -y alt-python37-devel' ServerStatusUtil.executioner(command, statusFile) command = 'yum reinstall -y cloudlinux-venv' ServerStatusUtil.executioner(command, statusFile) command = 'yum reinstall -y lvemanager lve-utils cagefs' ServerStatusUtil.executioner(command, statusFile) command = 'yum reinstall -y cloudlinux-venv' ServerStatusUtil.executioner(command, statusFile) command = 'systemctl restart lvemanager' ServerStatusUtil.executioner(command, statusFile) logging.CyberCPLogFileWriter.statusWriter(ServerStatusUtil.lswsInstallStatusPath, "Important components reinstalled..\n", 1) activatedPath = '/home/cyberpanel/cloudlinux' writeToFile = open(activatedPath, 'a') writeToFile.write('CLInstalled') writeToFile.close() #### mount session save paths if os.path.exists('/etc/cagefs/cagefs.mp'): from managePHP.phpManager import PHPManager php_versions = PHPManager.findPHPVersions() for php in php_versions: PHPVers = PHPManager.getPHPString(php) line = f'@/var/lib/lsphp/session/lsphp{PHPVers},700\n' WriteToFile = open('/etc/cagefs/cagefs.mp', 'a') WriteToFile.write(line) WriteToFile.close() command = 'cagefsctl --remount-all' ServerStatusUtil.executioner(command, statusFile) logging.CyberCPLogFileWriter.statusWriter(ServerStatusUtil.lswsInstallStatusPath, "Packages successfully installed.[200]\n", 1) except BaseException as msg: logging.CyberCPLogFileWriter.statusWriter(ServerStatusUtil.lswsInstallStatusPath, str(msg) + ' [404].', 1) @staticmethod def submitinstallImunify(key): try: imunifyKeyPath = '/home/cyberpanel/imunifyKeyPath' ## writeToFile = open(imunifyKeyPath, 'w') writeToFile.write(key) writeToFile.close() ## mailUtilities.checkHome() statusFile = open(ServerStatusUtil.lswsInstallStatusPath, 'w') logging.CyberCPLogFileWriter.statusWriter(ServerStatusUtil.lswsInstallStatusPath, "Starting Imunify Installation..\n", 1) ## command = 'mkdir -p /etc/sysconfig/imunify360/generic' ServerStatusUtil.executioner(command, statusFile) command = 'touch /etc/sysconfig/imunify360/generic/modsec.conf' ServerStatusUtil.executioner(command, statusFile) integrationFile = '/etc/sysconfig/imunify360/integration.conf' content = """[paths] ui_path =/usr/local/CyberCP/public/imunify [web_server] server_type = litespeed graceful_restart_script = /usr/local/lsws/bin/lswsctrl restart modsec_audit_log = /usr/local/lsws/logs/auditmodsec.log modsec_audit_logdir = /usr/local/lsws/logs/ [malware] basedir = /home pattern_to_watch = ^/home/.+?/(public_html|public_ftp|private_html)(/.*)?$ """ writeToFile = open(integrationFile, 'w') writeToFile.write(content) writeToFile.close() ## ### address issue to create imunify dir - https://app.clickup.com/t/86engx249 command = 'mkdir /usr/local/CyberCP/public/imunify' ProcessUtilities.executioner(command) command = 'pkill -f "bash i360deploy.sh"' ServerStatusUtil.executioner(command, statusFile) if not os.path.exists('i360deploy.sh'): command = 'wget https://repo.imunify360.cloudlinux.com/defence360/i360deploy.sh' ServerStatusUtil.executioner(command, statusFile) command = 'bash i360deploy.sh --uninstall --yes' ServerStatusUtil.executioner(command, statusFile) command = 'bash i360deploy.sh --key %s --yes' % (key) ServerStatusUtil.executioner(command, statusFile) logging.CyberCPLogFileWriter.statusWriter(ServerStatusUtil.lswsInstallStatusPath, "Imunify reinstalled..\n", 1) logging.CyberCPLogFileWriter.statusWriter(ServerStatusUtil.lswsInstallStatusPath, "Packages successfully installed.[200]\n", 1) except BaseException as msg: logging.CyberCPLogFileWriter.statusWriter(ServerStatusUtil.lswsInstallStatusPath, str(msg) + ' [404].', 1) @staticmethod def submitinstallImunifyAV(): try: mailUtilities.checkHome() statusFile = open(ServerStatusUtil.lswsInstallStatusPath, 'w') logging.CyberCPLogFileWriter.statusWriter(ServerStatusUtil.lswsInstallStatusPath, "Starting ImunifyAV Installation..\n", 1) ## command = 'mkdir -p /etc/sysconfig/imunify360' ServerStatusUtil.executioner(command, statusFile) integrationFile = '/etc/sysconfig/imunify360/integration.conf' content = """[paths] ui_path = /usr/local/CyberCP/public/imunifyav ui_path_owner = lscpd:lscpd """ writeToFile = open(integrationFile, 'w') writeToFile.write(content) writeToFile.close() ## ### address issue to create imunify dir - https://app.clickup.com/t/86engx249 command = 'mkdir /usr/local/CyberCP/public/imunifyav' ProcessUtilities.executioner(command) command = 'pkill -f "bash imav-deploy.sh"' ServerStatusUtil.executioner(command, statusFile) if not os.path.exists('imav-deploy.sh'): command = 'wget https://repo.imunify360.cloudlinux.com/defence360/imav-deploy.sh' ServerStatusUtil.executioner(command, statusFile) command = 'bash imav-deploy.sh --uninstall --yes' ServerStatusUtil.executioner(command, statusFile) command = 'bash imav-deploy.sh --yes' ServerStatusUtil.executioner(command, statusFile) logging.CyberCPLogFileWriter.statusWriter(ServerStatusUtil.lswsInstallStatusPath, "ImunifyAV reinstalled..\n", 1) logging.CyberCPLogFileWriter.statusWriter(ServerStatusUtil.lswsInstallStatusPath, "Packages successfully installed.[200]\n", 1) except BaseException as 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') parser.add_argument('--key', help='Imunify Key') args = vars(parser.parse_args()) if args["function"] == "submitCageFSInstall": CageFS.submitCageFSInstall() elif args["function"] == "submitinstallImunify": CageFS.submitinstallImunify(args["key"]) elif args["function"] == "submitinstallImunifyAV": CageFS.submitinstallImunifyAV() if __name__ == "__main__": main() static/CLManager/CLManager.js 0000644 00000063030 15027514651 0011763 0 ustar 00 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.installDockerStatus = 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.installDockerStatus = true; $timeout.cancel(); $scope.requestData = response.data.requestStatus; if (response.data.installed === 1) { $timeout(function () { $window.location.reload(); }, 3000); } } } function cantLoadInitialDatas(response) { $scope.installDockerStatus = 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); }); }); urls.py 0000644 00000002172 15027514651 0006113 0 ustar 00 from django.urls import re_path from . import views urlpatterns = [ re_path(r'^CreatePackage$', views.CreatePackage, name='CreatePackageCL'), re_path(r'^listPackages$', views.listPackages, name='listPackagesCL'), re_path(r'^monitorUsage$', views.monitorUsage, name='monitorUsage'), re_path(r'^CageFS$', views.CageFS, name='CageFS'), re_path(r'^submitCageFSInstall$', views.submitCageFSInstall, name='submitCageFSInstall'), # re_path(r'^submitWebsiteListing$', views.getFurtherAccounts, name='submitWebsiteListing'), # re_path(r'^enableOrDisable$', views.enableOrDisable, name='enableOrDisable'), # re_path(r'^submitCreatePackage$', views.submitCreatePackage, name='submitCreatePackageCL'), # re_path(r'^fetchPackages$', views.fetchPackages, name='fetchPackagesCL'), # re_path(r'^deleteCLPackage$', views.deleteCLPackage, name='deleteCLPackage'), # re_path(r'^saveSettings$', views.saveSettings, name='saveSettings'), # re_path(r'^manage/(?P<domain>(.*))$', views.websiteContainerLimit, name='websiteContainerLimitCL'), # re_path(r'^getUsageData$', views.getUsageData, name='getUsageData'), ] CLPackages.py 0000755 00000004405 15027514651 0007067 0 ustar 00 #!/usr/local/CyberCP/bin/python 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() templates/CLManager/cloudLinux.html 0000644 00000002274 15027514651 0013362 0 ustar 00 {% extends "baseTemplate/index.html" %} {% load i18n %} {% block title %}{% trans "CloudLinux - 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 "CloudLinux" %}</h2> <p>{% trans "Access LVEManager" %}</p> </div> <div class="panel"> <div class="panel-body"> <h3 class="title-hero"> {% trans "CloudLinux" %} </h3> <div class="example-box-wrapper"> <p>{% trans "CloudLinux is now integrated via their new API. You can manage CageFS and Package limits directly from LVEManager by clicking below. You can use your server root credentials to access LVEManager." %}</p> <br> <a target="_blank" href="http://{{ ipAddress }}:9000"> <button class="btn btn-primary">Access Now </button> </a> </div> </div> </div> </div> {% endblock %} templates/CLManager/listWebsites.html 0000644 00000011020 15027514651 0013702 0 ustar 00 {% extends "baseTemplate/index.html" %} {% load i18n %} {% block title %}{% trans "CageFS - CyberPanel" %}{% endblock %} {% block content %} {% load static %} {% get_current_language as LANGUAGE_CODE %} <!-- Current language: {{ LANGUAGE_CODE }} --> <div ng-controller="listWebsitesCage" class="container"> <div id="page-title"> <h2 id="domainNamePage">{% trans "List Websites" %}</h2> <p>{% trans "Enable/Disable and view CageFS status for websites." %}</p> </div> <div class="panel"> <div class="panel-body"> <div style="padding-bottom: 0px; padding-top: 15px;" class="form-group"> <label class="col-sm-3 control-label"></label> <div class="col-sm-6"> <div class="example-box-wrapper"> <div class="content-box remove-border clearfix text-center"> <a class="btn btn-primary" href="#" title=""> <span>{% trans "Default: " %} <b>{$ default $}</b></span> </a> <a href="#" ng-click="enableOrDisable(0, 0, 0, 1)" class="btn btn-border btn-alt border-green btn-link font-green" title=""><span>Toggle Default</span></a> <a href="#" ng-click="enableOrDisable(0, 1, 1, 0)" class="btn btn-success" title="Enable All"> <i class="fa fa-play btn-icon"></i> </a> <a href="#" ng-click="enableOrDisable(0, 1, 0, 0)" class="btn btn-warning" title="Disable All"> <i class="fa fa-pause btn-icon"></i> </a> <a href="#" ng-click="refreshStatus()" class="btn btn-info" title="Refresh Status"> <i class="fa fa-refresh btn-icon"></i> </a> </div> </div> </div> </div> <div class="example-box-wrapper"> <table cellpadding="0" cellspacing="0" border="0" class="table table-striped table-bordered" id="datatable-example"> <thead> <tr> <th>Domain <img ng-hide="cyberPanelLoading" src="/static/images/loading.gif"></th> <th>User</th> <th>Actions</th> </tr> </thead> <tbody> <tr ng-repeat="web in WebSitesList track by $index"> <td ng-bind="web.domain"></td> <td ng-bind="web.externalApp"></td> <td> <a ng-click="enableOrDisable(web.domain, 0, 0, 0)" ng-hide="web.status==0" class="btn btn-border btn-alt border-red btn-link font-red" title=""><span>Disable</span></a> <a ng-click="enableOrDisable(web.domain, 0, 1, 0)" ng-hide="web.status==1" class="btn btn-border btn-alt border-green btn-link font-green" title=""><span>Enable</span></a> </td> </tr> </tbody> </table> <div id="listFail" class="alert alert-danger"> <p>{% trans "Cannot list websites. Error message:" %} {$ errorMessage $}</p> </div> <div class="row"> <div class="col-sm-4 col-sm-offset-8"> <nav aria-label="Page navigation"> <ul class="pagination"> <li ng-repeat="page in pagination" ng-click="getFurtherWebsitesFromDB($index+1)" id="webPages"><a href="">{$ $index + 1 $}</a></li> </ul> </nav> </div> </div> </div> </div> </div> </div> {% endblock %} templates/CLManager/listPackages.html 0000644 00000034736 15027514651 0013656 0 ustar 00 {% extends "baseTemplate/index.html" %} {% load i18n %} {% block title %}{% trans "Manage CloudLinux Packages - CyberPanel" %}{% endblock %} {% block content %} {% load static %} {% get_current_language as LANGUAGE_CODE %} <!-- Current language: {{ LANGUAGE_CODE }} --> <div ng-controller="listCloudLinuxPackages" class="container"> <div id="page-title"> <h2 id="domainNamePage">{% trans "Manage CloudLinux Packages" %}</h2> <p>{% trans "Manage/Delete CloudLinux Packages." %}</p> </div> <div class="panel"> <div class="panel-body"> <div class="example-box-wrapper"> <table cellpadding="0" cellspacing="0" border="0" class="table table-striped table-bordered" id="datatable-example"> <thead> <tr> <th>Name<img ng-hide="cyberPanelLoading" src="/static/images/loading.gif"></th> <th>SPEED</th> <th>VMEM</th> <th>PMEM</th> <th>IO</th> <th>IOPS</th> <th>EP</th> <th>NPROC</th> <th>INODES soft</th> <th>INODES hard</th> <th>Actions</th> </tr> </thead> <tbody> <tr ng-repeat="pack in packages track by $index"> <td ng-bind="pack.name"></td> <td ng-bind="pack.SPEED"></td> <td ng-bind="pack.VMEM"></td> <td ng-bind="pack.PMEM"></td> <td ng-bind="pack.IO"></td> <td ng-bind="pack.IOPS"></td> <td ng-bind="pack.EP"></td> <td ng-bind="pack.NPROC"></td> <td ng-bind="pack.inodessoft"></td> <td ng-bind="pack.inodeshard"></td> <td> <a ng-click='deleteCLPackage(pack.name)' class="btn btn-border btn-alt border-red btn-link font-red" title=""><span>Delete</span></a> <a ng-click="populatePackage(pack.name, pack.SPEED, pack.VMEM, pack.PMEM, pack.IO, pack.IOPS, pack.EP, pack.NPROC, pack.inodessoft, pack.inodeshard)" data-toggle="modal" data-target="#settings" ng-click='deleteCLPackage()' class="btn btn-border btn-alt border-green btn-link font-green" title=""><span>Edit</span></a> <div id="settings" class="modal fade" role="dialog"> <div class="modal-dialog"> <!-- Modal content--> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal">× </button> <h4 class="modal-title">Edit Package <img id="containerSettingLoading" src="/static/images/loading.gif" style="display: none;"> </h4> </div> <div class="modal-body"> <form name="containerSettingsForm" action="/" class="form-horizontal"> <div ng-hide="installationDetailsForm" class="form-group"> <label class="col-sm-3 control-label">{% trans "Name" %}</label> <div class="col-sm-6"> <input name="name" type="text" class="form-control" ng-model="name" readonly> </div> </div> <hr> <div ng-hide="installationDetailsForm" class="form-group"> <div ng-hide="installationDetailsForm" class="form-group"> <label class="col-sm-3 control-label">{% trans "SPEED" %}</label> <div class="col-sm-6"> <input name="SPEED" type="text" class="form-control" ng-model="$parent.SPEED" required> </div> </div> </div> <hr> <div ng-hide="installationDetailsForm" class="form-group"> <div ng-hide="installationDetailsForm" class="form-group"> <label class="col-sm-3 control-label">{% trans "VMEM" %}</label> <div class="col-sm-6"> <input name="VMEM" type="text" class="form-control" ng-model="$parent.VMEM" required> </div> </div> </div> <hr> <div ng-hide="installationDetailsForm" class="form-group"> <div ng-hide="installationDetailsForm" class="form-group"> <label class="col-sm-3 control-label">{% trans "PMEM" %}</label> <div class="col-sm-6"> <input name="PMEM" type="text" class="form-control" ng-model="$parent.PMEM" required> </div> </div> </div> <hr> <div ng-hide="installationDetailsForm" class="form-group"> <div ng-hide="installationDetailsForm" class="form-group"> <label class="col-sm-3 control-label">{% trans "IO" %}</label> <div class="col-sm-6"> <input name="IO" type="text" class="form-control" ng-model="$parent.IO" required> </div> </div> </div> <hr> <div ng-hide="installationDetailsForm" class="form-group"> <div ng-hide="installationDetailsForm" class="form-group"> <label class="col-sm-3 control-label">{% trans "IOPS" %}</label> <div class="col-sm-6"> <input name="IOPS" type="text" class="form-control" ng-model="$parent.IOPS" required> </div> </div> </div> <hr> <div ng-hide="installationDetailsForm" class="form-group"> <div ng-hide="installationDetailsForm" class="form-group"> <label class="col-sm-3 control-label">{% trans "EP" %}</label> <div class="col-sm-6"> <input name="EP" type="text" class="form-control" ng-model="$parent.EP" required> </div> </div> </div> <hr> <div ng-hide="installationDetailsForm" class="form-group"> <div ng-hide="installationDetailsForm" class="form-group"> <label class="col-sm-3 control-label">{% trans "NPROC" %}</label> <div class="col-sm-6"> <input name="NPROC" type="text" class="form-control" ng-model="$parent.NPROC" required> </div> </div> </div> <hr> <div ng-hide="installationDetailsForm" class="form-group"> <div ng-hide="installationDetailsForm" class="form-group"> <label class="col-sm-3 control-label">{% trans "INODES soft" %}</label> <div class="col-sm-6"> <input name="inodessoft" type="text" class="form-control" ng-model="$parent.inodessoft" required> </div> </div> </div> <hr> <div ng-hide="installationDetailsForm" class="form-group"> <div ng-hide="installationDetailsForm" class="form-group"> <label class="col-sm-3 control-label">{% trans "INODES hard" %}</label> <div class="col-sm-6"> <input name="inodeshard" type="text" class="form-control" ng-model="$parent.inodeshard" required> </div> </div> </div> </form> </div> <div class="modal-footer"> <button type="button" ng-disabled="savingSettings" class="btn btn-primary" ng-click="saveSettings()" data-dismiss="modal">Save </button> <button type="button" ng-disabled="savingSettings" class="btn btn-default" data-dismiss="modal"> Close </button> </div> </div> </div> </div> </td> </tr> </tbody> </table> <div id="listFail" class="alert alert-danger"> <p>{% trans "Cannot list websites. Error message:" %} {$ errorMessage $}</p> </div> <div class="row"> <div class="col-sm-4 col-sm-offset-8"> <nav aria-label="Page navigation"> <ul class="pagination"> <li ng-repeat="page in pagination" ng-click="getFurtherWebsitesFromDB($index+1)" id="webPages"><a href="">{$ $index + 1 $}</a></li> </ul> </nav> </div> </div> </div> </div> </div> </div> {% endblock %} templates/CLManager/notAvailable.html 0000644 00000005146 15027514651 0013636 0 ustar 00 {% extends "baseTemplate/index.html" %} {% load i18n %} {% block title %}{% trans "Not available - 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 "Not available" %}</h2> <p>{% trans "Either CageFS is not installed or you are not on CloudLinux OS." %}</p> </div> {% if not CL %} <div class="row"> <div class="col-sm-12"> <div class="alert alert-danger"> <p>{% trans "CloudLinux is not installed on your server." %} <a target="_blank" href="https://community.cyberpanel.net/t/1-convert-cyberpanel-to-cloudlinux-os-and-install-cagefs/174">Click Here</a> {% trans " for conversion details." %}</p> </div> </div> </div> {% else %} <div ng-controller="installCageFS" class="panel"> <div class="panel-body"> <h3 class="title-hero"> {% trans "Activate Now" %} <img ng-hide="installDockerStatus" src="{% static 'images/loading.gif' %}"> </h3> <div class="example-box-wrapper"> <p>{% trans "CloudLinux is installed, but not activated." %}</p> <!------ LSWS Switch box -----------------> <div style="margin-top: 2%" ng-hide="installBoxGen" class="col-md-12"> <form action="/" id="" class="form-horizontal bordered-row"> <div class="form-group"> <div style="margin-top: 2%;" class="col-sm-12"> <textarea ng-model="requestData" rows="15" class="form-control">{{ requestData }}</textarea> </div> </div> </form> </div> <!----- LSWS Switch box -----------------> <br> <button ng-hide="dockerInstallBTN" class="btn btn-primary" ng-click="submitCageFSInstall()">Activate Now</button> </div> </div> </div> {% endif %} </div> {% endblock %} templates/CLManager/monitorUsage.html 0000644 00000006125 15027514651 0013707 0 ustar 00 {% extends "baseTemplate/index.html" %} {% load i18n %} {% block title %}{% trans "Monitor Usage - CyberPanel" %}{% endblock %} {% block content %} {% load static %} {% get_current_language as LANGUAGE_CODE %} <!-- Current language: {{ LANGUAGE_CODE }} --> <div class="container"> <div id="page-title"> <h2 id="domainNamePage">{% trans "List Websites" %}</h2> <p>{% trans "Monitor usage of your websites." %}</p> </div> <div class="panel"> <div class="panel-body"> <h3 class="title-hero"> {% trans "Websites" %} </h3> <div ng-controller="listWebsites" class="example-box-wrapper"> <table cellpadding="0" cellspacing="0" border="0" class="table table-striped table-bordered" id="datatable-example"> <thead> <tr> <th>Domain</th> <th>Launch</th> <th>IP Address</th> <th>Package</th> <th>Owner</th> <th>State</th> <th>Email</th> </tr> </thead> <tbody> <tr ng-repeat="web in WebSitesList track by $index"> <td ng-bind="web.domain"></td> <td><a href="/CloudLinux/manage/{$ web.domain $}"><img width="30px" height="30" class="center-block" src="{% static 'baseTemplate/assets/image-resources/webPanel.png' %}"></a> </td> <td ng-bind="web.ipAddress"></td> <td ng-bind="web.package"></td> <td ng-bind="web.admin"></td> <td ng-bind="web.state"></td> <td ng-bind="web.adminEmail"></td> </tr> </tbody> </table> <div id="listFail" class="alert alert-danger"> <p>{% trans "Cannot list websites. Error message:" %} {$ errorMessage $}</p> </div> <div class="row"> <div class="col-sm-4 col-sm-offset-8"> <nav aria-label="Page navigation"> <ul class="pagination"> <li ng-repeat="page in pagination" ng-click="getFurtherWebsitesFromDB($index+1)" id="webPages"><a href="">{$ $index + 1 $}</a></li> </ul> </nav> </div> </div> </div> </div> </div> </div> {% endblock %} templates/CLManager/createPackage.html 0000644 00000015557 15027514651 0013763 0 ustar 00 {% extends "baseTemplate/index.html" %} {% load i18n %} {% block title %}{% trans "Create Cloud Linux Package - CyberPanel" %}{% endblock %} {% block content %} {% load static %} <div class="container"> <div id="page-title"> <h2>{% trans "Create CloudLinux Package." %}</h2> <p>{% trans "Each CloudLinux package have one associated (owner) CyberPanel package. During website creation associated CloudLinux package will be assigned to website user." %}</p> </div> <div ng-controller="createCLPackage" class="panel"> <div class="panel-body"> <h3 class="content-box-header"> {% trans "Create Package" %} <img ng-hide="cyberPanelLoading" src="{% static 'images/loading.gif' %}"> </h3> <div class="example-box-wrapper"> <form action="/" class="form-horizontal bordered-row panel-body"> <div class="form-group"> <label class="col-sm-3 control-label">{% trans "Select Package" %} </label> <div class="col-sm-6"> <select ng-change="toggleView()" ng-model="selectedPackage" class="form-control"> {% for items in packList %} <option>{{ items }}</option> {% endfor %} </select> </div> </div> <!------ Modification form that appears after a click ---------------> <div ng-hide="modifyPackageForm"> <div class="form-group"> <label class="col-sm-3 control-label">{% trans "Package Name" %}</label> <div class="col-sm-6"> <input type="text" class="form-control" ng-model="name" required> </div> </div> <div class="form-group"> <label class="col-sm-3 control-label">{% trans "SPEED" %}</label> <div class="col-sm-6"> <input type="text" class="form-control" ng-model="SPEED" required> </div> <div class="current-pack ng-binding">Ex 100%</div> </div> <div class="form-group"> <label class="col-sm-3 control-label">{% trans "VMEM" %}</label> <div class="col-sm-6"> <input type="text" class="form-control" ng-model="VMEM" required> </div> <div class="current-pack ng-binding">Ex 256m or 1G</div> </div> <div class="form-group"> <label class="col-sm-3 control-label">{% trans "PMEM" %}</label> <div class="col-sm-6"> <input type="text" class="form-control" ng-model="PMEM" required> </div> <div class="current-pack ng-binding">Ex 256m or 1G</div> </div> <div class="form-group"> <label class="col-sm-3 control-label">{% trans "IO" %}</label> <div class="col-sm-6"> <input type="text" class="form-control" ng-model="IO" required> </div> <div class="current-pack ng-binding">Ex 1024</div> </div> <div class="form-group"> <label class="col-sm-3 control-label">{% trans "IOPS" %}</label> <div class="col-sm-6"> <input type="text" class="form-control" ng-model="IOPS" required> </div> <div class="current-pack ng-binding">Ex 1024</div> </div> <div class="form-group"> <label class="col-sm-3 control-label">{% trans "EP" %}</label> <div class="col-sm-6"> <input type="text" class="form-control" ng-model="EP" required> </div> <div class="current-pack ng-binding">Ex 10</div> </div> <div class="form-group"> <label class="col-sm-3 control-label">{% trans "NPROC" %}</label> <div class="col-sm-6"> <input type="text" class="form-control" ng-model="NPROC" required> </div> <div class="current-pack ng-binding">Ex 10</div> </div> <div class="form-group"> <label class="col-sm-3 control-label">{% trans "INODES soft" %}</label> <div class="col-sm-6"> <input type="text" class="form-control" ng-model="INODESsoft" required> </div> <div class="current-pack ng-binding">Ex 1024</div> </div> <div class="form-group"> <label class="col-sm-3 control-label">{% trans "INODES hard" %}</label> <div class="col-sm-6"> <input type="text" class="form-control" ng-model="INODEShard" required> </div> <div class="current-pack ng-binding">Ex 1024</div> </div> </div> <!------ Modification form that appears after a click ---------------> <div ng-hide="modifyPackageForm" class="form-group"> <label class="col-sm-3 control-label"></label> <div class="col-sm-4"> <button type="button" ng-click="createPackage()" class="btn btn-primary btn-lg ">{% trans "Create Package" %}</button> </div> </div> </form> </div> </div> </div> </div> {% endblock %} templates/CLManager/websiteContainerLimit.html 0000644 00000003150 15027514651 0015532 0 ustar 00 {% extends "baseTemplate/index.html" %} {% load i18n %} {% block title %}{{ domain }}{% trans " usage - CyberPanel" %}{% endblock %} {% block content %} {% load static %} {% get_current_language as LANGUAGE_CODE %} <!-- Current language: {{ LANGUAGE_CODE }} --> <div ng-controller="websiteContainerLimitCL" class="container"> <div id="page-title"> <h2 id="domainNamePage">{% trans "Usage" %}</h2> <p>{% trans "View CPU, Memory and Disk usage for " %} <span id="domain">{{ domain }}</span></p> </div> <div class="panel"> <div class="panel-body"> <h2 class="title-hero"> {% trans "CPU Usage of" %} {{ domain }} </h2> <div class="example-box-wrapper"> <div id="flot-placeholder1" style="width:auto;height:300px"></div> </div> </div> <div class="panel-body"> <h2 class="title-hero"> {% trans "Memory Usage of" %} {{ domain }} </h2> <div class="example-box-wrapper"> <div id="memoryUsage" style="width:auto;height:300px"></div> </div> </div> <div class="panel-body"> <h2 class="title-hero"> {% trans "Disk Usage of" %} {{ domain }} </h2> <div class="example-box-wrapper"> <div id="diskUsage" style="width:auto;height:300px"></div> </div> </div> </div> </div> {% endblock %} models.py 0000644 00000001234 15027514651 0006407 0 ustar 00 # -*- coding: utf-8 -*- from django.db import models from packages.models import Package # Create your models here. class CLPackages(models.Model): owner = models.ForeignKey(Package, on_delete=models.CASCADE) 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) CLManagerMain.py 0000644 00000015144 15027514651 0007527 0 ustar 00 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 CLManager.models import CLPackages from plogical.httpProc import httpProc 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 as msg: logging.CyberCPLogFileWriter.writeToFile(str(msg) + ' [ContainerManager.run]') def renderC(self): data = {} data['CL'] = 0 data['activatedPath'] = 0 CLPath = '/etc/sysconfig/cloudlinux' activatedPath = '/home/cyberpanel/cloudlinux' if os.path.exists(CLPath): data['CL'] = 1 if os.path.exists(activatedPath): data['activatedPath'] = 1 if data['CL'] == 0: proc = httpProc(self.request, 'CLManager/notAvailable.html', data, 'admin') return proc.render() elif data['activatedPath'] == 0: proc = httpProc(self.request, 'CLManager/notAvailable.html', data, 'admin') return proc.render() else: proc = httpProc(self.request, 'CLManager/cloudLinux.html', data, 'admin') return proc.render() 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 = "/usr/local/CyberCP/bin/python /usr/local/CyberCP/CLManager/CageFS.py" execPath = execPath + " --function submitCageFSInstall" ProcessUtilities.outputExecutioner(execPath) except BaseException as 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('<li><a href="\#"></a></li>') else: pages = ceil(pages) finalPages = int(pages) + 1 for i in range(1, finalPages): pagination.append('<li><a href="\#">' + str(i) + '</a></li>') 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 as 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 as 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) tests.py 0000644 00000000126 15027514651 0006265 0 ustar 00 # -*- coding: utf-8 -*- from django.test import TestCase # Create your tests here. apps.py 0000644 00000000167 15027514651 0006073 0 ustar 00 # -*- coding: utf-8 -*- from django.apps import AppConfig class ClmanagerConfig(AppConfig): name = 'CLManager' migrations/0001_initial.py 0000644 00000002315 15027514651 0011372 0 ustar 00 # Generated by Django 4.2.14 on 2025-03-25 19:37 from django.db import migrations, models import django.db.models.deletion class Migration(migrations.Migration): initial = True dependencies = [ ('packages', '0001_initial'), ] operations = [ migrations.CreateModel( name='CLPackages', fields=[ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('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)), ('owner', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='packages.package')), ], ), ] migrations/__init__.py 0000644 00000000000 15027514651 0011025 0 ustar 00 __init__.py 0000644 00000000000 15027514651 0006651 0 ustar 00
| ver. 1.4 |
Github
|
.
| PHP 8.2.28 | Generation time: 0.02 |
proxy
|
phpinfo
|
Settings