names: Introduce method to check if resolved is installed

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: Veiko Aasa <veiko17@disroot.org>
This commit is contained in:
Sunil Mohan Adapa 2024-10-01 18:41:31 -07:00 committed by Veiko Aasa
parent cfe3946b9a
commit dd16034e3c
No known key found for this signature in database
GPG Key ID: 478539CAE680674E

View File

@ -4,6 +4,7 @@ FreedomBox app to configure name services.
"""
import logging
import pathlib
import socket
import subprocess
@ -209,3 +210,8 @@ def get_available_tls_domains():
"""Return an iterator with all domains able to have a certificate."""
return (domain.name for domain in components.DomainName.list()
if domain.domain_type.can_have_certificate)
def is_resolved_installed():
"""Return whether systemd-resolved is installed."""
return pathlib.Path('/usr/bin/resolvectl').exists()