From 5e4890aeabdd2cb41ef93a78e4ac14e47e01cb81 Mon Sep 17 00:00:00 2001 From: ske087 Date: Fri, 20 Jun 2025 08:31:14 +0300 Subject: [PATCH] Updated SH file --- Install.sh | 57 +++++++++++++++ install.sh | 67 ------------------ run_app.sh | 2 +- src/Resurse/log.txt | 2 + .../python_functions.cpython-311.pyc | Bin 11103 -> 11240 bytes src/python_functions.py | 8 ++- 6 files changed, 67 insertions(+), 69 deletions(-) create mode 100644 Install.sh delete mode 100644 install.sh diff --git a/Install.sh b/Install.sh new file mode 100644 index 0000000..e63028f --- /dev/null +++ b/Install.sh @@ -0,0 +1,57 @@ +#!/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" + +# 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..." +sudo apt install -y python3 python3-pip git + +# Clone the repository +echo "Cloning the repository..." +if [ -d "$INSTALL_DIR" ]; then + echo "Directory $INSTALL_DIR already exists. Removing it..." + sudo rm -rf "$INSTALL_DIR" +fi +git clone "$REPO_URL" "$INSTALL_DIR" + +# Navigate to the cloned repository +cd "$INSTALL_DIR" || exit + +# Install Python dependencies +echo "Installing Python dependencies..." +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" + +echo "Installation and setup complete!" diff --git a/install.sh b/install.sh deleted file mode 100644 index 1ba433f..0000000 --- a/install.sh +++ /dev/null @@ -1,67 +0,0 @@ -#!/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 -RUN_SCRIPT="$PROJECT_DIR/run_app.sh" # Path to the run_app.sh script - -# 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..." -else - # 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" -fi - -# 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..." -sudo apt-get install -y python3-pip -pip3 install --upgrade pip -pip3 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 \ -libavcodec-extra libavdevice-dev libavfilter-dev - -# Step 8: Add run_app.sh to ~/.bashrc for autostart -echo "Adding $RUN_SCRIPT to ~/.bashrc for autostart..." -if ! grep -Fxq "$RUN_SCRIPT" ~/.bashrc; then - echo "$RUN_SCRIPT" >> ~/.bashrc - echo "Added $RUN_SCRIPT to ~/.bashrc." -else - echo "$RUN_SCRIPT is already in ~/.bashrc." -fi - -# Step 9: Make run_app.sh executable -echo "Making $RUN_SCRIPT executable..." -chmod +x "$RUN_SCRIPT" - -# Step 10: Confirm installation -echo "Installation completed successfully!" -echo "The application will now start automatically when the device starts." -echo "You can manually run the application using: $RUN_SCRIPT" \ No newline at end of file diff --git a/run_app.sh b/run_app.sh index 7726135..98a9320 100755 --- a/run_app.sh +++ b/run_app.sh @@ -3,7 +3,7 @@ # filepath: /home/pi/Desktop/signage-player/run_app.sh # Navigate to the application directory -cd /home/pi/Desktop/signage-player/src || exit +cd /home/pi/signage-player/src || exit # Check for the --verbose flag if [[ "$1" == "--verbose" ]]; then diff --git a/src/Resurse/log.txt b/src/Resurse/log.txt index 9521e97..b42c430 100644 --- a/src/Resurse/log.txt +++ b/src/Resurse/log.txt @@ -11,3 +11,5 @@ 2025-06-19 16:06:03 - STARTED: IMG-20250602-WA0011.jpg 2025-06-19 16:06:23 - STARTED: IMG_20250601_192845.jpg 2025-06-19 16:06:43 - STARTED: IMG_20250601_185017.jpg +2025-06-19 16:39:23 - STARTED: IMG-20250526-WA0003.jpg +2025-06-19 16:39:23 - STARTED: IMG-20250602-WA0011.jpg diff --git a/src/__pycache__/python_functions.cpython-311.pyc b/src/__pycache__/python_functions.cpython-311.pyc index 22747cfd37b9e57646100b4bd0c84ee4040d5d9e..5056009d0915b2c67fd176c768046c049a9eebf4 100644 GIT binary patch delta 1441 zcmah|O-vg{6n?XR%wl6Zcx^Vu#!Ik59qNz}$PZvsfl?y1%}>*$LW+beHgW7YYqZ{m zlB`1xJ@!B~ZPPX&aiUepCE8=8DyjtJR**PENKw^W50%QLr(8N?wD_m3I;(y2&3oUx z_s!q0*MI-m_kCMiE6{ec{iEBX(PusZ4;li%W3Ui&@3&Rjt+@lJfDLBY;tw29;K<^U zh+@N4kfABC!gcmbHR==4c?;K%m-!0P1slH=g}3}s>aBOGi5HQXkiiyKyyT>! zkQ=gJ6m4+@v(aVUlY=G=lGW+f1+XP6S{pSo%_S>di|O9aD4Xoa-D3^g=rZ)SRl5Ca z2S0SbzX6JT~%aQ*3BFVqqRZTtk5x#o0JRBi=7#71Jj zpF?x-DL(~ss6J6$9%cWQEEs304xd|_>Ik{G5O&c&71bpQ{f{8rEQmdmWcYsn`=zX| zktuKATfMXM*6orped`lr#>$tB^00QToHue>u{4t{YO}@cd@*0Pj*}~X#d+*~fY4

