mirror of
https://github.com/certbot/certbot.git
synced 2026-08-03 16:12:13 +02:00
Per-OS constants
This commit is contained in:
@@ -86,17 +86,17 @@ class ApacheConfigurator(augeas_configurator.AugeasConfigurator):
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def add_parser_arguments(cls, add):
|
def add_parser_arguments(cls, add):
|
||||||
add("ctl", default=constants.CLI_DEFAULTS["ctl"],
|
add("ctl", default=constants.os_constant("ctl"),
|
||||||
help="Path to the 'apache2ctl' binary, used for 'configtest', "
|
help="Path to the 'apache2ctl' binary, used for 'configtest', "
|
||||||
"retrieving the Apache2 version number, and initialization "
|
"retrieving the Apache2 version number, and initialization "
|
||||||
"parameters.")
|
"parameters.")
|
||||||
add("enmod", default=constants.CLI_DEFAULTS["enmod"],
|
add("enmod", default=constants.os_constant("enmod"),
|
||||||
help="Path to the Apache 'a2enmod' binary.")
|
help="Path to the Apache 'a2enmod' binary.")
|
||||||
add("dismod", default=constants.CLI_DEFAULTS["dismod"],
|
add("dismod", default=constants.os_constant("dismod"),
|
||||||
help="Path to the Apache 'a2enmod' binary.")
|
help="Path to the Apache 'a2enmod' binary.")
|
||||||
add("le-vhost-ext", default=constants.CLI_DEFAULTS["le_vhost_ext"],
|
add("le-vhost-ext", default=constants.os_constant("le_vhost_ext"),
|
||||||
help="SSL vhost configuration extension.")
|
help="SSL vhost configuration extension.")
|
||||||
add("server-root", default=constants.CLI_DEFAULTS["server_root"],
|
add("server-root", default=constants.os_constant("server_root"),
|
||||||
help="Apache server root directory.")
|
help="Apache server root directory.")
|
||||||
le_util.add_deprecated_argument(add, "init-script", 1)
|
le_util.add_deprecated_argument(add, "init-script", 1)
|
||||||
|
|
||||||
@@ -583,7 +583,7 @@ class ApacheConfigurator(augeas_configurator.AugeasConfigurator):
|
|||||||
|
|
||||||
Duplicates vhost and adds default ssl options
|
Duplicates vhost and adds default ssl options
|
||||||
New vhost will reside as (nonssl_vhost.path) +
|
New vhost will reside as (nonssl_vhost.path) +
|
||||||
``letsencrypt_apache.constants.CLI_DEFAULTS["le_vhost_ext"]``
|
``letsencrypt_apache.constants.os_constant("le_vhost_ext")``
|
||||||
|
|
||||||
.. note:: This function saves the configuration
|
.. note:: This function saves the configuration
|
||||||
|
|
||||||
|
|||||||
@@ -1,14 +1,27 @@
|
|||||||
"""Apache plugin constants."""
|
"""Apache plugin constants."""
|
||||||
import pkg_resources
|
import pkg_resources
|
||||||
|
from letsencrypt import le_util
|
||||||
|
|
||||||
|
|
||||||
CLI_DEFAULTS = dict(
|
CLI_DEFAULTS_DEBIAN = dict(
|
||||||
server_root="/etc/apache2",
|
server_root="/etc/apache2",
|
||||||
ctl="apache2ctl",
|
ctl="apache2ctl",
|
||||||
enmod="a2enmod",
|
enmod="a2enmod",
|
||||||
dismod="a2dismod",
|
dismod="a2dismod",
|
||||||
le_vhost_ext="-le-ssl.conf",
|
le_vhost_ext="-le-ssl.conf",
|
||||||
)
|
)
|
||||||
|
CLI_DEFAULTS_CENTOS = dict(
|
||||||
|
server_root="/etc/httpd",
|
||||||
|
ctl="apachectl",
|
||||||
|
enmod=None,
|
||||||
|
dismod=None,
|
||||||
|
le_vhost_ext="-le-ssl.conf",
|
||||||
|
)
|
||||||
|
CLI_DEFAULTS = {
|
||||||
|
"debian": CLI_DEFAULTS_DEBIAN,
|
||||||
|
"ubuntu": CLI_DEFAULTS_DEBIAN,
|
||||||
|
"centos": CLI_DEFAULTS_CENTOS
|
||||||
|
}
|
||||||
"""CLI defaults."""
|
"""CLI defaults."""
|
||||||
|
|
||||||
MOD_SSL_CONF_DEST = "options-ssl-apache.conf"
|
MOD_SSL_CONF_DEST = "options-ssl-apache.conf"
|
||||||
@@ -38,3 +51,10 @@ UIR_ARGS = ["always", "set", "Content-Security-Policy",
|
|||||||
HEADER_ARGS = {"Strict-Transport-Security": HSTS_ARGS,
|
HEADER_ARGS = {"Strict-Transport-Security": HSTS_ARGS,
|
||||||
"Upgrade-Insecure-Requests": UIR_ARGS}
|
"Upgrade-Insecure-Requests": UIR_ARGS}
|
||||||
|
|
||||||
|
def os_constant(key):
|
||||||
|
os_info = le_util.get_os_info()
|
||||||
|
try:
|
||||||
|
constants = CLI_DEFAULTS[os_info[0].lower()]
|
||||||
|
except KeyError:
|
||||||
|
constants = CLI_DEFAULTS["debian"]
|
||||||
|
return constants[key]
|
||||||
|
|||||||
Reference in New Issue
Block a user