letsencrypt: Handle both standard and custom repairs

Pass remaining failed checks to super.

Tests:

- Remove /etc/letsencrypt/renewal-hooks/deploy/50-freedombox so that
  the diagnostic fails. Running repair causes the file to be
  re-created.

- Set domain name to non-existing domain so that the diagnostic
  fails. Running repair attempts to obtain the certificate.

- Have both diagnostics failing. Running repair will attempt to repair
  both.

Signed-off-by: James Valleroy <jvalleroy@mailbox.org>
Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
This commit is contained in:
James Valleroy 2024-09-07 10:05:37 -04:00 committed by Sunil Mohan Adapa
parent cbfaee85b5
commit 58c7de8d66
No known key found for this signature in database
GPG Key ID: 43EA1CFF0AA7C5F2

View File

@ -104,18 +104,16 @@ class LetsEncryptApp(app_module.App):
return results
def repair(self, failed_checks: list) -> bool:
"""Try to repair failed diagnostics.
Returns whether the app setup should be re-run.
"""
"""Handle repair for custom diagnostic."""
status = get_status()
# Obtain/re-obtain certificates for failing domains
for failed_check in failed_checks:
if not failed_check.check_id.startswith('letsencrypt-domain'):
remaining_checks = []
for check in failed_checks:
if not check.check_id.startswith('letsencrypt-domain'):
remaining_checks.append(check)
continue
domain = failed_check.parameters['domain']
# Obtain/re-obtain certificates for failing domains
domain = check.parameters['domain']
try:
domain_status = status['domains'][domain]
if domain_status.get('certificate_available', False):
@ -128,7 +126,7 @@ class LetsEncryptApp(app_module.App):
# Add the error message to thread local storage
store_error_message(str(error))
return False
return super().repair(remaining_checks)
def setup(self, old_version):
"""Install and configure the app."""