From ab52c7e599a67d4bf1e2991696fe7d57ebdff382 Mon Sep 17 00:00:00 2001 From: Jens Ahrensfeld Date: Wed, 1 Jul 2026 00:58:48 +0200 Subject: [PATCH] fix: derive brewpi home from script location in service install Co-Authored-By: Claude Sonnet 4.6 Claude-Session: https://claude.ai/code/session_01VsJfJngYUpB4dr77GvcEb8 --- deploy/brewpi.service | 4 ++-- deploy/install.sh | 8 +++++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/deploy/brewpi.service b/deploy/brewpi.service index 4f866f8..124b757 100644 --- a/deploy/brewpi.service +++ b/deploy/brewpi.service @@ -5,8 +5,8 @@ After=network.target [Service] Type=simple User=jens -WorkingDirectory=/home/jens/work/repos/brewpi -ExecStart=/home/jens/work/repos/brewpi/.venv/bin/python3 /home/jens/work/repos/brewpi/server/brewpi.py +WorkingDirectory=${BREWPI_HOME} +ExecStart=${BREWPI_HOME}/.venv/bin/python3 ${BREWPI_HOME}/server/brewpi.py Restart=on-failure RestartSec=5 diff --git a/deploy/install.sh b/deploy/install.sh index 6cc6ace..edcd668 100755 --- a/deploy/install.sh +++ b/deploy/install.sh @@ -1,11 +1,13 @@ -#!/usr/bin/env bash + #!/usr/bin/env bash set -euo pipefail SERVICE=brewpi -UNIT_FILE="$(dirname "$(realpath "$0")")/${SERVICE}.service" +DEPLOY_DIR="$(dirname "$(realpath "$0")")" +UNIT_FILE="${DEPLOY_DIR}/${SERVICE}.service" TARGET=/etc/systemd/system/${SERVICE}.service -sudo cp "$UNIT_FILE" "$TARGET" +export BREWPI_HOME="$(realpath "${DEPLOY_DIR}/..")" +envsubst < "$UNIT_FILE" | sudo tee "$TARGET" > /dev/null sudo systemctl daemon-reload sudo systemctl enable "$SERVICE" echo "Installed. Start with: sudo systemctl start $SERVICE"