mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-09-19 04:59:01 +00:00
names: Don't control resolved daemon when package is not installed
Tests: - Ensure that systemd-resolved is not installed. - There is no warning showing that systemd-resolved daemon is not running. - When re-running setup, systemd-resolved is not enabled. - Diagnostic shows a warning that systemd-resolved is not installed. - Ensure that systemd-resolved is installed. - If daemon is not running, warning shown that it is not running. - If daemon is running, warning is not shown. - When re-running setup, systemd-resolved is enabled. - Diagnostic shows that the daemon is running when running and not running when it is not. Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org> Reviewed-by: Veiko Aasa <veiko17@disroot.org>
This commit is contained in:
parent
5c06b6c31a
commit
70c37f309e
@ -70,7 +70,7 @@ class NamesApp(app_module.App):
|
|||||||
'names:domains', can_have_certificate=True)
|
'names:domains', can_have_certificate=True)
|
||||||
self.add(domain_type)
|
self.add(domain_type)
|
||||||
|
|
||||||
daemon = Daemon('daemon-names', 'systemd-resolved')
|
daemon = ResolvedDaemon('daemon-names', 'systemd-resolved')
|
||||||
self.add(daemon)
|
self.add(daemon)
|
||||||
|
|
||||||
backup_restore = BackupRestore('backup-restore-names',
|
backup_restore = BackupRestore('backup-restore-names',
|
||||||
@ -122,6 +122,46 @@ class NamesApp(app_module.App):
|
|||||||
self.enable()
|
self.enable()
|
||||||
|
|
||||||
|
|
||||||
|
class ResolvedDaemon(Daemon):
|
||||||
|
"""Perform work only if systemd-resolved is installed."""
|
||||||
|
|
||||||
|
def is_enabled(self):
|
||||||
|
"""Return if the daemon/unit is enabled."""
|
||||||
|
if not is_resolved_installed():
|
||||||
|
return True
|
||||||
|
|
||||||
|
return super().is_enabled()
|
||||||
|
|
||||||
|
def enable(self):
|
||||||
|
"""Run operations to enable the daemon/unit."""
|
||||||
|
if is_resolved_installed():
|
||||||
|
super().enable()
|
||||||
|
|
||||||
|
def disable(self):
|
||||||
|
"""Run operations to disable the daemon/unit."""
|
||||||
|
if is_resolved_installed():
|
||||||
|
super().disable()
|
||||||
|
|
||||||
|
def is_running(self):
|
||||||
|
"""Return whether the daemon/unit is running."""
|
||||||
|
if not is_resolved_installed():
|
||||||
|
return True
|
||||||
|
|
||||||
|
return super().is_running()
|
||||||
|
|
||||||
|
def diagnose(self) -> list[DiagnosticCheck]:
|
||||||
|
"""Check if the daemon is running and listening on expected ports."""
|
||||||
|
if not is_resolved_installed():
|
||||||
|
return [
|
||||||
|
DiagnosticCheck(
|
||||||
|
'names-resolved-installed',
|
||||||
|
gettext_noop('Package systemd-resolved is installed'),
|
||||||
|
Result.WARNING, {}, self.component_id)
|
||||||
|
]
|
||||||
|
|
||||||
|
return super().diagnose()
|
||||||
|
|
||||||
|
|
||||||
def diagnose_resolution(domain: str) -> DiagnosticCheck:
|
def diagnose_resolution(domain: str) -> DiagnosticCheck:
|
||||||
"""Perform a diagnostic check for whether a domain can be resolved."""
|
"""Perform a diagnostic check for whether a domain can be resolved."""
|
||||||
result = Result.NOT_DONE
|
result = Result.NOT_DONE
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user