mirror of
https://github.com/usmannasir/cyberpanel.git
synced 2025-11-07 22:06:05 +01:00
bug fix to lsws switch
This commit is contained in:
@@ -1013,9 +1013,9 @@ class preFlightsChecks:
|
|||||||
while (1):
|
while (1):
|
||||||
|
|
||||||
if self.distro == centos:
|
if self.distro == centos:
|
||||||
command = 'yum -y install zip'
|
command = 'yum -y install unzip'
|
||||||
else:
|
else:
|
||||||
command = 'apt-get -y install zip'
|
command = 'apt-get -y install unzip'
|
||||||
|
|
||||||
cmd = shlex.split(command)
|
cmd = shlex.split(command)
|
||||||
res = subprocess.call(cmd)
|
res = subprocess.call(cmd)
|
||||||
|
|||||||
@@ -225,16 +225,15 @@ class InstallCyberPanel:
|
|||||||
def installAllPHPVersions(self):
|
def installAllPHPVersions(self):
|
||||||
try:
|
try:
|
||||||
count = 0
|
count = 0
|
||||||
|
|
||||||
while (1):
|
while (1):
|
||||||
|
|
||||||
if self.distro == ubuntu:
|
if self.distro == ubuntu:
|
||||||
command = 'DEBIAN_FRONTEND=noninteractive apt-get -y install ' \
|
command = 'DEBIAN_FRONTEND=noninteractive apt-get -y install ' \
|
||||||
'lsphp7? lsphp7?-common lsphp7?-curl lsphp7?-dev lsphp7?-imap lsphp7?-intl lsphp7?-json ' \
|
'lsphp7? lsphp7?-common lsphp7?-curl lsphp7?-dev lsphp7?-imap lsphp7?-intl lsphp7?-json ' \
|
||||||
'lsphp7?-ldap lsphp7?-mysql lsphp7?-opcache lsphp7?-pspell lsphp7?-recode ' \
|
'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)
|
res = os.system(command)
|
||||||
if res != 0:
|
|
||||||
res = 1 # Force a retry
|
|
||||||
else:
|
else:
|
||||||
command = 'yum -y groupinstall lsphp-all'
|
command = 'yum -y groupinstall lsphp-all'
|
||||||
cmd = shlex.split(command)
|
cmd = shlex.split(command)
|
||||||
|
|||||||
@@ -95,7 +95,7 @@ class ProcessUtilities:
|
|||||||
def decideServer():
|
def decideServer():
|
||||||
entPath = '/usr/local/lsws/bin/lshttpd'
|
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
|
return ProcessUtilities.OLS
|
||||||
else:
|
else:
|
||||||
return ProcessUtilities.ent
|
return ProcessUtilities.ent
|
||||||
|
|||||||
@@ -3,224 +3,386 @@ from installUtilities import installUtilities
|
|||||||
import argparse
|
import argparse
|
||||||
import subprocess
|
import subprocess
|
||||||
import shlex
|
import shlex
|
||||||
|
from processUtilities import ProcessUtilities
|
||||||
|
from xml.etree import ElementTree
|
||||||
|
|
||||||
class tuning:
|
class tuning:
|
||||||
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def fetchTuningDetails():
|
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")
|
||||||
|
|
||||||
try:
|
for items in datas:
|
||||||
dataToReturn = {}
|
if items.find("maxConnections")>-1:
|
||||||
|
data = items.split()
|
||||||
|
dataToReturn['maxConnections'] = data[1]
|
||||||
|
|
||||||
command = "sudo cat /usr/local/lsws/conf/httpd_config.conf"
|
if items.find("maxSSLConnections") > -1:
|
||||||
datas = subprocess.check_output(shlex.split(command)).split("\n")
|
data = items.split()
|
||||||
|
dataToReturn['maxSSLConnections'] = data[1]
|
||||||
|
|
||||||
for items in datas:
|
if items.find("connTimeout") > -1:
|
||||||
if items.find("maxConnections")>-1:
|
data = items.split()
|
||||||
data = items.split()
|
dataToReturn['connTimeout'] = data[1]
|
||||||
dataToReturn['maxConnections'] = data[1]
|
|
||||||
|
|
||||||
if items.find("maxSSLConnections") > -1:
|
|
||||||
data = items.split()
|
|
||||||
dataToReturn['maxSSLConnections'] = data[1]
|
|
||||||
|
|
||||||
if items.find("connTimeout") > -1:
|
|
||||||
data = items.split()
|
|
||||||
dataToReturn['connTimeout'] = data[1]
|
|
||||||
|
|
||||||
|
|
||||||
if items.find("maxConnections")>-1:
|
if items.find("maxConnections")>-1:
|
||||||
data = items.split()
|
data = items.split()
|
||||||
dataToReturn['maxConnections'] = data[1]
|
dataToReturn['maxConnections'] = data[1]
|
||||||
|
|
||||||
if items.find("keepAliveTimeout") > -1:
|
if items.find("keepAliveTimeout") > -1:
|
||||||
data = items.split()
|
data = items.split()
|
||||||
dataToReturn['keepAliveTimeout'] = data[1]
|
dataToReturn['keepAliveTimeout'] = data[1]
|
||||||
|
|
||||||
|
|
||||||
if items.find("totalInMemCacheSize") > -1:
|
if items.find("totalInMemCacheSize") > -1:
|
||||||
data = items.split()
|
data = items.split()
|
||||||
dataToReturn['totalInMemCacheSize'] = data[1]
|
dataToReturn['totalInMemCacheSize'] = data[1]
|
||||||
|
|
||||||
if items.find("enableGzipCompress") > -1:
|
if items.find("enableGzipCompress") > -1:
|
||||||
data = items.split()
|
data = items.split()
|
||||||
dataToReturn['enableGzipCompress'] = data[1]
|
dataToReturn['enableGzipCompress'] = data[1]
|
||||||
|
|
||||||
return dataToReturn
|
return dataToReturn
|
||||||
|
except BaseException, msg:
|
||||||
|
logging.CyberCPLogFileWriter.writeToFile(
|
||||||
|
str(msg) + " [fetchTuningDetails]")
|
||||||
|
return 0
|
||||||
|
else:
|
||||||
|
try:
|
||||||
|
dataToReturn = {}
|
||||||
|
|
||||||
except BaseException, msg:
|
command = "sudo cat /usr/local/lsws/conf/httpd_config.xml"
|
||||||
logging.CyberCPLogFileWriter.writeToFile(
|
datas = subprocess.check_output(shlex.split(command))
|
||||||
str(msg) + " [fetchTuningDetails]")
|
comTree = ElementTree.fromstring(datas)
|
||||||
return 0
|
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(
|
||||||
|
str(msg) + " [fetchTuningDetails]")
|
||||||
|
return 0
|
||||||
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def saveTuningDetails(maxConnections,maxSSLConnections,connectionTimeOut,keepAliveTimeOut,cacheSizeInMemory,gzipCompression):
|
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")
|
||||||
|
|
||||||
try:
|
if gzipCompression == "Enable":
|
||||||
datas = open("/usr/local/lsws/conf/httpd_config.conf").readlines()
|
gzip = 1
|
||||||
writeDataToFile = open("/usr/local/lsws/conf/httpd_config.conf","w")
|
|
||||||
|
|
||||||
if gzipCompression == "Enable":
|
|
||||||
gzip = 1
|
|
||||||
else:
|
|
||||||
gzip = 0
|
|
||||||
|
|
||||||
|
|
||||||
for items in datas:
|
|
||||||
if items.find("maxConnections") > -1:
|
|
||||||
data = " maxConnections "+str(maxConnections)+"\n"
|
|
||||||
writeDataToFile.writelines(data)
|
|
||||||
continue
|
|
||||||
|
|
||||||
elif items.find("maxSSLConnections") > -1:
|
|
||||||
data = " maxSSLConnections "+str(maxSSLConnections) + "\n"
|
|
||||||
writeDataToFile.writelines(data)
|
|
||||||
continue
|
|
||||||
|
|
||||||
elif items.find("connTimeout") > -1:
|
|
||||||
data =" connTimeout "+str(connectionTimeOut)+"\n"
|
|
||||||
writeDataToFile.writelines(data)
|
|
||||||
continue
|
|
||||||
|
|
||||||
elif items.find("keepAliveTimeout") > -1:
|
|
||||||
data = " keepAliveTimeout " + str(keepAliveTimeOut) + "\n"
|
|
||||||
writeDataToFile.writelines(data)
|
|
||||||
continue
|
|
||||||
|
|
||||||
elif items.find("totalInMemCacheSize") > -1:
|
|
||||||
data = " totalInMemCacheSize " + str(cacheSizeInMemory) + "\n"
|
|
||||||
writeDataToFile.writelines(data)
|
|
||||||
continue
|
|
||||||
|
|
||||||
elif items.find("enableGzipCompress") > -1:
|
|
||||||
data = " enableGzipCompress " + str(gzip) + "\n"
|
|
||||||
writeDataToFile.writelines(data)
|
|
||||||
continue
|
|
||||||
else:
|
else:
|
||||||
writeDataToFile.writelines(items)
|
gzip = 0
|
||||||
|
|
||||||
writeDataToFile.close()
|
|
||||||
|
|
||||||
print "1,None"
|
for items in datas:
|
||||||
|
if items.find("maxConnections") > -1:
|
||||||
|
data = " maxConnections "+str(maxConnections)+"\n"
|
||||||
|
writeDataToFile.writelines(data)
|
||||||
|
continue
|
||||||
|
|
||||||
except BaseException, msg:
|
elif items.find("maxSSLConnections") > -1:
|
||||||
logging.CyberCPLogFileWriter.writeToFile(
|
data = " maxSSLConnections "+str(maxSSLConnections) + "\n"
|
||||||
str(msg) + " [saveTuningDetails]")
|
writeDataToFile.writelines(data)
|
||||||
print "0," + str(msg)
|
continue
|
||||||
|
|
||||||
|
elif items.find("connTimeout") > -1:
|
||||||
|
data =" connTimeout "+str(connectionTimeOut)+"\n"
|
||||||
|
writeDataToFile.writelines(data)
|
||||||
|
continue
|
||||||
|
|
||||||
|
elif items.find("keepAliveTimeout") > -1:
|
||||||
|
data = " keepAliveTimeout " + str(keepAliveTimeOut) + "\n"
|
||||||
|
writeDataToFile.writelines(data)
|
||||||
|
continue
|
||||||
|
|
||||||
|
elif items.find("totalInMemCacheSize") > -1:
|
||||||
|
data = " totalInMemCacheSize " + str(cacheSizeInMemory) + "\n"
|
||||||
|
writeDataToFile.writelines(data)
|
||||||
|
continue
|
||||||
|
|
||||||
|
elif items.find("enableGzipCompress") > -1:
|
||||||
|
data = " enableGzipCompress " + str(gzip) + "\n"
|
||||||
|
writeDataToFile.writelines(data)
|
||||||
|
continue
|
||||||
|
else:
|
||||||
|
writeDataToFile.writelines(items)
|
||||||
|
|
||||||
|
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]")
|
||||||
|
print "0," + str(msg)
|
||||||
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def fetchPHPDetails(virtualHost):
|
def fetchPHPDetails(virtualHost):
|
||||||
try:
|
if ProcessUtilities.decideServer() == ProcessUtilities.OLS:
|
||||||
path = installUtilities.Server_root_path + "/conf/vhosts/"+virtualHost+"/vhost.conf"
|
try:
|
||||||
|
path = installUtilities.Server_root_path + "/conf/vhosts/"+virtualHost+"/vhost.conf"
|
||||||
|
|
||||||
command = "sudo cat "+path
|
command = "sudo cat "+path
|
||||||
datas = subprocess.check_output(shlex.split(command)).split("\n")
|
datas = subprocess.check_output(shlex.split(command)).split("\n")
|
||||||
|
|
||||||
dataToReturn = {}
|
dataToReturn = {}
|
||||||
|
|
||||||
for items in datas:
|
for items in datas:
|
||||||
if items.find("maxConns")>-1:
|
if items.find("maxConns")>-1:
|
||||||
data = items.split()
|
data = items.split()
|
||||||
dataToReturn['maxConns'] = data[1]
|
dataToReturn['maxConns'] = data[1]
|
||||||
|
|
||||||
if items.find("initTimeout") > -1:
|
if items.find("initTimeout") > -1:
|
||||||
data = items.split()
|
data = items.split()
|
||||||
dataToReturn['initTimeout'] = data[1]
|
dataToReturn['initTimeout'] = data[1]
|
||||||
|
|
||||||
if items.find("persistConn") > -1:
|
if items.find("persistConn") > -1:
|
||||||
data = items.split()
|
data = items.split()
|
||||||
dataToReturn['persistConn'] = data[1]
|
dataToReturn['persistConn'] = data[1]
|
||||||
|
|
||||||
|
|
||||||
if items.find("memSoftLimit")>-1:
|
if items.find("memSoftLimit")>-1:
|
||||||
data = items.split()
|
data = items.split()
|
||||||
dataToReturn['memSoftLimit'] = data[1]
|
dataToReturn['memSoftLimit'] = data[1]
|
||||||
|
|
||||||
if items.find("memHardLimit") > -1:
|
if items.find("memHardLimit") > -1:
|
||||||
data = items.split()
|
data = items.split()
|
||||||
dataToReturn['memHardLimit'] = data[1]
|
dataToReturn['memHardLimit'] = data[1]
|
||||||
|
|
||||||
|
|
||||||
if items.find("procSoftLimit") > -1:
|
if items.find("procSoftLimit") > -1:
|
||||||
data = items.split()
|
data = items.split()
|
||||||
dataToReturn['procSoftLimit'] = data[1]
|
dataToReturn['procSoftLimit'] = data[1]
|
||||||
|
|
||||||
if items.find("procHardLimit") > -1:
|
if items.find("procHardLimit") > -1:
|
||||||
data = items.split()
|
data = items.split()
|
||||||
dataToReturn['procHardLimit'] = data[1]
|
dataToReturn['procHardLimit'] = data[1]
|
||||||
|
|
||||||
return dataToReturn
|
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')
|
||||||
|
|
||||||
except BaseException, msg:
|
dataToReturn = {}
|
||||||
logging.CyberCPLogFileWriter.writeToFile(
|
|
||||||
str(msg) + " [fetchPHPDetails]")
|
for extProcessor in extProcessorList:
|
||||||
return 0
|
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]")
|
||||||
|
return 0
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def tunePHP(virtualHost,maxConns,initTimeout,persistConn,memSoftLimit,memHardLimit,procSoftLimit,procHardLimit):
|
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()
|
||||||
|
|
||||||
|
writeDataToFile = open(path,"w")
|
||||||
|
|
||||||
|
|
||||||
try:
|
for items in datas:
|
||||||
path = installUtilities.Server_root_path + "/conf/vhosts/" + virtualHost + "/vhost.conf"
|
if items.find("maxConns") > -1:
|
||||||
datas = open(path).readlines()
|
data = " maxConns "+str(maxConns)+"\n"
|
||||||
|
writeDataToFile.writelines(data)
|
||||||
|
continue
|
||||||
|
|
||||||
writeDataToFile = open(path,"w")
|
elif items.find("initTimeout") > -1:
|
||||||
|
data = " initTimeout "+str(initTimeout) + "\n"
|
||||||
|
writeDataToFile.writelines(data)
|
||||||
|
continue
|
||||||
|
|
||||||
|
elif items.find("memSoftLimit") > -1:
|
||||||
|
data =" memSoftLimit "+str(memSoftLimit)+"\n"
|
||||||
|
writeDataToFile.writelines(data)
|
||||||
|
continue
|
||||||
|
|
||||||
|
elif items.find("memHardLimit") > -1:
|
||||||
|
data = " memHardLimit " + str(memHardLimit) + "\n"
|
||||||
|
writeDataToFile.writelines(data)
|
||||||
|
continue
|
||||||
|
|
||||||
|
elif items.find("procSoftLimit") > -1:
|
||||||
|
data = " procSoftLimit " + str(procSoftLimit) + "\n"
|
||||||
|
writeDataToFile.writelines(data)
|
||||||
|
continue
|
||||||
|
|
||||||
|
elif items.find("procHardLimit") > -1:
|
||||||
|
data = " procHardLimit " + str(procHardLimit) + "\n"
|
||||||
|
writeDataToFile.writelines(data)
|
||||||
|
continue
|
||||||
|
elif items.find("persistConn") > -1:
|
||||||
|
if persistConn == "Enable":
|
||||||
|
persist = 1
|
||||||
|
else:
|
||||||
|
persist = 0
|
||||||
|
|
||||||
|
|
||||||
for items in datas:
|
data = " persistConn " + str(persist) + "\n"
|
||||||
if items.find("maxConns") > -1:
|
writeDataToFile.writelines(data)
|
||||||
data = " maxConns "+str(maxConns)+"\n"
|
continue
|
||||||
writeDataToFile.writelines(data)
|
|
||||||
continue
|
|
||||||
|
|
||||||
elif items.find("initTimeout") > -1:
|
|
||||||
data = " initTimeout "+str(initTimeout) + "\n"
|
|
||||||
writeDataToFile.writelines(data)
|
|
||||||
continue
|
|
||||||
|
|
||||||
elif items.find("memSoftLimit") > -1:
|
|
||||||
data =" memSoftLimit "+str(memSoftLimit)+"\n"
|
|
||||||
writeDataToFile.writelines(data)
|
|
||||||
continue
|
|
||||||
|
|
||||||
elif items.find("memHardLimit") > -1:
|
|
||||||
data = " memHardLimit " + str(memHardLimit) + "\n"
|
|
||||||
writeDataToFile.writelines(data)
|
|
||||||
continue
|
|
||||||
|
|
||||||
elif items.find("procSoftLimit") > -1:
|
|
||||||
data = " procSoftLimit " + str(procSoftLimit) + "\n"
|
|
||||||
writeDataToFile.writelines(data)
|
|
||||||
continue
|
|
||||||
|
|
||||||
elif items.find("procHardLimit") > -1:
|
|
||||||
data = " procHardLimit " + str(procHardLimit) + "\n"
|
|
||||||
writeDataToFile.writelines(data)
|
|
||||||
continue
|
|
||||||
elif items.find("persistConn") > -1:
|
|
||||||
if persistConn == "Enable":
|
|
||||||
persist = 1
|
|
||||||
else:
|
else:
|
||||||
persist = 0
|
writeDataToFile.writelines(items)
|
||||||
|
|
||||||
|
writeDataToFile.close()
|
||||||
|
|
||||||
data = " persistConn " + str(persist) + "\n"
|
print "1,None"
|
||||||
writeDataToFile.writelines(data)
|
except BaseException, msg:
|
||||||
continue
|
logging.CyberCPLogFileWriter.writeToFile(
|
||||||
else:
|
str(msg) + " [saveTuningDetails]")
|
||||||
writeDataToFile.writelines(items)
|
print "0,"+str(msg)
|
||||||
|
else:
|
||||||
|
try:
|
||||||
|
path = "/usr/local/lsws/conf/httpd_config.xml"
|
||||||
|
datas = open(path).readlines()
|
||||||
|
|
||||||
writeDataToFile.close()
|
writeDataToFile = open(path, "w")
|
||||||
|
activate = 0
|
||||||
|
|
||||||
print "1,None"
|
for items in datas:
|
||||||
|
if items.find(virtualHost) > -1:
|
||||||
|
writeDataToFile.writelines(items)
|
||||||
|
activate = 1
|
||||||
|
continue
|
||||||
|
|
||||||
except BaseException, msg:
|
elif activate == 1:
|
||||||
logging.CyberCPLogFileWriter.writeToFile(
|
if items.find('</extProcessor>') > -1:
|
||||||
str(msg) + " [saveTuningDetails]")
|
writeDataToFile.writelines(items)
|
||||||
print "0,"+str(msg)
|
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():
|
def main():
|
||||||
|
|
||||||
|
|||||||
@@ -98,6 +98,14 @@ class virtualHostUtilities:
|
|||||||
if retValues[0] == 0:
|
if retValues[0] == 0:
|
||||||
raise BaseException(retValues[1])
|
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:
|
if ssl == 1:
|
||||||
sslPath = "/home/" + virtualHostName + "/public_html"
|
sslPath = "/home/" + virtualHostName + "/public_html"
|
||||||
@@ -124,14 +132,6 @@ class virtualHostUtilities:
|
|||||||
if dkimCheck == 1:
|
if dkimCheck == 1:
|
||||||
DNS.createDKIMRecords(virtualHostName)
|
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]')
|
logging.CyberCPLogFileWriter.statusWriter(tempStatusPath, 'Website successfully created. [200]')
|
||||||
|
|
||||||
return 1, 'None'
|
return 1, 'None'
|
||||||
@@ -844,6 +844,9 @@ class virtualHostUtilities:
|
|||||||
|
|
||||||
## Now restart litespeed after initial configurations are done
|
## 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:
|
if ssl == 1:
|
||||||
logging.CyberCPLogFileWriter.statusWriter(tempStatusPath, 'Creating SSL..,50')
|
logging.CyberCPLogFileWriter.statusWriter(tempStatusPath, 'Creating SSL..,50')
|
||||||
installUtilities.installUtilities.reStartLiteSpeed()
|
installUtilities.installUtilities.reStartLiteSpeed()
|
||||||
@@ -864,10 +867,6 @@ class virtualHostUtilities:
|
|||||||
DNS.createDKIMRecords(virtualHostName)
|
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]')
|
logging.CyberCPLogFileWriter.statusWriter(tempStatusPath, 'Domain successfully created. [200]')
|
||||||
return 1, "None"
|
return 1, "None"
|
||||||
|
|
||||||
|
|||||||
@@ -10,6 +10,11 @@ import argparse
|
|||||||
import shutil
|
import shutil
|
||||||
import plogical.CyberCPLogFileWriter as logging
|
import plogical.CyberCPLogFileWriter as logging
|
||||||
from plogical.processUtilities import ProcessUtilities
|
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:
|
class ServerStatusUtil:
|
||||||
@@ -21,7 +26,7 @@ class ServerStatusUtil:
|
|||||||
try:
|
try:
|
||||||
res = subprocess.call(shlex.split(command), stdout=statusFile, stderr=statusFile)
|
res = subprocess.call(shlex.split(command), stdout=statusFile, stderr=statusFile)
|
||||||
if res == 1:
|
if res == 1:
|
||||||
raise 0
|
return 0
|
||||||
else:
|
else:
|
||||||
return 1
|
return 1
|
||||||
except BaseException, msg:
|
except BaseException, msg:
|
||||||
@@ -137,6 +142,94 @@ class ServerStatusUtil:
|
|||||||
if os.path.exists('/usr/local/usr'):
|
if os.path.exists('/usr/local/usr'):
|
||||||
shutil.rmtree('/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
|
@staticmethod
|
||||||
def switchTOLSWS(licenseKey):
|
def switchTOLSWS(licenseKey):
|
||||||
try:
|
try:
|
||||||
@@ -189,6 +282,15 @@ class ServerStatusUtil:
|
|||||||
ServerStatusUtil.recover()
|
ServerStatusUtil.recover()
|
||||||
return 0
|
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")
|
logging.CyberCPLogFileWriter.statusWriter(ServerStatusUtil.lswsInstallStatusPath,"Successfully switched to LITESPEED ENTERPRISE WEB SERVER. [200]\n")
|
||||||
|
|
||||||
except BaseException, msg:
|
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 () {
|
$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 */
|
/* Java script code to start/stop litespeed */
|
||||||
|
|||||||
@@ -3,144 +3,285 @@
|
|||||||
{% block title %}{% trans "PHP Tuning - CyberPanel" %}{% endblock %}
|
{% block title %}{% trans "PHP Tuning - CyberPanel" %}{% endblock %}
|
||||||
{% block content %}
|
{% block content %}
|
||||||
|
|
||||||
{% load static %}
|
{% load static %}
|
||||||
{% get_current_language as LANGUAGE_CODE %}
|
{% get_current_language as LANGUAGE_CODE %}
|
||||||
<!-- Current language: {{ LANGUAGE_CODE }} -->
|
<!-- Current language: {{ LANGUAGE_CODE }} -->
|
||||||
|
|
||||||
|
{% 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 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">
|
||||||
|
|
||||||
|
|
||||||
<div class="container">
|
<form ng-controller="tunePHP" action="/" id="modifyPackageForm"
|
||||||
<div id="page-title">
|
class="form-horizontal bordered-row">
|
||||||
<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 Domain" %}</label>
|
||||||
|
<div class="col-sm-6">
|
||||||
|
<select ng-change="fetchPHPDetails()" ng-model="domainSelection"
|
||||||
|
class="form-control">
|
||||||
|
{% for items in websiteList %}
|
||||||
|
<option>{{ items }}</option>
|
||||||
|
{% endfor %}
|
||||||
|
</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 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">
|
|
||||||
{% for items in websiteList %}
|
|
||||||
<option>{{ items }}</option>
|
|
||||||
{% endfor %}
|
|
||||||
</select>
|
|
||||||
</div>
|
</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>
|
</div>
|
||||||
|
|
||||||
<div class="form-group">
|
|
||||||
<label class="col-sm-3 control-label"></label>
|
</div>
|
||||||
<div class="col-sm-4">
|
{% else %}
|
||||||
<div id="canNotFetch" class="alert alert-danger">
|
<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>
|
<p>{% trans "Cannot fetch details. Error message:" %} {$ errorMessage $}</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="canNotTune" class="alert alert-danger">
|
<div id="canNotTune" class="alert alert-danger">
|
||||||
<p>{% trans "Cannot tune. Error message:" %} {$ errorMessage $}</p>
|
<p>{% trans "Cannot tune. Error message:" %} {$ errorMessage $}</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<div id="successfullyFetched" class="alert alert-success">
|
<div id="successfullyFetched" class="alert alert-success">
|
||||||
<p>{% trans "Details Successfully fetched." %}</p>
|
<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>
|
</div>
|
||||||
|
|
||||||
<div id="successfullyTuned" class="alert alert-success">
|
|
||||||
<p>{% trans "PHP for " %}<strong>{$ phpVersionTuned $}</strong> {% trans "Successfully tuned." %}</p>
|
</form>
|
||||||
</div>
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
</form>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
{% endif %}
|
||||||
</div>
|
|
||||||
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
|
|
||||||
{% endblock %}
|
{% 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 subprocess
|
||||||
import shlex
|
import shlex
|
||||||
from plogical.acl import ACLManager
|
from plogical.acl import ACLManager
|
||||||
|
from tuning import tuningManager
|
||||||
# Create your views here.
|
# Create your views here.
|
||||||
|
|
||||||
|
|
||||||
def loadTuningHome(request):
|
def loadTuningHome(request):
|
||||||
try:
|
try:
|
||||||
userID = request.session['userID']
|
userID = request.session['userID']
|
||||||
currentACL = ACLManager.loadedACL(userID)
|
tm = tuningManager()
|
||||||
|
return tm.loadTuningHome(request, userID)
|
||||||
if currentACL['admin'] == 1:
|
|
||||||
pass
|
|
||||||
else:
|
|
||||||
return ACLManager.loadError()
|
|
||||||
|
|
||||||
return render(request,'tuning/index.html',{})
|
|
||||||
except KeyError:
|
except KeyError:
|
||||||
return redirect(loadLoginPage)
|
return redirect(loadLoginPage)
|
||||||
|
|
||||||
|
|
||||||
def liteSpeedTuning(request):
|
def liteSpeedTuning(request):
|
||||||
try:
|
try:
|
||||||
userID = request.session['userID']
|
userID = request.session['userID']
|
||||||
currentACL = ACLManager.loadedACL(userID)
|
tm = tuningManager()
|
||||||
|
return tm.liteSpeedTuning(request, userID)
|
||||||
if currentACL['admin'] == 1:
|
|
||||||
pass
|
|
||||||
else:
|
|
||||||
return ACLManager.loadError()
|
|
||||||
return render(request,'tuning/liteSpeedTuning.html',{})
|
|
||||||
except KeyError:
|
except KeyError:
|
||||||
return redirect(loadLoginPage)
|
return redirect(loadLoginPage)
|
||||||
|
|
||||||
|
|
||||||
def phpTuning(request):
|
def phpTuning(request):
|
||||||
try:
|
try:
|
||||||
userID = request.session['userID']
|
userID = request.session['userID']
|
||||||
currentACL = ACLManager.loadedACL(userID)
|
tm = tuningManager()
|
||||||
|
return tm.phpTuning(request, userID)
|
||||||
if currentACL['admin'] == 1:
|
|
||||||
pass
|
|
||||||
else:
|
|
||||||
return ACLManager.loadError()
|
|
||||||
|
|
||||||
websitesName = ACLManager.findAllSites(currentACL, userID)
|
|
||||||
|
|
||||||
return render(request,'tuning/phpTuning.html',{'websiteList':websitesName})
|
|
||||||
except KeyError:
|
except KeyError:
|
||||||
return redirect(loadLoginPage)
|
return redirect(loadLoginPage)
|
||||||
|
|
||||||
|
|
||||||
def tuneLitespeed(request):
|
def tuneLitespeed(request):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
userID = request.session['userID']
|
userID = request.session['userID']
|
||||||
currentACL = ACLManager.loadedACL(userID)
|
tm = tuningManager()
|
||||||
|
return tm.tuneLitespeed(userID, json.loads(request.body))
|
||||||
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)
|
|
||||||
|
|
||||||
except KeyError:
|
except KeyError:
|
||||||
data_ret = {'fetch_status': 0, 'error_message': "not logged in as admin",'fetch_status': 0}
|
return redirect(loadLoginPage)
|
||||||
json_data = json.dumps(data_ret)
|
|
||||||
return HttpResponse(json_data)
|
|
||||||
|
|
||||||
|
|
||||||
def tunePHP(request):
|
def tunePHP(request):
|
||||||
try:
|
try:
|
||||||
userID = request.session['userID']
|
userID = request.session['userID']
|
||||||
currentACL = ACLManager.loadedACL(userID)
|
tm = tuningManager()
|
||||||
|
return tm.tunePHP(userID, json.loads(request.body))
|
||||||
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)
|
|
||||||
|
|
||||||
except KeyError:
|
except KeyError:
|
||||||
data_ret = {'tuneStatus': 0, 'error_message': "not logged in as admin",'fetch_status': 0}
|
return redirect(loadLoginPage)
|
||||||
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [tunePHP]]")
|
|
||||||
json_data = json.dumps(data_ret)
|
|
||||||
return HttpResponse(json_data)
|
|
||||||
Reference in New Issue
Block a user