mirror of
https://github.com/certbot/certbot.git
synced 2026-07-28 08:05:31 +02:00
Begin implementing pre / post-hook preservation
This commit is contained in:
+3
-3
@@ -43,11 +43,11 @@ def pre_hook(config):
|
||||
|
||||
pre_hook.already = False
|
||||
|
||||
def post_hook(config, final=False):
|
||||
def post_hook(config, renew_final=False):
|
||||
"""Run post hook if defined.
|
||||
|
||||
If the verb is renew, we might have more certs to renew, so we wait until
|
||||
we're called with final=True before actually doing anything.
|
||||
we're called with renew_final=True before actually doing anything.
|
||||
"""
|
||||
if config.post_hook:
|
||||
if not pre_hook.already:
|
||||
@@ -55,7 +55,7 @@ def post_hook(config, final=False):
|
||||
if config.verb != "renew":
|
||||
logger.warning("Sanity failure in renewal hooks")
|
||||
return
|
||||
if final or config.verb != "renew":
|
||||
if renew_final or config.verb != "renew":
|
||||
logger.info("Running post-hook command: %s", config.post_hook)
|
||||
_run_hook(config.post_hook)
|
||||
|
||||
|
||||
+2
-2
@@ -108,7 +108,7 @@ def _auth_from_available(le_client, config, domains=None, certname=None, lineage
|
||||
if lineage is False:
|
||||
raise errors.Error("Certificate could not be obtained")
|
||||
finally:
|
||||
hooks.post_hook(config, final=False)
|
||||
hooks.post_hook(config, renew_final=False)
|
||||
|
||||
if not config.dry_run and not config.verb == "renew":
|
||||
_report_new_cert(config, lineage.cert, lineage.fullchain)
|
||||
@@ -634,7 +634,7 @@ def renew(config, unused_plugins):
|
||||
try:
|
||||
renewal.handle_renewal_request(config)
|
||||
finally:
|
||||
hooks.post_hook(config, final=True)
|
||||
hooks.post_hook(config, renew_final=True)
|
||||
|
||||
|
||||
def setup_log_file_handler(config, logfile, fmt):
|
||||
|
||||
+2
-1
@@ -30,7 +30,8 @@ logger = logging.getLogger(__name__)
|
||||
# the renewal configuration process loses this information.
|
||||
STR_CONFIG_ITEMS = ["config_dir", "logs_dir", "work_dir", "user_agent",
|
||||
"server", "account", "authenticator", "installer",
|
||||
"standalone_supported_challenges", "renew_hook"]
|
||||
"standalone_supported_challenges", "renew_hook",
|
||||
"pre_hook", "post_hook"]
|
||||
INT_CONFIG_ITEMS = ["rsa_key_size", "tls_sni_01_port", "http01_port"]
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user