?HglddlZddlmZddlmZmZddlmZddlm Z m Z m Z m Z ddl mZmZmZddlmZddlmZd d lmZd ZGd d eZdS)N)contextmanager)DictList)Feature)ExternalProgramFailedis_ea4is_litespeed_runningis_testing_enabled_repo)get_apache_modulesget_boolean_paramis_da)MODULES_LOGS_DIR)InstallationFailedException)WizardInstallerz(/usr/local/directadmin/custombuild/buildceZdZejedZddgZdZ dZ dZ e j ZfdZdZd Zed efd Zd ed d fdZdZedZdZdZdZxZS)LsapiInstallerz lsapi.logliblsapizliblsapi-develzea-apache24-mod_lsapi mod_lsapiz/usr/bin/switch_mod_lsapic4t|jdd|_t r |j|jn|j|jtpg|_ dSN) super__init__GENERAL_PACKAGE_LISTlsapi_packagesrappendEA4_LSAPI_PACKAGEGENERAL_LSAPI_PACKAGEr apache_modules)self __class__s K/opt/cloudlinux/venv/lib/python3.11/site-packages/clwizard/modules/lsapi.pyrzLsapiInstaller.__init__'s "7: 88 C   & &t'= > > > >   & &t'A B B B0228bcg}|jD],}||s||-|rr |j|}nI#t$r<}|jdt|t|d}~wwxYw|j d|dS|j ddS)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_installedr_install_packager app_loggererrorstrrinfo)r packages_to_installpackageouterrs r"_install_lsapi_packagesz&LsapiInstaller._install_lsapi_packages0s !* 4 4G--g66 4#**7333  b =+d+-@A( = = =%%&RTWX[T\T\]]]133< = O !I3 O O O O O O !` a a a a as A B 7BB c ||jdgdS#t$r}t|d}~wwxYw)zT Configure lsapi on package base installation :return: None z--setupN) _run_commandUTILITYrr)r r.s r"_initialize_lsapiz LsapiInstaller._initialize_lsapiCsU  9   t|Y7 8 8 8 8 8$ 9 9 9-//S 8 9s >9>use_betac#Ktdd}|r |s|tdddg dV|r"|s"|tdddgdSdSdS#|r!|s |tdddgwwwxYw)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.confcloudlinux_betasetyesNno)r r1_DA_CUSTOMBUILD)r r4 inital_states r"use_cl_beta_on_daz LsapiInstaller.use_cl_beta_on_daMs) =?P    RL R   7H%P Q Q Q U EEE U  U!!?E;Ld"STTTTT U U U Ux U  U!!?E;Ld"STTTT U Us A""&BreturnNc ||5|tdg|tdddg|tddg|tdgd d d d S#1swxYwYd S#t$r}t |d }~wwxYw) zP Configure and build lsapi on DirectAdmin :return: None )r4updater7 php1_modelsphpphpnapacheN)r<r1r:rr)r r4r.s r"_install_lsapi_on_daz#LsapiInstaller._install_lsapi_on_da_s  9''':: ? ?!!?H"=>>>!!?E;"PQQQ!!?E3"?@@@!!?H"=>>>  ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? % 9 9 9-//S 8 9s;B&A4B B&BB& B!B&& C0B??Cctr2d|vr |d}nt}||dS||dS)zC Install lsapi in the system :return: None use_beta_for_daN)r r rEr/r3)r optionsrGs r"run_installationzLsapiInstaller.run_installationmsw 77 % G++")*;"<"9";";  % %o 6 6 6 6 6  ( ( * * *  " " $ $ $ $ $r#cdhS)NrG)clss r"supported_optionsz LsapiInstaller.supported_options|s !""r#cg}tr|ddid|jvr|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 tool suexec_modulezmod_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.url1https://docs.cloudlinux.com/apache_mod_lsapi.htmlrOcontext)r rr)r warningss r" _get_warningszLsapiInstaller._get_warningss|  77  OO]^    $"5 5 5 OOD !&'Z[   r#cg}tr|dddidd|jvr|dddidd|jvr|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.rQrRrS ruid2_modulezcmod_ruid2 is enabled, it is not compatible with mod_lsapi. Please see %(url)s for the requirements.mpm_itk_modulezaMPM ITK is enabled, it is not compatible with mod_lsapi. Please see %(url)s for the requirements.)r rr)r blockerss r" _get_blockerszLsapiInstaller._get_blockerss   ! !  OO @!&'Z[     T0 0 0 OO @R     t2 2 2 OO @R    r#cdtfdjDi}}|r|d|i}|r|d|i|S)Nalready_configuredc3BK|]}|VdSr)r%).0pkgr s r" z0LsapiInstaller.initial_status..sB&&47**3//&&&&&&r#rUrZ)allrrVr?r[)r resultrUrZs` r"initial_statuszLsapiInstaller.initial_statuss #&&&&;?;N&&&##  %%''  2 MM:x0 1 1 1%%''  2 MM:x0 1 1 1 r#)__name__ __module__ __qualname__ospathjoinrLOG_FILErrrr2rLSAPI_REQUIRED_CL_COMPONENT_SUPPORTrr/r3rboolr<rErI classmethodrMrVr[rd __classcell__)r!s@r"rrs>w||,k::H0')G%,]"99999bbb&999U$UUU^U" 9T 9d 9 9 9 9 % % %##[#2###J       r#r)rh contextlibrtypingrrclcommon.constrclcommon.utilsrrr r cldetectlibr r r clwizard.constantsrclwizard.exceptionsrbaserr:rrKr#r"rys" %%%%%%"""""" EDDDDDDDDD//////;;;;;;!!!!!!<nnnnn_nnnnnr#