#!/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 VENV_DIR="$PROJECT_DIR/venv" # Path to the virtual environment SERVICE_NAME="ds-player.service" # 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 and starting the service..." sudo systemctl start "$SERVICE_NAME" echo "Service started successfully!" exit 0 fi # 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" # Step 5: Navigate to the project directory cd "$PROJECT_DIR" || { echo "Failed to navigate to project directory."; exit 1; } # Step 6: Install Python virtual environment tools echo "Installing Python virtual environment tools..." sudo apt-get install -y python3-venv python3-pip # Step 7: Create a virtual environment echo "Creating a Python virtual environment in $VENV_DIR..." python3 -m venv "$VENV_DIR" # Step 8: Activate the virtual environment and install dependencies echo "Activating the virtual environment and installing dependencies..." source "$VENV_DIR/bin/activate" pip install --upgrade pip pip install -r requirements.txt # Step 9: 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 10: Install ffpyplayer in the virtual environment echo "Installing ffpyplayer in the virtual environment..." pip install ffpyplayer # Step 11: Create a systemd service for autostart echo "Creating systemd service for autostart..." SERVICE_FILE="/etc/systemd/system/$SERVICE_NAME" sudo bash -c "cat > $SERVICE_FILE" <