From a60ba040d193d8d5a14a0f4dc2910aa001c54a3d Mon Sep 17 00:00:00 2001 From: ske087 Date: Mon, 23 Jun 2025 13:56:48 +0300 Subject: [PATCH] updated to ruun app .sh --- Install.sh | 19 +++++++++++++++++++ run_app.sh | 2 +- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/Install.sh b/Install.sh index 49f085f..8d6a25e 100644 --- a/Install.sh +++ b/Install.sh @@ -4,6 +4,7 @@ REPO_URL="https://gitea.moto-adv.com/ske087/signage-player.git" DEFAULT_INSTALL_DIR="/home/pi/signage-player" SERVICE_FILE="/etc/systemd/system/signage_player.service" +RUN_APP_FILE="$DEFAULT_INSTALL_DIR/run_app.sh" # Ask the user whether to use the default installation directory echo "The default installation directory is: $DEFAULT_INSTALL_DIR" @@ -82,6 +83,24 @@ else echo "signage_player.service file created and configured successfully." fi +# Check and update the working directory in run_app.sh +echo "Checking run_app.sh for correct working directory..." +if [[ -f "$RUN_APP_FILE" ]]; then + CURRENT_WORKING_DIR=$(grep -oP '(?<=^cd ).*' "$RUN_APP_FILE" | head -n 1) + EXPECTED_WORKING_DIR="$INSTALL_DIR/src" + + if [[ "$CURRENT_WORKING_DIR" != "$EXPECTED_WORKING_DIR" ]]; then + echo "Updating working directory in run_app.sh..." + sudo sed -i "s|^cd .*|cd $EXPECTED_WORKING_DIR|" "$RUN_APP_FILE" + echo "run_app.sh updated successfully." + else + echo "run_app.sh is already configured correctly." + fi +else + echo "Error: run_app.sh file not found." + exit 1 +fi + # Enable the service echo "Enabling signage_player.service..." sudo systemctl enable signage_player.service diff --git a/run_app.sh b/run_app.sh index 7726135..98a9320 100755 --- a/run_app.sh +++ b/run_app.sh @@ -3,7 +3,7 @@ # filepath: /home/pi/Desktop/signage-player/run_app.sh # Navigate to the application directory -cd /home/pi/Desktop/signage-player/src || exit +cd /home/pi/signage-player/src || exit # Check for the --verbose flag if [[ "$1" == "--verbose" ]]; then