From 87d58a50a13026f09a2f7c567ae4aa7f4ca62e13 Mon Sep 17 00:00:00 2001 From: Usman Nasir Date: Sun, 12 Jun 2022 14:09:57 +0500 Subject: [PATCH 1/4] dynamically get php extensions --- managePHP/views.py | 47 +++++++++++++++++++------------- plogical/applicationInstaller.py | 1 - 2 files changed, 28 insertions(+), 20 deletions(-) diff --git a/managePHP/views.py b/managePHP/views.py index aa4711d2a..d942134ee 100755 --- a/managePHP/views.py +++ b/managePHP/views.py @@ -1290,34 +1290,43 @@ def getExtensionsInformation(request): data = json.loads(request.body) phpVers = data['phpSelection'] - phpVers = "php" + PHPManager.getPHPString(phpVers) + phpVers = f"lsphp{PHPManager.getPHPString(phpVers)}" - php = PHP.objects.get(phpVers=phpVers) + # php = PHP.objects.get(phpVers=phpVers) - records = php.installedpackages_set.all() + if os.path.exists('/etc/lsb-release'): + command = f'apt list | grep {phpVers}' + + result = ProcessUtilities.outputExecutioner(command).split('\n') + + #records = php.installedpackages_set.all() json_data = "[" checker = 0 + counter = 1 - for items in records: + for items in result: - if items.status == 0: - status = "Not-Installed" - else: - status = "Installed" + if items.find(phpVers) > -1: - dic = {'id': items.id, - 'phpVers': items.phpVers.phpVers, - 'extensionName': items.extensionName, - 'description': items.description, - 'status': status - } + if items.find('installed') == -1: + status = "Not-Installed" + else: + status = "Installed" - if checker == 0: - json_data = json_data + json.dumps(dic) - checker = 1 - else: - json_data = json_data + ',' + json.dumps(dic) + dic = {'id': counter, + 'phpVers': phpVers, + 'extensionName': items.split('/')[0], + 'description': items, + 'status': status + } + + if checker == 0: + json_data = json_data + json.dumps(dic) + checker = 1 + else: + json_data = json_data + ',' + json.dumps(dic) + counter += 1 json_data = json_data + ']' final_json = json.dumps({'fetchStatus': 1, 'error_message': "None", "data": json_data}) diff --git a/plogical/applicationInstaller.py b/plogical/applicationInstaller.py index 3c725a75a..0dc1a3090 100755 --- a/plogical/applicationInstaller.py +++ b/plogical/applicationInstaller.py @@ -2157,7 +2157,6 @@ $parameters = array( statusFile.close() return 0 - def DeploytoProduction(self): try: From 70fda0b1ef6a73f7a79314b28b832d7f3fad6a6e Mon Sep 17 00:00:00 2001 From: Usman Nasir Date: Sun, 12 Jun 2022 14:52:17 +0500 Subject: [PATCH 2/4] dynamically get php extensions centos/alma --- managePHP/views.py | 62 +++++++++++++++++++++++++++++++++------------- plogical/test.py | 5 ++++ 2 files changed, 50 insertions(+), 17 deletions(-) diff --git a/managePHP/views.py b/managePHP/views.py index d942134ee..cc9e75885 100755 --- a/managePHP/views.py +++ b/managePHP/views.py @@ -1296,6 +1296,11 @@ def getExtensionsInformation(request): if os.path.exists('/etc/lsb-release'): command = f'apt list | grep {phpVers}' + else: + command = 'yum list installed' + resultInstalled = ProcessUtilities.outputExecutioner(command) + + command = f'yum list | grep {phpVers} | xargs -n3 | column -t' result = ProcessUtilities.outputExecutioner(command).split('\n') @@ -1306,27 +1311,50 @@ def getExtensionsInformation(request): counter = 1 for items in result: + if os.path.exists('/etc/lsb-release'): + if items.find(phpVers) > -1: + if items.find('installed') == -1: + status = "Not-Installed" + else: + status = "Installed" - if items.find(phpVers) > -1: + dic = {'id': counter, + 'phpVers': phpVers, + 'extensionName': items.split('/')[0], + 'description': items, + 'status': status + } - if items.find('installed') == -1: - status = "Not-Installed" - else: - status = "Installed" + if checker == 0: + json_data = json_data + json.dumps(dic) + checker = 1 + else: + json_data = json_data + ',' + json.dumps(dic) + counter += 1 + else: + ResultExt = items.split(' ') + extesnion = ResultExt[0] - dic = {'id': counter, - 'phpVers': phpVers, - 'extensionName': items.split('/')[0], - 'description': items, - 'status': status - } + if extesnion.find(phpVers) > -1: + if resultInstalled.find(extesnion) == -1: + status = "Not-Installed" + else: + status = "Installed" - if checker == 0: - json_data = json_data + json.dumps(dic) - checker = 1 - else: - json_data = json_data + ',' + json.dumps(dic) - counter += 1 + dic = {'id': counter, + 'phpVers': phpVers, + 'extensionName': extesnion, + 'description': items, + 'status': status + } + + + if checker == 0: + json_data = json_data + json.dumps(dic) + checker = 1 + else: + json_data = json_data + ',' + json.dumps(dic) + counter += 1 json_data = json_data + ']' final_json = json.dumps({'fetchStatus': 1, 'error_message': "None", "data": json_data}) diff --git a/plogical/test.py b/plogical/test.py index e69de29bb..43397b4b2 100644 --- a/plogical/test.py +++ b/plogical/test.py @@ -0,0 +1,5 @@ +import subprocess, shlex +command = 'yum list | grep lsphp | xargs -n3 | column -t' +result = subprocess.check_output(command, shell=True).splitlines() +for item in result: + print(item.split(b' ')) From 92981c9284a1bd91473e8438d90decc7f4aba0d1 Mon Sep 17 00:00:00 2001 From: Usman Nasir Date: Sun, 12 Jun 2022 14:58:56 +0500 Subject: [PATCH 3/4] dynamically get php extensions centos/alma --- managePHP/views.py | 58 +++++++++++++++++++++++----------------------- 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/managePHP/views.py b/managePHP/views.py index cc9e75885..779752e5b 100755 --- a/managePHP/views.py +++ b/managePHP/views.py @@ -1447,14 +1447,14 @@ def getRequestStatus(request): command = "sudo rm -f " + phpUtilities.installLogPath ProcessUtilities.executioner(command) - if ProcessUtilities.outputExecutioner(checkCommand).find(extensionName) > -1: - ext = installedPackages.objects.get(extensionName=extensionName) - ext.status = 1 - ext.save() - else: - ext = installedPackages.objects.get(extensionName=extensionName) - ext.status = 0 - ext.save() + # if ProcessUtilities.outputExecutioner(checkCommand).find(extensionName) > -1: + # ext = installedPackages.objects.get(extensionName=extensionName) + # ext.status = 1 + # ext.save() + # else: + # ext = installedPackages.objects.get(extensionName=extensionName) + # ext.status = 0 + # ext.save() final_json = json.dumps({'finished': 1, 'extensionRequestStatus': 1, 'error_message': "None", @@ -1466,15 +1466,15 @@ def getRequestStatus(request): command = "sudo rm -f " + phpUtilities.installLogPath ProcessUtilities.executioner(command) - if ProcessUtilities.outputExecutioner(checkCommand).find(extensionName) > -1: - ext = installedPackages.objects.get(extensionName=extensionName) - ext.status = 1 - ext.save() - - else: - ext = installedPackages.objects.get(extensionName=extensionName) - ext.status = 0 - ext.save() + # if ProcessUtilities.outputExecutioner(checkCommand).find(extensionName) > -1: + # ext = installedPackages.objects.get(extensionName=extensionName) + # ext.status = 1 + # ext.save() + # + # else: + # ext = installedPackages.objects.get(extensionName=extensionName) + # ext.status = 0 + # ext.save() final_json = json.dumps({'finished': 1, 'extensionRequestStatus': 1, 'error_message': "None", @@ -1486,15 +1486,15 @@ def getRequestStatus(request): command = "sudo rm -f " + phpUtilities.installLogPath ProcessUtilities.executioner(command) - if ProcessUtilities.outputExecutioner(checkCommand).find(extensionName) > -1: - ext = installedPackages.objects.get(extensionName=extensionName) - ext.status = 1 - ext.save() - - else: - ext = installedPackages.objects.get(extensionName=extensionName) - ext.status = 0 - ext.save() + # if ProcessUtilities.outputExecutioner(checkCommand).find(extensionName) > -1: + # ext = installedPackages.objects.get(extensionName=extensionName) + # ext.status = 1 + # ext.save() + # + # else: + # ext = installedPackages.objects.get(extensionName=extensionName) + # ext.status = 0 + # ext.save() final_json = json.dumps({'finished': 1, 'extensionRequestStatus': 1, 'error_message': "None", @@ -1506,9 +1506,9 @@ def getRequestStatus(request): command = "sudo rm -f " + phpUtilities.installLogPath ProcessUtilities.executioner(command) - ext = installedPackages.objects.get(extensionName=extensionName) - ext.status = 0 - ext.save() + # ext = installedPackages.objects.get(extensionName=extensionName) + # ext.status = 0 + # ext.save() final_json = json.dumps({'finished': 1, 'extensionRequestStatus': 1, 'error_message': "None", From eb52985beb099af53a8017b299e86cc2d0c44f5d Mon Sep 17 00:00:00 2001 From: Usman Nasir Date: Mon, 13 Jun 2022 15:29:27 +0500 Subject: [PATCH 4/4] bug fix: ha cluster --- install/installLog.py | 2 +- plogical/ClusterManager.py | 4 ++-- plogical/CyberPanelUpgrade.py | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/install/installLog.py b/install/installLog.py index 58a3ed2c7..ec0e1b58a 100755 --- a/install/installLog.py +++ b/install/installLog.py @@ -7,7 +7,7 @@ import requests class InstallLog: fileName = "/var/log/installLogs.txt" currentPercent = '10' - LogURL = 'https://cloud.cyberpanel.net/servers/RecvData' + LogURL = 'https://platform.cyberpersons.com/servers/RecvData' ServerIP = '' @staticmethod diff --git a/plogical/ClusterManager.py b/plogical/ClusterManager.py index d9df35733..4c27c327b 100644 --- a/plogical/ClusterManager.py +++ b/plogical/ClusterManager.py @@ -16,8 +16,8 @@ from plogical.CyberCPLogFileWriter import CyberCPLogFileWriter as logging from plogical.mysqlUtilities import mysqlUtilities class ClusterManager: - LogURL = "https://cloud.cyberpanel.net/HighAvailability/RecvData" - UptimeURL = "https://cloud.cyberpanel.net/servers/UptimeReport" + LogURL = "https://platform.cyberpersons.com/HighAvailability/RecvData" + UptimeURL = "https://platform.cyberpersons.com/servers/UptimeReport" ClusterFile = '/home/cyberpanel/cluster' CloudConfig = '/home/cyberpanel/cloud' vhostConfPath = '/usr/local/lsws/conf/vhosts' diff --git a/plogical/CyberPanelUpgrade.py b/plogical/CyberPanelUpgrade.py index 6f1833c2e..a9179374b 100644 --- a/plogical/CyberPanelUpgrade.py +++ b/plogical/CyberPanelUpgrade.py @@ -9,7 +9,7 @@ os.environ.setdefault("DJANGO_SETTINGS_MODULE", "CyberCP.settings") class UpgradeCyberPanel: - LogURL = "https://cloud.cyberpanel.net/settings/RecvData" + LogURL = "https://platform.cyberpersons.com/settings/RecvData" def __init__(self, branch, mail, dns, ftp): ipFile = "/etc/cyberpanel/machineIP"