mirror of
https://github.com/usmannasir/cyberpanel.git
synced 2025-11-14 17:26:17 +01:00
added check for not-available php versions
This commit is contained in:
@@ -110,15 +110,15 @@ DATABASES = {
|
|||||||
'ENGINE': 'django.db.backends.mysql',
|
'ENGINE': 'django.db.backends.mysql',
|
||||||
'NAME': 'cyberpanel',
|
'NAME': 'cyberpanel',
|
||||||
'USER': 'cyberpanel',
|
'USER': 'cyberpanel',
|
||||||
'PASSWORD': 'a9AwLb7zY7ZwCd',
|
'PASSWORD': 'Bz9gF7Hr7X4RtD',
|
||||||
'HOST': '127.0.0.1',
|
'HOST': '127.0.0.1',
|
||||||
'PORT':''
|
'PORT':'3307'
|
||||||
},
|
},
|
||||||
'rootdb': {
|
'rootdb': {
|
||||||
'ENGINE': 'django.db.backends.mysql',
|
'ENGINE': 'django.db.backends.mysql',
|
||||||
'NAME': 'mysql',
|
'NAME': 'mysql',
|
||||||
'USER': 'root',
|
'USER': 'root',
|
||||||
'PASSWORD': '3bL8X7wGo0kT3b',
|
'PASSWORD': 'sXm5VlRaAsXkDd',
|
||||||
'HOST': 'localhost',
|
'HOST': 'localhost',
|
||||||
'PORT': '',
|
'PORT': '',
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -31,7 +31,8 @@ def preDockerRun(function):
|
|||||||
else:
|
else:
|
||||||
return render(request, 'dockerManager/install.html', {'status':admin.type, 'conErr':0})
|
return render(request, 'dockerManager/install.html', {'status':admin.type, 'conErr':0})
|
||||||
|
|
||||||
# Check if docker is running and we are able to connect
|
# Check if docker is running and we are able to connect
|
||||||
|
|
||||||
try:
|
try:
|
||||||
client = docker.from_env()
|
client = docker.from_env()
|
||||||
client.ping()
|
client.ping()
|
||||||
|
|||||||
@@ -686,6 +686,10 @@ class vhost:
|
|||||||
|
|
||||||
php = PHPManager.getPHPString(phpVersion)
|
php = PHPManager.getPHPString(phpVersion)
|
||||||
|
|
||||||
|
if not os.path.exists("/usr/local/lsws/lsphp" + str(php) + "/bin/lsphp"):
|
||||||
|
print 0, 'This PHP version is not available on your CyberPanel.'
|
||||||
|
return [0, "[This PHP version is not available on your CyberPanel. [changePHP]"]
|
||||||
|
|
||||||
writeDataToFile = open(vhFile, "w")
|
writeDataToFile = open(vhFile, "w")
|
||||||
|
|
||||||
path = " path /usr/local/lsws/lsphp" + str(php) + "/bin/lsphp\n"
|
path = " path /usr/local/lsws/lsphp" + str(php) + "/bin/lsphp\n"
|
||||||
@@ -704,15 +708,19 @@ class vhost:
|
|||||||
return 1,'None'
|
return 1,'None'
|
||||||
except BaseException, msg:
|
except BaseException, msg:
|
||||||
logging.CyberCPLogFileWriter.writeToFile(
|
logging.CyberCPLogFileWriter.writeToFile(
|
||||||
str(msg) + " [IO Error with per host config file [changePHP]]")
|
str(msg) + " [IO Error with per host config file [changePHP]")
|
||||||
print 0,str(msg)
|
print 0,str(msg)
|
||||||
return [0, str(msg) + " [IO Error with per host config file [changePHP]]"]
|
return [0, str(msg) + " [IO Error with per host config file [changePHP]"]
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
data = open(vhFile, "r").readlines()
|
data = open(vhFile, "r").readlines()
|
||||||
|
|
||||||
php = PHPManager.getPHPString(phpVersion)
|
php = PHPManager.getPHPString(phpVersion)
|
||||||
|
|
||||||
|
if not os.path.exists("/usr/local/lsws/lsphp" + str(php) + "/bin/lsphp"):
|
||||||
|
print 0, 'This PHP version is not available on your CyberPanel.'
|
||||||
|
return [0, "[This PHP version is not available on your CyberPanel. [changePHP]"]
|
||||||
|
|
||||||
writeDataToFile = open(vhFile, "w")
|
writeDataToFile = open(vhFile, "w")
|
||||||
|
|
||||||
finalString = ' AddHandler application/x-httpd-php' + str(php) + ' .php\n'
|
finalString = ' AddHandler application/x-httpd-php' + str(php) + ' .php\n'
|
||||||
|
|||||||
@@ -394,6 +394,7 @@ app.controller('servicesManager', function ($scope, $http) {
|
|||||||
|
|
||||||
|
|
||||||
function ListInitialDatas(response) {
|
function ListInitialDatas(response) {
|
||||||
|
console.log(response.data)
|
||||||
|
|
||||||
if (response.data.status.litespeed) {
|
if (response.data.status.litespeed) {
|
||||||
$scope.olsStatus = "Running";
|
$scope.olsStatus = "Running";
|
||||||
@@ -408,7 +409,7 @@ app.controller('servicesManager', function ($scope, $http) {
|
|||||||
$scope.olsStart = true;
|
$scope.olsStart = true;
|
||||||
$scope.olsStop = false;
|
$scope.olsStop = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (response.data.status.docker) {
|
if (response.data.status.docker) {
|
||||||
$scope.dockerStatus = "Running";
|
$scope.dockerStatus = "Running";
|
||||||
$scope.dockerStart = false;
|
$scope.dockerStart = false;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
from django.shortcuts import render,redirect
|
from django.shortcuts import render, redirect
|
||||||
from django.http import HttpResponse
|
from django.http import HttpResponse
|
||||||
import plogical.CyberCPLogFileWriter as logging
|
import plogical.CyberCPLogFileWriter as logging
|
||||||
from loginSystem.views import loadLoginPage
|
from loginSystem.views import loadLoginPage
|
||||||
@@ -17,17 +17,19 @@ import time
|
|||||||
import serverStatusUtil
|
import serverStatusUtil
|
||||||
from plogical.processUtilities import ProcessUtilities
|
from plogical.processUtilities import ProcessUtilities
|
||||||
from plogical.httpProc import httpProc
|
from plogical.httpProc import httpProc
|
||||||
|
|
||||||
|
|
||||||
# Create your views here.
|
# Create your views here.
|
||||||
|
|
||||||
def serverStatusHome(request):
|
def serverStatusHome(request):
|
||||||
try:
|
try:
|
||||||
userID = request.session['userID']
|
userID = request.session['userID']
|
||||||
return render(request,'serverStatus/index.html')
|
return render(request, 'serverStatus/index.html')
|
||||||
except KeyError:
|
except KeyError:
|
||||||
return redirect(loadLoginPage)
|
return redirect(loadLoginPage)
|
||||||
|
|
||||||
def litespeedStatus(request):
|
|
||||||
|
|
||||||
|
def litespeedStatus(request):
|
||||||
try:
|
try:
|
||||||
userID = request.session['userID']
|
userID = request.session['userID']
|
||||||
currentACL = ACLManager.loadedACL(userID)
|
currentACL = ACLManager.loadedACL(userID)
|
||||||
@@ -58,24 +60,26 @@ def litespeedStatus(request):
|
|||||||
else:
|
else:
|
||||||
loadedModules.append(items)
|
loadedModules.append(items)
|
||||||
|
|
||||||
except subprocess.CalledProcessError,msg:
|
except subprocess.CalledProcessError, msg:
|
||||||
logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[litespeedStatus]")
|
logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[litespeedStatus]")
|
||||||
return render(request,"serverStatus/litespeedStatus.html",{"processList":processList,"liteSpeedVersionStatus":"For some reaons not able to load version details, see CyberCP main log file.", 'OLS': OLS})
|
return render(request, "serverStatus/litespeedStatus.html", {"processList": processList,
|
||||||
|
"liteSpeedVersionStatus": "For some reaons not able to load version details, see CyberCP main log file.",
|
||||||
|
'OLS': OLS})
|
||||||
|
|
||||||
|
if (processList != 0):
|
||||||
if(processList!=0):
|
|
||||||
dataForHtml = {"processList": processList, "lsversion": lsversion, "modules": modules,
|
dataForHtml = {"processList": processList, "lsversion": lsversion, "modules": modules,
|
||||||
"loadedModules": loadedModules, 'OLS':OLS}
|
"loadedModules": loadedModules, 'OLS': OLS}
|
||||||
return render(request,"serverStatus/litespeedStatus.html",dataForHtml)
|
return render(request, "serverStatus/litespeedStatus.html", dataForHtml)
|
||||||
else:
|
else:
|
||||||
dataForHtml = {"lsversion": lsversion, "modules": modules,
|
dataForHtml = {"lsversion": lsversion, "modules": modules,
|
||||||
"loadedModules": loadedModules, 'OLS': OLS}
|
"loadedModules": loadedModules, 'OLS': OLS}
|
||||||
return render(request, "serverStatus/litespeedStatus.html",dataForHtml)
|
return render(request, "serverStatus/litespeedStatus.html", dataForHtml)
|
||||||
|
|
||||||
except KeyError,msg:
|
except KeyError, msg:
|
||||||
logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[litespeedStatus]")
|
logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[litespeedStatus]")
|
||||||
return redirect(loadLoginPage)
|
return redirect(loadLoginPage)
|
||||||
|
|
||||||
|
|
||||||
def stopOrRestartLitespeed(request):
|
def stopOrRestartLitespeed(request):
|
||||||
try:
|
try:
|
||||||
userID = request.session['userID']
|
userID = request.session['userID']
|
||||||
@@ -91,16 +95,16 @@ def stopOrRestartLitespeed(request):
|
|||||||
|
|
||||||
reboot = data['reboot']
|
reboot = data['reboot']
|
||||||
|
|
||||||
if reboot==1:
|
if reboot == 1:
|
||||||
if ProcessUtilities.restartLitespeed() == 1:
|
if ProcessUtilities.restartLitespeed() == 1:
|
||||||
status = {"reboot":1,"shutdown":0}
|
status = {"reboot": 1, "shutdown": 0}
|
||||||
else:
|
else:
|
||||||
status = {"reboot": 0, "shutdown": 0, "error_message":"Please see CyberCP main log file."}
|
status = {"reboot": 0, "shutdown": 0, "error_message": "Please see CyberCP main log file."}
|
||||||
else:
|
else:
|
||||||
if ProcessUtilities.stopLitespeed() == 1:
|
if ProcessUtilities.stopLitespeed() == 1:
|
||||||
status = {"reboot":0,"shutdown":1}
|
status = {"reboot": 0, "shutdown": 1}
|
||||||
else:
|
else:
|
||||||
status = {"reboot": 0, "shutdown": 0, "error_message":"Please see CyberCP main log file."}
|
status = {"reboot": 0, "shutdown": 0, "error_message": "Please see CyberCP main log file."}
|
||||||
|
|
||||||
final_json = json.dumps(status)
|
final_json = json.dumps(status)
|
||||||
return HttpResponse(final_json)
|
return HttpResponse(final_json)
|
||||||
@@ -109,8 +113,8 @@ def stopOrRestartLitespeed(request):
|
|||||||
logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[stopOrRestartLitespeed]")
|
logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[stopOrRestartLitespeed]")
|
||||||
return HttpResponse("Not Logged in as admin")
|
return HttpResponse("Not Logged in as admin")
|
||||||
|
|
||||||
def cyberCPMainLogFile(request):
|
|
||||||
|
|
||||||
|
def cyberCPMainLogFile(request):
|
||||||
try:
|
try:
|
||||||
userID = request.session['userID']
|
userID = request.session['userID']
|
||||||
|
|
||||||
@@ -121,13 +125,13 @@ def cyberCPMainLogFile(request):
|
|||||||
else:
|
else:
|
||||||
return ACLManager.loadError()
|
return ACLManager.loadError()
|
||||||
|
|
||||||
|
return render(request, 'serverStatus/cybercpmainlogfile.html')
|
||||||
|
|
||||||
return render(request,'serverStatus/cybercpmainlogfile.html')
|
except KeyError, msg:
|
||||||
|
|
||||||
except KeyError,msg:
|
|
||||||
logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[cyberCPMainLogFile]")
|
logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[cyberCPMainLogFile]")
|
||||||
return redirect(loadLoginPage)
|
return redirect(loadLoginPage)
|
||||||
|
|
||||||
|
|
||||||
def getFurtherDataFromLogFile(request):
|
def getFurtherDataFromLogFile(request):
|
||||||
try:
|
try:
|
||||||
userID = request.session['userID']
|
userID = request.session['userID']
|
||||||
@@ -145,10 +149,12 @@ def getFurtherDataFromLogFile(request):
|
|||||||
return HttpResponse(final_json)
|
return HttpResponse(final_json)
|
||||||
|
|
||||||
except KeyError, msg:
|
except KeyError, msg:
|
||||||
status = {"logstatus":0,"error":"Could not fetch data from log file, please see CyberCP main log file through command line."}
|
status = {"logstatus": 0,
|
||||||
|
"error": "Could not fetch data from log file, please see CyberCP main log file through command line."}
|
||||||
logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[getFurtherDataFromLogFile]")
|
logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[getFurtherDataFromLogFile]")
|
||||||
return HttpResponse("Not Logged in as admin")
|
return HttpResponse("Not Logged in as admin")
|
||||||
|
|
||||||
|
|
||||||
def services(request):
|
def services(request):
|
||||||
try:
|
try:
|
||||||
userID = request.session['userID']
|
userID = request.session['userID']
|
||||||
@@ -164,17 +170,18 @@ def services(request):
|
|||||||
data['serverName'] = 'OpenLiteSpeed'
|
data['serverName'] = 'OpenLiteSpeed'
|
||||||
else:
|
else:
|
||||||
data['serverName'] = 'LiteSpeed Ent'
|
data['serverName'] = 'LiteSpeed Ent'
|
||||||
|
|
||||||
dockerInstallPath = '/usr/bin/docker'
|
dockerInstallPath = '/usr/bin/docker'
|
||||||
if not os.path.exists(dockerInstallPath):
|
if not os.path.exists(dockerInstallPath):
|
||||||
data['isDocker'] = False
|
data['isDocker'] = False
|
||||||
else:
|
else:
|
||||||
data['isDocker'] = True
|
data['isDocker'] = True
|
||||||
|
|
||||||
return render(request, 'serverStatus/services.html', data)
|
return render(request, 'serverStatus/services.html', data)
|
||||||
except KeyError:
|
except KeyError:
|
||||||
return redirect(loadLoginPage)
|
return redirect(loadLoginPage)
|
||||||
|
|
||||||
|
|
||||||
def servicesStatus(request):
|
def servicesStatus(request):
|
||||||
try:
|
try:
|
||||||
userID = request.session['userID']
|
userID = request.session['userID']
|
||||||
@@ -211,7 +218,7 @@ def servicesStatus(request):
|
|||||||
|
|
||||||
# Docker status
|
# Docker status
|
||||||
dockerStatus.append(getServiceStats('docker'))
|
dockerStatus.append(getServiceStats('docker'))
|
||||||
|
|
||||||
# mysql status
|
# mysql status
|
||||||
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||||
result = s.connect_ex(('127.0.0.1', 3306))
|
result = s.connect_ex(('127.0.0.1', 3306))
|
||||||
@@ -263,6 +270,7 @@ def servicesStatus(request):
|
|||||||
except KeyError:
|
except KeyError:
|
||||||
return redirect(loadLoginPage)
|
return redirect(loadLoginPage)
|
||||||
|
|
||||||
|
|
||||||
def servicesAction(request):
|
def servicesAction(request):
|
||||||
try:
|
try:
|
||||||
userID = request.session['userID']
|
userID = request.session['userID']
|
||||||
@@ -324,6 +332,7 @@ def servicesAction(request):
|
|||||||
final_json = json.dumps(final_dic)
|
final_json = json.dumps(final_dic)
|
||||||
return HttpResponse(final_json)
|
return HttpResponse(final_json)
|
||||||
|
|
||||||
|
|
||||||
def switchTOLSWS(request):
|
def switchTOLSWS(request):
|
||||||
try:
|
try:
|
||||||
userID = request.session['userID']
|
userID = request.session['userID']
|
||||||
@@ -352,6 +361,7 @@ def switchTOLSWS(request):
|
|||||||
json_data = json.dumps(data_ret)
|
json_data = json.dumps(data_ret)
|
||||||
return HttpResponse(json_data)
|
return HttpResponse(json_data)
|
||||||
|
|
||||||
|
|
||||||
def switchTOLSWSStatus(request):
|
def switchTOLSWSStatus(request):
|
||||||
try:
|
try:
|
||||||
|
|
||||||
@@ -376,6 +386,7 @@ def switchTOLSWSStatus(request):
|
|||||||
json_data = json.dumps(data_ret)
|
json_data = json.dumps(data_ret)
|
||||||
return HttpResponse(json_data)
|
return HttpResponse(json_data)
|
||||||
|
|
||||||
|
|
||||||
def licenseStatus(request):
|
def licenseStatus(request):
|
||||||
try:
|
try:
|
||||||
userID = request.session['userID']
|
userID = request.session['userID']
|
||||||
@@ -391,7 +402,6 @@ def licenseStatus(request):
|
|||||||
command = 'sudo cat /usr/local/lsws/conf/serial.no'
|
command = 'sudo cat /usr/local/lsws/conf/serial.no'
|
||||||
serial = subprocess.check_output(shlex.split(command))
|
serial = subprocess.check_output(shlex.split(command))
|
||||||
|
|
||||||
|
|
||||||
command = 'sudo /usr/local/lsws/bin/lshttpd -V'
|
command = 'sudo /usr/local/lsws/bin/lshttpd -V'
|
||||||
expiration = subprocess.check_output(shlex.split(command))
|
expiration = subprocess.check_output(shlex.split(command))
|
||||||
|
|
||||||
@@ -408,6 +418,7 @@ def licenseStatus(request):
|
|||||||
final_json = json.dumps(final_dic)
|
final_json = json.dumps(final_dic)
|
||||||
return HttpResponse(final_json)
|
return HttpResponse(final_json)
|
||||||
|
|
||||||
|
|
||||||
def changeLicense(request):
|
def changeLicense(request):
|
||||||
try:
|
try:
|
||||||
userID = request.session['userID']
|
userID = request.session['userID']
|
||||||
@@ -434,14 +445,12 @@ def changeLicense(request):
|
|||||||
command = 'sudo chown -R lsadm:lsadm /usr/local/lsws/conf'
|
command = 'sudo chown -R lsadm:lsadm /usr/local/lsws/conf'
|
||||||
subprocess.call(shlex.split(command))
|
subprocess.call(shlex.split(command))
|
||||||
|
|
||||||
|
|
||||||
command = 'sudo /usr/local/lsws/bin/lshttpd -r'
|
command = 'sudo /usr/local/lsws/bin/lshttpd -r'
|
||||||
subprocess.call(shlex.split(command))
|
subprocess.call(shlex.split(command))
|
||||||
|
|
||||||
command = 'sudo /usr/local/lsws/bin/lswsctrl restart'
|
command = 'sudo /usr/local/lsws/bin/lswsctrl restart'
|
||||||
subprocess.call(shlex.split(command))
|
subprocess.call(shlex.split(command))
|
||||||
|
|
||||||
|
|
||||||
final_dic = {'status': 1, "erroMessage": 'None'}
|
final_dic = {'status': 1, "erroMessage": 'None'}
|
||||||
final_json = json.dumps(final_dic)
|
final_json = json.dumps(final_dic)
|
||||||
return HttpResponse(final_json)
|
return HttpResponse(final_json)
|
||||||
@@ -455,6 +464,7 @@ def changeLicense(request):
|
|||||||
final_json = json.dumps(final_dic)
|
final_json = json.dumps(final_dic)
|
||||||
return HttpResponse(final_json)
|
return HttpResponse(final_json)
|
||||||
|
|
||||||
|
|
||||||
def topProcesses(request):
|
def topProcesses(request):
|
||||||
try:
|
try:
|
||||||
userID = request.session['userID']
|
userID = request.session['userID']
|
||||||
@@ -469,10 +479,11 @@ def topProcesses(request):
|
|||||||
proc = httpProc(request, templateName)
|
proc = httpProc(request, templateName)
|
||||||
return proc.renderPre()
|
return proc.renderPre()
|
||||||
|
|
||||||
except KeyError,msg:
|
except KeyError, msg:
|
||||||
logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[litespeedStatus]")
|
logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[litespeedStatus]")
|
||||||
return redirect(loadLoginPage)
|
return redirect(loadLoginPage)
|
||||||
|
|
||||||
|
|
||||||
def topProcessesStatus(request):
|
def topProcessesStatus(request):
|
||||||
try:
|
try:
|
||||||
|
|
||||||
@@ -491,7 +502,6 @@ def topProcessesStatus(request):
|
|||||||
loadNow = data[2].split(' ')
|
loadNow = data[2].split(' ')
|
||||||
loadNow = filter(lambda a: a != '', loadNow)
|
loadNow = filter(lambda a: a != '', loadNow)
|
||||||
|
|
||||||
|
|
||||||
memory = data[3].split(' ')
|
memory = data[3].split(' ')
|
||||||
memory = filter(lambda a: a != '', memory)
|
memory = filter(lambda a: a != '', memory)
|
||||||
|
|
||||||
@@ -541,10 +551,10 @@ def topProcessesStatus(request):
|
|||||||
data['Softirqs'] = loadNow[13] + '%'
|
data['Softirqs'] = loadNow[13] + '%'
|
||||||
|
|
||||||
## Memory
|
## Memory
|
||||||
data['totalMemory'] = str(int(float(memory[3])/1024)) + 'MB'
|
data['totalMemory'] = str(int(float(memory[3]) / 1024)) + 'MB'
|
||||||
data['freeMemory'] = str(int(float(memory[5])/1024)) + 'MB'
|
data['freeMemory'] = str(int(float(memory[5]) / 1024)) + 'MB'
|
||||||
data['usedMemory'] = str(int(float(memory[7])/1024)) + 'MB'
|
data['usedMemory'] = str(int(float(memory[7]) / 1024)) + 'MB'
|
||||||
data['buffCache'] = str(int(float(memory[9])/1024)) + 'MB'
|
data['buffCache'] = str(int(float(memory[9]) / 1024)) + 'MB'
|
||||||
|
|
||||||
## Swap
|
## Swap
|
||||||
|
|
||||||
@@ -589,6 +599,7 @@ def topProcessesStatus(request):
|
|||||||
json_data = json.dumps(data_ret)
|
json_data = json.dumps(data_ret)
|
||||||
return HttpResponse(json_data)
|
return HttpResponse(json_data)
|
||||||
|
|
||||||
|
|
||||||
def killProcess(request):
|
def killProcess(request):
|
||||||
try:
|
try:
|
||||||
userID = request.session['userID']
|
userID = request.session['userID']
|
||||||
|
|||||||
Reference in New Issue
Block a user