§
    áˆFj×  ã                   ó<  — d Z ddlZddlZddlZddlZ ej        e¦  «        ZdZ	dZ
d„ Zd„ Zd„ Zd„ Zd	„ Zd
„ Zd„ Zd„ Zd„ Zej        j        j                             d¦  «        d„ ¦   «         Zej        j        j                             d¦  «        d„ ¦   «         ZdS )zÚ
Support for Apache

Please note: The functions in here are Debian-specific. Placing them in this
separate file will allow them to load only on Debian-based systems, while still
loading under the ``apache`` namespace.
é    NÚapachez/etc/apache2/sites-enabledc                  óš   — t          ¦   «         } t          j        j                             | ¦  «        rt
          d         dk    rt          S dS )z5
    Only load the module if apache is installed
    Ú	os_familyÚDebian)Fz9apache execution module not loaded: apache not installed.)Ú
_detect_osÚsaltÚutilsÚpathÚwhichÚ
__grains__Ú__virtualname__)Úcmds    úD/opt/saltstack/salt/extras-3.11/saltext/apache/modules/deb_apache.pyÚ__virtual__r      sB   € õ ‰,Œ,€CÝ„z„×Ò˜SÑ!Ô!ð ¥j°Ô&=ÀÒ&IÐ&IÝÐØOÐOó    c                  óR   — t           d         dk    rdS t           d         dk    rdS dS )zA
    Apache commands and paths differ depending on packaging
    r   ÚRedHatÚ	apachectlr   Ú
apache2ctl)r   © r   r   r   r       s3   € õ
 �+Ô (Ò*Ð*Øˆ{Ý�+Ô (Ò*Ð*Øˆ|Øˆ;r   c                 óø   — |                       d¦  «        r| }n| › d�}t          j                             t          › d|› �¦  «        rdS | dk    r+t          j                             t          › d|› �¦  «        rdS dS )aT  
    Checks to see if the specific site symlink is in /etc/apache2/sites-enabled.

    This will only be functional on Debian-based operating systems (Ubuntu,
    Mint, etc).

    CLI Examples:

    .. code-block:: bash

        salt '*' apache.check_site_enabled example.com
        salt '*' apache.check_site_enabled example.com.conf
    ú.confú/TÚdefaultz/000-F)ÚendswithÚosr
   ÚislinkÚSITE_ENABLED_DIR)ÚsiteÚ	site_files     r   Úcheck_site_enabledr!   ,   s‹   € ð ‡}‚}�WÑÔð #Øˆ	ˆ	à�N�N�Nˆ	Ý	„w‡~‚~Õ)Ð7Ð7¨IÐ7Ð7Ñ8Ô8ð ØˆtØˆyÒÐ�RœWŸ^š^Õ/?Ð,QÐ,QÀiÐ,QÐ,QÑRÔRÐØˆtØˆ5r   c                 óÔ   — i }d| g}	 t          d         |d¬¦  «        }n# t          $ r}|cY d}~S d}~ww xY wd|d<   | |d<   |d	k    r
d
| › d�|d<   n|dk    r
d
| › d�|d<   n||d<   |S )zã
    Runs a2ensite for the given site.

    This will only be functional on Debian-based operating systems (Ubuntu,
    Mint, etc).

    CLI Examples:

    .. code-block:: bash

        salt '*' apache.a2ensite example.com
    Úa2ensiteúcmd.retcodeF©Úpython_shellNzApache2 Enable SiteÚNameÚSiteé   úSite ú
 Not foundÚStatusr   ú enabled©Ú__salt__Ú	Exception©r   ÚretÚcommandÚstatusÚes        r   r#   r#   E   s¿   € ð €CØ˜4Ð €GðÝ˜-Ô(¨¸uÐEÑEÔEˆˆøÝð ð ð Øˆˆˆˆˆˆøøøøðøøøð (€Cˆ�KØ€Cˆ�Kà�‚{€{Ø0 Ð0Ð0Ð0ˆˆH‰ˆØ	�1ŠˆØ. Ð.Ð.Ð.ˆˆH‰ˆàˆˆH‰à€Jó   ˆ   
