Skip to content
Merged
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
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 username | cut -d: -f7) -l -c "/usr/local/bin/shelltime-daemon"'
ExecStart=/bin/sh -c 'exec $(getent passwd $USER | cut -d: -f7) -l -c "/usr/local/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.

high

While using $USER is an improvement over a hardcoded username, it's better practice and more robust to use systemd's own specifiers in unit files. The $USER variable might not always be set in all environments where the service could run, whereas systemd specifiers are guaranteed to be substituted correctly.

You can use the %s specifier, which expands to the user's configured shell from the user database. This simplifies the ExecStart directive significantly and makes it more efficient by avoiding the need to run /bin/sh, getent, and cut just to find the user's shell.

This is cleaner, more efficient, and less prone to errors.

ExecStart=%s -l -c "/usr/local/bin/shelltime-daemon"

Restart=always

# Resource limits
Expand Down