action_utils: Stop associated service when stopping a socket unit

Tests:

- Unit tests pass.

- Radicale and Bepasty functional tests pass with changes to migrate to new
systemd socket-activated units.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
This commit is contained in:
Sunil Mohan Adapa 2026-03-17 16:53:35 -07:00
parent 65fecdc4cd
commit 7cbbc3633b
No known key found for this signature in database
GPG Key ID: 43EA1CFF0AA7C5F2

View File

@ -123,6 +123,14 @@ def service_disable(service_name: str, check: bool = False):
except subprocess.CalledProcessError:
pass
if service_name.endswith('.socket'):
# Instead, may need to query the unit for associated .service file.
base_name = service_name.rpartition('.')[0]
try:
service_stop(f'{base_name}.service', check=check)
except subprocess.CalledProcessError:
pass
def service_mask(service_name: str, check: bool = False):
"""Mask a service"""