o
    Œ }i¯	  ã                   @   sF   d Z ddlZddlZe e¡ZdZdd„ Zdd„ Z	dd	„ Z
d
d„ ZdS )zÐ
Support for Apache

Please note: The functions in here are SUSE-specific. Placing them in this
separate file will allow them to load only on SUSE systems, while still
loading under the ``apache`` namespace.
é    NÚapachec                   C   s"   t jj d¡rtd dkrtS dS )z6
    Only load the module if apache is installed.
    Z	apachectlZ	os_familyZSuse)Fz9apache execution module not loaded: apache not installed.)ÚsaltÚutilsÚpathÚwhichZ
__grains__Ú__virtualname__© r   r   úE/opt/saltstack/salt/extras-3.10/saltext/apache/modules/suse_apache.pyÚ__virtual__   s   r
   c              
   C   st   |   d¡s
|   d¡r| dd… }n| }d}ztd |dd� d	¡}W ||v S  ty9 } z|W  Y d}~S d}~ww )
a  
    Checks to see if the specific apache mod is enabled.

    This will only be functional on operating systems that support
    `a2enmod -l` to list the enabled mods.

    CLI Example:

    .. code-block:: bash

        salt '*' apache.check_mod_enabled status
    z.loadz.confNéûÿÿÿz
a2enmod -lzcmd.runF©Zpython_shellú )ÚendswithÚ__salt__ÚsplitÚ	Exception)ÚmodÚmod_nameÚcmdZactive_modsÚer   r   r	   Úcheck_mod_enabled   s   ý€ÿr   c              
   C   óž   i }d| g}z
t d |dd�}W n ty$ } z|W  Y d}~S d}~ww d|d< | |d< |d	kr;d
| › d�|d< |S |dkrId
| › d�|d< |S ||d< |S )z‚
    Runs a2enmod for the given mod.

    CLI Example:

    .. code-block:: bash

        salt '*' apache.a2enmod vhost_alias
    Úa2enmodúcmd.retcodeFr   NzApache2 Enable ModÚNameÚModé   úMod ú
 Not foundÚStatusr   z enabled©r   r   ©r   ÚretÚcommandÚstatusr   r   r   r	   r   6   ó$   
€ÿûþr   c              
   C   r   )z„
    Runs a2dismod for the given mod.

    CLI Example:

    .. code-block:: bash

        salt '*' apache.a2dismod vhost_alias
    Úa2dismodr   Fr   NzApache2 Disable Modr   r   é   r   r   r   r   z	 disabledr    r!   r   r   r	   r&   U   r%   r&   )Ú__doc__ÚloggingZsalt.utils.pathr   Ú	getLoggerÚ__name__Úlogr   r
   r   r   r&   r   r   r   r	   Ú<module>   s    
	