Sindbad~EG File Manager
import subprocess
import os
import xml.etree.ElementTree as etree
from logging import getLogger
logger = getLogger(__name__)
MU_PLUGIN_INSTALLATION = "mu_plugin_installation"
ADVICE_EMAIL_NOTIFICATION = "advice_email_notification"
MU_PLUGIN_KEYS = [MU_PLUGIN_INSTALLATION, ADVICE_EMAIL_NOTIFICATION]
XRAY_MANAGER = "/usr/sbin/cloudlinux-xray-manager"
def get_rhn_value(name):
try:
rhn_systemid_xml = etree.parse("/etc/sysconfig/rhn/systemid")
for member in rhn_systemid_xml.iter("member"):
if member.find("name").text == name:
return member.find("value")[0].text
except (IOError, IndexError, KeyError, etree.ParseError):
return None
return None
class WordPressMuPlugin:
@staticmethod
def _setup_agent():
system_id = get_rhn_value("system_id")
if system_id:
proc = subprocess.run(
[
"/usr/sbin/cloudlinux-xray-manager",
"enable-user-agent",
"--system_id",
system_id.replace("ID-", ""),
],
capture_output=True,
text=True,
)
logger.info(
"Activation xray manager captured out: %s, err: %s",
proc.stdout,
proc.stderr,
)
def prepare_for_mu_plugin_installation(
self, activation_status, mu_plugin_status
):
"""
Must use plugin works only if xray-user-agent is running
So it is a requirement to be sure it is turned on
It is expected to be turned on by default after conversion to Cloulinux Pro edition
"""
if not all([activation_status == "active", mu_plugin_status]):
logger.warning(
"Nothing to prepare for Must Use plugin as settings "
"are not turned on, activation status=%s mu_plugin_status=%s",
str(activation_status),
str(mu_plugin_status),
)
return
if not mu_plugin_status:
logger.warning(
"Nothing to prepare for Must Use plugin "
"as mu_plugin_status=%s",
str(mu_plugin_status),
)
return
if not os.path.exists(XRAY_MANAGER):
raise ValueError(
"alt-php-xray rpm package is not installed "
"in the system, please install it and try again"
)
self._setup_agent()
Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists