U
    ]
                     @   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optionZoptionsself	__class__ @/usr/lib/python3/dist-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_resourcesZ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    Z	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_cmdZ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.interfacezopeZcertbotr   r   r   r   r   Z	interfaceZproviderZIPluginFactoryZApacheConfiguratorr   ZApacheParserr   r   r   r   r   <module>   s   &