403Webshell
Server IP : 198.38.94.67  /  Your IP : 216.73.217.178
Web Server : LiteSpeed
System : Linux d6054.dxb1.stableserver.net 5.14.0-570.25.1.el9_6.x86_64 #1 SMP PREEMPT_DYNAMIC Wed Jul 9 04:57:09 EDT 2025 x86_64
User : azfilmst ( 1070)
PHP Version : 7.4.33
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/suse_apache.py
"""
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.
"""

import logging

import salt.utils.path

log = logging.getLogger(__name__)

__virtualname__ = "apache"


def __virtual__():
    """
    Only load the module if apache is installed.
    """
    if salt.utils.path.which("apache2ctl") and __grains__["os_family"] == "Suse":
        return __virtualname__
    return (False, "apache execution module not loaded: apache not installed.")


def check_mod_enabled(mod):
    """
    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
    """
    if mod.endswith(".load") or mod.endswith(".conf"):
        mod_name = mod[:-5]
    else:
        mod_name = mod

    cmd = "a2enmod -l"
    try:
        active_mods = __salt__["cmd.run"](cmd, python_shell=False).split(" ")
    except Exception as e:  # pylint: disable=broad-except
        return e

    return mod_name in active_mods


def a2enmod(mod):
    """
    Runs a2enmod for the given mod.

    CLI Example:

    .. code-block:: bash

        salt '*' apache.a2enmod vhost_alias
    """
    ret = {}
    command = ["a2enmod", mod]

    try:
        status = __salt__["cmd.retcode"](command, python_shell=False)
    except Exception as e:  # pylint: disable=broad-except
        return e

    ret["Name"] = "Apache2 Enable Mod"
    ret["Mod"] = mod

    if status == 1:
        ret["Status"] = f"Mod {mod} Not found"
    elif status == 0:
        ret["Status"] = f"Mod {mod} enabled"
    else:
        ret["Status"] = status

    return ret


def a2dismod(mod):
    """
    Runs a2dismod for the given mod.

    CLI Example:

    .. code-block:: bash

        salt '*' apache.a2dismod vhost_alias
    """
    ret = {}
    command = ["a2dismod", mod]

    try:
        status = __salt__["cmd.retcode"](command, python_shell=False)
    except Exception as e:  # pylint: disable=broad-except
        return e

    ret["Name"] = "Apache2 Disable Mod"
    ret["Mod"] = mod

    if status == 256:
        ret["Status"] = f"Mod {mod} Not found"
    elif status == 0:
        ret["Status"] = f"Mod {mod} disabled"
    else:
        ret["Status"] = status

    return ret

Youez - 2016 - github.com/yon3zu
LinuXploit