Skip to content

Commit 0c40851

Browse files
committed
refactor(linux): use @bindir@ placeholder in service template
Both install.sh (PREFIX/bin) and nfpm postinstall (/usr/bin) now expand the placeholder explicitly, removing the implicit assumption that the template's hardcoded path matches any particular installer.
1 parent b13fb91 commit 0c40851

2 files changed

Lines changed: 10 additions & 8 deletions

File tree

packaging/linux/install.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,10 @@ fi
9191
SYSTEMD_UNIT_DIR=/usr/lib/systemd/user
9292
if [ -d "$SYSTEMD_UNIT_DIR" ] || command -v systemctl > /dev/null 2>&1; then
9393
echo "Installing systemd user unit …"
94-
# Rewrite ExecStart to match the actual install prefix. Escape the
95-
# replacement string so sed metacharacters (& \ |) in the path are literal.
96-
ESCAPED_EXEC="$(printf '%s\n' "${BINDIR}/openlogi-agent" | sed 's|[&\\|]|\\&|g')"
97-
sed "s|ExecStart=.*|ExecStart=${ESCAPED_EXEC}|" \
94+
# Expand the @BINDIR@ placeholder to match the actual install prefix.
95+
# Escape the replacement so sed metacharacters (& \ |) in the path are literal.
96+
ESCAPED_BINDIR="$(printf '%s\n' "${BINDIR}" | sed 's|[&\\|]|\\&|g')"
97+
sed "s|@BINDIR@|${ESCAPED_BINDIR}|g" \
9898
"${SCRIPT_DIR}/systemd/openlogi-agent.service" \
9999
| sudo tee "${SYSTEMD_UNIT_DIR}/openlogi-agent.service" > /dev/null
100100
# Best-effort daemon-reload for the invoking user so a reinstall picks up

packaging/linux/systemd/openlogi-agent.service

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
# OpenLogi background agent — packaged user unit.
22
#
3-
# This file is installed to /usr/lib/systemd/user/ by the package manager (or
4-
# install.sh). It is the system-provided template; the agent's launch_at_login
5-
# setting writes its own copy to $XDG_CONFIG_HOME/systemd/user/ — both coexist,
3+
# This file is a template — @BINDIR@ is substituted at install time:
4+
# - nfpm (.deb/.rpm): postinstall.sh expands it to /usr/bin
5+
# - install.sh: expanded to PREFIX/bin (default /usr/local/bin)
6+
# The agent's launch_at_login setting writes its own copy to
7+
# $XDG_CONFIG_HOME/systemd/user/ using the current binary path — both coexist,
68
# enabling either works.
79
#
810
# Enable for the current user:
@@ -14,7 +16,7 @@ After=graphical-session.target
1416

1517
[Service]
1618
Type=simple
17-
ExecStart=/usr/bin/openlogi-agent
19+
ExecStart=@BINDIR@/openlogi-agent
1820
Restart=on-failure
1921
RestartSec=5
2022

0 commit comments

Comments
 (0)