HEX
Server: Apache
System: Linux insrv.serversdaddy.com 5.14.0-362.24.2.el9_3.x86_64 #1 SMP PREEMPT_DYNAMIC Sat Mar 30 14:11:54 EDT 2024 x86_64
User: jsaha (1066)
PHP: 8.3.6
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //opt/alt/python37/lib/python3.7/site-packages/clwizard/modules/__pycache__/lsapi.cpython-37.pyc
B

ʀ��VY��@s�ddlmZddlZddlmZddlmZmZddlm	Z	ddl
mZmZm
Z
mZddlmZmZmZddlmZdd	lmZd
dlmZdZGd
d�de�ZdS)�)�absolute_importN)�contextmanager)�Dict�List)�Feature)�ExternalProgramFailed�is_ea4�is_litespeed_running�is_testing_enabled_repo)�get_apache_modules�get_boolean_param�is_da)�MODULES_LOGS_DIR)�InstallationFailedException�)�WizardInstallerz(/usr/local/directadmin/custombuild/buildcs�eZdZej�ed�ZddgZdZ	dZ
dZej
Z�fdd�Zd	d
�Zdd�Zeed
�dd��Zedd�dd�Zdd�Zedd��Zdd�Zdd�Zdd�Z�ZS)�LsapiInstallerz	lsapi.logZliblsapizliblsapi-develzea-apache24-mod_lsapiZ	mod_lsapiz/usr/bin/switch_mod_lsapicsRtt|���|jdd�|_t�r4|j�|j�n|j�|j�t	�pJg|_
dS)N)�superr�__init__�GENERAL_PACKAGE_LIST�lsapi_packagesr�append�EA4_LSAPI_PACKAGE�GENERAL_LSAPI_PACKAGEr�apache_modules)�self)�	__class__��py/clwizard/modules/lsapi.pyr*szLsapiInstaller.__init__c
Cs�g}x"|jD]}|�|�s|�|�qW|r�y|j|�}Wn<tk
rv}z|j�dt|��t�|�Wdd}~XYnX|j�	d|�n|j�	d�dS)zH
        Install lsapi packages if needed
        :return: None
        z*Package installation failed with error: %sNz&Package was installed successfully: %sz=Skip package installation, all packages are already installed)
r�_is_package_installedrZ_install_packagerZ
app_logger�error�strr�info)rZpackages_to_install�package�out�errrrr�_install_lsapi_packages3s
z&LsapiInstaller._install_lsapi_packagesc
CsDy|�|jdg�Wn*tk
r>}zt�|�Wdd}~XYnXdS)zT
        Configure lsapi on package base installation
        :return: None
        z--setupN)�_run_command�UTILITYrr)rr%rrr�_initialize_lsapiFsz LsapiInstaller._initialize_lsapi)�use_betaccsPtdd�}|r$|s$|�tdddg�z
dVWd|rJ|sJ|�tdddg�XdS)z�
        Context manager for set option `cloudlinux_beta` in DA custombuild
        @param use_beta: True == `cloudlinux_beta=yes`, False == `cloudlinux_beta=no`
        z//usr/local/directadmin/custombuild/options.confZcloudlinux_beta�setZyesNZno)rr'�_DA_CUSTOMBUILD)rr*Zinital_staterrr�use_cl_beta_on_daPs
z LsapiInstaller.use_cl_beta_on_daN)r*�returnc
Cs�yZ|j|d��D|�tdg�|�tdddg�|�tddg�|�tdg�Wd	QRXWn*tk
r�}zt�|�Wd	d	}~XYnXd	S)
zP
        Configure and build lsapi on DirectAdmin
        :return: None
        )r*�updater+Z	php1_modeZlsphpZphp�nZapacheN)r-r'r,rr)rr*r%rrr�_install_lsapi_on_dabsz#LsapiInstaller._install_lsapi_on_dacCs>t�r*d|kr|d}nt�}|�|�n|��|��dS)zC
        Install lsapi in the system
        :return: None
        �use_beta_for_daN)r
r
r1r&r))rZoptionsr2rrr�run_installationps
zLsapiInstaller.run_installationcCsdhS)Nr2r)�clsrrr�supported_optionssz LsapiInstaller.supported_optionscCs:g}t�r|�ddi�d|jkr6|�dddid��|S)zo
        Get a list of warnings that should be shown in wizard before the module
        installation.
        �messagez?Installation will be performed via DirectAdmin Custombuild toolZ
suexec_modulez�mod_suexec is not installed. It is recommended to use mod_suexec with mod_lsapi. It is also required for CRIU to work. Please see %(url)s for more information.�urlz1https://docs.cloudlinux.com/apache_mod_lsapi.html)r6�context)r
rr)r�warningsrrr�
_get_warnings�s

zLsapiInstaller._get_warningscCs^g}t�r|�dddid��d|jkr<|�dddid��d|jkrZ|�dddid��|S)	zQ
        Get a list of possible blockers to disable module in Wizard UI.
        z|The server is running under Litespeed. mod_lsapi works with the Apache server only. Please see %(url)s for the requirements.r7z1https://docs.cloudlinux.com/apache_mod_lsapi.html)r6r8Zruid2_modulezcmod_ruid2 is enabled, it is not compatible with mod_lsapi. Please see %(url)s for the requirements.Zmpm_itk_modulezaMPM ITK is enabled, it is not compatible with mod_lsapi. Please see %(url)s for the requirements.)r	rr)r�blockersrrr�
_get_blockers�s

zLsapiInstaller._get_blockerscsTdt�fdd��jD��i}���}|r6|�d|i����}|rP|�d|i�|S)NZalready_configuredc3s|]}��|�VqdS)N)r)�.0Zpkg)rrr�	<genexpr>�sz0LsapiInstaller.initial_status.<locals>.<genexpr>r9r;)�allrr:r/r<)r�resultr9r;r)rr�initial_status�szLsapiInstaller.initial_status)�__name__�
__module__�__qualname__�os�path�joinrZLOG_FILErrrr(rZLSAPIZ_REQUIRED_CL_COMPONENT_SUPPORTrr&r)r�boolr-r1r3�classmethodr5r:r<rA�
__classcell__rr)rrrs$	
%r)Z
__future__rrE�
contextlibr�typingrrZclcommon.constrZclcommon.utilsrrr	r
Zcldetectlibrrr
Zclwizard.constantsrZclwizard.exceptionsr�baserr,rrrrr�<module>	s