From 3d0a4c934ff1ca21585119c52fa42e5eab26a0ee Mon Sep 17 00:00:00 2001 From: nkoexe Date: Thu, 21 Nov 2024 11:49:15 +0100 Subject: [PATCH] removed inner reboot call, handle it outside --- sostituzioni/control/configurazione.py | 16 ---------------- sostituzioni/view/impostazioni/events.py | 3 ++- sostituzioni/view/impostazioni/routes.py | 21 +-------------------- 3 files changed, 3 insertions(+), 37 deletions(-) diff --git a/sostituzioni/control/configurazione.py b/sostituzioni/control/configurazione.py index b79f3a6..12f17dc 100644 --- a/sostituzioni/control/configurazione.py +++ b/sostituzioni/control/configurazione.py @@ -43,9 +43,6 @@ or ROOT_PATH / "database" / "configurazione.json.template" ) -SYSTEMD_SERVICE = os.getenv("SCUOLASYNC_SERVICE") or "scuolasync.service" - - # error caught in model/app.py to enter setup mode # this will reimport the module without loading the default config file if not CONFIG_FILE.exists() and "SCUOLASYNC_SETUP" not in os.environ: @@ -606,15 +603,6 @@ def __init__(self): if os.name == "nt": self.shell_commands["update"] = ["git", "pull"] - self.shell_commands["reboot"] = [ - "kill", - "-9", - str(os.getpid()), - "&&", - "python", - "-m", - "sostituzioni", - ] self.shell_commands["get_version"] = [ "git", "rev-parse", @@ -628,11 +616,7 @@ def __init__(self): "main", ] else: - if which("systemctl") is None: - logger.error("Systemctl non trovato.") - self.shell_commands["update"] = ["git", "pull"] - self.shell_commands["reboot"] = ["systemctl", "restart", SYSTEMD_SERVICE] self.shell_commands["get_version"] = [ "git", "rev-parse", diff --git a/sostituzioni/view/impostazioni/events.py b/sostituzioni/view/impostazioni/events.py index 7dad84b..caab744 100644 --- a/sostituzioni/view/impostazioni/events.py +++ b/sostituzioni/view/impostazioni/events.py @@ -132,7 +132,8 @@ def update(): @login_required @role_required("impostazioni.write") def reboot(): - subprocess.Popen(configurazione.shell_commands["reboot"], cwd=os.getcwd()) + # reboot is handled externally. The process exits and is restarted by systemd or others + exit(0) # ////////////////////////////// diff --git a/sostituzioni/view/impostazioni/routes.py b/sostituzioni/view/impostazioni/routes.py index b8cd721..347eaa1 100644 --- a/sostituzioni/view/impostazioni/routes.py +++ b/sostituzioni/view/impostazioni/routes.py @@ -146,23 +146,4 @@ def version(): @login_required @role_required("impostazioni.write") def log(): - import subprocess - from sostituzioni.control.configurazione import SYSTEMD_SERVICE - - return ( - subprocess.check_output( - [ - "/usr/bin/journalctl", - "--output", - "cat", - "-u", - SYSTEMD_SERVICE, - "-n", - "1000", - "--no-pager", - ], - stderr=subprocess.STDOUT, - ) - .decode("utf-8") - .replace("\n", "
") - ) + return 'deprecated'