From 71a1d53f0d718b01fb500dc77088c022f2a93db0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D0=BC=D0=B8=D1=82=D1=80=D0=B8=D0=B9=20=D0=90=D0=B1?= =?UTF-8?q?=D0=B4=D1=80=D0=B0=D1=85=D0=BC=D0=B0=D0=BD=D0=BE=D0=B2?= <565963@gmail.com> Date: Fri, 11 Oct 2024 09:37:34 +0300 Subject: [PATCH] fix: auto path for service --- scripts/runner.sh | 2 +- services/wthrc.service | 5 ++--- src/installer.py | 8 ++++++++ src/main.py | 3 ++- 4 files changed, 13 insertions(+), 5 deletions(-) diff --git a/scripts/runner.sh b/scripts/runner.sh index dd6c2cc..9a3f29f 100644 --- a/scripts/runner.sh +++ b/scripts/runner.sh @@ -2,4 +2,4 @@ # Launch daemon /usr/bin/systemctl --user restart wthrc.service -echo "Done runner" \ No newline at end of file +echo "Daemon started" \ No newline at end of file diff --git a/services/wthrc.service b/services/wthrc.service index 30956e6..826b857 100644 --- a/services/wthrc.service +++ b/services/wthrc.service @@ -2,10 +2,9 @@ Description=Weather collection service [Service] -$DIR=/home/citrullux/ModernOSWeather Type=simple -WorkingDirectory=/home/citrullux/ModernOSWeather/src -ExecStart=/usr/bin/python3 /home/citrullux/ModernOSWeather/src/main.py +WorkingDirectory=/home/citrullux/ModernOSLabs/src +ExecStart=/usr/bin/python3 /home/citrullux/ModernOSLabs/src/main.py Restart=always [Install] diff --git a/src/installer.py b/src/installer.py index 19ddeea..1e59ec5 100644 --- a/src/installer.py +++ b/src/installer.py @@ -12,6 +12,14 @@ def install() -> None: serviceDirExist = os.path.isdir(os.path.join(homeDir, ".config/systemd/user/")) delivered = False + # Service file change for userspace + with open(os.path.join(projectDir, "services/wthrc.service"), "r") as service: + lines = service.readlines() + lines[5] = "WorkingDirectory=" + os.path.join(projectDir, "src") + "\n" + lines[6] = "ExecStart=/usr/bin/python3 " + os.path.join(projectDir, "src/main.py") + "\n" + with open(os.path.join(projectDir, "services/wthrc.service"), "w") as service: + service.writelines(lines) + if serviceDirExist: delivered = filecmp.cmp( os.path.join(projectDir, "services/wthrc.service"), diff --git a/src/main.py b/src/main.py index 1811eb2..bab1d3d 100644 --- a/src/main.py +++ b/src/main.py @@ -8,4 +8,5 @@ args = flags.parse_args() if args.install: install() -weather_run() \ No newline at end of file +else: + weather_run() \ No newline at end of file