Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion model/daemon-installer.linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This line correctly adds the BaseFolder to the template data, fixing one of the bugs.

However, as mentioned in my comment on model/sys-desc/shelltime.service, the service file can be improved to use systemd's %h specifier for the home directory. If you apply that suggestion, {{.BaseFolder}} will no longer be needed in the template, and this line can be removed.

})
return
}
2 changes: 1 addition & 1 deletion model/sys-desc/shelltime.service
Original file line number Diff line number Diff line change
Expand Up @@ -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"'
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

While this change correctly fixes the issue with $USER not being available, the ExecStart command can be significantly simplified and made more robust by using systemd's built-in specifiers.

You can replace the complex shell invocation with a more direct command that uses %s for the user's shell and %h for the user's home directory. This avoids shelling out to id, getent, and cut, making the service file cleaner and less dependent on external commands. Adopting this would also make the change in daemon-installer.linux.go unnecessary.

ExecStart=%s -l -c "%h/.shelltime/bin/shelltime-daemon"

Restart=always

# Resource limits
Expand Down