From 45c4040fa48d9c9dad92b7bb9e7d80f8b5f064b7 Mon Sep 17 00:00:00 2001 From: ske087 Date: Mon, 23 Jun 2025 14:48:02 +0300 Subject: [PATCH] updated sh file --- Install.sh | 70 ++++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 58 insertions(+), 12 deletions(-) diff --git a/Install.sh b/Install.sh index 8d6a25e..fdf90ca 100644 --- a/Install.sh +++ b/Install.sh @@ -22,6 +22,7 @@ else mkdir -p "$INSTALL_DIR" if [[ $? -ne 0 ]]; then echo "Error: Failed to create directory $INSTALL_DIR." + read -p "Press any key to close the terminal..." -n 1 -s exit 1 fi fi @@ -30,11 +31,19 @@ fi # Update system packages echo "Updating system packages..." -sudo apt update && sudo apt upgrade -y - +sudo apt update && sudo apt upgrade -y || { + echo "Error: Failed to update system packages." + read -p "Press any key to close the terminal..." -n 1 -s + exit 1 +} +echo "Installation directory is set to: $INSTALL_DIR and is starting the installation process." # Install required system packages echo "Installing required system packages..." -sudo apt install -y python3 python3-pip git +sudo apt install -y python3 python3-pip git || { + echo "Error: Failed to install required system packages." + read -p "Press any key to close the terminal..." -n 1 -s + exit 1 +} # Clone the repository echo "Cloning the repository..." @@ -42,18 +51,34 @@ if [ -d "$INSTALL_DIR" ]; then echo "Directory $INSTALL_DIR already exists. Removing it..." sudo rm -rf "$INSTALL_DIR" fi -git clone "$REPO_URL" "$INSTALL_DIR" +git clone "$REPO_URL" "$INSTALL_DIR" || { + echo "Error: Failed to clone the repository." + read -p "Press any key to close the terminal..." -n 1 -s + exit 1 +} # Navigate to the cloned repository -cd "$INSTALL_DIR" || exit +cd "$INSTALL_DIR" || { + echo "Error: Failed to navigate to the cloned repository." + read -p "Press any key to close the terminal..." -n 1 -s + exit 1 +} # Install Python dependencies echo "Installing Python dependencies..." -pip3 install -r requirements.txt --break-system-packages +pip3 install -r requirements.txt --break-system-packages || { + echo "Error: Failed to install Python dependencies." + read -p "Press any key to close the terminal..." -n 1 -s + exit 1 +} # Set permissions for the run_app.sh script echo "Setting permissions for run_app.sh..." -chmod +x "$INSTALL_DIR/run_app.sh" +chmod +x "$INSTALL_DIR/run_app.sh" || { + echo "Error: Failed to set permissions for run_app.sh." + read -p "Press any key to close the terminal..." -n 1 -s + exit 1 +} # Check and update the signage_player.service file if [[ -f "$SERVICE_FILE" ]]; then @@ -69,7 +94,11 @@ if [[ -f "$SERVICE_FILE" ]]; then sudo cp "$INSTALL_DIR/signage_player.service" "$SERVICE_FILE" sudo sed -i "s|^WorkingDirectory=.*|WorkingDirectory=$INSTALL_DIR|" "$SERVICE_FILE" sudo sed -i "s|^ExecStart=.*|ExecStart=$INSTALL_DIR/run_app.sh|" "$SERVICE_FILE" - sudo systemctl daemon-reload + sudo systemctl daemon-reload || { + echo "Error: Failed to reload systemd daemon." + read -p "Press any key to close the terminal..." -n 1 -s + exit 1 + } echo "signage_player.service file updated successfully." else echo "signage_player.service file is already configured correctly." @@ -79,7 +108,11 @@ else sudo cp "$INSTALL_DIR/signage_player.service" "$SERVICE_FILE" sudo sed -i "s|^WorkingDirectory=.*|WorkingDirectory=$INSTALL_DIR|" "$SERVICE_FILE" sudo sed -i "s|^ExecStart=.*|ExecStart=$INSTALL_DIR/run_app.sh|" "$SERVICE_FILE" - sudo systemctl daemon-reload + sudo systemctl daemon-reload || { + echo "Error: Failed to reload systemd daemon." + read -p "Press any key to close the terminal..." -n 1 -s + exit 1 + } echo "signage_player.service file created and configured successfully." fi @@ -91,20 +124,33 @@ if [[ -f "$RUN_APP_FILE" ]]; then 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" + sudo sed -i "s|^cd .*|cd $EXPECTED_WORKING_DIR|" "$RUN_APP_FILE" || { + echo "Error: Failed to update working directory in run_app.sh." + read -p "Press any key to close the terminal..." -n 1 -s + exit 1 + } 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." + read -p "Press any key to close the terminal..." -n 1 -s exit 1 fi # Enable the service echo "Enabling signage_player.service..." -sudo systemctl enable signage_player.service +sudo systemctl enable signage_player.service || { + echo "Error: Failed to enable signage_player.service." + read -p "Press any key to close the terminal..." -n 1 -s + exit 1 +} # Restart the system to check if the service starts echo "Restarting the system to check if the service starts..." -sudo reboot \ No newline at end of file +sudo reboot || { + echo "Error: Failed to restart the system." + read -p "Press any key to close the terminal..." -n 1 -s + exit 1 +} \ No newline at end of file