install app
This commit is contained in:
84
Install.sh
84
Install.sh
@@ -1,31 +1,35 @@
|
||||
#!/bin/bash
|
||||
|
||||
# filepath: /home/pi/Desktop/signage-player/install.sh
|
||||
|
||||
# Define variables
|
||||
REPO_URL="https://gitea.moto-adv.com/ske087/signage-player.git"
|
||||
INSTALL_DIR="/home/pi/signage-player"
|
||||
DEFAULT_INSTALL_DIR="/home/pi/signage-player"
|
||||
SERVICE_FILE="/etc/systemd/system/signage_player.service"
|
||||
|
||||
# Ask the user whether to use the default installation directory
|
||||
echo "The default installation directory is: $DEFAULT_INSTALL_DIR"
|
||||
read -p "Do you want to use the default installation directory? (y/n): " response
|
||||
|
||||
# Handle the user's response
|
||||
if [[ "$response" == "y" || "$response" == "Y" ]]; then
|
||||
INSTALL_DIR="$DEFAULT_INSTALL_DIR"
|
||||
echo "Using default installation directory: $INSTALL_DIR"
|
||||
else
|
||||
read -p "Enter the custom installation directory: " CUSTOM_INSTALL_DIR
|
||||
INSTALL_DIR="$CUSTOM_INSTALL_DIR"
|
||||
if [[ ! -d "$INSTALL_DIR" ]]; then
|
||||
echo "Directory $INSTALL_DIR does not exist. Creating it..."
|
||||
mkdir -p "$INSTALL_DIR"
|
||||
if [[ $? -ne 0 ]]; then
|
||||
echo "Error: Failed to create directory $INSTALL_DIR."
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
echo "Using custom installation directory: $INSTALL_DIR"
|
||||
fi
|
||||
|
||||
# Update system packages
|
||||
echo "Updating system packages..."
|
||||
sudo apt update && sudo apt upgrade -y
|
||||
# Install SDL2 and related libraries
|
||||
sudo apt install -y libsdl2-dev libsdl2-image-dev libsdl2-mixer-dev libsdl2-ttf-dev
|
||||
|
||||
# Install OpenGL ES and EGL libraries
|
||||
sudo apt install -y libgles2-mesa-dev libegl1-mesa-dev
|
||||
|
||||
# Install GStreamer and related plugins
|
||||
sudo apt install -y libgstreamer1.0-dev gstreamer1.0-plugins-base gstreamer1.0-plugins-good gstreamer1.0-plugins-bad gstreamer1.0-plugins-ugly gstreamer1.0-libav
|
||||
|
||||
# Install X11 libraries
|
||||
sudo apt install -y libx11-dev libxrandr-dev libxinerama-dev libxcursor-dev
|
||||
|
||||
# Install framebuffer support
|
||||
sudo apt install -y libmtdev-dev
|
||||
|
||||
# install Python3
|
||||
sudo apt install -y python3
|
||||
|
||||
# Install required system packages
|
||||
echo "Installing required system packages..."
|
||||
@@ -44,14 +48,44 @@ cd "$INSTALL_DIR" || exit
|
||||
|
||||
# Install Python dependencies
|
||||
echo "Installing Python dependencies..."
|
||||
pip3 install -r requirements.txt --break-system-packages
|
||||
pip3 install -r requirements.txt --break-system-packages
|
||||
|
||||
# Set permissions for the run_app.sh script
|
||||
echo "Setting permissions for run_app.sh..."
|
||||
chmod +x "$INSTALL_DIR/run_app.sh"
|
||||
|
||||
# Run the application
|
||||
echo "Launching the application..."
|
||||
"$INSTALL_DIR/run_app.sh --verbose"
|
||||
# Check and update the signage_player.service file
|
||||
if [[ -f "$SERVICE_FILE" ]]; then
|
||||
echo "Checking signage_player.service file..."
|
||||
WORKING_DIR=$(grep -oP '(?<=^WorkingDirectory=).*' "$SERVICE_FILE")
|
||||
EXEC_START=$(grep -oP '(?<=^ExecStart=).*' "$SERVICE_FILE")
|
||||
|
||||
echo "Installation and setup complete!"
|
||||
EXPECTED_WORKING_DIR="$INSTALL_DIR"
|
||||
EXPECTED_EXEC_START="$INSTALL_DIR/run_app.sh"
|
||||
|
||||
if [[ "$WORKING_DIR" != "$EXPECTED_WORKING_DIR" || "$EXEC_START" != "$EXPECTED_EXEC_START" ]]; then
|
||||
echo "Updating signage_player.service file..."
|
||||
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
|
||||
echo "signage_player.service file updated successfully."
|
||||
else
|
||||
echo "signage_player.service file is already configured correctly."
|
||||
fi
|
||||
else
|
||||
echo "signage_player.service file not found. Copying and configuring it..."
|
||||
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
|
||||
echo "signage_player.service file created and configured successfully."
|
||||
fi
|
||||
|
||||
# Enable the service
|
||||
echo "Enabling signage_player.service..."
|
||||
sudo systemctl enable signage_player.service
|
||||
|
||||
# Restart the system to check if the service starts
|
||||
echo "Restarting the system to check if the service starts..."
|
||||
sudo reboot
|
||||
15
signage-player.service
Normal file
15
signage-player.service
Normal file
@@ -0,0 +1,15 @@
|
||||
[Unit]
|
||||
Description=Signage Player Service
|
||||
After=network.targhet
|
||||
|
||||
[Service]
|
||||
ExecStart=/home/pi/signage-player/run_app.sh
|
||||
WorkingDirectory=/home/pi/signage-player
|
||||
StandardOutput=inherit
|
||||
StandardError=inherit
|
||||
Restart=always
|
||||
User=pi
|
||||
Enviroment=DISPLAY=:0
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.targhet
|
||||
Reference in New Issue
Block a user