service: Stop service not before but after disabling it

Services that have socket activation enabled (e.g avahi) could automatically
start again after they are stopped manually. This change disables service
before stopping it, preventing it from auto-starting again.

Closes #1772

Signed-off-by: Veiko Aasa <veiko17@disroot.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
Veiko Aasa 2020-02-06 11:25:49 +02:00 committed by James Valleroy
parent 77a76eb40f
commit a75c1da683
No known key found for this signature in database
GPG Key ID: 77C0C75E7B650808

View File

@ -84,11 +84,11 @@ def service_enable(service_name):
def service_disable(service_name):
"""Disable and stop service in systemd and sysvinit using update-rc.d."""
subprocess.call(['systemctl', 'disable', service_name])
try:
service_stop(service_name)
except subprocess.CalledProcessError:
pass
subprocess.call(['systemctl', 'disable', service_name])
def service_unmask(service_name):