mirror of
https://github.com/usmannasir/cyberpanel.git
synced 2025-11-13 08:46:09 +01:00
bug fix cPanel importer internal ticket: https://app.clickup.com/t/865d12g34
This commit is contained in:
@@ -70,7 +70,7 @@ class cPanelImporter:
|
|||||||
if value[2] == 'main':
|
if value[2] == 'main':
|
||||||
self.MainSite = value
|
self.MainSite = value
|
||||||
self.PHPVersion = value[9]
|
self.PHPVersion = value[9]
|
||||||
self.InheritPHP = self.PHPDecider()
|
self.InheritPHP = self.PHPDecider(key)
|
||||||
else:
|
else:
|
||||||
self.OtherDomainNames.append(key)
|
self.OtherDomainNames.append(key)
|
||||||
self.OtherDomains.append(value)
|
self.OtherDomains.append(value)
|
||||||
@@ -78,7 +78,7 @@ class cPanelImporter:
|
|||||||
except BaseException as msg:
|
except BaseException as msg:
|
||||||
print(str(msg))
|
print(str(msg))
|
||||||
|
|
||||||
def PHPDecider(self):
|
def PHPDecider(self, domainName):
|
||||||
|
|
||||||
if self.PHPVersion == 'inherit':
|
if self.PHPVersion == 'inherit':
|
||||||
self.PHPVersion = 'PHP 7.4'
|
self.PHPVersion = 'PHP 7.4'
|
||||||
@@ -104,6 +104,8 @@ class cPanelImporter:
|
|||||||
self.PHPVersion = 'PHP 8.0'
|
self.PHPVersion = 'PHP 8.0'
|
||||||
elif self.PHPVersion.find('81') > -1:
|
elif self.PHPVersion.find('81') > -1:
|
||||||
self.PHPVersion = 'PHP 8.1'
|
self.PHPVersion = 'PHP 8.1'
|
||||||
|
elif self.PHPVersion.find('82') > -1:
|
||||||
|
self.PHPVersion = 'PHP 8.2'
|
||||||
|
|
||||||
if self.PHPVersion == '':
|
if self.PHPVersion == '':
|
||||||
if self.InheritPHP != '':
|
if self.InheritPHP != '':
|
||||||
@@ -111,6 +113,22 @@ class cPanelImporter:
|
|||||||
else:
|
else:
|
||||||
self.PHPVersion = 'PHP 7.4'
|
self.PHPVersion = 'PHP 7.4'
|
||||||
|
|
||||||
|
### if the PHP Version extracted from file is not available then change it to next available
|
||||||
|
|
||||||
|
try:
|
||||||
|
|
||||||
|
from plogical.phpUtilities import phpUtilities
|
||||||
|
|
||||||
|
completePathToConfigFile = f'/usr/local/lsws/conf/vhosts/{domainName}/vhost.conf'
|
||||||
|
|
||||||
|
phpVersion = phpUtilities.FindIfSaidPHPIsAvaiableOtherwiseMaketheNextOneAvailableToUse(completePathToConfigFile, self.PHPVersion)
|
||||||
|
|
||||||
|
if phpVersion != self.PHPVersion:
|
||||||
|
logging.statusWriter(self.logFile, f'PHP version for {self.mainDomain} has been changed from {self.PHPVersion} to {phpVersion}.', 1)
|
||||||
|
self.PHPVersion = phpVersion
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
return self.PHPVersion
|
return self.PHPVersion
|
||||||
|
|
||||||
def SetupSSL(self, path, domain):
|
def SetupSSL(self, path, domain):
|
||||||
@@ -207,7 +225,7 @@ class cPanelImporter:
|
|||||||
logging.statusWriter(self.logFile, message, 1)
|
logging.statusWriter(self.logFile, message, 1)
|
||||||
|
|
||||||
self.PHPVersion = self.MainSite[9]
|
self.PHPVersion = self.MainSite[9]
|
||||||
self.PHPDecider()
|
self.PHPDecider(self.mainDomain)
|
||||||
|
|
||||||
message = 'PHP version of %s is %s.' % (DomainName, self.PHPVersion)
|
message = 'PHP version of %s is %s.' % (DomainName, self.PHPVersion)
|
||||||
logging.statusWriter(self.logFile, message, 1)
|
logging.statusWriter(self.logFile, message, 1)
|
||||||
@@ -355,7 +373,7 @@ class cPanelImporter:
|
|||||||
## Find PHP Version
|
## Find PHP Version
|
||||||
|
|
||||||
self.PHPVersion = self.OtherDomains[counter][9]
|
self.PHPVersion = self.OtherDomains[counter][9]
|
||||||
self.PHPDecider()
|
self.PHPDecider(items)
|
||||||
|
|
||||||
message = 'Calling core to create %s.' % (items)
|
message = 'Calling core to create %s.' % (items)
|
||||||
logging.statusWriter(self.logFile, message, 1)
|
logging.statusWriter(self.logFile, message, 1)
|
||||||
|
|||||||
@@ -226,13 +226,13 @@ class phpUtilities:
|
|||||||
return result
|
return result
|
||||||
|
|
||||||
else:
|
else:
|
||||||
command = f'grep -Eo -m 1 "php[0-9]+" {vhFile}'
|
command = f'grep -Po "php\d+" {vhFile} | head -n 1'
|
||||||
result = ProcessUtilities.outputExecutioner(command, None, True).rstrip('\n')
|
result = ProcessUtilities.outputExecutioner(command, None, True).rstrip('\n')
|
||||||
result = f'/usr/local/lsws/ls{result}/bin/lsphp'
|
result = f'/usr/local/lsws/ls{result}/bin/lsphp'
|
||||||
result = result.rsplit("lsphp", 1)[0] + "php"
|
result = result.rsplit("lsphp", 1)[0] + "php"
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
## returns something like PHP 8.2
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def WrapGetPHPVersionFromFileToGetVersionWithPHP(vhFile):
|
def WrapGetPHPVersionFromFileToGetVersionWithPHP(vhFile):
|
||||||
result = phpUtilities.GetPHPVersionFromFile(vhFile)
|
result = phpUtilities.GetPHPVersionFromFile(vhFile)
|
||||||
@@ -240,6 +240,17 @@ class phpUtilities:
|
|||||||
php_version = ProcessUtilities.outputExecutioner(command, None, True).rstrip('\n')
|
php_version = ProcessUtilities.outputExecutioner(command, None, True).rstrip('\n')
|
||||||
return f"PHP {php_version}"
|
return f"PHP {php_version}"
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def FindIfSaidPHPIsAvaiableOtherwiseMaketheNextOneAvailableToUse(vhFile, phpVersion):
|
||||||
|
result = phpUtilities.GetPHPVersionFromFile(vhFile)
|
||||||
|
|
||||||
|
if os.path.exists(result):
|
||||||
|
return phpVersion
|
||||||
|
else:
|
||||||
|
from managePHP.phpManager import PHPManager
|
||||||
|
return PHPManager.findPHPVersions()[-2]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import sys
|
|||||||
import django
|
import django
|
||||||
|
|
||||||
from plogical.acl import ACLManager
|
from plogical.acl import ACLManager
|
||||||
|
|
||||||
sys.path.append('/usr/local/CyberCP')
|
sys.path.append('/usr/local/CyberCP')
|
||||||
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "CyberCP.settings")
|
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "CyberCP.settings")
|
||||||
try:
|
try:
|
||||||
@@ -629,6 +628,10 @@ class vhost:
|
|||||||
#HomePath = website.externalApp
|
#HomePath = website.externalApp
|
||||||
virtualHostUser = externalApp
|
virtualHostUser = externalApp
|
||||||
|
|
||||||
|
from plogical.phpUtilities import phpUtilities
|
||||||
|
|
||||||
|
phpVersion = phpUtilities.FindIfSaidPHPIsAvaiableOtherwiseMaketheNextOneAvailableToUse(vhFile, phpVersion)
|
||||||
|
|
||||||
phpDetachUpdatePath = '/home/%s/.lsphp_restart.txt' % (vhFile.split('/')[-2])
|
phpDetachUpdatePath = '/home/%s/.lsphp_restart.txt' % (vhFile.split('/')[-2])
|
||||||
if ProcessUtilities.decideServer() == ProcessUtilities.OLS:
|
if ProcessUtilities.decideServer() == ProcessUtilities.OLS:
|
||||||
try:
|
try:
|
||||||
|
|||||||
Reference in New Issue
Block a user