mirror of
https://github.com/usmannasir/cyberpanel.git
synced 2025-11-08 06:16:08 +01:00
add php 8.2 and also add support for cloud linux 8
This commit is contained in:
@@ -14,6 +14,11 @@ yum update curl wget ca-certificates -y 1> /dev/null
|
||||
elif echo $OUTPUT | grep -q "CloudLinux 7" ; then
|
||||
echo "Checking and installing curl and wget"
|
||||
yum install curl wget -y 1> /dev/null
|
||||
yum update curl wget ca-certificates -y 1> /dev/null
|
||||
SERVER_OS="CloudLinux"
|
||||
elif echo $OUTPUT | grep -q "CloudLinux 8" ; then
|
||||
echo "Checking and installing curl and wget"
|
||||
yum install curl wget -y 1> /dev/null
|
||||
yum update curl wget ca-certificates -y 1> /dev/null
|
||||
SERVER_OS="CloudLinux"
|
||||
elif echo $OUTPUT | grep -q "Ubuntu 18.04" ; then
|
||||
|
||||
@@ -136,68 +136,70 @@ class preFlightsChecks:
|
||||
|
||||
def mountTemp(self):
|
||||
try:
|
||||
## On OpenVZ there is an issue using .tempdisk for /tmp as it breaks network on container after reboot.
|
||||
# ## On OpenVZ there is an issue using .tempdisk for /tmp as it breaks network on container after reboot.
|
||||
#
|
||||
# if subprocess.check_output('systemd-detect-virt').decode("utf-8").find("openvz") > -1:
|
||||
#
|
||||
# varTmp = "/var/tmp /tmp none bind 0 0\n"
|
||||
#
|
||||
# fstab = "/etc/fstab"
|
||||
# writeToFile = open(fstab, "a")
|
||||
# writeToFile.writelines(varTmp)
|
||||
# writeToFile.close()
|
||||
#
|
||||
# else:
|
||||
#
|
||||
# command = "dd if=/dev/zero of=/usr/.tempdisk bs=100M count=15"
|
||||
# preFlightsChecks.call(command, self.distro, command,
|
||||
# command,
|
||||
# 1, 0, os.EX_OSERR)
|
||||
#
|
||||
# command = "mkfs.ext4 -F /usr/.tempdisk"
|
||||
# preFlightsChecks.call(command, self.distro, command,
|
||||
# command,
|
||||
# 1, 0, os.EX_OSERR)
|
||||
#
|
||||
# command = "mkdir -p /usr/.tmpbak/"
|
||||
# preFlightsChecks.call(command, self.distro, command,
|
||||
# command,
|
||||
# 1, 0, os.EX_OSERR)
|
||||
#
|
||||
# command = "cp -pr /tmp/* /usr/.tmpbak/"
|
||||
# subprocess.call(command, shell=True)
|
||||
#
|
||||
# command = "mount -o loop,rw,nodev,nosuid,noexec,nofail /usr/.tempdisk /tmp"
|
||||
# preFlightsChecks.call(command, self.distro, command,
|
||||
# command,
|
||||
# 1, 0, os.EX_OSERR)
|
||||
#
|
||||
# command = "chmod 1777 /tmp"
|
||||
# preFlightsChecks.call(command, self.distro, command,
|
||||
# command,
|
||||
# 1, 0, os.EX_OSERR)
|
||||
#
|
||||
# command = "cp -pr /usr/.tmpbak/* /tmp/"
|
||||
# subprocess.call(command, shell=True)
|
||||
#
|
||||
# command = "rm -rf /usr/.tmpbak"
|
||||
# preFlightsChecks.call(command, self.distro, command,
|
||||
# command,
|
||||
# 1, 0, os.EX_OSERR)
|
||||
#
|
||||
# command = "mount --bind /tmp /var/tmp"
|
||||
# preFlightsChecks.call(command, self.distro, command,
|
||||
# command,
|
||||
# 1, 0, os.EX_OSERR)
|
||||
#
|
||||
# tmp = "/usr/.tempdisk /tmp ext4 loop,rw,noexec,nosuid,nodev,nofail 0 0\n"
|
||||
# varTmp = "/tmp /var/tmp none bind 0 0\n"
|
||||
#
|
||||
# fstab = "/etc/fstab"
|
||||
# writeToFile = open(fstab, "a")
|
||||
# writeToFile.writelines(tmp)
|
||||
# writeToFile.writelines(varTmp)
|
||||
# writeToFile.close()
|
||||
|
||||
if subprocess.check_output('systemd-detect-virt').decode("utf-8").find("openvz") > -1:
|
||||
|
||||
varTmp = "/var/tmp /tmp none bind 0 0\n"
|
||||
|
||||
fstab = "/etc/fstab"
|
||||
writeToFile = open(fstab, "a")
|
||||
writeToFile.writelines(varTmp)
|
||||
writeToFile.close()
|
||||
|
||||
else:
|
||||
|
||||
command = "dd if=/dev/zero of=/usr/.tempdisk bs=100M count=15"
|
||||
preFlightsChecks.call(command, self.distro, command,
|
||||
command,
|
||||
1, 0, os.EX_OSERR)
|
||||
|
||||
command = "mkfs.ext4 -F /usr/.tempdisk"
|
||||
preFlightsChecks.call(command, self.distro, command,
|
||||
command,
|
||||
1, 0, os.EX_OSERR)
|
||||
|
||||
command = "mkdir -p /usr/.tmpbak/"
|
||||
preFlightsChecks.call(command, self.distro, command,
|
||||
command,
|
||||
1, 0, os.EX_OSERR)
|
||||
|
||||
command = "cp -pr /tmp/* /usr/.tmpbak/"
|
||||
subprocess.call(command, shell=True)
|
||||
|
||||
command = "mount -o loop,rw,nodev,nosuid,noexec,nofail /usr/.tempdisk /tmp"
|
||||
preFlightsChecks.call(command, self.distro, command,
|
||||
command,
|
||||
1, 0, os.EX_OSERR)
|
||||
|
||||
command = "chmod 1777 /tmp"
|
||||
preFlightsChecks.call(command, self.distro, command,
|
||||
command,
|
||||
1, 0, os.EX_OSERR)
|
||||
|
||||
command = "cp -pr /usr/.tmpbak/* /tmp/"
|
||||
subprocess.call(command, shell=True)
|
||||
|
||||
command = "rm -rf /usr/.tmpbak"
|
||||
preFlightsChecks.call(command, self.distro, command,
|
||||
command,
|
||||
1, 0, os.EX_OSERR)
|
||||
|
||||
command = "mount --bind /tmp /var/tmp"
|
||||
preFlightsChecks.call(command, self.distro, command,
|
||||
command,
|
||||
1, 0, os.EX_OSERR)
|
||||
|
||||
tmp = "/usr/.tempdisk /tmp ext4 loop,rw,noexec,nosuid,nodev,nofail 0 0\n"
|
||||
varTmp = "/tmp /var/tmp none bind 0 0\n"
|
||||
|
||||
fstab = "/etc/fstab"
|
||||
writeToFile = open(fstab, "a")
|
||||
writeToFile.writelines(tmp)
|
||||
writeToFile.writelines(varTmp)
|
||||
writeToFile.close()
|
||||
pass
|
||||
|
||||
except BaseException as msg:
|
||||
preFlightsChecks.stdOut('[ERROR] ' + str(msg))
|
||||
|
||||
@@ -204,6 +204,9 @@ class InstallCyberPanel:
|
||||
command = 'DEBIAN_FRONTEND=noninteractive apt-get -y install lsphp81*'
|
||||
os.system(command)
|
||||
|
||||
command = 'DEBIAN_FRONTEND=noninteractive apt-get -y install lsphp82*'
|
||||
os.system(command)
|
||||
|
||||
elif self.distro == centos:
|
||||
command = 'yum -y groupinstall lsphp-all'
|
||||
install.preFlightsChecks.call(command, self.distro, command, command, 1, 1, os.EX_OSERR)
|
||||
@@ -241,7 +244,7 @@ class InstallCyberPanel:
|
||||
command = 'dnf install lsphp71* lsphp72* lsphp73* lsphp74* lsphp80* --exclude lsphp73-pecl-zip --exclude *imagick* -y --skip-broken'
|
||||
subprocess.call(command, shell=True)
|
||||
|
||||
command = 'dnf install lsphp81* --exclude *imagick* -y --skip-broken'
|
||||
command = 'dnf install lsphp81* lsphp82* --exclude *imagick* -y --skip-broken'
|
||||
subprocess.call(command, shell=True)
|
||||
|
||||
if self.distro == openeuler:
|
||||
|
||||
@@ -70,7 +70,7 @@ class cPanelImporter:
|
||||
if value[2] == 'main':
|
||||
self.MainSite = value
|
||||
self.PHPVersion = value[9]
|
||||
self.InheritPHP = self.PHPDecider(key)
|
||||
self.InheritPHP = self.PHPDecider(None)
|
||||
else:
|
||||
self.OtherDomainNames.append(key)
|
||||
self.OtherDomains.append(value)
|
||||
@@ -119,7 +119,10 @@ class cPanelImporter:
|
||||
|
||||
from plogical.phpUtilities import phpUtilities
|
||||
|
||||
if domainName !=None:
|
||||
completePathToConfigFile = f'/usr/local/lsws/conf/vhosts/{domainName}/vhost.conf'
|
||||
else:
|
||||
completePathToConfigFile = None
|
||||
|
||||
phpVersion = phpUtilities.FindIfSaidPHPIsAvaiableOtherwiseMaketheNextOneAvailableToUse(completePathToConfigFile, self.PHPVersion)
|
||||
|
||||
@@ -225,7 +228,7 @@ class cPanelImporter:
|
||||
logging.statusWriter(self.logFile, message, 1)
|
||||
|
||||
self.PHPVersion = self.MainSite[9]
|
||||
self.PHPDecider(self.mainDomain)
|
||||
self.PHPDecider(None)
|
||||
|
||||
message = 'PHP version of %s is %s.' % (DomainName, self.PHPVersion)
|
||||
logging.statusWriter(self.logFile, message, 1)
|
||||
@@ -270,7 +273,7 @@ class cPanelImporter:
|
||||
if result[0] == 1:
|
||||
pass
|
||||
else:
|
||||
message = 'Failed to create main site %s from archive file: %s' % (DomainName, self.backupFile)
|
||||
message = f'Failed to create main site %s from archive file: %s. Error {str(result)}' % (DomainName, self.backupFile)
|
||||
logging.statusWriter(self.logFile, message, 1)
|
||||
return 0
|
||||
|
||||
@@ -373,7 +376,7 @@ class cPanelImporter:
|
||||
## Find PHP Version
|
||||
|
||||
self.PHPVersion = self.OtherDomains[counter][9]
|
||||
self.PHPDecider(items)
|
||||
self.PHPDecider(None)
|
||||
|
||||
message = 'Calling core to create %s.' % (items)
|
||||
logging.statusWriter(self.logFile, message, 1)
|
||||
|
||||
@@ -242,6 +242,7 @@ class phpUtilities:
|
||||
|
||||
@staticmethod
|
||||
def FindIfSaidPHPIsAvaiableOtherwiseMaketheNextOneAvailableToUse(vhFile, phpVersion):
|
||||
if vhFile != None:
|
||||
result = phpUtilities.GetPHPVersionFromFile(vhFile)
|
||||
|
||||
if os.path.exists(result):
|
||||
@@ -249,6 +250,15 @@ class phpUtilities:
|
||||
else:
|
||||
from managePHP.phpManager import PHPManager
|
||||
return PHPManager.findPHPVersions()[-2]
|
||||
else:
|
||||
from managePHP.phpManager import PHPManager
|
||||
php = PHPManager.getPHPString(phpVersion)
|
||||
finalPath = f'/usr/local/lsws/lsphp{php}/bin/php'
|
||||
if os.path.exists(finalPath):
|
||||
return phpVersion
|
||||
else:
|
||||
from managePHP.phpManager import PHPManager
|
||||
return PHPManager.findPHPVersions()[-2]
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,30 +0,0 @@
|
||||
import os
|
||||
|
||||
def find_php_versions():
|
||||
import re
|
||||
import os
|
||||
php_versions = []
|
||||
lsws_directory = "/usr/local/lsws"
|
||||
|
||||
if os.path.exists(lsws_directory):
|
||||
for dir_name in os.listdir(lsws_directory):
|
||||
full_path = os.path.join(lsws_directory, dir_name)
|
||||
if os.path.isdir(full_path) and dir_name.startswith("lsphp"):
|
||||
php_version = dir_name.replace("lsphp", "PHP ").replace("", ".")
|
||||
php_versions.append(php_version)
|
||||
|
||||
result_list = []
|
||||
for item in sorted(php_versions):
|
||||
# Use regular expression to find numbers in the string
|
||||
numbers = re.findall(r'\d+', item)
|
||||
|
||||
# Join the numbers with dots and add 'PHP' back to the string
|
||||
result = 'PHP ' + '.'.join(numbers)
|
||||
|
||||
result_list.append(result)
|
||||
|
||||
return result_list
|
||||
|
||||
if __name__ == "__main__":
|
||||
php_versions = find_php_versions()
|
||||
print(php_versions)
|
||||
|
||||
Reference in New Issue
Block a user