- 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
266 lines
6.7 KiB
Bash
Executable File
266 lines
6.7 KiB
Bash
Executable File
#!/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/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 window manager
|
|
echo "Installing minimal X server and Openbox window manager..."
|
|
sudo apt install -y xorg openbox
|
|
|
|
# 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 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"
|
|
|
|
# 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
|
|
|
|
# Install Python requirements
|
|
echo "Installing Python packages..."
|
|
pip install requests
|
|
pip install bcrypt
|
|
pip install python-vlc
|
|
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"
|