diff --git a/backend/localplatformlinux.py b/backend/localplatformlinux.py index 811db8a62..c85cbcf2a 100644 --- a/backend/localplatformlinux.py +++ b/backend/localplatformlinux.py @@ -129,11 +129,19 @@ async def service_restart(service_name : str) -> bool: return res.returncode == 0 async def service_stop(service_name : str) -> bool: + if not await service_active(service_name): + # Service isn't running. pretend we stopped it + return True + cmd = ["systemctl", "stop", service_name] res = run(cmd, stdout=PIPE, stderr=STDOUT) return res.returncode == 0 async def service_start(service_name : str) -> bool: + if await service_active(service_name): + # Service is running. pretend we started it + return True + cmd = ["systemctl", "start", service_name] res = run(cmd, stdout=PIPE, stderr=STDOUT) return res.returncode == 0