#!/bin/bash # Define variables REPO_URL="https://gitea.moto-adv.com/ske087/signage-player.git" # Replace with your Gitea repository URL PROJECT_DIR="/home/pi/Desktop/ds-player" # Full path to the installation folder RUN_SCRIPT="$PROJECT_DIR/run_app.sh" # Path to the run_app.sh script # Step 0: Check if an internet connection exists echo "Checking internet connection..." if ! ping -c 1 google.com &> /dev/null; then echo "No internet connection detected. Please ensure the device is connected to the internet." exit 1 else echo "Internet connection is active." fi # Step 1: Check if the installation folder exists if [ -d "$PROJECT_DIR" ]; then echo "Installation folder already exists: $PROJECT_DIR" echo "Skipping installation steps..." else # Step 2: Update the system echo "Updating the system..." sudo apt-get update -y sudo apt-get upgrade -y # Step 3: Clone the repository echo "Cloning the repository from $REPO_URL..." git clone "$REPO_URL" "$PROJECT_DIR" # Step 4: Set permissions for the project directory echo "Setting permissions for the project directory to 0777..." sudo chmod -R 0777 "$PROJECT_DIR" fi # Step 5: Navigate to the project directory cd "$PROJECT_DIR" || { echo "Failed to navigate to project directory."; exit 1; } # Step 6: Install Python dependencies echo "Installing Python dependencies..." sudo apt-get install -y python3-pip pip3 install --upgrade pip pip3 install -r requirements.txt --break-system-packages # Step 7: Install system dependencies for ffpyplayer echo "Installing system dependencies for ffpyplayer..." sudo apt-get install -y libsdl2-dev libsdl2-ttf-dev libsdl2-image-dev libsdl2-mixer-dev \ libavcodec-dev libavformat-dev libavdevice-dev libavutil-dev libswscale-dev libswresample-dev libpostproc-dev \ libavcodec-extra libavdevice-dev libavfilter-dev # Step 8: Add run_app.sh to ~/.bashrc for autostart echo "Adding $RUN_SCRIPT to ~/.bashrc for autostart..." if ! grep -Fxq "$RUN_SCRIPT" ~/.bashrc; then echo "$RUN_SCRIPT" >> ~/.bashrc echo "Added $RUN_SCRIPT to ~/.bashrc." else echo "$RUN_SCRIPT is already in ~/.bashrc." fi # Step 9: Make run_app.sh executable echo "Making $RUN_SCRIPT executable..." chmod +x "$RUN_SCRIPT" # Step 10: Confirm installation echo "Installation completed successfully!" echo "The application will now start automatically when the device starts." echo "You can manually run the application using: $RUN_SCRIPT"