gW!$ddlmZddlZddlmZddlmZmZmZddl m Z ddl m Z m Z mZmZmZddlmZmZmZddlmZdd lmZd d lmZd ZeGd dZeddgddZeddgddZGddeZdS)) dataclassN)contextmanager)AnyDictList)Feature)ExternalProgramFailedis_ea4is_litespeed_runningis_testing_enabled_repo is_ubuntu)get_apache_modulesget_boolean_paramis_da)MODULES_LOGS_DIR)InstallationFailedException)WizardInstallerz(/usr/local/directadmin/custombuild/buildc:eZdZUeeed<eed<eed<dS)LsapiPackageSetgeneral general_lsapi ea4_lsapiN)__name__ __module__ __qualname__rstr__annotations__M/opt/cloudlinux/venv/lib64/python3.11/site-packages/clwizard/modules/lsapi.pyrrs5 #YNNNNNr rliblsapizliblsapi-devel mod_lsapizea-apache24-mod_lsapi)rrrz liblsapi-devz mod-lsapizea-apache24-mod-lsapicBeZdZejedZdZe j Z fdZ dZ dZdZedefdZded d fd Zd Zed Zd eeeeeeefzffdZd eeeeeeefzffdZdZxZS)LsapiInstallerz lsapi.logz/usr/bin/switch_mod_lsapict|tpg|_dSN)super__init___prepare_lsapi_packagesrapache_modules)self __class__s r!r)zLsapiInstaller.__init__4sD  $$&&&0228br ctrtnt}|jdd|_t r!|j|jdS|j|jdSr') r ubuntu_lsapi_set cl_lsapi_setrlsapi_packagesr appendrr)r, package_sets r!r*z&LsapiInstaller._prepare_lsapi_packages9sw*3++G&&< )1!!!4 88 B   & &{'< = = = = =   & &{'@ A A A A Ar cg}|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) r1_is_package_installedr2_install_packager app_loggererrorrrinfo)r,packages_to_installpackageouterrs r!_install_lsapi_packagesz&LsapiInstaller._install_lsapi_packagesBs !* 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)zU Configure lsapi on base package installation. :return: None z--setupN) _run_commandUTILITYr r)r,r=s r!_initialize_lsapiz LsapiInstaller._initialize_lsapiUsU  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 to set the option `cloudlinux_beta` in DA custombuild options. @param use_beta: True == `cloudlinux_beta=yes`, False == `cloudlinux_beta=no` z//usr/local/directadmin/custombuild/options.confcloudlinux_betasetyesNno)rr@_DA_CUSTOMBUILD)r,rC inital_states r!use_cl_beta_on_daz LsapiInstaller.use_cl_beta_on_da_s))Z\mnn  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) z Configure and build lsapi on DirectAdmin. :param use_beta: Whether to use the beta version of CloudLinux packages. :return: None )rCupdaterF php1_modelsphpphpnapacheN)rKr@rIr r)r,rCr=s r!_install_lsapi_on_daz#LsapiInstaller._install_lsapi_on_daos 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)zO Install the lsapi module on the system. :return: None use_beta_for_daN)rr rTr>rB)r,optionsrVs r!run_installationzLsapiInstaller.run_installationsw 77 % G++")*;"<"9";";  % %o 6 6 6 6 6  ( ( * * *  " " $ $ $ $ $r cdhS)NrVr)clss r!supported_optionsz LsapiInstaller.supported_optionss !""r cg}tr|ddid|jvr|dddid|S)ap Get a list of warnings that should be shown in Wizard before the module installation. :return: List of warnings to be shown in UI. Warning is a dictionary with the following keys and values: - message: str - warning message with placeholders for additional context - context: dict - additional context for the message 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.htmlr]context)rr2r+)r,warningss r! _get_warningszLsapiInstaller._get_warningsst;= 77 l OOY(ij k k k $"5 5 5 OOD !&'Z[   r cg}tr|dddidd|jvr|dddidd|jvr|dddid|S) a` Get a list of possible blockers that may disable module in Wizard UI. :return: List of blockers to be shown in UI. Blocker is a dictionary with the following keys and values: - message: str - blocker message with placeholders for additional context - context: dict - additional context for the message z|The server is running under Litespeed. mod_lsapi works with the Apache server only. Please see %(url)s for the requirements.r_r`ra 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 r2r+)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')r5).0pkgr,s r! z0LsapiInstaller.initial_status..s1%e%e#d&@&@&E&E%e%e%e%e%e%er rcrh)allr1rdrNri)r,resultrcrhs` r!initial_statuszLsapiInstaller.initial_statuss #%e%e%e%eQUQd%e%e%e"e"e" %%''  2 MM:x0 1 1 1%%''  2 MM:x0 1 1 1 r )rrrospathjoinrLOG_FILErArLSAPI_REQUIRED_CL_COMPONENT_SUPPORTr)r*r>rBrboolrKrTrX classmethodr[rrrdictrdrirr __classcell__)r-s@r!r%r%.sw||,k::H)G%,]"99999 BBBbbb&999 U$ U U U^ U9T9d9999 % % %##[#tDcDcN.B)B$CD4'tDcDcN.B)B$CD''''R       r r%) dataclassesrrs contextlibrtypingrrrclcommon.constrclcommon.utilsr r r r r cldetectlibrrrclwizard.constantsrclwizard.exceptionsrbaserrIrr0r/r%rr r!rs"!!!!! %%%%%%""""""""""""""""rrrrrrrrrrrrrrDDDDDDDDDD//////;;;;;;!!!!!!<     ) *% #?  (%rrrrr_rrrrrr