mirror of
https://github.com/usmannasir/cyberpanel.git
synced 2025-10-26 07:46:35 +01:00
bug fix: fix dynamic latest version of lsws server
This commit is contained in:
@@ -9,6 +9,8 @@ import install
|
|||||||
from os.path import exists
|
from os.path import exists
|
||||||
import time
|
import time
|
||||||
import install_utils
|
import install_utils
|
||||||
|
import urllib.request
|
||||||
|
import re
|
||||||
|
|
||||||
# distros - using from install_utils
|
# distros - using from install_utils
|
||||||
centos = install_utils.centos
|
centos = install_utils.centos
|
||||||
@@ -172,6 +174,34 @@ class InstallCyberPanel:
|
|||||||
def stdOut(message, log=0, exit=0, code=os.EX_OK):
|
def stdOut(message, log=0, exit=0, code=os.EX_OK):
|
||||||
install_utils.stdOut(message, log, exit, code)
|
install_utils.stdOut(message, log, exit, code)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def getLatestLSWSVersion():
|
||||||
|
"""Fetch the latest LSWS Enterprise version from LiteSpeed's website"""
|
||||||
|
try:
|
||||||
|
# Try to fetch from the download page
|
||||||
|
url = "https://www.litespeedtech.com/products/litespeed-web-server/download"
|
||||||
|
req = urllib.request.Request(url, headers={'User-Agent': 'Mozilla/5.0'})
|
||||||
|
with urllib.request.urlopen(req, timeout=10) as response:
|
||||||
|
html = response.read().decode('utf-8')
|
||||||
|
|
||||||
|
# Look for the latest version pattern: lsws-X.Y.Z-ent
|
||||||
|
version_pattern = r'lsws-(\d+\.\d+\.\d+)-ent'
|
||||||
|
versions = re.findall(version_pattern, html)
|
||||||
|
|
||||||
|
if versions:
|
||||||
|
# Get the latest version
|
||||||
|
latest_version = sorted(versions, key=lambda v: [int(x) for x in v.split('.')])[-1]
|
||||||
|
InstallCyberPanel.stdOut(f"Found latest LSWS Enterprise version: {latest_version}", 1)
|
||||||
|
return latest_version
|
||||||
|
else:
|
||||||
|
InstallCyberPanel.stdOut("Could not find version pattern in HTML, using fallback", 1)
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
InstallCyberPanel.stdOut(f"Failed to fetch latest LSWS version: {str(e)}, using fallback", 1)
|
||||||
|
|
||||||
|
# Fallback to known latest version
|
||||||
|
return "6.3.4"
|
||||||
|
|
||||||
def installLiteSpeed(self):
|
def installLiteSpeed(self):
|
||||||
if self.ent == 0:
|
if self.ent == 0:
|
||||||
self.install_package('openlitespeed')
|
self.install_package('openlitespeed')
|
||||||
@@ -190,34 +220,37 @@ class InstallCyberPanel:
|
|||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
# Get the latest LSWS Enterprise version dynamically
|
||||||
|
lsws_version = InstallCyberPanel.getLatestLSWSVersion()
|
||||||
|
|
||||||
if InstallCyberPanel.ISARM():
|
if InstallCyberPanel.ISARM():
|
||||||
command = 'wget https://www.litespeedtech.com/packages/6.0/lsws-6.2-ent-aarch64-linux.tar.gz'
|
command = f'wget https://www.litespeedtech.com/packages/6.0/lsws-{lsws_version}-ent-aarch64-linux.tar.gz'
|
||||||
else:
|
else:
|
||||||
command = 'wget https://www.litespeedtech.com/packages/6.0/lsws-6.2-ent-x86_64-linux.tar.gz'
|
command = f'wget https://www.litespeedtech.com/packages/6.0/lsws-{lsws_version}-ent-x86_64-linux.tar.gz'
|
||||||
|
|
||||||
install_utils.call(command, self.distro, command, command, 1, 1, os.EX_OSERR)
|
install_utils.call(command, self.distro, command, command, 1, 1, os.EX_OSERR)
|
||||||
|
|
||||||
if InstallCyberPanel.ISARM():
|
if InstallCyberPanel.ISARM():
|
||||||
command = 'tar zxf lsws-6.2-ent-aarch64-linux.tar.gz'
|
command = f'tar zxf lsws-{lsws_version}-ent-aarch64-linux.tar.gz'
|
||||||
else:
|
else:
|
||||||
command = 'tar zxf lsws-6.2-ent-x86_64-linux.tar.gz'
|
command = f'tar zxf lsws-{lsws_version}-ent-x86_64-linux.tar.gz'
|
||||||
|
|
||||||
install_utils.call(command, self.distro, command, command, 1, 1, os.EX_OSERR)
|
install_utils.call(command, self.distro, command, command, 1, 1, os.EX_OSERR)
|
||||||
|
|
||||||
if str.lower(self.serial) == 'trial':
|
if str.lower(self.serial) == 'trial':
|
||||||
command = 'wget -q --output-document=lsws-6.2/trial.key http://license.litespeedtech.com/reseller/trial.key'
|
command = f'wget -q --output-document=lsws-{lsws_version}/trial.key http://license.litespeedtech.com/reseller/trial.key'
|
||||||
if self.serial == '1111-2222-3333-4444':
|
if self.serial == '1111-2222-3333-4444':
|
||||||
command = 'wget -q --output-document=/root/cyberpanel/install/lsws-6.2/trial.key http://license.litespeedtech.com/reseller/trial.key'
|
command = f'wget -q --output-document=/root/cyberpanel/install/lsws-{lsws_version}/trial.key http://license.litespeedtech.com/reseller/trial.key'
|
||||||
install_utils.call(command, self.distro, command, command, 1, 1, os.EX_OSERR)
|
install_utils.call(command, self.distro, command, command, 1, 1, os.EX_OSERR)
|
||||||
else:
|
else:
|
||||||
writeSerial = open('lsws-6.2/serial.no', 'w')
|
writeSerial = open(f'lsws-{lsws_version}/serial.no', 'w')
|
||||||
writeSerial.writelines(self.serial)
|
writeSerial.writelines(self.serial)
|
||||||
writeSerial.close()
|
writeSerial.close()
|
||||||
|
|
||||||
shutil.copy('litespeed/install.sh', 'lsws-6.2/')
|
shutil.copy('litespeed/install.sh', f'lsws-{lsws_version}/')
|
||||||
shutil.copy('litespeed/functions.sh', 'lsws-6.2/')
|
shutil.copy('litespeed/functions.sh', f'lsws-{lsws_version}/')
|
||||||
|
|
||||||
os.chdir('lsws-6.2')
|
os.chdir(f'lsws-{lsws_version}')
|
||||||
|
|
||||||
command = 'chmod +x install.sh'
|
command = 'chmod +x install.sh'
|
||||||
install_utils.call(command, self.distro, command, command, 1, 1, os.EX_OSERR)
|
install_utils.call(command, self.distro, command, command, 1, 1, os.EX_OSERR)
|
||||||
|
|||||||
@@ -17,6 +17,8 @@ from plogical.sslUtilities import sslUtilities
|
|||||||
from plogical.vhost import vhost
|
from plogical.vhost import vhost
|
||||||
from shutil import ignore_patterns
|
from shutil import ignore_patterns
|
||||||
import threading as multi
|
import threading as multi
|
||||||
|
import urllib.request
|
||||||
|
import re
|
||||||
|
|
||||||
|
|
||||||
class ServerStatusUtil(multi.Thread):
|
class ServerStatusUtil(multi.Thread):
|
||||||
@@ -46,6 +48,37 @@ class ServerStatusUtil(multi.Thread):
|
|||||||
logging.CyberCPLogFileWriter.writeToFile(str(msg))
|
logging.CyberCPLogFileWriter.writeToFile(str(msg))
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def getLatestLSWSVersion():
|
||||||
|
"""Fetch the latest LSWS Enterprise version from LiteSpeed's website"""
|
||||||
|
try:
|
||||||
|
# Try to fetch from the download page
|
||||||
|
url = "https://www.litespeedtech.com/products/litespeed-web-server/download"
|
||||||
|
req = urllib.request.Request(url, headers={'User-Agent': 'Mozilla/5.0'})
|
||||||
|
with urllib.request.urlopen(req, timeout=10) as response:
|
||||||
|
html = response.read().decode('utf-8')
|
||||||
|
|
||||||
|
# Look for the latest version pattern: lsws-X.Y.Z-ent
|
||||||
|
version_pattern = r'lsws-(\d+\.\d+\.\d+)-ent'
|
||||||
|
versions = re.findall(version_pattern, html)
|
||||||
|
|
||||||
|
if versions:
|
||||||
|
# Get the latest version
|
||||||
|
latest_version = sorted(versions, key=lambda v: [int(x) for x in v.split('.')])[-1]
|
||||||
|
logging.CyberCPLogFileWriter.statusWriter(ServerStatusUtil.lswsInstallStatusPath,
|
||||||
|
f"Found latest LSWS Enterprise version: {latest_version}\n", 1)
|
||||||
|
return latest_version
|
||||||
|
else:
|
||||||
|
logging.CyberCPLogFileWriter.statusWriter(ServerStatusUtil.lswsInstallStatusPath,
|
||||||
|
"Could not find version pattern in HTML, using fallback\n", 1)
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
logging.CyberCPLogFileWriter.statusWriter(ServerStatusUtil.lswsInstallStatusPath,
|
||||||
|
f"Failed to fetch latest LSWS version: {str(e)}, using fallback\n", 1)
|
||||||
|
|
||||||
|
# Fallback to known latest version
|
||||||
|
return "6.3.4"
|
||||||
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def installLiteSpeed(licenseKey, statusFile):
|
def installLiteSpeed(licenseKey, statusFile):
|
||||||
@@ -73,11 +106,14 @@ class ServerStatusUtil(multi.Thread):
|
|||||||
|
|
||||||
from plogical.acl import ACLManager
|
from plogical.acl import ACLManager
|
||||||
|
|
||||||
|
# Get the latest LSWS Enterprise version dynamically
|
||||||
|
lsws_version = ServerStatusUtil.getLatestLSWSVersion()
|
||||||
|
|
||||||
if ACLManager.ISARM():
|
if ACLManager.ISARM():
|
||||||
command = 'wget https://www.litespeedtech.com/packages/6.0/lsws-6.2-ent-aarch64-linux.tar.gz'
|
command = f'wget https://www.litespeedtech.com/packages/6.0/lsws-{lsws_version}-ent-aarch64-linux.tar.gz'
|
||||||
else:
|
else:
|
||||||
|
|
||||||
command = 'wget https://www.litespeedtech.com/packages/6.0/lsws-6.2-ent-x86_64-linux.tar.gz'
|
command = f'wget https://www.litespeedtech.com/packages/6.0/lsws-{lsws_version}-ent-x86_64-linux.tar.gz'
|
||||||
|
|
||||||
if ServerStatusUtil.executioner(command, statusFile) == 0:
|
if ServerStatusUtil.executioner(command, statusFile) == 0:
|
||||||
return 0
|
return 0
|
||||||
@@ -85,30 +121,30 @@ class ServerStatusUtil(multi.Thread):
|
|||||||
if os.path.exists('/usr/local/CyberCP/lsws-6.0/'):
|
if os.path.exists('/usr/local/CyberCP/lsws-6.0/'):
|
||||||
shutil.rmtree('/usr/local/CyberCP/lsws-6.0')
|
shutil.rmtree('/usr/local/CyberCP/lsws-6.0')
|
||||||
|
|
||||||
if os.path.exists('/usr/local/CyberCP/lsws-6.2/'):
|
if os.path.exists(f'/usr/local/CyberCP/lsws-{lsws_version}/'):
|
||||||
shutil.rmtree('/usr/local/CyberCP/lsws-6.2/')
|
shutil.rmtree(f'/usr/local/CyberCP/lsws-{lsws_version}/')
|
||||||
|
|
||||||
if ACLManager.ISARM():
|
if ACLManager.ISARM():
|
||||||
command = 'tar zxf lsws-6.2-ent-aarch64-linux.tar.gz -C /usr/local/CyberCP'
|
command = f'tar zxf lsws-{lsws_version}-ent-aarch64-linux.tar.gz -C /usr/local/CyberCP'
|
||||||
else:
|
else:
|
||||||
command = 'tar zxf lsws-6.2-ent-x86_64-linux.tar.gz -C /usr/local/CyberCP'
|
command = f'tar zxf lsws-{lsws_version}-ent-x86_64-linux.tar.gz -C /usr/local/CyberCP'
|
||||||
|
|
||||||
if ServerStatusUtil.executioner(command, statusFile) == 0:
|
if ServerStatusUtil.executioner(command, statusFile) == 0:
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
if licenseKey == 'trial':
|
if licenseKey == 'trial':
|
||||||
command = 'wget -q --output-document=/usr/local/CyberCP/lsws-6.2/trial.key http://license.litespeedtech.com/reseller/trial.key'
|
command = f'wget -q --output-document=/usr/local/CyberCP/lsws-{lsws_version}/trial.key http://license.litespeedtech.com/reseller/trial.key'
|
||||||
if ServerStatusUtil.executioner(command, statusFile) == 0:
|
if ServerStatusUtil.executioner(command, statusFile) == 0:
|
||||||
return 0
|
return 0
|
||||||
else:
|
else:
|
||||||
writeSerial = open('/usr/local/CyberCP/lsws-6.2/serial.no', 'w')
|
writeSerial = open(f'/usr/local/CyberCP/lsws-{lsws_version}/serial.no', 'w')
|
||||||
writeSerial.writelines(licenseKey)
|
writeSerial.writelines(licenseKey)
|
||||||
writeSerial.close()
|
writeSerial.close()
|
||||||
|
|
||||||
shutil.copy('/usr/local/CyberCP/serverStatus/litespeed/install.sh', '/usr/local/CyberCP/lsws-6.2/')
|
shutil.copy('/usr/local/CyberCP/serverStatus/litespeed/install.sh', f'/usr/local/CyberCP/lsws-{lsws_version}/')
|
||||||
shutil.copy('/usr/local/CyberCP/serverStatus/litespeed/functions.sh', '/usr/local/CyberCP/lsws-6.2/')
|
shutil.copy('/usr/local/CyberCP/serverStatus/litespeed/functions.sh', f'/usr/local/CyberCP/lsws-{lsws_version}/')
|
||||||
|
|
||||||
os.chdir('/usr/local/CyberCP/lsws-6.2/')
|
os.chdir(f'/usr/local/CyberCP/lsws-{lsws_version}/')
|
||||||
|
|
||||||
command = 'chmod +x install.sh'
|
command = 'chmod +x install.sh'
|
||||||
if ServerStatusUtil.executioner(command, statusFile) == 0:
|
if ServerStatusUtil.executioner(command, statusFile) == 0:
|
||||||
@@ -135,7 +171,7 @@ class ServerStatusUtil(multi.Thread):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
try:
|
try:
|
||||||
os.rmdir("/usr/local/CyberCP/lsws-6.2")
|
os.rmdir(f"/usr/local/CyberCP/lsws-{lsws_version}")
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user