Fix OLS binary compatibility by detecting OS distribution
Add OS detection logic to download correct OpenLiteSpeed binaries based on system type: - Ubuntu/Debian systems: Download binaries with libcrypt.so.1 (GLIBC 2.35) - RHEL/AlmaLinux/Rocky 8+/9+: Download binaries with libcrypt.so.2 (GLIBC 2.34) This fixes the "libcrypt.so.2: cannot open shared object file" error that occurred when Ubuntu systems tried to use RHEL-compiled binaries. Changes: - Added detectBinarySuffix() method to both installCyberPanel.py and upgrade.py - Updated binary URLs to use https://cyberpanel.net with OS-specific suffix - Module URL: cyberpanel_ols_x86_64_{ubuntu|rhel}.so - Binary URL: openlitespeed-phpconfig-x86_64-{ubuntu|rhel} Binary compatibility matrix: - Ubuntu 20.04/22.04/24.04, Debian 10+, CentOS 7 → ubuntu binaries - AlmaLinux 8+/9+, Rocky 8+/9+, RHEL 8+/9+, OpenEuler → rhel binaries
This commit is contained in:
parent
5b7bcb462f
commit
39b74cb9b7
|
|
@ -224,6 +224,35 @@ class InstallCyberPanel:
|
|||
logging.InstallLog.writeToFile(str(msg) + " [detectArchitecture]")
|
||||
return False
|
||||
|
||||
def detectBinarySuffix(self):
|
||||
"""Detect which binary suffix to use based on OS distribution
|
||||
Returns 'ubuntu' for Ubuntu/Debian systems with libcrypt.so.1
|
||||
Returns 'rhel' for RHEL/AlmaLinux/Rocky systems with libcrypt.so.2
|
||||
"""
|
||||
try:
|
||||
# Ubuntu/Debian → ubuntu suffix
|
||||
if self.distro == ubuntu:
|
||||
return 'ubuntu'
|
||||
|
||||
# CentOS 8+/AlmaLinux/Rocky/OpenEuler → rhel suffix
|
||||
# These systems use libcrypt.so.2 and GLIBC 2.34+
|
||||
elif self.distro == cent8 or self.distro == openeuler:
|
||||
return 'rhel'
|
||||
|
||||
# CentOS 7 → ubuntu suffix (uses libcrypt.so.1)
|
||||
elif self.distro == centos:
|
||||
return 'ubuntu'
|
||||
|
||||
# Default to ubuntu for unknown distros
|
||||
else:
|
||||
InstallCyberPanel.stdOut("Unknown OS distribution, defaulting to Ubuntu binaries", 1)
|
||||
return 'ubuntu'
|
||||
|
||||
except Exception as msg:
|
||||
logging.InstallLog.writeToFile(str(msg) + " [detectBinarySuffix]")
|
||||
InstallCyberPanel.stdOut("Error detecting OS, defaulting to Ubuntu binaries", 1)
|
||||
return 'ubuntu'
|
||||
|
||||
def downloadCustomBinary(self, url, destination):
|
||||
"""Download custom binary file"""
|
||||
try:
|
||||
|
|
@ -261,12 +290,6 @@ class InstallCyberPanel:
|
|||
InstallCyberPanel.stdOut("Installing Custom OpenLiteSpeed Binaries", 1)
|
||||
InstallCyberPanel.stdOut("=" * 50, 1)
|
||||
|
||||
# URLs for custom binaries
|
||||
OLS_BINARY_URL = "https://cyberpanel.net/openlitespeed-phpconfig-x86_64"
|
||||
MODULE_URL = "https://cyberpanel.net/cyberpanel_ols_x86_64.so"
|
||||
OLS_BINARY_PATH = "/usr/local/lsws/bin/openlitespeed"
|
||||
MODULE_PATH = "/usr/local/lsws/modules/cyberpanel_ols.so"
|
||||
|
||||
# Check architecture
|
||||
if not self.detectArchitecture():
|
||||
InstallCyberPanel.stdOut("WARNING: Custom binaries only available for x86_64", 1)
|
||||
|
|
@ -274,6 +297,17 @@ class InstallCyberPanel:
|
|||
InstallCyberPanel.stdOut("Standard OLS will be used", 1)
|
||||
return True # Not a failure, just skip
|
||||
|
||||
# Detect OS and select appropriate binary suffix
|
||||
binary_suffix = self.detectBinarySuffix()
|
||||
InstallCyberPanel.stdOut(f"Detected OS type: using '{binary_suffix}' binaries", 1)
|
||||
|
||||
# URLs for custom binaries with OS-specific suffix
|
||||
BASE_URL = "https://cyberpanel.net"
|
||||
OLS_BINARY_URL = f"{BASE_URL}/openlitespeed-phpconfig-x86_64-{binary_suffix}"
|
||||
MODULE_URL = f"{BASE_URL}/cyberpanel_ols_x86_64_{binary_suffix}.so"
|
||||
OLS_BINARY_PATH = "/usr/local/lsws/bin/openlitespeed"
|
||||
MODULE_PATH = "/usr/local/lsws/modules/cyberpanel_ols.so"
|
||||
|
||||
# Create backup
|
||||
from datetime import datetime
|
||||
timestamp = datetime.now().strftime("%Y%m%d-%H%M%S")
|
||||
|
|
|
|||
|
|
@ -630,6 +630,45 @@ class Upgrade:
|
|||
Upgrade.stdOut(str(msg) + " [detectArchitecture]", 0)
|
||||
return False
|
||||
|
||||
@staticmethod
|
||||
def detectBinarySuffix():
|
||||
"""Detect which binary suffix to use based on OS distribution
|
||||
Returns 'ubuntu' for Ubuntu/Debian systems with libcrypt.so.1
|
||||
Returns 'rhel' for RHEL/AlmaLinux/Rocky systems with libcrypt.so.2
|
||||
"""
|
||||
try:
|
||||
# Check if we're on RHEL/CentOS/AlmaLinux 8+ (uses libcrypt.so.2)
|
||||
if os.path.exists('/etc/os-release'):
|
||||
with open('/etc/os-release', 'r') as f:
|
||||
os_release = f.read().lower()
|
||||
|
||||
# AlmaLinux 9+, Rocky 9+, RHEL 9+, CentOS Stream 9+
|
||||
if any(x in os_release for x in ['almalinux', 'rocky', 'rhel']) and 'version="9' in os_release:
|
||||
return 'rhel'
|
||||
elif 'centos stream 9' in os_release:
|
||||
return 'rhel'
|
||||
|
||||
# Check CentOS/RHEL path
|
||||
if os.path.exists(Upgrade.CentOSPath):
|
||||
data = open(Upgrade.CentOSPath, 'r').read()
|
||||
# CentOS/AlmaLinux/Rocky 8+ → rhel suffix
|
||||
if 'release 8' in data or 'release 9' in data:
|
||||
return 'rhel'
|
||||
# CentOS 7 → ubuntu suffix (uses libcrypt.so.1)
|
||||
else:
|
||||
return 'ubuntu'
|
||||
|
||||
# OpenEuler → rhel suffix
|
||||
if os.path.exists(Upgrade.openEulerPath):
|
||||
return 'rhel'
|
||||
|
||||
# Ubuntu/Debian → ubuntu suffix (default for unknown)
|
||||
return 'ubuntu'
|
||||
|
||||
except Exception as msg:
|
||||
Upgrade.stdOut(f"Error detecting OS: {msg}, defaulting to Ubuntu binaries", 0)
|
||||
return 'ubuntu'
|
||||
|
||||
@staticmethod
|
||||
def downloadCustomBinary(url, destination):
|
||||
"""Download custom binary file"""
|
||||
|
|
@ -668,12 +707,6 @@ class Upgrade:
|
|||
Upgrade.stdOut("Installing Custom OpenLiteSpeed Binaries", 0)
|
||||
Upgrade.stdOut("=" * 50, 0)
|
||||
|
||||
# URLs for custom binaries
|
||||
OLS_BINARY_URL = "https://cyberpanel.net/openlitespeed-phpconfig-x86_64"
|
||||
MODULE_URL = "https://cyberpanel.net/cyberpanel_ols_x86_64.so"
|
||||
OLS_BINARY_PATH = "/usr/local/lsws/bin/openlitespeed"
|
||||
MODULE_PATH = "/usr/local/lsws/modules/cyberpanel_ols.so"
|
||||
|
||||
# Check architecture
|
||||
if not Upgrade.detectArchitecture():
|
||||
Upgrade.stdOut("WARNING: Custom binaries only available for x86_64", 0)
|
||||
|
|
@ -681,6 +714,17 @@ class Upgrade:
|
|||
Upgrade.stdOut("Standard OLS will be used", 0)
|
||||
return True # Not a failure, just skip
|
||||
|
||||
# Detect OS and select appropriate binary suffix
|
||||
binary_suffix = Upgrade.detectBinarySuffix()
|
||||
Upgrade.stdOut(f"Detected OS type: using '{binary_suffix}' binaries", 0)
|
||||
|
||||
# URLs for custom binaries with OS-specific suffix
|
||||
BASE_URL = "https://cyberpanel.net"
|
||||
OLS_BINARY_URL = f"{BASE_URL}/openlitespeed-phpconfig-x86_64-{binary_suffix}"
|
||||
MODULE_URL = f"{BASE_URL}/cyberpanel_ols_x86_64_{binary_suffix}.so"
|
||||
OLS_BINARY_PATH = "/usr/local/lsws/bin/openlitespeed"
|
||||
MODULE_PATH = "/usr/local/lsws/modules/cyberpanel_ols.so"
|
||||
|
||||
# Create backup
|
||||
from datetime import datetime
|
||||
timestamp = datetime.now().strftime("%Y%m%d-%H%M%S")
|
||||
|
|
|
|||
Loading…
Reference in New Issue