mirror of
https://github.com/usmannasir/cyberpanel.git
synced 2025-11-08 06:16:08 +01:00
Improvments to WordPress and Joomla installer!
This commit is contained in:
@@ -14,7 +14,7 @@ import subprocess
|
|||||||
import shlex
|
import shlex
|
||||||
import os
|
import os
|
||||||
import plogical.CyberCPLogFileWriter as logging
|
import plogical.CyberCPLogFileWriter as logging
|
||||||
from django.utils.translation import ugettext,ungettext
|
from plogical.virtualHostUtilities import virtualHostUtilities
|
||||||
# Create your views here.
|
# Create your views here.
|
||||||
|
|
||||||
|
|
||||||
@@ -70,8 +70,7 @@ def getSystemStatus(request):
|
|||||||
HTTPData = SystemInformation.getSystemInformation()
|
HTTPData = SystemInformation.getSystemInformation()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
command = "sudo cat /tmp/lshttpd/tempReport"
|
command = "sudo cat /tmp/lshttpd/.rtreport"
|
||||||
logging.CyberCPLogFileWriter.writeToFile(shlex.split(command))
|
|
||||||
data = subprocess.check_output(shlex.split(command)).split("\n")
|
data = subprocess.check_output(shlex.split(command)).split("\n")
|
||||||
|
|
||||||
httpData = data[3]
|
httpData = data[3]
|
||||||
@@ -91,7 +90,7 @@ def getSystemStatus(request):
|
|||||||
HTTPData['AvailSSL'] = finalHTTP[14]
|
HTTPData['AvailSSL'] = finalHTTP[14]
|
||||||
|
|
||||||
except BaseException,msg:
|
except BaseException,msg:
|
||||||
|
#logging.CyberCPLogFileWriter.writeToFile("Failed to read status file, error: " + str(msg))
|
||||||
HTTPData['RequestProcessing'] = 0
|
HTTPData['RequestProcessing'] = 0
|
||||||
HTTPData['TotalRequests'] = 0
|
HTTPData['TotalRequests'] = 0
|
||||||
|
|
||||||
|
|||||||
@@ -2,9 +2,11 @@ import platform
|
|||||||
import os
|
import os
|
||||||
import datetime
|
import datetime
|
||||||
import math
|
import math
|
||||||
|
import argparse
|
||||||
|
|
||||||
class SystemInformation:
|
class SystemInformation:
|
||||||
now = datetime.datetime.now()
|
now = datetime.datetime.now()
|
||||||
|
olsReport = ""
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def cpuLoad():
|
def cpuLoad():
|
||||||
@@ -95,4 +97,24 @@ class SystemInformation:
|
|||||||
'cpuUsage': 0,
|
'cpuUsage': 0,
|
||||||
'diskUsage': 0}
|
'diskUsage': 0}
|
||||||
|
|
||||||
return SystemInfo
|
return SystemInfo
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def populateOLSReport():
|
||||||
|
SystemInformation.olsReport = open("/tmp/lshttpd/.rtreport", "r").readlines()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
|
||||||
|
parser = argparse.ArgumentParser(description='CyberPanel Installer')
|
||||||
|
parser.add_argument('function', help='Specific a function to call!')
|
||||||
|
|
||||||
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
if args.function == "populateOLSReport":
|
||||||
|
SystemInformation.populateOLSReport()
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
@@ -217,10 +217,12 @@ class virtualHostUtilities:
|
|||||||
extprocessor = "extprocessor "+virtualHostUser+" {\n"
|
extprocessor = "extprocessor "+virtualHostUser+" {\n"
|
||||||
type = " type lsapi\n"
|
type = " type lsapi\n"
|
||||||
address = " address UDS://tmp/lshttpd/"+virtualHostUser+".sock\n"
|
address = " address UDS://tmp/lshttpd/"+virtualHostUser+".sock\n"
|
||||||
maxConns = " maxConns 35\n"
|
maxConns = " maxConns 10\n"
|
||||||
|
env = " env LSAPI_CHILDREN=10\n"
|
||||||
initTimeout = " initTimeout 60\n"
|
initTimeout = " initTimeout 60\n"
|
||||||
retryTimeout = " retryTimeout 0\n"
|
retryTimeout = " retryTimeout 0\n"
|
||||||
persistConn = " persistConn 1\n"
|
persistConn = " persistConn 1\n"
|
||||||
|
persistConnTimeout = " pcKeepAliveTimeout 1\n"
|
||||||
respBuffer = " respBuffer 0\n"
|
respBuffer = " respBuffer 0\n"
|
||||||
autoStart = " autoStart 1\n"
|
autoStart = " autoStart 1\n"
|
||||||
path = " path /usr/local/lsws/lsphp"+php+"/bin/lsphp\n"
|
path = " path /usr/local/lsws/lsphp"+php+"/bin/lsphp\n"
|
||||||
@@ -236,9 +238,11 @@ class virtualHostUtilities:
|
|||||||
confFile.writelines(type)
|
confFile.writelines(type)
|
||||||
confFile.writelines(address)
|
confFile.writelines(address)
|
||||||
confFile.writelines(maxConns)
|
confFile.writelines(maxConns)
|
||||||
|
confFile.writelines(env)
|
||||||
confFile.writelines(initTimeout)
|
confFile.writelines(initTimeout)
|
||||||
confFile.writelines(retryTimeout)
|
confFile.writelines(retryTimeout)
|
||||||
confFile.writelines(persistConn)
|
confFile.writelines(persistConn)
|
||||||
|
confFile.writelines(persistConnTimeout)
|
||||||
confFile.writelines(respBuffer)
|
confFile.writelines(respBuffer)
|
||||||
confFile.writelines(autoStart)
|
confFile.writelines(autoStart)
|
||||||
confFile.writelines(path)
|
confFile.writelines(path)
|
||||||
@@ -499,10 +503,12 @@ class virtualHostUtilities:
|
|||||||
extprocessor = "extprocessor " + virtualHostUser+sockRandomPath + " {\n"
|
extprocessor = "extprocessor " + virtualHostUser+sockRandomPath + " {\n"
|
||||||
type = " type lsapi\n"
|
type = " type lsapi\n"
|
||||||
address = " address UDS://tmp/lshttpd/" + virtualHostUser+sockRandomPath + ".sock\n"
|
address = " address UDS://tmp/lshttpd/" + virtualHostUser+sockRandomPath + ".sock\n"
|
||||||
maxConns = " maxConns 35\n"
|
maxConns = " maxConns 10\n"
|
||||||
|
env = " env LSAPI_CHILDREN=10\n"
|
||||||
initTimeout = " initTimeout 60\n"
|
initTimeout = " initTimeout 60\n"
|
||||||
retryTimeout = " retryTimeout 0\n"
|
retryTimeout = " retryTimeout 0\n"
|
||||||
persistConn = " persistConn 1\n"
|
persistConn = " persistConn 1\n"
|
||||||
|
persistConnTimeout = " pcKeepAliveTimeout 1\n"
|
||||||
respBuffer = " respBuffer 0\n"
|
respBuffer = " respBuffer 0\n"
|
||||||
autoStart = " autoStart 1\n"
|
autoStart = " autoStart 1\n"
|
||||||
path = " path /usr/local/lsws/lsphp" + php + "/bin/lsphp\n"
|
path = " path /usr/local/lsws/lsphp" + php + "/bin/lsphp\n"
|
||||||
@@ -518,9 +524,11 @@ class virtualHostUtilities:
|
|||||||
confFile.writelines(type)
|
confFile.writelines(type)
|
||||||
confFile.writelines(address)
|
confFile.writelines(address)
|
||||||
confFile.writelines(maxConns)
|
confFile.writelines(maxConns)
|
||||||
|
confFile.writelines(env)
|
||||||
confFile.writelines(initTimeout)
|
confFile.writelines(initTimeout)
|
||||||
confFile.writelines(retryTimeout)
|
confFile.writelines(retryTimeout)
|
||||||
confFile.writelines(persistConn)
|
confFile.writelines(persistConn)
|
||||||
|
confFile.writelines(persistConnTimeout)
|
||||||
confFile.writelines(respBuffer)
|
confFile.writelines(respBuffer)
|
||||||
confFile.writelines(autoStart)
|
confFile.writelines(autoStart)
|
||||||
confFile.writelines(path)
|
confFile.writelines(path)
|
||||||
@@ -1283,6 +1291,7 @@ def installWordPress(domainName,finalPath,virtualHostUser,dbName,dbUser,dbPasswo
|
|||||||
except BaseException, msg:
|
except BaseException, msg:
|
||||||
# remove the downloaded files
|
# remove the downloaded files
|
||||||
try:
|
try:
|
||||||
|
|
||||||
shutil.rmtree(finalPath)
|
shutil.rmtree(finalPath)
|
||||||
except:
|
except:
|
||||||
logging.CyberCPLogFileWriter.writeToFile("shutil.rmtree(finalPath)")
|
logging.CyberCPLogFileWriter.writeToFile("shutil.rmtree(finalPath)")
|
||||||
@@ -1305,9 +1314,15 @@ def installJoomla(domainName,finalPath,virtualHostUser,dbName,dbUser,dbPassword,
|
|||||||
try:
|
try:
|
||||||
FNULL = open(os.devnull, 'w')
|
FNULL = open(os.devnull, 'w')
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if not os.path.exists(finalPath):
|
if not os.path.exists(finalPath):
|
||||||
os.makedirs(finalPath)
|
os.makedirs(finalPath)
|
||||||
|
|
||||||
|
## checking for directories/files
|
||||||
|
|
||||||
|
dirFiles = os.listdir(finalPath)
|
||||||
|
|
||||||
if len(dirFiles) == 1:
|
if len(dirFiles) == 1:
|
||||||
if dirFiles[0] == ".well-known":
|
if dirFiles[0] == ".well-known":
|
||||||
pass
|
pass
|
||||||
|
|||||||
@@ -1170,7 +1170,6 @@ def installWordpress(request):
|
|||||||
execPath = execPath + " installWordPress --virtualHostName " + domainName + " --virtualHostUser " + externalApp + " --path " + finalPath + " --dbName " + dbName + " --dbUser " + dbUser + " --dbPassword " + dbPassword
|
execPath = execPath + " installWordPress --virtualHostName " + domainName + " --virtualHostUser " + externalApp + " --path " + finalPath + " --dbName " + dbName + " --dbUser " + dbUser + " --dbPassword " + dbPassword
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
output = subprocess.check_output(shlex.split(execPath))
|
output = subprocess.check_output(shlex.split(execPath))
|
||||||
|
|
||||||
if output.find("1,None") > -1:
|
if output.find("1,None") > -1:
|
||||||
@@ -1178,6 +1177,9 @@ def installWordpress(request):
|
|||||||
json_data = json.dumps(data_ret)
|
json_data = json.dumps(data_ret)
|
||||||
return HttpResponse(json_data)
|
return HttpResponse(json_data)
|
||||||
else:
|
else:
|
||||||
|
mysqlUtilities.deleteDatabase(dbName, dbUser)
|
||||||
|
db = Databases.objects.get(dbName=dbName)
|
||||||
|
db.delete()
|
||||||
data_ret = {'installStatus': 0, 'error_message': output}
|
data_ret = {'installStatus': 0, 'error_message': output}
|
||||||
json_data = json.dumps(data_ret)
|
json_data = json.dumps(data_ret)
|
||||||
return HttpResponse(json_data)
|
return HttpResponse(json_data)
|
||||||
@@ -1292,6 +1294,9 @@ def installJoomla(request):
|
|||||||
json_data = json.dumps(data_ret)
|
json_data = json.dumps(data_ret)
|
||||||
return HttpResponse(json_data)
|
return HttpResponse(json_data)
|
||||||
else:
|
else:
|
||||||
|
mysqlUtilities.deleteDatabase(dbName,dbUser)
|
||||||
|
db = Databases.objects.get(dbName=dbName)
|
||||||
|
db.delete()
|
||||||
data_ret = {'installStatus': 0, 'error_message': output}
|
data_ret = {'installStatus': 0, 'error_message': output}
|
||||||
json_data = json.dumps(data_ret)
|
json_data = json.dumps(data_ret)
|
||||||
return HttpResponse(json_data)
|
return HttpResponse(json_data)
|
||||||
|
|||||||
Reference in New Issue
Block a user