mirror of
https://github.com/usmannasir/cyberpanel.git
synced 2025-11-07 05:45:59 +01:00
bug fix to lsws switch
This commit is contained in:
@@ -1013,9 +1013,9 @@ class preFlightsChecks:
|
||||
while (1):
|
||||
|
||||
if self.distro == centos:
|
||||
command = 'yum -y install zip'
|
||||
command = 'yum -y install unzip'
|
||||
else:
|
||||
command = 'apt-get -y install zip'
|
||||
command = 'apt-get -y install unzip'
|
||||
|
||||
cmd = shlex.split(command)
|
||||
res = subprocess.call(cmd)
|
||||
|
||||
@@ -225,16 +225,15 @@ class InstallCyberPanel:
|
||||
def installAllPHPVersions(self):
|
||||
try:
|
||||
count = 0
|
||||
|
||||
while (1):
|
||||
|
||||
if self.distro == ubuntu:
|
||||
command = 'DEBIAN_FRONTEND=noninteractive apt-get -y install ' \
|
||||
'lsphp7? lsphp7?-common lsphp7?-curl lsphp7?-dev lsphp7?-imap lsphp7?-intl lsphp7?-json ' \
|
||||
'lsphp7?-ldap lsphp7?-mysql lsphp7?-opcache lsphp7?-pspell lsphp7?-recode ' \
|
||||
'lsphp7?-sqlite3 lsphp7?-tidy >> /var/log/installPHPs 2>&1'
|
||||
'lsphp7?-sqlite3 lsphp7?-tidy'
|
||||
res = os.system(command)
|
||||
if res != 0:
|
||||
res = 1 # Force a retry
|
||||
else:
|
||||
command = 'yum -y groupinstall lsphp-all'
|
||||
cmd = shlex.split(command)
|
||||
|
||||
@@ -95,7 +95,7 @@ class ProcessUtilities:
|
||||
def decideServer():
|
||||
entPath = '/usr/local/lsws/bin/lshttpd'
|
||||
|
||||
if os.readlink(entPath) == '/usr/local/lsws/bin/lshttpd/openlitespeed':
|
||||
if os.path.exists('/usr/local/lsws/bin/openlitespeed'):
|
||||
return ProcessUtilities.OLS
|
||||
else:
|
||||
return ProcessUtilities.ent
|
||||
|
||||
@@ -3,16 +3,17 @@ from installUtilities import installUtilities
|
||||
import argparse
|
||||
import subprocess
|
||||
import shlex
|
||||
from processUtilities import ProcessUtilities
|
||||
from xml.etree import ElementTree
|
||||
|
||||
class tuning:
|
||||
|
||||
|
||||
@staticmethod
|
||||
def fetchTuningDetails():
|
||||
|
||||
if ProcessUtilities.decideServer() == ProcessUtilities.OLS:
|
||||
try:
|
||||
dataToReturn = {}
|
||||
|
||||
command = "sudo cat /usr/local/lsws/conf/httpd_config.conf"
|
||||
datas = subprocess.check_output(shlex.split(command)).split("\n")
|
||||
|
||||
@@ -48,6 +49,27 @@ class tuning:
|
||||
dataToReturn['enableGzipCompress'] = data[1]
|
||||
|
||||
return dataToReturn
|
||||
except BaseException, msg:
|
||||
logging.CyberCPLogFileWriter.writeToFile(
|
||||
str(msg) + " [fetchTuningDetails]")
|
||||
return 0
|
||||
else:
|
||||
try:
|
||||
dataToReturn = {}
|
||||
|
||||
command = "sudo cat /usr/local/lsws/conf/httpd_config.xml"
|
||||
datas = subprocess.check_output(shlex.split(command))
|
||||
comTree = ElementTree.fromstring(datas)
|
||||
tuningData = comTree.find('tuning')
|
||||
|
||||
dataToReturn['maxConnections'] = tuningData.find('maxConnections').text
|
||||
dataToReturn['maxSSLConnections'] = tuningData.find('maxSSLConnections').text
|
||||
dataToReturn['connTimeout'] = tuningData.find('connTimeout').text
|
||||
dataToReturn['keepAliveTimeout'] = tuningData.find('keepAliveTimeout').text
|
||||
dataToReturn['totalInMemCacheSize'] = tuningData.find('totalInMemCacheSize').text
|
||||
dataToReturn['enableGzipCompress'] = tuningData.find('enableGzipCompress').text
|
||||
|
||||
return dataToReturn
|
||||
|
||||
except BaseException, msg:
|
||||
logging.CyberCPLogFileWriter.writeToFile(
|
||||
@@ -57,7 +79,7 @@ class tuning:
|
||||
|
||||
@staticmethod
|
||||
def saveTuningDetails(maxConnections,maxSSLConnections,connectionTimeOut,keepAliveTimeOut,cacheSizeInMemory,gzipCompression):
|
||||
|
||||
if ProcessUtilities.decideServer() == ProcessUtilities.OLS:
|
||||
try:
|
||||
datas = open("/usr/local/lsws/conf/httpd_config.conf").readlines()
|
||||
writeDataToFile = open("/usr/local/lsws/conf/httpd_config.conf","w")
|
||||
@@ -104,7 +126,54 @@ class tuning:
|
||||
writeDataToFile.close()
|
||||
|
||||
print "1,None"
|
||||
except BaseException, msg:
|
||||
logging.CyberCPLogFileWriter.writeToFile(
|
||||
str(msg) + " [saveTuningDetails]")
|
||||
print "0," + str(msg)
|
||||
else:
|
||||
try:
|
||||
datas = open("/usr/local/lsws/conf/httpd_config.xml").readlines()
|
||||
writeDataToFile = open("/usr/local/lsws/conf/httpd_config.xml", "w")
|
||||
|
||||
if gzipCompression == "Enable":
|
||||
gzip = 1
|
||||
else:
|
||||
gzip = 0
|
||||
|
||||
for items in datas:
|
||||
if items.find("maxConnections") > -1:
|
||||
data = " <maxConnections>" + str(maxConnections) + "</maxConnections>\n"
|
||||
writeDataToFile.writelines(data)
|
||||
continue
|
||||
|
||||
elif items.find("maxSSLConnections") > -1:
|
||||
data = " <maxSSLConnections>" + str(maxSSLConnections) + "</maxSSLConnections>\n"
|
||||
writeDataToFile.writelines(data)
|
||||
continue
|
||||
|
||||
elif items.find("<connTimeout>") > -1:
|
||||
data = " <connTimeout>" + str(connectionTimeOut) + "</connTimeout>\n"
|
||||
writeDataToFile.writelines(data)
|
||||
continue
|
||||
|
||||
elif items.find("<keepAliveTimeout>") > -1:
|
||||
data = " <keepAliveTimeout>" + str(keepAliveTimeOut) + "</keepAliveTimeout>\n"
|
||||
writeDataToFile.writelines(data)
|
||||
continue
|
||||
|
||||
elif items.find("<totalInMemCacheSize>") > -1:
|
||||
data = " <totalInMemCacheSize>" + str(cacheSizeInMemory) + "</totalInMemCacheSize>\n"
|
||||
writeDataToFile.writelines(data)
|
||||
continue
|
||||
|
||||
elif items.find("<enableGzipCompress>") > -1:
|
||||
data = " <enableGzipCompress>" + str(gzip) + "</enableGzipCompress>\n"
|
||||
writeDataToFile.writelines(data)
|
||||
continue
|
||||
else:
|
||||
writeDataToFile.writelines(items)
|
||||
writeDataToFile.close()
|
||||
print "1,None"
|
||||
except BaseException, msg:
|
||||
logging.CyberCPLogFileWriter.writeToFile(
|
||||
str(msg) + " [saveTuningDetails]")
|
||||
@@ -113,6 +182,7 @@ class tuning:
|
||||
|
||||
@staticmethod
|
||||
def fetchPHPDetails(virtualHost):
|
||||
if ProcessUtilities.decideServer() == ProcessUtilities.OLS:
|
||||
try:
|
||||
path = installUtilities.Server_root_path + "/conf/vhosts/"+virtualHost+"/vhost.conf"
|
||||
|
||||
@@ -153,7 +223,31 @@ class tuning:
|
||||
dataToReturn['procHardLimit'] = data[1]
|
||||
|
||||
return dataToReturn
|
||||
except BaseException, msg:
|
||||
logging.CyberCPLogFileWriter.writeToFile(
|
||||
str(msg) + " [fetchPHPDetails]")
|
||||
return 0
|
||||
else:
|
||||
try:
|
||||
command = "sudo cat /usr/local/lsws/conf/httpd_config.xml"
|
||||
datas = subprocess.check_output(shlex.split(command))
|
||||
comTree = ElementTree.fromstring(datas)
|
||||
extProcessorList = comTree.findall('extProcessorList/extProcessor')
|
||||
|
||||
dataToReturn = {}
|
||||
|
||||
for extProcessor in extProcessorList:
|
||||
if extProcessor.find('name').text == virtualHost:
|
||||
dataToReturn['maxConns'] = extProcessor.find('maxConns').text
|
||||
dataToReturn['initTimeout'] = extProcessor.find('initTimeout').text
|
||||
dataToReturn['persistConn'] = extProcessor.find('persistConn').text
|
||||
dataToReturn['memSoftLimit'] = extProcessor.find('memSoftLimit').text
|
||||
dataToReturn['memHardLimit'] = extProcessor.find('memHardLimit').text
|
||||
dataToReturn['procSoftLimit'] = extProcessor.find('procSoftLimit').text
|
||||
dataToReturn['procHardLimit'] = extProcessor.find('procHardLimit').text
|
||||
break
|
||||
|
||||
return dataToReturn
|
||||
except BaseException, msg:
|
||||
logging.CyberCPLogFileWriter.writeToFile(
|
||||
str(msg) + " [fetchPHPDetails]")
|
||||
@@ -161,8 +255,7 @@ class tuning:
|
||||
|
||||
@staticmethod
|
||||
def tunePHP(virtualHost,maxConns,initTimeout,persistConn,memSoftLimit,memHardLimit,procSoftLimit,procHardLimit):
|
||||
|
||||
|
||||
if ProcessUtilities.decideServer() == ProcessUtilities.OLS:
|
||||
try:
|
||||
path = installUtilities.Server_root_path + "/conf/vhosts/" + virtualHost + "/vhost.conf"
|
||||
datas = open(path).readlines()
|
||||
@@ -216,11 +309,80 @@ class tuning:
|
||||
writeDataToFile.close()
|
||||
|
||||
print "1,None"
|
||||
|
||||
except BaseException, msg:
|
||||
logging.CyberCPLogFileWriter.writeToFile(
|
||||
str(msg) + " [saveTuningDetails]")
|
||||
print "0,"+str(msg)
|
||||
else:
|
||||
try:
|
||||
path = "/usr/local/lsws/conf/httpd_config.xml"
|
||||
datas = open(path).readlines()
|
||||
|
||||
writeDataToFile = open(path, "w")
|
||||
activate = 0
|
||||
|
||||
for items in datas:
|
||||
if items.find(virtualHost) > -1:
|
||||
writeDataToFile.writelines(items)
|
||||
activate = 1
|
||||
continue
|
||||
|
||||
elif activate == 1:
|
||||
if items.find('</extProcessor>') > -1:
|
||||
writeDataToFile.writelines(items)
|
||||
activate = 0
|
||||
continue
|
||||
if items.find("<maxConns>") > -1:
|
||||
data = " <maxConns>" + str(maxConns) + "</maxConns>\n"
|
||||
writeDataToFile.writelines(data)
|
||||
continue
|
||||
|
||||
elif items.find("<initTimeout>") > -1:
|
||||
data = " <initTimeout>" + str(initTimeout) + "</initTimeout>\n"
|
||||
writeDataToFile.writelines(data)
|
||||
continue
|
||||
|
||||
elif items.find("memSoftLimit") > -1:
|
||||
data = " <memSoftLimit>" + str(memSoftLimit) + "</memSoftLimit>\n"
|
||||
writeDataToFile.writelines(data)
|
||||
continue
|
||||
|
||||
elif items.find("<memHardLimit>") > -1:
|
||||
data = " <memHardLimit>" + str(memHardLimit) + "</memHardLimit>\n"
|
||||
writeDataToFile.writelines(data)
|
||||
continue
|
||||
|
||||
elif items.find("<procSoftLimit>") > -1:
|
||||
data = " <procSoftLimit>" + str(procSoftLimit) + "</procSoftLimit>\n"
|
||||
writeDataToFile.writelines(data)
|
||||
continue
|
||||
|
||||
elif items.find("<procHardLimit>") > -1:
|
||||
data = " <procHardLimit>" + str(procHardLimit) + "</procHardLimit>\n"
|
||||
writeDataToFile.writelines(data)
|
||||
continue
|
||||
elif items.find("<persistConn>") > -1:
|
||||
if persistConn == "Enable":
|
||||
persist = 1
|
||||
else:
|
||||
persist = 0
|
||||
|
||||
data = " <persistConn>" + str(persist) + "</persistConn>\n"
|
||||
writeDataToFile.writelines(data)
|
||||
continue
|
||||
else:
|
||||
writeDataToFile.writelines(items)
|
||||
else:
|
||||
writeDataToFile.writelines(items)
|
||||
|
||||
writeDataToFile.close()
|
||||
|
||||
print "1,None"
|
||||
|
||||
except BaseException, msg:
|
||||
logging.CyberCPLogFileWriter.writeToFile(
|
||||
str(msg) + " [saveTuningDetails]")
|
||||
print "0," + str(msg)
|
||||
|
||||
def main():
|
||||
|
||||
|
||||
@@ -98,6 +98,14 @@ class virtualHostUtilities:
|
||||
if retValues[0] == 0:
|
||||
raise BaseException(retValues[1])
|
||||
|
||||
selectedPackage = Package.objects.get(packageName=packageName)
|
||||
|
||||
website = Websites(admin=admin, package=selectedPackage, domain=virtualHostName,
|
||||
adminEmail=administratorEmail,
|
||||
phpSelection=phpVersion, ssl=ssl, externalApp=virtualHostUser)
|
||||
|
||||
website.save()
|
||||
|
||||
|
||||
if ssl == 1:
|
||||
sslPath = "/home/" + virtualHostName + "/public_html"
|
||||
@@ -124,14 +132,6 @@ class virtualHostUtilities:
|
||||
if dkimCheck == 1:
|
||||
DNS.createDKIMRecords(virtualHostName)
|
||||
|
||||
selectedPackage = Package.objects.get(packageName=packageName)
|
||||
|
||||
website = Websites(admin=admin, package=selectedPackage, domain=virtualHostName,
|
||||
adminEmail=administratorEmail,
|
||||
phpSelection=phpVersion, ssl=ssl, externalApp=virtualHostUser)
|
||||
|
||||
website.save()
|
||||
|
||||
logging.CyberCPLogFileWriter.statusWriter(tempStatusPath, 'Website successfully created. [200]')
|
||||
|
||||
return 1, 'None'
|
||||
@@ -844,6 +844,9 @@ class virtualHostUtilities:
|
||||
|
||||
## Now restart litespeed after initial configurations are done
|
||||
|
||||
website = ChildDomains(master=master, domain=virtualHostName, path=path, phpSelection=phpVersion, ssl=ssl)
|
||||
website.save()
|
||||
|
||||
if ssl == 1:
|
||||
logging.CyberCPLogFileWriter.statusWriter(tempStatusPath, 'Creating SSL..,50')
|
||||
installUtilities.installUtilities.reStartLiteSpeed()
|
||||
@@ -864,10 +867,6 @@ class virtualHostUtilities:
|
||||
DNS.createDKIMRecords(virtualHostName)
|
||||
|
||||
|
||||
website = ChildDomains(master=master, domain=virtualHostName, path=path, phpSelection=phpVersion, ssl=ssl)
|
||||
website.save()
|
||||
|
||||
|
||||
logging.CyberCPLogFileWriter.statusWriter(tempStatusPath, 'Domain successfully created. [200]')
|
||||
return 1, "None"
|
||||
|
||||
|
||||
@@ -10,6 +10,11 @@ import argparse
|
||||
import shutil
|
||||
import plogical.CyberCPLogFileWriter as logging
|
||||
from plogical.processUtilities import ProcessUtilities
|
||||
from websiteFunctions.models import Websites, ChildDomains, aliasDomains
|
||||
from plogical.virtualHostUtilities import virtualHostUtilities
|
||||
from plogical.sslUtilities import sslUtilities
|
||||
from plogical.vhost import vhost
|
||||
|
||||
|
||||
|
||||
class ServerStatusUtil:
|
||||
@@ -21,7 +26,7 @@ class ServerStatusUtil:
|
||||
try:
|
||||
res = subprocess.call(shlex.split(command), stdout=statusFile, stderr=statusFile)
|
||||
if res == 1:
|
||||
raise 0
|
||||
return 0
|
||||
else:
|
||||
return 1
|
||||
except BaseException, msg:
|
||||
@@ -137,6 +142,94 @@ class ServerStatusUtil:
|
||||
if os.path.exists('/usr/local/usr'):
|
||||
shutil.rmtree('/usr/local/usr')
|
||||
|
||||
@staticmethod
|
||||
def createWebsite(website):
|
||||
try:
|
||||
virtualHostName = website.domain
|
||||
|
||||
confPath = vhost.Server_root + "/conf/vhosts/" + virtualHostName
|
||||
FNULL = open(os.devnull, 'w')
|
||||
if not os.path.exists(confPath):
|
||||
command = 'mkdir -p ' + confPath
|
||||
ServerStatusUtil.executioner(command, FNULL)
|
||||
|
||||
completePathToConfigFile = confPath + "/vhost.conf"
|
||||
|
||||
if vhost.perHostVirtualConf(completePathToConfigFile, website.adminEmail , website.externalApp, website.phpSelection,
|
||||
virtualHostName, 1) == 1:
|
||||
pass
|
||||
else:
|
||||
return 0
|
||||
|
||||
retValues = vhost.createConfigInMainVirtualHostFile(virtualHostName)
|
||||
if retValues[0] == 0:
|
||||
return 0
|
||||
|
||||
if os.path.exists('/etc/letsencrypt/live/' + virtualHostName):
|
||||
sslUtilities.installSSLForDomain(virtualHostUtilities, website.adminEmail)
|
||||
|
||||
vhostPath = vhost.Server_root + "/conf/vhosts"
|
||||
FNULL = open(os.devnull, 'w')
|
||||
command = "chown -R " + "lsadm" + ":" + "lsadm" + " " + vhostPath
|
||||
cmd = shlex.split(command)
|
||||
subprocess.call(cmd, stdout=FNULL, stderr=subprocess.STDOUT)
|
||||
|
||||
except BaseException, msg:
|
||||
logging.CyberCPLogFileWriter.writeToFile(str(msg))
|
||||
return 0
|
||||
|
||||
@staticmethod
|
||||
def createDomain(website):
|
||||
try:
|
||||
virtualHostName = website.domain
|
||||
|
||||
confPath = vhost.Server_root + "/conf/vhosts/" + virtualHostName
|
||||
completePathToConfigFile = confPath + "/vhost.conf"
|
||||
|
||||
confPath = vhost.Server_root + "/conf/vhosts/" + virtualHostName
|
||||
FNULL = open(os.devnull, 'w')
|
||||
if not os.path.exists(confPath):
|
||||
command = 'mkdir -p ' + confPath
|
||||
ServerStatusUtil.executioner(command, FNULL)
|
||||
|
||||
if vhost.perHostDomainConf(website.path, website.master.domain, virtualHostName, completePathToConfigFile, website.master.adminEmail, website.master.externalApp,
|
||||
website.phpSelection, 1) == 1:
|
||||
pass
|
||||
else:
|
||||
return 0
|
||||
|
||||
retValues = vhost.createConfigInMainDomainHostFile(virtualHostName, website.master.domain)
|
||||
|
||||
if retValues[0] == 0:
|
||||
return 0
|
||||
|
||||
if os.path.exists('/etc/letsencrypt/live/' + virtualHostName):
|
||||
sslUtilities.installSSLForDomain(virtualHostUtilities, website.adminEmail)
|
||||
|
||||
vhostPath = vhost.Server_root + "/conf/vhosts"
|
||||
FNULL = open(os.devnull, 'w')
|
||||
command = "chown -R " + "lsadm" + ":" + "lsadm" + " " + vhostPath
|
||||
cmd = shlex.split(command)
|
||||
subprocess.call(cmd, stdout=FNULL, stderr=subprocess.STDOUT)
|
||||
|
||||
except BaseException, msg:
|
||||
logging.CyberCPLogFileWriter.writeToFile(str(msg))
|
||||
return 0
|
||||
|
||||
@staticmethod
|
||||
def rebuildvConf():
|
||||
try:
|
||||
allWebsites = Websites.objects.all()
|
||||
for website in allWebsites:
|
||||
logging.CyberCPLogFileWriter.statusWriter(ServerStatusUtil.lswsInstallStatusPath,
|
||||
"Building vhost conf for:" + website.domain + ".\n")
|
||||
ServerStatusUtil.createWebsite(website)
|
||||
logging.CyberCPLogFileWriter.statusWriter(ServerStatusUtil.lswsInstallStatusPath,
|
||||
"vhost conf successfully built for:" + website.domain + ".\n")
|
||||
except BaseException, msg:
|
||||
logging.CyberCPLogFileWriter.writeToFile(str(msg))
|
||||
return 0
|
||||
|
||||
@staticmethod
|
||||
def switchTOLSWS(licenseKey):
|
||||
try:
|
||||
@@ -189,6 +282,15 @@ class ServerStatusUtil:
|
||||
ServerStatusUtil.recover()
|
||||
return 0
|
||||
|
||||
logging.CyberCPLogFileWriter.statusWriter(ServerStatusUtil.lswsInstallStatusPath,
|
||||
"Rebuilding vhost conf..\n")
|
||||
|
||||
ServerStatusUtil.rebuildvConf()
|
||||
|
||||
logging.CyberCPLogFileWriter.statusWriter(ServerStatusUtil.lswsInstallStatusPath,
|
||||
"vhost conf successfully built.\n")
|
||||
|
||||
|
||||
logging.CyberCPLogFileWriter.statusWriter(ServerStatusUtil.lswsInstallStatusPath,"Successfully switched to LITESPEED ENTERPRISE WEB SERVER. [200]\n")
|
||||
|
||||
except BaseException, msg:
|
||||
|
||||
BIN
static/images/agreement.png
Normal file
BIN
static/images/agreement.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.1 KiB |
BIN
static/images/change.png
Normal file
BIN
static/images/change.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.1 KiB |
@@ -73,7 +73,6 @@ app.controller('litespeedStatus', function ($scope, $http) {
|
||||
|
||||
};
|
||||
|
||||
|
||||
$scope.stopLitespeed = function () {
|
||||
|
||||
|
||||
@@ -134,6 +133,127 @@ app.controller('litespeedStatus', function ($scope, $http) {
|
||||
|
||||
};
|
||||
|
||||
/// License Manager
|
||||
|
||||
$scope.cpLoading = true;
|
||||
$scope.fetchedData = true;
|
||||
$scope.changeSerialBox = true;
|
||||
|
||||
$scope.hideLicenseStatus = function () {
|
||||
$scope.fetchedData = true;
|
||||
};
|
||||
|
||||
$scope.licenseStatus = function () {
|
||||
|
||||
$scope.cpLoading = false;
|
||||
$scope.changeSerialBox = true;
|
||||
|
||||
var url = "/serverstatus/licenseStatus";
|
||||
|
||||
var data = {};
|
||||
|
||||
var config = {
|
||||
headers: {
|
||||
'X-CSRFToken': getCookie('csrftoken')
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
|
||||
|
||||
|
||||
function ListInitialDatas(response) {
|
||||
|
||||
if (response.data.status === 1) {
|
||||
$scope.cpLoading = true;
|
||||
$scope.fetchedData = false;
|
||||
new PNotify({
|
||||
title: 'Success!',
|
||||
text: 'Status successfully fetched',
|
||||
type: 'success'
|
||||
});
|
||||
$scope.lsSerial = response.data.lsSerial;
|
||||
$scope.lsexpiration = response.data.lsexpiration;
|
||||
}
|
||||
else {
|
||||
$scope.cpLoading = true;
|
||||
new PNotify({
|
||||
title: 'Operation Failed!',
|
||||
text: response.data.erroMessage,
|
||||
type: 'error'
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function cantLoadInitialDatas(response) {
|
||||
$scope.cpLoading = true;
|
||||
new PNotify({
|
||||
title: 'Operation Failed!',
|
||||
text: 'Could not connect to server, please refresh this page.',
|
||||
type: 'error'
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
$scope.showSerialBox = function () {
|
||||
$scope.fetchedData = true;
|
||||
$scope.changeSerialBox = false;
|
||||
};
|
||||
$scope.changeLicense = function () {
|
||||
|
||||
$scope.cpLoading = false;
|
||||
|
||||
var url = "/serverstatus/changeLicense";
|
||||
|
||||
var data = {newKey: $scope.newKey};
|
||||
|
||||
var config = {
|
||||
headers: {
|
||||
'X-CSRFToken': getCookie('csrftoken')
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
|
||||
|
||||
|
||||
function ListInitialDatas(response) {
|
||||
|
||||
if (response.data.status === 1) {
|
||||
$scope.cpLoading = true;
|
||||
new PNotify({
|
||||
title: 'Success!',
|
||||
text: 'License successfully Updated',
|
||||
type: 'success'
|
||||
});
|
||||
}
|
||||
else {
|
||||
$scope.cpLoading = true;
|
||||
new PNotify({
|
||||
title: 'Operation Failed!',
|
||||
text: response.data.erroMessage,
|
||||
type: 'error'
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function cantLoadInitialDatas(response) {
|
||||
$scope.cpLoading = true;
|
||||
new PNotify({
|
||||
title: 'Operation Failed!',
|
||||
text: 'Could not connect to server, please refresh this page.',
|
||||
type: 'error'
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
});
|
||||
|
||||
/* Java script code to start/stop litespeed */
|
||||
|
||||
@@ -3,31 +3,34 @@
|
||||
{% block title %}{% trans "PHP Tuning - CyberPanel" %}{% endblock %}
|
||||
{% block content %}
|
||||
|
||||
{% load static %}
|
||||
{% get_current_language as LANGUAGE_CODE %}
|
||||
<!-- Current language: {{ LANGUAGE_CODE }} -->
|
||||
{% load static %}
|
||||
{% get_current_language as LANGUAGE_CODE %}
|
||||
<!-- Current language: {{ LANGUAGE_CODE }} -->
|
||||
|
||||
|
||||
<div class="container">
|
||||
<div id="page-title">
|
||||
{% if OLS %}
|
||||
<div class="container">
|
||||
<div id="page-title">
|
||||
<h2>{% trans "PHP Tuning" %}</h2>
|
||||
<p>{% trans "Set how each version of PHP behaves in your server here." %}</p>
|
||||
</div>
|
||||
<div class="panel">
|
||||
</div>
|
||||
<div class="panel">
|
||||
<div class="panel-body">
|
||||
<h3 class="title-hero">
|
||||
{% trans "Select PHP Version" %} <img id="tunePHPLoading" src="{% static 'images/loading.gif' %}">
|
||||
{% trans "Select PHP Version" %} <img id="tunePHPLoading"
|
||||
src="{% static 'images/loading.gif' %}">
|
||||
</h3>
|
||||
<div class="example-box-wrapper">
|
||||
|
||||
|
||||
<form ng-controller="tunePHP" action="/" id="modifyPackageForm" class="form-horizontal bordered-row">
|
||||
<form ng-controller="tunePHP" action="/" id="modifyPackageForm"
|
||||
class="form-horizontal bordered-row">
|
||||
|
||||
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label">{% trans "Select Domain" %}</label>
|
||||
<div class="col-sm-6">
|
||||
<select ng-change="fetchPHPDetails()" ng-model="domainSelection" class="form-control">
|
||||
<select ng-change="fetchPHPDetails()" ng-model="domainSelection"
|
||||
class="form-control">
|
||||
{% for items in websiteList %}
|
||||
<option>{{ items }}</option>
|
||||
{% endfor %}
|
||||
@@ -99,7 +102,8 @@
|
||||
<div ng-hide="hideDetails" class="form-group">
|
||||
<label class="col-sm-3 control-label"></label>
|
||||
<div class="col-sm-4">
|
||||
<button type="button" ng-click="tunePHPFunc()" class="btn btn-primary btn-lg btn-block">{% trans "Tune PHP" %}</button>
|
||||
<button type="button" ng-click="tunePHPFunc()"
|
||||
class="btn btn-primary btn-lg btn-block">{% trans "Tune PHP" %}</button>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
@@ -121,26 +125,163 @@
|
||||
</div>
|
||||
|
||||
<div id="successfullyTuned" class="alert alert-success">
|
||||
<p>{% trans "PHP for " %}<strong>{$ phpVersionTuned $}</strong> {% trans "Successfully tuned." %}</p>
|
||||
<p>{% trans "PHP for " %}<strong>{$ phpVersionTuned
|
||||
$}</strong> {% trans "Successfully tuned." %}</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
</form>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
{% else %}
|
||||
<div class="container">
|
||||
<div id="page-title">
|
||||
<h2>{% trans "PHP Tuning" %}</h2>
|
||||
<p>{% trans "Set how each version of PHP behaves in your server here." %}</p>
|
||||
</div>
|
||||
<div class="panel">
|
||||
<div class="panel-body">
|
||||
<h3 class="title-hero">
|
||||
{% trans "Select PHP Version" %} <img id="tunePHPLoading"
|
||||
src="{% static 'images/loading.gif' %}">
|
||||
</h3>
|
||||
<div class="example-box-wrapper">
|
||||
|
||||
|
||||
<form ng-controller="tunePHP" action="/" id="modifyPackageForm"
|
||||
class="form-horizontal bordered-row">
|
||||
|
||||
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label">{% trans "Select PHP" %}</label>
|
||||
<div class="col-sm-6">
|
||||
<select ng-change="fetchPHPDetails()" ng-model="domainSelection"
|
||||
class="form-control">
|
||||
<option>lsphp53</option>
|
||||
<option>lsphp54</option>
|
||||
<option>lsphp55</option>
|
||||
<option>lsphp56</option>
|
||||
<option>lsphp71</option>
|
||||
<option>lsphp72</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<!------ Modification form that appears after a click --------------->
|
||||
|
||||
<div ng-hide="hideDetails" class="form-group">
|
||||
<label class="col-sm-3 control-label">{% trans "Initial Request Timeout (secs)" %}</label>
|
||||
<div class="col-sm-6">
|
||||
<input type="number" class="form-control" ng-model="initTimeout" required>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div ng-hide="hideDetails" class="form-group">
|
||||
<label class="col-sm-3 control-label">{% trans "Max Connections" %}</label>
|
||||
<div class="col-sm-6">
|
||||
<input type="number" class="form-control" ng-model="maxConns" required>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div ng-hide="hideDetails" class="form-group">
|
||||
<label class="col-sm-3 control-label">{% trans "Memory Soft Limit" %}</label>
|
||||
<div class="col-sm-6">
|
||||
<input type="text" class="form-control" ng-model="memSoftLimit" required>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div ng-hide="hideDetails" class="form-group">
|
||||
<label class="col-sm-3 control-label">{% trans "Memory Hard Limit" %}</label>
|
||||
<div class="col-sm-6">
|
||||
<input type="text" class="form-control" ng-model="memHardLimit" required>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div ng-hide="hideDetails" class="form-group">
|
||||
<label class="col-sm-3 control-label">{% trans "Process Soft Limit" %}</label>
|
||||
<div class="col-sm-6">
|
||||
<input type="number" class="form-control" ng-model="procSoftLimit" required>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div ng-hide="hideDetails" class="form-group">
|
||||
<label class="col-sm-3 control-label">{% trans "Process Hard Limit" %}</label>
|
||||
<div class="col-sm-6">
|
||||
<input type="number" class="form-control" ng-model="procHardLimit" required>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div ng-hide="hideDetails" class="form-group">
|
||||
<label class="col-sm-3 control-label">{% trans "Persistent Connection" %}</label>
|
||||
<div class="col-sm-6">
|
||||
<select ng-model="persistConn" class="form-control">
|
||||
<option>{% trans "Enable" %}</option>
|
||||
<option>{% trans "Disable" %}</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="current-pack">{% trans "Currently:" %} {$ persistStatus $}</div>
|
||||
</div>
|
||||
<!------ Modification form that appears after a click --------------->
|
||||
|
||||
|
||||
<div ng-hide="hideDetails" class="form-group">
|
||||
<label class="col-sm-3 control-label"></label>
|
||||
<div class="col-sm-4">
|
||||
<button type="button" ng-click="tunePHPFunc()"
|
||||
class="btn btn-primary btn-lg btn-block">{% trans "Tune PHP" %}</button>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label"></label>
|
||||
<div class="col-sm-4">
|
||||
<div id="canNotFetch" class="alert alert-danger">
|
||||
<p>{% trans "Cannot fetch details. Error message:" %} {$ errorMessage $}</p>
|
||||
</div>
|
||||
|
||||
<div id="canNotTune" class="alert alert-danger">
|
||||
<p>{% trans "Cannot tune. Error message:" %} {$ errorMessage $}</p>
|
||||
</div>
|
||||
|
||||
|
||||
<div id="successfullyFetched" class="alert alert-success">
|
||||
<p>{% trans "Details Successfully fetched." %}</p>
|
||||
</div>
|
||||
|
||||
<div id="successfullyTuned" class="alert alert-success">
|
||||
<p>{% trans "PHP for " %}<strong>{$ phpVersionTuned
|
||||
$}</strong> {% trans "Successfully tuned." %}</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
</form>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% endblock %}
|
||||
185
tuning/tuning.py
Normal file
185
tuning/tuning.py
Normal file
@@ -0,0 +1,185 @@
|
||||
#!/usr/local/CyberCP/bin/python2
|
||||
import os.path
|
||||
import sys
|
||||
import django
|
||||
sys.path.append('/usr/local/CyberCP')
|
||||
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "CyberCP.settings")
|
||||
django.setup()
|
||||
from django.shortcuts import render,redirect
|
||||
from django.http import HttpResponse
|
||||
import json
|
||||
import plogical.CyberCPLogFileWriter as logging
|
||||
from plogical.tuning import tuning
|
||||
from loginSystem.views import loadLoginPage
|
||||
from plogical.virtualHostUtilities import virtualHostUtilities
|
||||
import subprocess
|
||||
import shlex
|
||||
from plogical.acl import ACLManager
|
||||
from plogical.processUtilities import ProcessUtilities
|
||||
|
||||
|
||||
class tuningManager:
|
||||
def loadTuningHome(self, request, userID):
|
||||
try:
|
||||
userID = request.session['userID']
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
|
||||
if currentACL['admin'] == 1:
|
||||
pass
|
||||
else:
|
||||
return ACLManager.loadError()
|
||||
|
||||
return render(request, 'tuning/index.html', {})
|
||||
except KeyError:
|
||||
return redirect(loadLoginPage)
|
||||
|
||||
def liteSpeedTuning(self, request, userID):
|
||||
try:
|
||||
userID = request.session['userID']
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
|
||||
if currentACL['admin'] == 1:
|
||||
pass
|
||||
else:
|
||||
return ACLManager.loadError()
|
||||
return render(request, 'tuning/liteSpeedTuning.html', {})
|
||||
except KeyError:
|
||||
return redirect(loadLoginPage)
|
||||
|
||||
def phpTuning(self, request, userID):
|
||||
try:
|
||||
userID = request.session['userID']
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
|
||||
if currentACL['admin'] == 1:
|
||||
pass
|
||||
else:
|
||||
return ACLManager.loadError()
|
||||
|
||||
if ProcessUtilities.decideServer() == ProcessUtilities.OLS:
|
||||
websitesName = ACLManager.findAllSites(currentACL, userID)
|
||||
OLS = 1
|
||||
return render(request, 'tuning/phpTuning.html', {'websiteList': websitesName, 'OLS': OLS})
|
||||
else:
|
||||
OLS = 0
|
||||
return render(request, 'tuning/phpTuning.html', {'OLS': OLS})
|
||||
|
||||
except KeyError:
|
||||
return redirect(loadLoginPage)
|
||||
|
||||
def tuneLitespeed(self, userID, data):
|
||||
try:
|
||||
|
||||
status = data['status']
|
||||
if status == "fetch":
|
||||
|
||||
json_data = json.dumps(tuning.fetchTuningDetails())
|
||||
|
||||
data_ret = {'fetch_status': 1, 'error_message': "None", "tuning_data": json_data,
|
||||
'tuneStatus': 0}
|
||||
|
||||
final_json = json.dumps(data_ret)
|
||||
return HttpResponse(final_json)
|
||||
|
||||
else:
|
||||
if not data['maxConn']:
|
||||
data_ret = {'fetch_status': 1, 'error_message': "Provide Max Connections", 'tuneStatus': 0}
|
||||
final_json = json.dumps(data_ret)
|
||||
return HttpResponse(final_json)
|
||||
|
||||
if not data['maxSSLConn']:
|
||||
data_ret = {'fetch_status': 1, 'error_message': "Provide Max SSL Connections",
|
||||
'tuneStatus': 0}
|
||||
final_json = json.dumps(data_ret)
|
||||
return HttpResponse(final_json)
|
||||
|
||||
if not data['keepAlive']:
|
||||
data_ret = {'fetch_status': 1, 'error_message': "Provide Keep Alive", 'tuneStatus': 0}
|
||||
final_json = json.dumps(data_ret)
|
||||
return HttpResponse(final_json)
|
||||
|
||||
if not data['inMemCache']:
|
||||
data_ret = {'fetch_status': 1, 'error_message': "Provide Cache Size in memory",
|
||||
'tuneStatus': 0}
|
||||
final_json = json.dumps(data_ret)
|
||||
return HttpResponse(final_json)
|
||||
|
||||
if not data['gzipCompression']:
|
||||
data_ret = {'fetch_status': 1, 'error_message': "Provide Enable GZIP Compression",
|
||||
'tuneStatus': 0}
|
||||
final_json = json.dumps(data_ret)
|
||||
return HttpResponse(final_json)
|
||||
|
||||
maxConn = data['maxConn']
|
||||
maxSSLConn = data['maxSSLConn']
|
||||
connTime = data['connTime']
|
||||
keepAlive = data['keepAlive']
|
||||
inMemCache = data['inMemCache']
|
||||
gzipCompression = data['gzipCompression']
|
||||
|
||||
execPath = "sudo python " + virtualHostUtilities.cyberPanel + "/plogical/tuning.py"
|
||||
|
||||
execPath = execPath + " saveTuningDetails --maxConn " + maxConn + " --maxSSLConn " + maxSSLConn + " --connTime " + connTime + " --keepAlive " + keepAlive + " --inMemCache '" + inMemCache + "' --gzipCompression " + gzipCompression
|
||||
|
||||
output = subprocess.check_output(shlex.split(execPath))
|
||||
|
||||
if output.find("1,None") > -1:
|
||||
data_ret = {'fetch_status': 1, 'error_message': "None", 'tuneStatus': 1}
|
||||
final_json = json.dumps(data_ret)
|
||||
return HttpResponse(final_json)
|
||||
else:
|
||||
data_ret = {'fetch_status': 1, 'error_message': "None", 'tuneStatus': 0}
|
||||
final_json = json.dumps(data_ret)
|
||||
return HttpResponse(final_json)
|
||||
|
||||
except BaseException, msg:
|
||||
data_ret = {'fetch_status': 0, 'error_message': str(msg), 'tuneStatus': 0}
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
|
||||
def tunePHP(self, userID, data):
|
||||
try:
|
||||
status = data['status']
|
||||
domainSelection = str(data['domainSelection'])
|
||||
|
||||
if status == "fetch":
|
||||
|
||||
json_data = json.dumps(tuning.fetchPHPDetails(domainSelection))
|
||||
|
||||
data_ret = {'fetch_status': 1, 'error_message': "None", "tuning_data": json_data,
|
||||
'tuneStatus': 0}
|
||||
|
||||
final_json = json.dumps(data_ret)
|
||||
|
||||
return HttpResponse(final_json)
|
||||
|
||||
else:
|
||||
initTimeout = str(data['initTimeout'])
|
||||
maxConns = str(data['maxConns'])
|
||||
memSoftLimit = data['memSoftLimit']
|
||||
memHardLimit = data['memHardLimit']
|
||||
procSoftLimit = str(data['procSoftLimit'])
|
||||
procHardLimit = str(data['procHardLimit'])
|
||||
persistConn = data['persistConn']
|
||||
|
||||
execPath = "sudo python " + virtualHostUtilities.cyberPanel + "/plogical/tuning.py"
|
||||
|
||||
execPath = execPath + " tunePHP --virtualHost " + domainSelection + " --initTimeout " + initTimeout + " --maxConns " + maxConns + " --memSoftLimit " + memSoftLimit + " --memHardLimit '" + memHardLimit + "' --procSoftLimit " + procSoftLimit + " --procHardLimit " + procHardLimit + " --persistConn " + persistConn
|
||||
|
||||
output = subprocess.check_output(shlex.split(execPath))
|
||||
|
||||
if output.find("1,None") > -1:
|
||||
data_ret = {'tuneStatus': 1, 'fetch_status': 0, 'error_message': "None"}
|
||||
final_json = json.dumps(data_ret)
|
||||
return HttpResponse(final_json)
|
||||
else:
|
||||
data_ret = {'fetch_status': 0, 'error_message': output, 'tuneStatus': 0}
|
||||
logging.CyberCPLogFileWriter.writeToFile(output + " [tunePHP]]")
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
|
||||
except BaseException, msg:
|
||||
data_ret = {'fetch_status': 0, 'error_message': str(msg), 'tuneStatus': 0}
|
||||
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [tunePHP]]")
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
178
tuning/views.py
178
tuning/views.py
@@ -11,198 +11,46 @@ from plogical.virtualHostUtilities import virtualHostUtilities
|
||||
import subprocess
|
||||
import shlex
|
||||
from plogical.acl import ACLManager
|
||||
from tuning import tuningManager
|
||||
# Create your views here.
|
||||
|
||||
|
||||
def loadTuningHome(request):
|
||||
try:
|
||||
userID = request.session['userID']
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
|
||||
if currentACL['admin'] == 1:
|
||||
pass
|
||||
else:
|
||||
return ACLManager.loadError()
|
||||
|
||||
return render(request,'tuning/index.html',{})
|
||||
tm = tuningManager()
|
||||
return tm.loadTuningHome(request, userID)
|
||||
except KeyError:
|
||||
return redirect(loadLoginPage)
|
||||
|
||||
|
||||
def liteSpeedTuning(request):
|
||||
try:
|
||||
userID = request.session['userID']
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
|
||||
if currentACL['admin'] == 1:
|
||||
pass
|
||||
else:
|
||||
return ACLManager.loadError()
|
||||
return render(request,'tuning/liteSpeedTuning.html',{})
|
||||
tm = tuningManager()
|
||||
return tm.liteSpeedTuning(request, userID)
|
||||
except KeyError:
|
||||
return redirect(loadLoginPage)
|
||||
|
||||
|
||||
def phpTuning(request):
|
||||
try:
|
||||
userID = request.session['userID']
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
|
||||
if currentACL['admin'] == 1:
|
||||
pass
|
||||
else:
|
||||
return ACLManager.loadError()
|
||||
|
||||
websitesName = ACLManager.findAllSites(currentACL, userID)
|
||||
|
||||
return render(request,'tuning/phpTuning.html',{'websiteList':websitesName})
|
||||
tm = tuningManager()
|
||||
return tm.phpTuning(request, userID)
|
||||
except KeyError:
|
||||
return redirect(loadLoginPage)
|
||||
|
||||
|
||||
def tuneLitespeed(request):
|
||||
|
||||
try:
|
||||
userID = request.session['userID']
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
|
||||
if currentACL['admin'] == 1:
|
||||
pass
|
||||
else:
|
||||
return ACLManager.loadErrorJson('fetch_status', 0)
|
||||
try:
|
||||
|
||||
if request.method == 'POST':
|
||||
data = json.loads(request.body)
|
||||
status = data['status']
|
||||
|
||||
if status == "fetch":
|
||||
|
||||
json_data = json.dumps(tuning.fetchTuningDetails())
|
||||
|
||||
data_ret = {'fetch_status': 1, 'error_message': "None", "tuning_data": json_data, 'tuneStatus': 0}
|
||||
|
||||
final_json = json.dumps(data_ret)
|
||||
return HttpResponse(final_json)
|
||||
|
||||
else:
|
||||
if not data['maxConn']:
|
||||
data_ret = {'fetch_status': 1, 'error_message': "Provide Max Connections", 'tuneStatus': 0}
|
||||
final_json = json.dumps(data_ret)
|
||||
return HttpResponse(final_json)
|
||||
|
||||
if not data['maxSSLConn']:
|
||||
data_ret = {'fetch_status': 1, 'error_message': "Provide Max SSL Connections", 'tuneStatus': 0}
|
||||
final_json = json.dumps(data_ret)
|
||||
return HttpResponse(final_json)
|
||||
|
||||
if not data['keepAlive']:
|
||||
data_ret = {'fetch_status': 1, 'error_message': "Provide Keep Alive", 'tuneStatus': 0}
|
||||
final_json = json.dumps(data_ret)
|
||||
return HttpResponse(final_json)
|
||||
|
||||
if not data['inMemCache']:
|
||||
data_ret = {'fetch_status': 1, 'error_message': "Provide Cache Size in memory", 'tuneStatus': 0}
|
||||
final_json = json.dumps(data_ret)
|
||||
return HttpResponse(final_json)
|
||||
|
||||
if not data['gzipCompression']:
|
||||
data_ret = {'fetch_status': 1, 'error_message': "Provide Enable GZIP Compression",
|
||||
'tuneStatus': 0}
|
||||
final_json = json.dumps(data_ret)
|
||||
return HttpResponse(final_json)
|
||||
|
||||
maxConn = data['maxConn']
|
||||
maxSSLConn = data['maxSSLConn']
|
||||
connTime = data['connTime']
|
||||
keepAlive = data['keepAlive']
|
||||
inMemCache = data['inMemCache']
|
||||
gzipCompression = data['gzipCompression']
|
||||
|
||||
execPath = "sudo python " + virtualHostUtilities.cyberPanel + "/plogical/tuning.py"
|
||||
|
||||
execPath = execPath + " saveTuningDetails --maxConn " + maxConn + " --maxSSLConn " + maxSSLConn + " --connTime " + connTime + " --keepAlive " + keepAlive + " --inMemCache '" + inMemCache + "' --gzipCompression " + gzipCompression
|
||||
|
||||
output = subprocess.check_output(shlex.split(execPath))
|
||||
|
||||
if output.find("1,None") > -1:
|
||||
data_ret = {'fetch_status': 1, 'error_message': "None", 'tuneStatus': 1}
|
||||
final_json = json.dumps(data_ret)
|
||||
return HttpResponse(final_json)
|
||||
else:
|
||||
data_ret = {'fetch_status': 1, 'error_message': "None", 'tuneStatus': 0}
|
||||
final_json = json.dumps(data_ret)
|
||||
return HttpResponse(final_json)
|
||||
|
||||
except BaseException,msg:
|
||||
data_ret = {'fetch_status': 0, 'error_message': str(msg), 'tuneStatus': 0}
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
|
||||
tm = tuningManager()
|
||||
return tm.tuneLitespeed(userID, json.loads(request.body))
|
||||
except KeyError:
|
||||
data_ret = {'fetch_status': 0, 'error_message': "not logged in as admin",'fetch_status': 0}
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
|
||||
return redirect(loadLoginPage)
|
||||
|
||||
def tunePHP(request):
|
||||
try:
|
||||
userID = request.session['userID']
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
|
||||
if currentACL['admin'] == 1:
|
||||
pass
|
||||
else:
|
||||
return ACLManager.loadErrorJson('fetch_status', 0)
|
||||
try:
|
||||
if request.method == 'POST':
|
||||
data = json.loads(request.body)
|
||||
status = data['status']
|
||||
domainSelection = str(data['domainSelection'])
|
||||
|
||||
if status == "fetch":
|
||||
|
||||
json_data = json.dumps(tuning.fetchPHPDetails(domainSelection))
|
||||
|
||||
data_ret = {'fetch_status': 1, 'error_message': "None", "tuning_data": json_data, 'tuneStatus': 0}
|
||||
|
||||
final_json = json.dumps(data_ret)
|
||||
|
||||
return HttpResponse(final_json)
|
||||
|
||||
else:
|
||||
initTimeout = str(data['initTimeout'])
|
||||
maxConns = str(data['maxConns'])
|
||||
memSoftLimit = data['memSoftLimit']
|
||||
memHardLimit = data['memHardLimit']
|
||||
procSoftLimit = str(data['procSoftLimit'])
|
||||
procHardLimit = str(data['procHardLimit'])
|
||||
persistConn = data['persistConn']
|
||||
|
||||
execPath = "sudo python " + virtualHostUtilities.cyberPanel + "/plogical/tuning.py"
|
||||
|
||||
execPath = execPath + " tunePHP --virtualHost " + domainSelection + " --initTimeout " + initTimeout + " --maxConns " + maxConns + " --memSoftLimit " + memSoftLimit + " --memHardLimit '" + memHardLimit + "' --procSoftLimit " + procSoftLimit + " --procHardLimit " + procHardLimit + " --persistConn " + persistConn
|
||||
|
||||
output = subprocess.check_output(shlex.split(execPath))
|
||||
|
||||
if output.find("1,None") > -1:
|
||||
data_ret = {'tuneStatus': 1, 'fetch_status': 0, 'error_message': "None"}
|
||||
final_json = json.dumps(data_ret)
|
||||
return HttpResponse(final_json)
|
||||
else:
|
||||
data_ret = {'fetch_status': 0, 'error_message': output, 'tuneStatus': 0}
|
||||
logging.CyberCPLogFileWriter.writeToFile(output + " [tunePHP]]")
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
|
||||
except BaseException,msg:
|
||||
data_ret = {'fetch_status': 0, 'error_message': str(msg),'tuneStatus': 0}
|
||||
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [tunePHP]]")
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
|
||||
tm = tuningManager()
|
||||
return tm.tunePHP(userID, json.loads(request.body))
|
||||
except KeyError:
|
||||
data_ret = {'tuneStatus': 0, 'error_message': "not logged in as admin",'fetch_status': 0}
|
||||
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [tunePHP]]")
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
return redirect(loadLoginPage)
|
||||
Reference in New Issue
Block a user