From a2a28fe3d2023ab076223417dcc59a38edbaebca Mon Sep 17 00:00:00 2001 From: Alvin Schiller <103769832+AlvinSchiller@users.noreply.github.com> Date: Wed, 15 Nov 2023 02:04:59 +0100 Subject: [PATCH] remove hardwired path. replace during installation --- installation/includes/00_constants.sh | 2 +- installation/routines/setup_jukebox_core.sh | 7 +++++-- resources/default-services/jukebox-daemon.service | 4 ++-- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/installation/includes/00_constants.sh b/installation/includes/00_constants.sh index f643cdc47..e19dd1327 100644 --- a/installation/includes/00_constants.sh +++ b/installation/includes/00_constants.sh @@ -1,7 +1,7 @@ RPI_BOOT_CONFIG_FILE="/boot/config.txt" SHARED_PATH="${INSTALLATION_PATH}/shared" SETTINGS_PATH="${SHARED_PATH}/settings" -SYSTEMD_USR_PATH="/usr/lib/systemd/user/" +SYSTEMD_USR_PATH="/usr/lib/systemd/user" # The default upstream user, release branch, and develop branch # These are used to prepare the repo for developers diff --git a/installation/routines/setup_jukebox_core.sh b/installation/routines/setup_jukebox_core.sh index 15d658de5..e6dfa6d8f 100644 --- a/installation/routines/setup_jukebox_core.sh +++ b/installation/routines/setup_jukebox_core.sh @@ -124,8 +124,11 @@ _jukebox_core_install_settings() { _jukebox_core_register_as_service() { echo " Register Jukebox Core user service" - sudo cp -f "${INSTALLATION_PATH}/resources/default-services/jukebox-daemon.service" "${SYSTEMD_USR_PATH}" - sudo chmod 644 "${SYSTEMD_USR_PATH}/jukebox-daemon.service" + + local jukebox_service="${SYSTEMD_USR_PATH}/jukebox-daemon.service" + sudo cp -f "${INSTALLATION_PATH}/resources/default-services/jukebox-daemon.service" "${jukebox_service}" + sudo sed -i "s|%%INSTALLATION_PATH%%|${INSTALLATION_PATH}|g" "${jukebox_service}" + sudo chmod 644 "${jukebox_service}" systemctl --user daemon-reload systemctl --user enable jukebox-daemon.service diff --git a/resources/default-services/jukebox-daemon.service b/resources/default-services/jukebox-daemon.service index df7d4c24a..050897e14 100644 --- a/resources/default-services/jukebox-daemon.service +++ b/resources/default-services/jukebox-daemon.service @@ -10,8 +10,8 @@ After=network.target sound.target mpd.service pulseaudio.service Requires=mpd.service pulseaudio.service [Service] -WorkingDirectory=/home/pi/RPi-Jukebox-RFID/src/jukebox -ExecStart=/bin/bash -c 'source /home/pi/RPi-Jukebox-RFID/.venv/bin/activate && python run_jukebox.py' +WorkingDirectory=%%INSTALLATION_PATH%%/src/jukebox +ExecStart=/bin/bash -c 'source %%INSTALLATION_PATH%%/.venv/bin/activate && python run_jukebox.py' StandardOutput=inherit StandardError=inherit Restart=always