6ª1«6±6c                 óÔ   — i }d| g}	 t          d         |d¬¦  «        }n# t          $ r}|cY d}~S d}~ww xY wd|d<   | |d<   |d	k    r
d
| › d�|d<   n|dk    r
d
| › d�|d<   n||d<   |S )zå
    Runs a2dissite for the given site.

    This will only be functional on Debian-based operating systems (Ubuntu,
    Mint, etc).

    CLI Examples:

    .. code-block:: bash

        salt '*' apache.a2dissite example.com
    Ú	a2dissiter$   Fr%   NzApache2 Disable Siter'   r(   é   r*   r+   r,   r   ú	 disabledr.   r1   s        r   r8   r8   g   s¿   € ð €CØ˜DÐ!€GðÝ˜-Ô(¨¸uÐEÑEÔEˆˆøÝð ð ð Øˆˆˆˆˆˆøøøøðøøøð )€Cˆ�KØ€Cˆ�Kà�‚}€}Ø0 Ð0Ð0Ð0ˆˆH‰ˆØ	�1ŠˆØ/ Ð/Ð/Ð/ˆˆH‰ˆàˆˆH‰à€Jr6   c                 óª   — |                       d¦  «        s|                       d¦  «        r| }n| › d�}t          j                             d|› �¦  «        S )a|  
    Checks to see if the specific mod symlink is in /etc/apache2/mods-enabled.

    This will only be functional on Debian-based operating systems (Ubuntu,
    Mint, etc).

    CLI Examples:

    .. code-block:: bash

        salt '*' apache.check_mod_enabled status
        salt '*' apache.check_mod_enabled status.load
        salt '*' apache.check_mod_enabled status.conf
    z.loadr   z/etc/apache2/mods-enabled/©r   r   r
   r   )ÚmodÚmod_files     r   Úcheck_mod_enabledr?   ‰   sZ   € ð ‡|‚|�GÑÔð ! §¢¨WÑ 5Ô 5ð !Øˆˆà�=�=�=ˆÝŒ7�>Š>ÐA°xÐAÐAÑBÔBÐBr   c                 óÔ   — i }d| g}	 t          d         |d¬¦  «        }n# t          $ r}|cY d}~S d}~ww xY wd|d<   | |d<   |d	k    r
d
| › d�|d<   n|dk    r
d
| › d�|d<   n||d<   |S )zà
    Runs a2enmod for the given mod.

    This will only be functional on Debian-based operating systems (Ubuntu,
    Mint, etc).

    CLI Examples:

    .. code-block:: bash

        salt '*' apache.a2enmod vhost_alias
    Úa2enmodr$   Fr%   NzApache2 Enable Modr'   ÚModr)   úMod r+   r,   r   r-   r.   ©r=   r2   r3   r4   r5   s        r   rA   rA   Ÿ   s¿   € ð €CØ˜#Ð€GðÝ˜-Ô(¨¸uÐEÑEÔEˆˆøÝð ð ð Øˆˆˆˆˆˆøøøøðøøøð '€Cˆ�KØ€Cˆ�Jà�‚{€{Ø.˜sÐ.Ð.Ð.ˆˆH‰ˆØ	�1ŠˆØ,˜sÐ,Ð,Ð,ˆˆH‰ˆàˆˆH‰à€Jr6   c                 óÔ   — i }d| g}	 t          d         |d¬¦  «        }n# t          $ r}|cY d}~S d}~ww xY wd|d<   | |d<   |d	k    r
