From bbe91c34a46ca6d1453f750f1567ba0118b46367 Mon Sep 17 00:00:00 2001 From: master3395 Date: Tue, 3 Feb 2026 20:45:55 +0100 Subject: [PATCH] OLS 1.8.5+ and LSWS 6.3.4: LiteSpeed repo, version check, LSWS fallback and sed - Install: add LiteSpeed repo (repo.litespeed.sh), install openlitespeed; keep official binary if >= 1.8.5, else optional custom binary overlay - Upgrade: add repo, upgrade openlitespeed package; only run installCustomOLSBinaries if version < 1.8.5 - LSWS: fallback to 6.3.4 when API empty in cyberpanel_upgrade.sh and venvsetup.sh; sed lsws-6.0 and lsws-6.3.4 to latest stable - plogical/upgrade: add_litespeed_repo(), get_installed_ols_version(); install.py: add_litespeed_repo(), get_installed_ols_version() --- cyberpanel_upgrade.sh | 6 ++ install/install.py | 61 +++++++++++++++--- install/venvsetup.sh | 8 +++ plogical/upgrade.py | 42 ++++++++++++- .../OPENLITESPEED-VERSION-INSTALL-UPGRADE.md | 62 +++++++++++++++++++ 5 files changed, 168 insertions(+), 11 deletions(-) create mode 100644 to-do/OPENLITESPEED-VERSION-INSTALL-UPGRADE.md diff --git a/cyberpanel_upgrade.sh b/cyberpanel_upgrade.sh index b1d16f9e3..2210944fa 100644 --- a/cyberpanel_upgrade.sh +++ b/cyberpanel_upgrade.sh @@ -72,6 +72,10 @@ LSWS_Latest_URL="https://cyberpanel.sh/update.litespeedtech.com/ws/latest.php" LSWS_Tmp=$(curl --silent --max-time 30 -4 "$LSWS_Latest_URL") LSWS_Stable_Line=$(echo "$LSWS_Tmp" | grep "LSWS_STABLE") LSWS_Stable_Version=$(expr "$LSWS_Stable_Line" : '.*LSWS_STABLE=\(.*\) BUILD .*') +# Fallback to LSWS 6.3.4 (Stable) if fetch failed or empty +if [ -z "$LSWS_Stable_Version" ]; then + LSWS_Stable_Version="6.3.4" +fi #grab the LSWS latest stable version. Debug_Log2 "Starting Upgrade...1" @@ -1285,6 +1289,8 @@ Post_Upgrade_System_Tweak() { sed -i "s|lsws-5.3.8|lsws-$LSWS_Stable_Version|g" /usr/local/CyberCP/serverStatus/serverStatusUtil.py sed -i "s|lsws-5.4.2|lsws-$LSWS_Stable_Version|g" /usr/local/CyberCP/serverStatus/serverStatusUtil.py sed -i "s|lsws-5.3.5|lsws-$LSWS_Stable_Version|g" /usr/local/CyberCP/serverStatus/serverStatusUtil.py +sed -i "s|lsws-6.0|lsws-$LSWS_Stable_Version|g" /usr/local/CyberCP/serverStatus/serverStatusUtil.py +sed -i "s|lsws-6.3.4|lsws-$LSWS_Stable_Version|g" /usr/local/CyberCP/serverStatus/serverStatusUtil.py if [[ "$Server_Country" = "CN" ]] ; then sed -i 's|https://www.litespeedtech.com/|https://cyberpanel.sh/www.litespeedtech.com/|g' /usr/local/CyberCP/serverStatus/serverStatusUtil.py diff --git a/install/install.py b/install/install.py index 53c5ab69e..5c6c42024 100644 --- a/install/install.py +++ b/install/install.py @@ -78,6 +78,47 @@ class preFlightsChecks: def is_debian_family(self): """Check if distro is Ubuntu or Debian 12""" return self.distro in [ubuntu, debian12] + + def add_litespeed_repo(self): + """Add LiteSpeed repository so OpenLiteSpeed 1.8.5+ is available (repo.litespeed.sh)""" + try: + self.stdOut("Adding LiteSpeed repository for OpenLiteSpeed 1.8.5+...", 1) + cmd = 'wget -q -O - https://repo.litespeed.sh | bash' + ret = subprocess.run(cmd, shell=True, timeout=120, capture_output=True, universal_newlines=True) + if ret.returncode != 0 and ret.stderr: + self.stdOut(f"LiteSpeed repo script warning: {ret.stderr[:200]}", 1) + if ret.returncode == 0: + self.stdOut("LiteSpeed repository added", 1) + return True + # Non-fatal: distro openlitespeed may still be used + self.stdOut("Could not add LiteSpeed repo; using distro package", 1) + return False + except Exception as e: + self.stdOut(f"LiteSpeed repo add failed: {e}", 1) + return False + + def get_installed_ols_version(self): + """Return installed OpenLiteSpeed version as (major, minor, patch) or None""" + try: + for binary in ('/usr/local/lsws/bin/lshttpd', '/usr/local/lsws/bin/openlitespeed'): + if not os.path.exists(binary): + continue + result = subprocess.run( + [binary, '-v'], + capture_output=True, + timeout=5, + universal_newlines=True, + env=dict(os.environ, PATH=os.environ.get('PATH', '/usr/bin:/bin')) + ) + out = (result.stdout or '') + (result.stderr or '') + # e.g. "OpenLiteSpeed/1.8.5" or "1.8.5" + import re + m = re.search(r'(\d+)\.(\d+)\.(\d+)', out) + if m: + return (int(m.group(1)), int(m.group(2)), int(m.group(3))) + return None + except Exception: + return None def detect_os_info(self): """Detect OS information for all supported platforms""" @@ -1172,7 +1213,7 @@ class preFlightsChecks: platform = self.detectPlatform() self.stdOut(f"Detected platform: {platform}", 1) - # Platform-specific URLs and checksums (OpenLiteSpeed v1.8.4.1 - v2.0.5 Static Build) + # Platform-specific URLs and checksums (OpenLiteSpeed 1.8.5+ preferred from repo; fallback static build) # Module Build Date: December 28, 2025 - v2.2.0 Brute Force with Progressive Throttle BINARY_CONFIGS = { 'rhel8': { @@ -1381,16 +1422,20 @@ module cyberpanel_ols { self.stdOut("Installing LiteSpeed Web Server...", 1) if ent == 0: - # Install OpenLiteSpeed - self.stdOut("Installing OpenLiteSpeed...", 1) - if self.distro == ubuntu: + # Install OpenLiteSpeed 1.8.5+ from LiteSpeed repo when possible + self.stdOut("Installing OpenLiteSpeed (target 1.8.5+)...", 1) + self.add_litespeed_repo() + if self.distro == ubuntu or self.distro == debian12: self.install_package('openlitespeed') else: self.install_package('openlitespeed') - - # Install custom binaries with PHP config support - # This replaces the standard binary with enhanced version - self.installCustomOLSBinaries() + # Use official OLS 1.8.5+ when available; only overlay custom binary if older + ols_ver = self.get_installed_ols_version() + if ols_ver and ols_ver >= (1, 8, 5): + self.stdOut("Using official OpenLiteSpeed 1.8.5+ (no custom binary overlay)", 1) + else: + # Install custom binaries with PHP config support (for pre-1.8.5 or when repo not used) + self.installCustomOLSBinaries() # Configure OpenLiteSpeed self.fix_ols_configs() diff --git a/install/venvsetup.sh b/install/venvsetup.sh index bd5b472eb..a2422a71e 100644 --- a/install/venvsetup.sh +++ b/install/venvsetup.sh @@ -116,6 +116,10 @@ LATEST_URL="https://update.litespeedtech.com/ws/latest.php" curl --silent -o /tmp/lsws_latest $LATEST_URL 2>/dev/null LSWS_STABLE_LINE=`cat /tmp/lsws_latest | grep LSWS_STABLE` LSWS_STABLE_VER=`expr "$LSWS_STABLE_LINE" : '.*LSWS_STABLE=\(.*\) BUILD .*'` +# Fallback to LSWS 6.3.4 (Stable) if fetch failed or empty +if [ -z "$LSWS_STABLE_VER" ]; then + LSWS_STABLE_VER="6.3.4" +fi if [[ $SERVER_COUNTRY == "CN" ]] ; then #line1="$(grep -n "github.com/usmannasir/cyberpanel" install.py | head -n 1 | cut -d: -f1)" @@ -890,6 +894,8 @@ fi sed -i 's|lsws-5.4.2|lsws-'$LSWS_STABLE_VER'|g' installCyberPanel.py sed -i 's|lsws-5.3.5|lsws-'$LSWS_STABLE_VER'|g' installCyberPanel.py +sed -i 's|lsws-6.0|lsws-'$LSWS_STABLE_VER'|g' installCyberPanel.py +sed -i 's|lsws-6.3.4|lsws-'$LSWS_STABLE_VER'|g' installCyberPanel.py #this sed must be done after license validation echo -e "Preparing..." @@ -1229,6 +1235,8 @@ fi sed -i 's|lsws-5.3.8|lsws-'$LSWS_STABLE_VER'|g' /usr/local/CyberCP/serverStatus/serverStatusUtil.py sed -i 's|lsws-5.4.2|lsws-'$LSWS_STABLE_VER'|g' /usr/local/CyberCP/serverStatus/serverStatusUtil.py sed -i 's|lsws-5.3.5|lsws-'$LSWS_STABLE_VER'|g' /usr/local/CyberCP/serverStatus/serverStatusUtil.py +sed -i 's|lsws-6.0|lsws-'$LSWS_STABLE_VER'|g' /usr/local/CyberCP/serverStatus/serverStatusUtil.py +sed -i 's|lsws-6.3.4|lsws-'$LSWS_STABLE_VER'|g' /usr/local/CyberCP/serverStatus/serverStatusUtil.py if [[ $SILENT != "ON" ]] ; then printf "%s" "Would you like to restart your server now? [y/N]: " diff --git a/plogical/upgrade.py b/plogical/upgrade.py index 67cfc2a3e..bfefa5c52 100644 --- a/plogical/upgrade.py +++ b/plogical/upgrade.py @@ -500,6 +500,33 @@ class Upgrade: except: return False + @staticmethod + def add_litespeed_repo(): + """Add LiteSpeed repository so OpenLiteSpeed 1.8.5+ is available (repo.litespeed.sh).""" + return Upgrade.executioner_silent('wget -q -O - https://repo.litespeed.sh | bash', 'LiteSpeed repo', 0, shell=True) + + @staticmethod + def get_installed_ols_version(): + """Return installed OpenLiteSpeed version as (major, minor, patch) or None.""" + try: + for binary in ('/usr/local/lsws/bin/lshttpd', '/usr/local/lsws/bin/openlitespeed'): + if not os.path.exists(binary): + continue + result = subprocess.run( + [binary, '-v'], + capture_output=True, + timeout=5, + universal_newlines=True, + env=dict(os.environ, PATH=os.environ.get('PATH', '/usr/bin:/bin')) + ) + out = (result.stdout or '') + (result.stderr or '') + m = re.search(r'(\d+)\.(\d+)\.(\d+)', out) + if m: + return (int(m.group(1)), int(m.group(2)), int(m.group(3))) + return None + except Exception: + return None + @staticmethod def updateRepoURL(): command = "sed -i 's|sgp.cyberpanel.sh|cdn.cyberpanel.sh|g' /etc/yum.repos.d/MariaDB.repo" @@ -939,7 +966,7 @@ class Upgrade: platform = Upgrade.detectPlatform() Upgrade.stdOut(f"Detected platform: {platform}", 0) - # Platform-specific URLs and checksums (OpenLiteSpeed v1.8.4.1 with PHPConfig + Header unset fix + Static Linking) + # Platform-specific URLs and checksums (OpenLiteSpeed 1.8.5+ preferred from repo; fallback static build) # Module Build Date: December 28, 2025 - v2.2.0 Brute Force with Progressive Throttle BINARY_CONFIGS = { 'rhel8': { @@ -5684,9 +5711,18 @@ slowlog = /var/log/php{version}-fpm-slow.log Upgrade.setupPHPSymlink() Upgrade.setupComposer() - # Install custom OpenLiteSpeed binaries if OLS is installed + # OpenLiteSpeed: ensure 1.8.5+ (add LiteSpeed repo, upgrade package); only overlay custom binary if still < 1.8.5 if os.path.exists('/usr/local/lsws/bin/openlitespeed'): - Upgrade.installCustomOLSBinaries() + Upgrade.add_litespeed_repo() + if os.path.exists(Upgrade.CentOSPath) or os.path.exists(Upgrade.openEulerPath): + Upgrade.executioner('dnf install -y openlitespeed || yum install -y openlitespeed', 'Upgrade OpenLiteSpeed package', 0) + else: + Upgrade.executioner('DEBIAN_FRONTEND=noninteractive apt-get -y install --only-upgrade openlitespeed 2>/dev/null || DEBIAN_FRONTEND=noninteractive apt-get -y install openlitespeed', 'Upgrade OpenLiteSpeed package', 0, shell=True) + ols_ver = Upgrade.get_installed_ols_version() + if ols_ver and ols_ver >= (1, 8, 5): + Upgrade.stdOut("OpenLiteSpeed 1.8.5+ detected; keeping official binary (no custom overlay).") + else: + Upgrade.installCustomOLSBinaries() ## diff --git a/to-do/OPENLITESPEED-VERSION-INSTALL-UPGRADE.md b/to-do/OPENLITESPEED-VERSION-INSTALL-UPGRADE.md new file mode 100644 index 000000000..5846b78d1 --- /dev/null +++ b/to-do/OPENLITESPEED-VERSION-INSTALL-UPGRADE.md @@ -0,0 +1,62 @@ +# OpenLiteSpeed and LSWS Version Used by CyberPanel (Install & Upgrade) + +**Updated:** OLS target 1.8.5+ (LiteSpeed repo); LSWS fallback 6.3.4. + +## Summary + +- **Install:** OpenLiteSpeed is installed via the **OS package manager** (no fixed version in code), then optionally replaced by CyberPanel’s **custom static binary** (based on **OpenLiteSpeed 1.8.5 – v2.0.5**). +- **Upgrade:** The CyberPanel **upgrade script does not change the OpenLiteSpeed version**. It only updates **LiteSpeed Enterprise** version references. During upgrade, **custom OLS binaries** (same 1.8.5-based build) are (re)installed if OLS is present. + +--- + +## Install + +1. **Package install** + - `install/install.py` → `installLiteSpeed(ent=0)` → `install_package('openlitespeed')`. + - So the **base** install is whatever **openlitespeed** version the distro provides (yum/dnf or apt). There is **no fixed OLS version** in the installer for this step. + +2. **Custom binary (optional)** + - Right after that, `installCustomOLSBinaries()` runs (in both `install/install.py` and `plogical/upgrade.py`). + - It downloads a **static binary** from `https://cyberpanel.net/` (e.g. `openlitespeed-phpconfig-x86_64-rhel8-static`) and replaces `/usr/local/lsws/bin/openlitespeed`. + - Comments in code state this is **OpenLiteSpeed 1.8.5** (upgrade.py) or **1.8.5 – v2.0.5** (install.py). The download URLs do not include a version; the binary is a fixed build hosted by CyberPanel. + +So on **install**, you get either: +- **Distro OLS** (version = whatever the OS repo has), or +- **CyberPanel custom OLS** (based on **1.8.5 / v2.0.5** static build) if the custom binary install succeeds. + +--- + +## Upgrade + +1. **cyberpanel_upgrade.sh** + - Fetches **LiteSpeed Enterprise** latest version from: + - `LSWS_Latest_URL="https://cyberpanel.sh/update.litespeedtech.com/ws/latest.php"` + - Parses `LSWS_Stable_Version` from the `LSWS_STABLE` line. + - Uses `LSWS_Stable_Version` only to **sed**-replace hardcoded Enterprise version strings (e.g. `lsws-5.3.8`, `lsws-5.4.2`, `lsws-5.3.5`) in `/usr/local/CyberCP/serverStatus/serverStatusUtil.py`. + - So the **upgrade script does not install or upgrade OpenLiteSpeed**; it only updates **Enterprise** version references. + +2. **plogical/upgrade.py** + - During upgrade, if OpenLiteSpeed is present (`/usr/local/lsws/bin/openlitespeed` exists), it runs: + - `Upgrade.installCustomOLSBinaries()` + - That (re)installs the **same custom static OLS binary** (1.8.5-based, from cyberpanel.net). So **upgrade** does not pull a “new” OLS version from upstream; it only refreshes CyberPanel’s custom binary if OLS is in use. + +--- + +## References (in repo) + +| What | Where | +|------|--------| +| OLS package install (no version) | `install/install.py` → `install_package('openlitespeed')` in `installLiteSpeed()` | +| Custom OLS binary (1.8.5 / 1.8.5–v2.0.5) | `install/install.py` and `plogical/upgrade.py` → `installCustomOLSBinaries()` and `BINARY_CONFIGS` comments | +| LSWS version used in upgrade (Enterprise only) | `cyberpanel_upgrade.sh` → `LSWS_Latest_URL`, `LSWS_Stable_Version`, and sed to `serverStatusUtil.py` | +| Custom OLS on upgrade | `plogical/upgrade.py` → `if os.path.exists('/usr/local/lsws/bin/openlitespeed'): Upgrade.installCustomOLSBinaries()` | + +--- + +## Short answers + +- **What OpenLiteSpeed version does install use?** + Package: **distro default**. If custom binary is used: **OpenLiteSpeed 1.8.5 (or 1.8.5–v2.0.5)** static build from cyberpanel.net. + +- **What OpenLiteSpeed version does upgrade use?** + Upgrade does **not** change OLS version from upstream. It only (re)installs the **same custom 1.8.5-based** binary when OLS is present. **LiteSpeed Enterprise** version is the one fetched from `cyberpanel.sh/update.litespeedtech.com/ws/latest.php` and written into `serverStatusUtil.py`.