diff --git a/plinth/modules/names/__init__.py b/plinth/modules/names/__init__.py index c46ca09ad..54597ea17 100644 --- a/plinth/modules/names/__init__.py +++ b/plinth/modules/names/__init__.py @@ -12,7 +12,7 @@ from django.utils.translation import gettext_lazy as _ from django.utils.translation import gettext_noop from plinth import app as app_module -from plinth import cfg, menu, network +from plinth import cfg, glib, menu, network, setup from plinth.daemon import Daemon from plinth.diagnostic_check import (DiagnosticCheck, DiagnosticCheckParameters, Result) @@ -90,6 +90,11 @@ class NamesApp(app_module.App): domain_type='domain-type-static', name=domain_name, services='__all__') + # Schedule installation of systemd-resolved if not already installed. + if not is_resolved_installed(): + # Try to install the package hourly. + glib.schedule(3600, install_systemd_resolved) + def diagnose(self) -> list[DiagnosticCheck]: """Run diagnostics and return the results.""" results = super().diagnose() @@ -171,6 +176,12 @@ class ResolvedDaemon(Daemon): return super().diagnose() +def install_systemd_resolved(_data): + """Re-run setup on app to install systemd-resolved.""" + if not is_resolved_installed(): + setup.run_setup_on_app('names', rerun=True) + + def diagnose_resolution(domain: str) -> DiagnosticCheck: """Perform a diagnostic check for whether a domain can be resolved.""" result = Result.NOT_DONE