+;wHTHe(*;3NmIJ1K@TR8K|AKSt)=a0Y_+`=9PZ)8h2T)s=Q{4lOe zrs3!GxcY7i)!z^)NP(4@2Nf7 zID;8#%IqC$n#r!Y+3%X1^Q}50p)vAH*OF(Dc~3EOn%s+bNuvy=$#?P7=pC{hA3?U$ zrgchakR*?OfR@SJ(PwCgBzwO`Upg;(zd{pi?yl!f{@(oYVkwuqX`1YTm;q*nnTb>h vGbQ6zJ~yprt*lwCd4k1GGBZHFNya30Bxb+!JozE=51_~%9GC)$_D%c^G|2r< delta 1213 zcmah|OHUL*5U!r*&OTX~eZacx;I1Mdf(yt?G=dzeK_7go-@pSxUk zAfv{9?n+Z=&du4xCJtZNno%~9C#@z;}?>L?N4l<3~>XJr>44L(-_~GI-JeW(E=AWab6}Jz`;ms3c)`oH`@{twOK}iUTu5UU;xe&W0g<$<=;^3uv;IIwoXuA9)D!2a zr#?dPVnFV6vWpdgPLX{t@|{j|LUyodz?=@m5NgD4fKB%m5R zzxOnndQdutYVmyOBpNqQ?t6$(9IupxN*ifb5i!e-zQOe6f&N}Kp(nJp;#HKZrsg0n cDGv*@wOWgLy!_;W5ux>8lXBBO~0WV|TAOHXW diff --git a/src/python_functions.py b/src/python_functions.py index 2ccf9fa..88e5a10 100644 --- a/src/python_functions.py +++ b/src/python_functions.py @@ -49,6 +49,12 @@ Logger.info(f"python_functions: Configuration status: {config_status}") def load_playlist(): """Load playlist from the server or local storage.""" + # Check if the local playlist exists and is valid + local_playlist = load_local_playlist() + if local_playlist: + Logger.info("python_functions: Using local playlist.") + return local_playlist # Skip server download if local playlist is valid + try: Logger.info("python_functions: Attempting to load playlist from server...") server_ip = f'{server}:{port}' # Construct the server IP with port @@ -91,7 +97,7 @@ def load_playlist(): Logger.error(f"python_functions: Failed to load playlist: {e}") # Fallback to local playlist - return load_local_playlist() + return local_playlist def load_local_playlist():