Added a2dismod support

This commit is contained in:
Brad Warren 2015-08-04 12:18:10 -07:00
parent 0252272430
commit fb79245773
5 changed files with 27 additions and 8 deletions

View file

@ -11,6 +11,7 @@ ENV APACHE_RUN_USER=daemon \
APACHE_LOG_DIR=/usr/local/apache2/logs
COPY letsencrypt-compatibility-test/letsencrypt_compatibility_test/configurators/apache/a2enmod.sh /usr/local/bin/
COPY letsencrypt-compatibility-test/letsencrypt_compatibility_test/configurators/apache/a2dismod.sh /usr/local/bin/
COPY letsencrypt-compatibility-test/letsencrypt_compatibility_test/testdata/rsa1024_key2.pem /usr/local/apache2/conf/
COPY letsencrypt-compatibility-test/letsencrypt_compatibility_test/testdata/empty_cert.pem /usr/local/apache2/conf/

View file

@ -0,0 +1,14 @@
#!/bin/bash
# An extremely simplified version of `a2enmod` for disabling modules in the
# httpd docker image. First argument is the server_root and the second is the
# module to be disabled.
apache_confdir=$1
module=$2
sed -i "/.*"$module".*/d" "$apache_confdir/test.conf"
enabled_conf="$apache_confdir/mods-enabled/"$module".conf"
if [ -e "$enabled_conf" ]
then
rm $enabled_conf
fi

View file

@ -1,7 +1,7 @@
#!/bin/bash
# An extremely simplified (and hacky) version of 'a2enmod' for the httpd
# docker image. First argument is server_root and second argument is the module
# to be enabled.
# An extremely simplified version of `a2enmod` for enabling modules in the
# httpd docker image. First argument is the server_root and the second is the
# module to be enabled.
APACHE_CONFDIR=$1

View file

@ -16,7 +16,7 @@ from letsencrypt_compatibility_test.configurators import common as configurators
APACHE_VERSION_REGEX = re.compile(r"Apache/([0-9\.]*)", re.IGNORECASE)
APACHE_COMMANDS = ["apachectl", "a2enmod"]
APACHE_COMMANDS = ["apachectl", "a2enmod", "a2dismod"]
class Proxy(configurators_common.Proxy):
@ -148,7 +148,7 @@ class Proxy(configurators_common.Proxy):
self.le_config.apache_ctl = "apachectl -d {0} -f {1}".format(
server_root, config_file)
self.le_config.apache_enmod = "a2enmod.sh {0}".format(server_root)
self.le_config.apache_dismod = self.le_config.apache_enmod
self.le_config.apache_dismod = "a2dismod.sh {0}".format(server_root)
self.le_config.apache_init_script = self.le_config.apache_ctl + " -k"
self._apache_configurator = configurator.ApacheConfigurator(

View file

@ -177,10 +177,14 @@ def test_enhancements(plugin, domains):
for domain in domains:
try:
plugin.enhance(domain, "redirect")
except le_errors.Error as error:
except le_errors.PluginError as error:
# Don't immediately fail because a redirect may already be enabled
logger.warning("Plugin failed to enable redirect for %s:", domain)
logger.warning("%s", error)
except le_errors.Error as error:
logger.error("An error occurred while enabling redirect for %s:",
domain)
logger.exception(error)
if not _save_and_restart(plugin, "enhanced"):
return False
@ -199,13 +203,13 @@ def test_enhancements(plugin, domains):
return success
def _try_until_true(func, max_tries=3):
def _try_until_true(func, max_tries=5, sleep_time=0.5):
"""Calls func up to max_tries times until it returns True"""
for _ in xrange(0, max_tries):
if func():
return True
else:
time.sleep(1)
time.sleep(sleep_time)
return False