created virtual env
This commit is contained in:
238
install.sh
238
install.sh
@@ -3,17 +3,11 @@
|
||||
# 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
|
||||
VENV_DIR="$PROJECT_DIR/venv" # Path to the virtual environment
|
||||
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
|
||||
@@ -65,20 +59,30 @@ 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 6: Install Python virtual environment tools
|
||||
echo "Installing Python virtual environment tools..."
|
||||
sudo apt-get install -y python3-venv python3-pip
|
||||
|
||||
# Step 7: Install system dependencies for ffpyplayer
|
||||
# Step 7: Create a virtual environment
|
||||
echo "Creating a Python virtual environment in $VENV_DIR..."
|
||||
python3 -m venv "$VENV_DIR"
|
||||
|
||||
# Step 8: Activate the virtual environment and install dependencies
|
||||
echo "Activating the virtual environment and installing dependencies..."
|
||||
source "$VENV_DIR/bin/activate"
|
||||
pip install --upgrade pip
|
||||
pip install -r requirements.txt
|
||||
|
||||
# Step 9: 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 10: Install ffpyplayer in the virtual environment
|
||||
echo "Installing ffpyplayer in the virtual environment..."
|
||||
pip install ffpyplayer
|
||||
|
||||
# Step 9: Create a systemd service for autostart
|
||||
# Step 11: 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
|
||||
@@ -87,7 +91,7 @@ Description=Kivy Media Player
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
ExecStart=/usr/bin/python3 $PROJECT_DIR/src/main.py
|
||||
ExecStart=$VENV_DIR/bin/python3 $PROJECT_DIR/src/main.py
|
||||
WorkingDirectory=$PROJECT_DIR
|
||||
Restart=always
|
||||
User=pi
|
||||
@@ -98,211 +102,13 @@ Environment=XAUTHORITY=/home/pi/.Xauthority
|
||||
WantedBy=multi-user.target
|
||||
EOL
|
||||
|
||||
# Step 10: Enable and start the service
|
||||
# Step 12: 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 11: 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"
|
||||
# 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" <<EOL
|
||||
[Unit]
|
||||
Description=Kivy Media Player
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
ExecStart=/usr/bin/python3 $PROJECT_DIR/src/main.py
|
||||
WorkingDirectory=$PROJECT_DIR
|
||||
Restart=always
|
||||
User=pi
|
||||
Environment=DISPLAY=:0
|
||||
Environment=XAUTHORITY=/home/pi/.Xauthority
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
EOL
|
||||
|
||||
# Step 10: 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 11: 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"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
|
||||
sudo apt-get install -y 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" <<EOL
|
||||
[Unit]
|
||||
Description=Kivy Media Player
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
ExecStart=/usr/bin/python3 $PROJECT_DIR/src/main.py
|
||||
WorkingDirectory=$PROJECT_DIR
|
||||
Restart=always
|
||||
User=pi
|
||||
Environment=DISPLAY=:0
|
||||
Environment=XAUTHORITY=/home/pi/.Xauthority
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
EOL
|
||||
|
||||
# Step 10: 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 11: Confirm installation
|
||||
# Step 13: 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"
|
||||
|
||||
@@ -2,6 +2,7 @@ from kivy.config import Config
|
||||
Config.set('kivy', 'video', 'ffpyplayer')
|
||||
Config.set('ffpyplayer', 'audio', 'on') # Enable audio
|
||||
|
||||
# Now import other Kivy modules
|
||||
from kivy.app import App
|
||||
from kivy.uix.screenmanager import ScreenManager, Screen # Import ScreenManager and Screen for managing screens
|
||||
from kivy.clock import Clock # Import Clock for scheduling tasks
|
||||
|
||||
Reference in New Issue
Block a user