Resolve /usr/local/CyberPanel/bin/python on install, upgrade, downgrade

Install:
- install.py: in preFlightsChecks.call(), replace missing CyberPanel python
  with /usr/bin/python3 and force shell=True so any code path (including
  old/cached script) never hits FileNotFoundError.

Upgrade:
- cyberpanel_upgrade.sh: resolve CP_PYTHON (CyberPanel, CyberCP, python3)
  before running upgrade.py and configure.py; use it for both.
- plogical/upgrade.py: add _python_for_manage(), use it in GeneralMigrations,
  collectstatic, and upgradePip so migrations/collectstatic work when
  /usr/local/CyberPanel/bin/python is missing.
This commit is contained in:
master3395
2026-02-04 22:46:48 +01:00
parent 527938cd21
commit fe3f3ff1ca
3 changed files with 38 additions and 23 deletions

View File

@@ -2839,6 +2839,13 @@ module cyberpanel_ols {
# Using shared function from install_utils
@staticmethod
def call(command, distro, bracket, message, log=0, do_exit=0, code=os.EX_OK, shell=False):
# Fix missing /usr/local/CyberPanel/bin/python on install/upgrade (avoid FileNotFoundError)
if isinstance(command, str) and '/usr/local/CyberPanel/bin/python' in command:
if not os.path.isfile('/usr/local/CyberPanel/bin/python'):
fallback = '/usr/bin/python3' if os.path.isfile('/usr/bin/python3') else '/usr/local/bin/python3'
if os.path.isfile(fallback):
command = command.replace('/usr/local/CyberPanel/bin/python', fallback, 1)
shell = True
return install_utils.call(command, distro, bracket, message, log, do_exit, code, shell)
def checkIfSeLinuxDisabled(self):