fix: auto path for service

This commit is contained in:
Дмитрий Абдрахманов 2024-10-11 09:37:34 +03:00
parent 4cff2d65a7
commit 71a1d53f0d
4 changed files with 13 additions and 5 deletions

View File

@ -2,4 +2,4 @@
# Launch daemon
/usr/bin/systemctl --user restart wthrc.service
echo "Done runner"
echo "Daemon started"

View File

@ -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]

View File

@ -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"),

View File

@ -8,4 +8,5 @@ args = flags.parse_args()
if args.install:
install()
else:
weather_run()