#!/bin/bash # Kivy Signage Player Installation Script # Supports both online and offline installation set -e SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" REPO_DIR="$SCRIPT_DIR/repo" WHEELS_DIR="$REPO_DIR/python-wheels" SYSTEM_DIR="$REPO_DIR/system-packages" DEB_DIR="$SYSTEM_DIR/debs" # Check for offline mode OFFLINE_MODE=false if [ "$1" == "--offline" ] || [ "$1" == "-o" ]; then OFFLINE_MODE=true echo "==========================================" echo "Offline Installation Mode" echo "==========================================" elif [ -d "$WHEELS_DIR" ] && [ "$(ls -A $WHEELS_DIR 2>/dev/null)" ]; then echo "==========================================" echo "Offline packages detected - Using repo folder" echo "==========================================" OFFLINE_MODE=true else echo "==========================================" echo "Online Installation Mode" echo "==========================================" fi echo "" echo "Installing Kivy Signage Player dependencies..." echo "" # Install system dependencies echo "Step 1: Installing system dependencies..." echo "--------------------" if [ "$OFFLINE_MODE" = true ] && [ -d "$DEB_DIR" ] && [ "$(ls -A $DEB_DIR/*.deb 2>/dev/null)" ]; then # Offline: Install from local .deb files echo "Installing from offline .deb packages..." cd "$DEB_DIR" # Install all .deb files with dependencies sudo dpkg -i *.deb 2>/dev/null || true # Fix any broken dependencies sudo apt-get install -f -y || true echo "System packages installed from offline repository" else # Online: Use apt-get echo "Updating package lists..." sudo apt update echo "Installing system packages..." # Read packages from file if available, otherwise use default list if [ -f "$SYSTEM_DIR/apt-packages.txt" ]; then PACKAGES=$(grep -v '^#' "$SYSTEM_DIR/apt-packages.txt" | grep -v '^$' | tr '\n' ' ') sudo apt install -y $PACKAGES else # Default package list sudo apt install -y python3-pip python3-setuptools python3-dev sudo apt install -y libsdl2-dev libsdl2-image-dev libsdl2-mixer-dev libsdl2-ttf-dev sudo apt install -y libportmidi-dev libswscale-dev libavformat-dev libavcodec-dev sudo apt install -y zlib1g-dev ffmpeg libavcodec-extra sudo apt install -y gstreamer1.0-plugins-base gstreamer1.0-plugins-good fi echo "System packages installed successfully" fi echo "" # Install Python dependencies echo "Step 2: Installing Python dependencies..." echo "--------------------" if [ "$OFFLINE_MODE" = true ] && [ -d "$WHEELS_DIR" ] && [ "$(ls -A $WHEELS_DIR/*.whl 2>/dev/null)" ]; then # Offline: Install from local wheels echo "Installing from offline Python wheels..." echo "Wheel files found: $(ls -1 $WHEELS_DIR/*.whl 2>/dev/null | wc -l)" if pip3 install --break-system-packages --no-index --find-links="$WHEELS_DIR" -r requirements.txt 2>&1 | tee /tmp/pip_install.log; then echo "Python packages installed from offline repository" else echo "Warning: Offline installation failed (possibly due to Python version mismatch)" echo "Falling back to online installation..." pip3 install --break-system-packages -r requirements.txt echo "Python packages installed from PyPI" fi else # Online: Use pip from PyPI echo "Installing from PyPI..." pip3 install --break-system-packages -r requirements.txt echo "Python packages installed successfully" fi echo "" echo "==========================================" echo "Installation completed successfully!" echo "==========================================" echo "" echo "To run the signage player:" echo " cd src && python3 main.py" echo "" echo "Or use the run script:" echo " bash run_player.sh" echo "" # Check if config exists if [ ! -d "$SCRIPT_DIR/config" ] || [ ! "$(ls -A $SCRIPT_DIR/config)" ]; then echo "Note: No configuration found." echo "Please configure the player before running:" echo " 1. Copy config/app_config.txt.example to config/app_config.txt" echo " 2. Edit the configuration file with your server details" echo "" fi