U
    ÔZjº
  ã                   @   sz   d Z ddlZddlZddlmZ ddlmZ ddlmZ ddlm	Z	 ej
 ej¡G dd„ dejƒƒZG d	d
„ d
e	jƒZdS )z7 Distribution specific override class for Gentoo Linux é    N)Ú
interfaces)Úapache_util©Úconfigurator)Úparserc                       sh   e Zd ZdZedddddddgddgdd	gdd
gdddddde dd¡d�Z‡ fdd„Zdd„ Z	‡  Z
S )ÚGentooConfiguratorz1Gentoo specific ApacheConfigurator override classz/etc/apache2z/etc/apache2/vhosts.dz*.confz/var/log/apache2Z
apache2ctlz-vZgracefulZrestartZ
configtestNz-le-ssl.confFÚcertbot_apachezoptions-ssl-apache.conf)Úserver_rootÚ
vhost_rootZvhost_filesZ	logs_rootÚctlZversion_cmdZrestart_cmdÚrestart_cmd_altZconftest_cmdZenmodZdismodZle_vhost_extZhandle_modulesZhandle_sitesZchallenge_locationZMOD_SSL_CONF_SRCc                    s&   t t| ƒ ¡  |  d¡| jd d< dS )z„
        Override the options dictionary initialization in order to support
        alternative restart cmd used in Gentoo.
        r   r   r   N)Úsuperr   Ú_prepare_optionsÚoptionÚoptions©Úself©Ú	__class__© úa/var/www/html/TRUCKING_PROJECT/venv/lib/python3.8/site-packages/certbot_apache/override_gentoo.pyr   $   s    z#GentooConfigurator._prepare_optionsc                 C   s   t |  d¡|  d¡| j| d�S )zInitializes the ApacheParserr	   r
   r   )ÚGentooParserr   Úversionr   r   r   r   Ú
get_parser,   s      þzGentooConfigurator.get_parser)Ú__name__Ú
__module__Ú__qualname__Ú__doc__ÚdictÚpkg_resourcesÚresource_filenameZOS_DEFAULTSr   r   Ú__classcell__r   r   r   r   r      s0    ÿðr   c                       s8   e Zd ZdZ‡ fdd„Zdd„ Zdd„ Zdd	„ Z‡  ZS )
r   z+Gentoo specific ApacheParser override classc                    s   d| _ tt| ƒj||Ž d S )Nz/etc/conf.d/apache2)Úapacheconfig_filepr   r   Ú__init__)r   ÚargsÚkwargsr   r   r   r#   5   s    zGentooParser.__init__c                 C   s   |   ¡  |  ¡  dS )z: Override for update_runtime_variables for custom parsing N)Úparse_sysconfig_varÚupdate_modulesr   r   r   r   Úupdate_runtime_variables:   s    z%GentooParser.update_runtime_variablesc                 C   s*   t  | jd¡}|D ]}|| | j|< qdS )z: Parses Apache CLI options from Gentoo configuration file ZAPACHE2_OPTSN)r   Zparse_define_filer"   Ú	variables)r   ZdefinesÚkr   r   r   r&   ?   s
    ÿz GentooParser.parse_sysconfig_varc                 C   s8   | j  d¡dg}|  |d¡}|D ]}|  | ¡ ¡ q dS )z:Get loaded modules from httpd process, and add them to DOMr   Úmodulesz(.*)_moduleN)r   r   Zparse_from_subprocessZadd_modÚstrip)r   Zmod_cmdÚmatchesÚmodr   r   r   r'   F   s    zGentooParser.update_modules)	r   r   r   r   r#   r(   r&   r'   r!   r   r   r   r   r   3   s
   r   )r   r   Zzope.interfaceZzopeZcertbotr   r   r   r   r   Z	interfaceÚproviderZIPluginFactoryZApacheConfiguratorr   ZApacheParserr   r   r   r   r   Ú<module>   s   &