From 0f083e78b0b803f0cd4f4583307e60dc9c7a8ccb Mon Sep 17 00:00:00 2001 From: Scheianu Ionut Date: Sat, 10 May 2025 22:04:14 +0300 Subject: [PATCH] update sh --- install.sh | 213 ++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 209 insertions(+), 4 deletions(-) diff --git a/install.sh b/install.sh index 3af7524..3fef73d 100644 --- a/install.sh +++ b/install.sh @@ -2,10 +2,215 @@ # Define variables REPO_URL="https://gitea.moto-adv.com/ske087/signage-player.git" # Replace with your Gitea repository URL -PROJECT_DIR="/home/pi/Desktop/digital-signage-player" # Full path to the installation folder -SERVICE_NAME="digital-signage-player.service" -WIFI_SSID="Hating.Backup2-4G" # Replace with your Wi-Fi SSID -WIFI_PASSWORD="EuropaUnita2020" # Replace with your Wi-Fi password +PROJECT_DIR="/home/pi/Desktop/ds-player" # Full path to the installation folder +SERVICE_NAME="ds-player.service" +WIFI_SSID="CosaNostra" # Replace with your Wi-Fi SSID +WIFI_PASSWORD="Leonardo" # Replace with your Wi-Fi password + +# 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 +SERVICE_NAME="ds-player.service" +#WIFI_SSID="Hating.Backup2-4G" # Replace with your Wi-Fi SSID +#WIFI_PASSWORD="EuropaUnita2020" # Replace with your Wi-Fi password + +# Step 0: Check if Wi-Fi is enabled and connect to Wi-Fi +echo "Checking if Wi-Fi is enabled..." +if ! rfkill list wifi | grep -q "Soft blocked: no"; then + echo "Wi-Fi is disabled. Enabling Wi-Fi..." + rfkill unblock wifi + sleep 5 +else + echo "Wi-Fi is already enabled." +fi + +echo "Checking Wi-Fi connection..." +if ! iwgetid -r > /dev/null; then + echo "Not connected to Wi-Fi. Connecting to $WIFI_SSID..." + sudo bash -c "wpa_passphrase \"$WIFI_SSID\" \"$WIFI_PASSWORD\" > /etc/wpa_supplicant/wpa_supplicant.conf" + sudo wpa_cli -i wlan0 reconfigure + sleep 10 + if iwgetid -r > /dev/null; then + echo "Successfully connected to Wi-Fi: $WIFI_SSID" + else + echo "Failed to connect to Wi-Fi. Please check your credentials." + exit 1 + fi +else + echo "Already connected to Wi-Fi: $(iwgetid -r)" +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 dependencies +echo "Installing Python dependencies from requirements.txt..." +pip 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 + +# Step 8: Install ffpyplayer +echo "Installing ffpyplayer..." +pip install ffpyplayer --break-system-packages + +# Step 9: 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" < /dev/null; then + echo "Not connected to Wi-Fi. Connecting to $WIFI_SSID..." + sudo bash -c "wpa_passphrase \"$WIFI_SSID\" \"$WIFI_PASSWORD\" > /etc/wpa_supplicant/wpa_supplicant.conf" + sudo wpa_cli -i wlan0 reconfigure + sleep 10 + if iwgetid -r > /dev/null; then + echo "Successfully connected to Wi-Fi: $WIFI_SSID" + else + echo "Failed to connect to Wi-Fi. Please check your credentials." + exit 1 + fi +else + echo "Already connected to Wi-Fi: $(iwgetid -r)" +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 dependencies +echo "Installing Python dependencies from requirements.txt..." +pip 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 + +# Step 8: Install ffpyplayer +echo "Installing ffpyplayer..." +pip install ffpyplayer --break-system-packages + +# Step 9: 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" <