From 3647289c3f8722f9d58ad7885d74eaef9c1d62b3 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 26 Dec 2025 03:39:59 +0000 Subject: [PATCH] fix(daemon): fix Linux systemd service template rendering The Linux systemd service was failing to start due to two issues: 1. BaseFolder was missing from template data in GetDaemonServiceFile, causing {{.BaseFolder}} to render as empty, resulting in invalid daemon path "/bin/shelltime-daemon" instead of the correct path. 2. $USER environment variable is not available in systemd user services, causing getent passwd $USER to fail. Replaced with $(id -un) which reliably returns the current username without depending on environment. This aligns the Linux implementation with the working macOS version. --- model/daemon-installer.linux.go | 3 ++- model/sys-desc/shelltime.service | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/model/daemon-installer.linux.go b/model/daemon-installer.linux.go index 2a319f1..603b437 100644 --- a/model/daemon-installer.linux.go +++ b/model/daemon-installer.linux.go @@ -166,7 +166,8 @@ func (l *LinuxDaemonInstaller) GetDaemonServiceFile(username string) (buf bytes. return } err = tmpl.Execute(&buf, map[string]string{ - "UserName": username, + "UserName": username, + "BaseFolder": l.baseFolder, }) return } diff --git a/model/sys-desc/shelltime.service b/model/sys-desc/shelltime.service index 5b6752d..3a95f77 100644 --- a/model/sys-desc/shelltime.service +++ b/model/sys-desc/shelltime.service @@ -4,7 +4,7 @@ After=network.target [Service] Type=simple -ExecStart=/bin/sh -c 'exec $(getent passwd $USER | cut -d: -f7) -l -c "{{.BaseFolder}}/bin/shelltime-daemon"' +ExecStart=/bin/sh -c 'exec $(getent passwd $(id -un) | cut -d: -f7) -l -c "{{.BaseFolder}}/bin/shelltime-daemon"' Restart=always # Resource limits