| Server IP : 62.60.133.156 / Your IP : 216.73.217.51 Web Server : LiteSpeed System : Linux linux24.centraldnserver.com 4.18.0-553.141.2.lve.el8.x86_64 #1 SMP Wed Jul 8 16:10:02 UTC 2026 x86_64 User : mimradmin ( 1166) PHP Version : 7.4.33 Disable Function : show_source, system, shell_exec, passthru, exec, popen, proc_open MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /opt/imunify360/venv/lib64/python3.11/site-packages/im360/subsys/panels/directadmin/ |
Upload File : |
import asyncio
import logging
import functools
import os
from defence360agent.subsys.panels.base import PanelException
from defence360agent.subsys.panels.directadmin.config import ConfigOptions
from defence360agent.utils import check_run, CheckRunError
logger = logging.getLogger(__name__)
BASEDIR = "/usr/local/directadmin/custombuild"
BUILD = os.path.join(BASEDIR, "build")
class CustomBuildOptions(ConfigOptions):
DEFAULT_FILENAME = os.path.join(BASEDIR, "options.conf")
async def build(option):
MAX_RETRIES = 3
for attempt in range(MAX_RETRIES + 1):
try:
return await check_run([BUILD, option], cwd=BASEDIR)
except CheckRunError as e:
if attempt == MAX_RETRIES:
raise PanelException(
"Failed to run custombuild command '{} {}' after {}"
" attempts: {}".format(BUILD, option, MAX_RETRIES, e)
)
if "Another instance of custombuild" in str(e):
logger.warning(
"Failed to run custombuild command '%s %s': %s",
BUILD,
option,
e,
)
logger.info("Retrying custombuild command after delay...")
await asyncio.sleep(5)
else:
raise PanelException(
"Failed to run custombuild command '{} {}': {}".format(
BUILD, option, e
)
)
def custombuild2_only(fun):
@functools.wraps(fun)
async def wrapper(*args, **kwargs):
try:
out = await build("version")
except (CheckRunError, FileNotFoundError, PermissionError):
pass
else:
if out.startswith(b"2."):
return await fun(*args, **kwargs)
raise PanelException(
"{} is only supported on installations "
"with Custombuild 2.0".format(fun.__name__)
)
return wrapper