From 43dee863cd5b9d43d79c603021b747ef290ab544 Mon Sep 17 00:00:00 2001 From: Sefa Eyeoglu Date: Thu, 18 Aug 2022 23:50:59 +0200 Subject: Add CEF Remote Debugging toggle (#129) * feat: add CEF Remote Debugging toggle * feat: disable remote debugger on startup * refactor: stop debugger instead of disable * feat: add option to allow remote debugging by default Co-authored-by: TrainDoctor --- backend/helpers.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'backend/helpers.py') diff --git a/backend/helpers.py b/backend/helpers.py index 8d329560..5e26f163 100644 --- a/backend/helpers.py +++ b/backend/helpers.py @@ -2,11 +2,15 @@ import certifi import ssl import uuid import re +import subprocess from aiohttp.web import middleware, Response from subprocess import check_output from time import sleep + +REMOTE_DEBUGGER_UNIT = "steam-web-debug-portforward.service" + # global vars csrf_token = str(uuid.uuid4()) ssl_ctx = ssl.create_default_context(cafile=certifi.where()) @@ -63,3 +67,17 @@ def get_user_group() -> str: if group == None: raise ValueError("helpers.get_user_group method called before group variable was set. Run helpers.set_user_group first.") return group + +async def is_systemd_unit_active(unit_name: str) -> bool: + res = subprocess.run(["systemctl", "is-active", unit_name], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) + return res.returncode == 0 + +async def stop_systemd_unit(unit_name: str) -> subprocess.CompletedProcess: + cmd = ["systemctl", "stop", unit_name] + + return subprocess.run(cmd, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) + +async def start_systemd_unit(unit_name: str) -> subprocess.CompletedProcess: + cmd = ["systemctl", "start", unit_name] + + return subprocess.run(cmd, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) -- cgit v1.2.3