summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan <sentrycraft123@gmail.com>2023-11-11 21:50:23 +0100
committerAAGaming <aagaming@riseup.net>2023-12-29 18:40:52 -0500
commit6cb545c78da982e6ffc46f45e1578f4226d6413c (patch)
treefc9967c9dc8acf7b6245112813e16eec28d9b3c1
parent41c62c3a3436e0e2968bfaea9c612ba2873fcdfb (diff)
downloaddecky-loader-6cb545c78da982e6ffc46f45e1578f4226d6413c.tar.gz
decky-loader-6cb545c78da982e6ffc46f45e1578f4226d6413c.zip
Check if Linux service is running before trying to start or stop it (#540)
this prevents needless prompts opening up
-rw-r--r--backend/decky_loader/localplatform/localplatformlinux.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/backend/decky_loader/localplatform/localplatformlinux.py b/backend/decky_loader/localplatform/localplatformlinux.py
index d5bea6ab..9bbb59a7 100644
--- a/backend/decky_loader/localplatform/localplatformlinux.py
+++ b/backend/decky_loader/localplatform/localplatformlinux.py
@@ -125,11 +125,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