d
| › d�|d<   n|dk    r
d
| › d�|d<   n||d<   |S )zâ
    Runs a2dismod for the given mod.

    This will only be functional on Debian-based operating systems (Ubuntu,
    Mint, etc).

    CLI Examples:

    .. code-block:: bash

        salt '*' apache.a2dismod vhost_alias
    Úa2dismodr$   Fr%   NzApache2 Disable Modr'   rB   r9   rC   r+   r,   r   r:   r.   rD   s        r   rF   rF   Á   s¿   € ð €CØ˜3Ð€GðÝ˜-Ô(¨¸uÐEÑEÔEˆˆøÝð ð ð Øˆˆˆˆˆˆøøøøðøøøð (€Cˆ�KØ€Cˆ�Jà�‚}€}Ø.˜sÐ.Ð.Ð.ˆˆH‰ˆØ	�1ŠˆØ-˜sÐ-Ð-Ð-ˆˆH‰ˆàˆˆH‰à€Jr6   c                 ó€   — |                       d¦  «        r| }n| › d�}t          j                             d|› �¦  «        S )am  
    .. versionadded:: 2016.3.0

    Checks to see if the specific conf symlink is in /etc/apache2/conf-enabled.

    This will only be functional on Debian-based operating systems (Ubuntu,
    Mint, etc).

    CLI Examples:

    .. code-block:: bash

        salt '*' apache.check_conf_enabled security
        salt '*' apache.check_conf_enabled security.conf
    r   z/etc/apache2/conf-enabled/r<   )ÚconfÚ	conf_files     r   Úcheck_conf_enabledrJ   ã   sG   € ð  ‡}‚}�WÑÔð #Øˆ	ˆ	à�N�N�Nˆ	ÝŒ7�>Š>ÐB°yÐBÐBÑCÔCÐCr   Úa2enconfc                 óÔ   — i }d| g}	 t          d         |d¬¦  «        }n# t          $ r}|cY d}~S d}~ww xY wd|d<   | |d<   |d	k    r
d
| › d�|d<   n|dk    r
d
| › d�|d<   n||d<   |S )a   
    .. versionadded:: 2016.3.0

    Runs a2enconf for the given conf.

    This will only be functional on Debian-based operating systems (Ubuntu,
    Mint, etc).

    CLI Examples:

    .. code-block:: bash

        salt '*' apache.a2enconf security
    rK   r$   Fr%   NzApache2 Enable Confr'   ÚConfr)   úConf r+   r,   r   r-   r.   ©rH   r2   r3   r4   r5   s        r   rK   rK   ú   s¿   € ð  €CØ˜4Ð €GðÝ˜-Ô(¨¸uÐEÑEÔEˆˆøÝð ð ð Øˆˆˆˆˆˆøøøøðøøøð (€Cˆ�KØ€Cˆ�Kà�‚{€{Ø0 Ð0Ð0Ð0ˆˆH‰ˆØ	�1ŠˆØ. Ð.Ð.Ð.ˆˆH‰ˆàˆˆH‰à€Jr6   Ú	a2disconfc                 óÔ   — i }d| g}	 t          d         |d¬¦  «        }n# t          $ r}|cY d}~S d}~ww xY wd|d<   | |d<   |d	k    r
d
| › d�|d<   n|dk    r
d
| › d�|d<   n||d<   |S )a  
    .. versionadded:: 2016.3.0

    Runs a2disconf for the given conf.

    This will only be functional on Debian-based operating systems (Ubuntu,
    Mint, etc).

    CLI Examples:

    .. code-block:: bash

        salt '*' apache.a2disconf security
    rP   r$   Fr%   NzApache2 Disable Confr'   rM   r9   rN   r+   r,   r   r:   r.   rO   s        r   rP   rP     s¿   € ð  €CØ˜DÐ!€GðÝ˜-Ô(¨¸uÐEÑEÔEˆˆøÝð ð ð Øˆˆˆˆˆˆøøøøðøøøð )€Cˆ�KØ€Cˆ�Kà�‚}€}Ø0 Ð0Ð0Ð0ˆˆH‰ˆØ	�1ŠˆØ/ Ð/Ð/Ð/ˆˆH‰ˆàˆˆH‰à€Jr6   )Ú__doc__Úloggingr   Úsalt.utils.decorators.pathr   Úsalt.utils.pathÚ	getLoggerÚ__name__Úlogr   r   r   r   r!   r#   r8   r?   rA   rF   rJ   r	   Ú
decoratorsr
   r   rK   rP   r   r   r   ú<module>rZ      s[  ððð ð €€€Ø 	€	€	€	à !Ð !Ð !Ð !Ø Ð Ð Ð à€gÔ˜Ñ!Ô!€à€à/Ð ðPð Pð Pð	ð 	ð 	ðð ð ð2ð ð ðDð ð ðDCð Cð Cð,ð ð ðDð ð ðDDð Dð Dð. „ÔÔ×!Ò! *Ñ-Ô-ð!ð !ñ .Ô-ð!ðH „ÔÔ×!Ò! +Ñ.Ô.ð!ð !ñ /Ô.ð!ð !ð !r   