added Install Sh
This commit is contained in:
72
install.sh
Normal file
72
install.sh
Normal file
@@ -0,0 +1,72 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Define variables
|
||||
REPO_URL="https://gitea.moto-adv.com/ske087/signage-player.git" # Replace with your Gitea repository URL
|
||||
PROJECT_DIR="digital-signage-player"
|
||||
SERVICE_NAME="digital-signage-player.service"
|
||||
|
||||
# Step 1: Update the system
|
||||
echo "Updating the system..."
|
||||
sudo apt-get update -y
|
||||
sudo apt-get upgrade -y
|
||||
|
||||
# Step 2: Clone the repository
|
||||
echo "Cloning the repository from $REPO_URL..."
|
||||
if [ -d "$PROJECT_DIR" ]; then
|
||||
echo "Project directory already exists. Pulling the latest changes..."
|
||||
cd "$PROJECT_DIR" && git pull && cd ..
|
||||
else
|
||||
git clone "$REPO_URL"
|
||||
fi
|
||||
|
||||
# Step 3: Set permissions for the project directory
|
||||
echo "Setting permissions for the project directory to 0777..."
|
||||
sudo chmod -R 0777 "$PROJECT_DIR"
|
||||
|
||||
# Step 4: Navigate to the project directory
|
||||
cd "$PROJECT_DIR" || { echo "Failed to navigate to project directory."; exit 1; }
|
||||
|
||||
# Step 5: Install Python dependencies
|
||||
echo "Installing Python dependencies from requirements.txt..."
|
||||
pip install -r requirements.txt
|
||||
|
||||
# Step 6: 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
|
||||
sudo apt-get install -y libavcodec-dev libavformat-dev libavdevice-dev libavutil-dev libswscale-dev libswresample-dev libpostproc-dev
|
||||
|
||||
# Step 7: Install ffpyplayer
|
||||
echo "Installing ffpyplayer..."
|
||||
pip install ffpyplayer
|
||||
|
||||
# Step 8: 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" <<EOL
|
||||
[Unit]
|
||||
Description=Kivy Media Player
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
ExecStart=/usr/bin/python3 /home/pi/Desktop/kivy-media-player/src/main.py
|
||||
WorkingDirectory=/home/pi/Desktop/kivy-media-player
|
||||
Restart=always
|
||||
User=pi
|
||||
Environment=DISPLAY=:0
|
||||
Environment=XAUTHORITY=/home/pi/.Xauthority
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
EOL
|
||||
|
||||
# Step 9: Enable and start the service
|
||||
echo "Enabling and starting the systemd service..."
|
||||
sudo systemctl daemon-reload
|
||||
sudo systemctl enable "$SERVICE_NAME"
|
||||
sudo systemctl start "$SERVICE_NAME"
|
||||
|
||||
# Step 10: Confirm installation
|
||||
echo "Installation completed successfully!"
|
||||
echo "The application will now start automatically on boot."
|
||||
echo "You can manually start it using: sudo systemctl start $SERVICE_NAME"
|
||||
echo "You can check its status using: sudo systemctl status $SERVICE_NAME"
|
||||
Reference in New Issue
Block a user