Complete auto-startup installation system for Raspberry Pi Zero
- Enhanced install_minimal_xorg.sh with full automatic startup configuration - Added systemd service for robust signage player auto-start - Configured autologin and X server auto-launch on boot - Added multiple startup methods (systemd, bashrc, rc.local) for reliability - Disabled screen blanking and power management for kiosk operation - Updated requirements.txt with proper version specifications - Fixed run_tkinter_debug.sh for correct directory structure - Added comprehensive logging and error handling - Optimized for headless Raspberry Pi Zero deployment Features: ✅ Plug-and-play operation - boots directly to signage player ✅ Automatic restart on crashes ✅ Multiple fallback startup methods ✅ Complete dependency installation ✅ Service management commands ✅ Hardware optimizations for digital signage
This commit is contained in:
255
install_minimal_xorg.sh
Normal file → Executable file
255
install_minimal_xorg.sh
Normal file → Executable file
@@ -1,34 +1,265 @@
|
||||
#!/bin/bash
|
||||
# Minimal installer for Raspberry Pi OS (no desktop environment)
|
||||
# Installs Xorg, Openbox, disables power saving, and configures auto-launch of the signage player
|
||||
# Compatible with Raspberry Pi Zero and all Pi models
|
||||
|
||||
set -e
|
||||
|
||||
USER_HOME="/home/pi"
|
||||
PROJECT_DIR="$USER_HOME/Desktop/signage-player"
|
||||
APP_LAUNCH_SCRIPT="$PROJECT_DIR/run_tkinter_app.sh"
|
||||
PROJECT_DIR="$USER_HOME/Desktop/tkinter_player"
|
||||
APP_LAUNCH_SCRIPT="$PROJECT_DIR/run_tkinter_debug.sh"
|
||||
|
||||
echo "=== Installing Tkinter Player on Raspberry Pi ==="
|
||||
echo "Project directory: $PROJECT_DIR"
|
||||
|
||||
# Update system
|
||||
echo "Updating system packages..."
|
||||
sudo apt update
|
||||
sudo apt upgrade -y
|
||||
|
||||
# Install minimal X server and Openbox
|
||||
# Install minimal X server and window manager
|
||||
echo "Installing minimal X server and Openbox window manager..."
|
||||
sudo apt install -y xorg openbox
|
||||
|
||||
# Install VLC for video playback
|
||||
sudo apt install -y vlc
|
||||
# Install VLC for video playback with essential codecs
|
||||
echo "Installing VLC media player and codecs..."
|
||||
sudo apt install -y vlc vlc-plugin-base vlc-plugin-video-output
|
||||
|
||||
# Install Python and dependencies
|
||||
sudo apt install -y python3 python3-pip python3-venv python3-tk ffmpeg libopencv-dev python3-opencv \
|
||||
libsdl2-dev libsdl2-mixer-dev libsdl2-image-dev libsdl2-ttf-dev \
|
||||
libjpeg-dev zlib1g-dev libfreetype6-dev liblcms2-dev libwebp-dev tcl8.6-dev tk8.6-dev
|
||||
# Install Python and system dependencies for tkinter app
|
||||
echo "Installing Python and system libraries..."
|
||||
sudo apt install -y \
|
||||
python3 \
|
||||
python3-pip \
|
||||
python3-venv \
|
||||
python3-tk \
|
||||
python3-pil \
|
||||
python3-pil.imagetk \
|
||||
ffmpeg \
|
||||
libjpeg-dev \
|
||||
zlib1g-dev \
|
||||
libfreetype6-dev \
|
||||
liblcms2-dev \
|
||||
libwebp-dev \
|
||||
tcl8.6-dev \
|
||||
tk8.6-dev \
|
||||
libxss1 \
|
||||
libgconf-2-4 \
|
||||
libxrandr2 \
|
||||
libasound2-dev \
|
||||
libpangocairo-1.0-0 \
|
||||
libatk1.0-0 \
|
||||
libcairo-gobject2 \
|
||||
libgtk-3-0 \
|
||||
libgdk-pixbuf2.0-0
|
||||
|
||||
# Install build dependencies for Python packages
|
||||
echo "Installing build dependencies..."
|
||||
sudo apt install -y \
|
||||
build-essential \
|
||||
libffi-dev \
|
||||
libssl-dev \
|
||||
python3-dev \
|
||||
pkg-config
|
||||
|
||||
# Create virtual environment and install Python requirements
|
||||
echo "Setting up Python virtual environment..."
|
||||
cd "$PROJECT_DIR"
|
||||
python3 -m venv venv
|
||||
|
||||
# Create venv if it doesn't exist
|
||||
if [ ! -d "venv" ]; then
|
||||
python3 -m venv venv
|
||||
fi
|
||||
|
||||
# Activate virtual environment
|
||||
source venv/bin/activate
|
||||
|
||||
# Upgrade pip
|
||||
pip install --upgrade pip
|
||||
pip install -r tkinter_requirements.txt
|
||||
|
||||
# Install Python requirements
|
||||
echo "Installing Python packages..."
|
||||
pip install requests
|
||||
pip install bcrypt
|
||||
pip install python-vlc
|
||||
chmod +x "$APP_LAUNCH_SCRIPT"
|
||||
pip install pyautogui
|
||||
pip install Pillow
|
||||
|
||||
# Install additional packages that might be needed
|
||||
pip install psutil
|
||||
|
||||
# Make launch script executable if it exists
|
||||
if [ -f "$APP_LAUNCH_SCRIPT" ]; then
|
||||
chmod +x "$APP_LAUNCH_SCRIPT"
|
||||
echo "Made $APP_LAUNCH_SCRIPT executable"
|
||||
fi
|
||||
|
||||
deactivate
|
||||
|
||||
# Configure X server for headless operation
|
||||
echo "Configuring X server for auto-start..."
|
||||
sudo tee /etc/X11/xorg.conf > /dev/null << 'EOF'
|
||||
Section "ServerLayout"
|
||||
Identifier "Layout0"
|
||||
Screen 0 "Screen0" 0 0
|
||||
EndSection
|
||||
|
||||
Section "Device"
|
||||
Identifier "Device0"
|
||||
Driver "fbdev"
|
||||
Option "fbdev" "/dev/fb0"
|
||||
EndSection
|
||||
|
||||
Section "Screen"
|
||||
Identifier "Screen0"
|
||||
Device "Device0"
|
||||
Monitor "Monitor0"
|
||||
DefaultDepth 24
|
||||
SubSection "Display"
|
||||
Depth 24
|
||||
Modes "1920x1080" "1680x1050" "1280x1024" "1024x768"
|
||||
EndSubSection
|
||||
EndSection
|
||||
|
||||
Section "Monitor"
|
||||
Identifier "Monitor0"
|
||||
HorizSync 30-70
|
||||
VertRefresh 50-75
|
||||
EndSection
|
||||
EOF
|
||||
|
||||
# Create autostart script for signage player
|
||||
echo "Creating autostart configuration..."
|
||||
mkdir -p "$USER_HOME/.config/openbox"
|
||||
|
||||
cat > "$USER_HOME/.config/openbox/autostart" << 'EOF'
|
||||
# Disable screen blanking and power management
|
||||
xset s off
|
||||
xset -dpms
|
||||
xset s noblank
|
||||
|
||||
# Hide cursor after 1 second of inactivity
|
||||
unclutter -idle 1 -root &
|
||||
|
||||
# Wait a moment for X to fully initialize
|
||||
sleep 2
|
||||
|
||||
# Launch the signage player
|
||||
cd /home/pi/Desktop/tkinter_player
|
||||
./run_tkinter_debug.sh &
|
||||
EOF
|
||||
|
||||
chmod +x "$USER_HOME/.config/openbox/autostart"
|
||||
|
||||
# Install unclutter for hiding mouse cursor
|
||||
echo "Installing cursor hiding utility..."
|
||||
sudo apt install -y unclutter
|
||||
|
||||
# Configure automatic boot to GUI (signage player)
|
||||
echo "Configuring automatic startup on boot..."
|
||||
|
||||
# Create systemd service for auto-starting X and the signage player
|
||||
sudo tee /etc/systemd/system/signage-player.service > /dev/null << 'EOF'
|
||||
[Unit]
|
||||
Description=Digital Signage Player
|
||||
After=multi-user.target
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
User=pi
|
||||
Environment=HOME=/home/pi
|
||||
Environment=XDG_RUNTIME_DIR=/tmp/runtime-pi
|
||||
WorkingDirectory=/home/pi/Desktop/tkinter_player
|
||||
ExecStartPre=/bin/mkdir -p /tmp/runtime-pi
|
||||
ExecStartPre=/bin/chown pi:pi /tmp/runtime-pi
|
||||
ExecStart=/bin/bash -c 'DISPLAY=:0 startx'
|
||||
Restart=always
|
||||
RestartSec=10
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
EOF
|
||||
|
||||
# Enable the service to start on boot
|
||||
sudo systemctl enable signage-player.service
|
||||
|
||||
# Configure autologin for pi user (required for auto X start)
|
||||
echo "Configuring autologin for pi user..."
|
||||
sudo systemctl set-default multi-user.target
|
||||
|
||||
# Create getty override to enable autologin
|
||||
sudo mkdir -p /etc/systemd/system/getty@tty1.service.d
|
||||
sudo tee /etc/systemd/system/getty@tty1.service.d/override.conf > /dev/null << 'EOF'
|
||||
[Service]
|
||||
ExecStart=
|
||||
ExecStart=-/sbin/agetty --autologin pi --noclear %I $TERM
|
||||
EOF
|
||||
|
||||
# Configure bash profile to start X automatically on tty1
|
||||
echo "Configuring automatic X server startup..."
|
||||
cat >> "$USER_HOME/.bashrc" << 'EOF'
|
||||
|
||||
# Auto-start X server for signage player (only on tty1)
|
||||
if [ -z "$DISPLAY" ] && [ "$XDG_VTNR" = "1" ]; then
|
||||
echo "Starting X server for digital signage..."
|
||||
exec startx
|
||||
fi
|
||||
EOF
|
||||
|
||||
# Disable screen blanking in boot config
|
||||
echo "Disabling screen blanking and power management..."
|
||||
if ! grep -q "disable_splash=1" /boot/config.txt; then
|
||||
echo "disable_splash=1" | sudo tee -a /boot/config.txt
|
||||
fi
|
||||
if ! grep -q "avoid_warnings=1" /boot/config.txt; then
|
||||
echo "avoid_warnings=1" | sudo tee -a /boot/config.txt
|
||||
fi
|
||||
|
||||
# Configure console blanking
|
||||
sudo tee -a /boot/cmdline.txt << 'EOF'
|
||||
consoleblank=0 logo.nologo quiet loglevel=0
|
||||
EOF
|
||||
|
||||
# Create a backup startup script in rc.local as fallback
|
||||
echo "Creating fallback startup in rc.local..."
|
||||
sudo cp /etc/rc.local /etc/rc.local.backup 2>/dev/null || true
|
||||
|
||||
sudo tee /etc/rc.local > /dev/null << 'EOF'
|
||||
#!/bin/sh -e
|
||||
#
|
||||
# rc.local - executed at the end of each multiuser runlevel
|
||||
|
||||
# Disable HDMI power saving
|
||||
/usr/bin/tvservice -p
|
||||
|
||||
# Ensure runtime directory exists
|
||||
mkdir -p /tmp/runtime-pi
|
||||
chown pi:pi /tmp/runtime-pi
|
||||
|
||||
# Start X server as pi user if not already running (fallback)
|
||||
if ! pgrep -x "Xorg" > /dev/null; then
|
||||
su - pi -c 'DISPLAY=:0 startx' &
|
||||
fi
|
||||
|
||||
exit 0
|
||||
EOF
|
||||
|
||||
sudo chmod +x /etc/rc.local
|
||||
|
||||
echo "=== Installation Complete ==="
|
||||
echo ""
|
||||
echo "✅ Digital Signage Player configured for automatic startup!"
|
||||
echo ""
|
||||
echo "The system will now:"
|
||||
echo "1. Auto-login as 'pi' user on boot"
|
||||
echo "2. Automatically start X server"
|
||||
echo "3. Launch the signage player application"
|
||||
echo "4. Restart the player if it crashes"
|
||||
echo ""
|
||||
echo "To test the setup:"
|
||||
echo "- Reboot the system: sudo reboot"
|
||||
echo "- The signage player should start automatically"
|
||||
echo ""
|
||||
echo "Manual controls:"
|
||||
echo "- Stop service: sudo systemctl stop signage-player"
|
||||
echo "- Check status: sudo systemctl status signage-player"
|
||||
echo "- View logs: journalctl -u signage-player -f"
|
||||
|
||||
@@ -1,5 +1,18 @@
|
||||
# Core requirements for tkinter_player signage app
|
||||
requests
|
||||
bcrypt
|
||||
python-vlc
|
||||
pyautogui
|
||||
# Network and API requirements
|
||||
requests>=2.28.0
|
||||
|
||||
# Security and encryption
|
||||
bcrypt>=4.0.0
|
||||
|
||||
# Media playback
|
||||
python-vlc>=3.0.16120
|
||||
|
||||
# GUI automation and system control
|
||||
pyautogui>=0.9.54
|
||||
|
||||
# Image processing (PIL/Pillow)
|
||||
Pillow>=9.3.0
|
||||
|
||||
# System monitoring
|
||||
psutil>=5.9.0
|
||||
|
||||
@@ -1,14 +1,40 @@
|
||||
#!/bin/bash
|
||||
# Debugging launch script for the tkinter player application
|
||||
|
||||
# Activate the virtual environment
|
||||
source venv/bin/activate
|
||||
# Set working directory to script location
|
||||
cd "$(dirname "$0")"
|
||||
|
||||
# Change to the tkinter app src directory
|
||||
cd signage_player/src
|
||||
# Activate the virtual environment if it exists
|
||||
if [ -d "venv" ]; then
|
||||
source venv/bin/activate
|
||||
echo "Virtual environment activated"
|
||||
else
|
||||
echo "Warning: No virtual environment found, using system Python"
|
||||
fi
|
||||
|
||||
# Set environment variables for better display on Raspberry Pi
|
||||
export DISPLAY=${DISPLAY:-:0.0}
|
||||
export XDG_RUNTIME_DIR=${XDG_RUNTIME_DIR:-/tmp/runtime-pi}
|
||||
|
||||
# Change to the signage_player directory
|
||||
cd signage_player
|
||||
|
||||
# Run the main application with full error output
|
||||
python main.py
|
||||
echo "Starting tkinter player..."
|
||||
echo "Working directory: $(pwd)"
|
||||
echo "Python path: $(which python3)"
|
||||
echo "Display: $DISPLAY"
|
||||
|
||||
# Run with error logging
|
||||
python3 main.py 2>&1 | tee ../main_data/app_debug.log
|
||||
|
||||
# Capture exit code
|
||||
EXIT_CODE=$?
|
||||
|
||||
# Deactivate virtual environment when done
|
||||
deactivate
|
||||
if [ -d "../venv" ]; then
|
||||
deactivate
|
||||
fi
|
||||
|
||||
echo "Application exited with code: $EXIT_CODE"
|
||||
exit $EXIT_CODE
|
||||
Reference in New Issue
Block a user