Server-side PPTX shift: Docs updated (README, copilot instructions) to reflect PDF-only workflow; legacy LibreOffice paths marked optional.

Setup improvements: Added pi-setup.sh (clone-before-venv, requirements-based install) + HDMI-CEC cec-utils inclusion.
Dependencies: Corrected python-dotenv, added server-side rendering + CEC notes in requirements.txt.
CEC integration: Confirmed and documented usage; minor wording adjustments.
This commit is contained in:
RobbStarkAustria
2025-11-23 11:14:35 +01:00
parent 6617c3d7b9
commit d14789b1f4
6 changed files with 165 additions and 330 deletions

View File

@@ -1,319 +0,0 @@
#!/bin/bash
# pi-dev-setup.sh - Complete development environment setup for Raspberry Pi
set -e
echo "🍓 Setting up Raspberry Pi development environment for infoscreen client..."
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color
# Configuration
PROJECT_DIR="$HOME/infoscreen-dev"
VENV_DIR="$PROJECT_DIR/venv"
print_step() {
echo -e "${BLUE}📋 $1${NC}"
}
print_success() {
echo -e "${GREEN}$1${NC}"
}
print_warning() {
echo -e "${YELLOW}⚠️ $1${NC}"
}
# Step 1: System Update
print_step "Updating system packages..."
sudo apt update && sudo apt upgrade -y
print_success "System updated"
# Step 2: Install development tools
print_step "Installing development tools..."
sudo apt install -y \
git \
vim \
nano \
htop \
curl \
wget \
tmux \
screen \
tree \
unzip
print_success "Development tools installed"
# Step 3: Install Python and development dependencies
print_step "Installing Python development environment..."
sudo apt install -y \
python3 \
python3-pip \
python3-venv \
python3-dev \
build-essential
print_success "Python environment installed"
# Step 4: Install presentation and display tools
print_step "Installing presentation tools..."
sudo apt install -y \
chromium-browser \
libreoffice \
vlc \
feh \
scrot \
imagemagick \
xdotool \
wmctrl
print_success "Presentation tools installed"
# Step 5: Install MQTT tools for debugging
print_step "Installing MQTT tools..."
sudo apt install -y mosquitto-clients
print_success "MQTT tools installed"
# Step 6: Create project directory
print_step "Setting up project directory..."
mkdir -p "$PROJECT_DIR"/{config,presentation,logs,screenshots,scripts}
cd "$PROJECT_DIR"
print_success "Project directory created: $PROJECT_DIR"
# Step 7: Create Python virtual environment
print_step "Creating Python virtual environment..."
python3 -m venv "$VENV_DIR"
source "$VENV_DIR/bin/activate"
pip install --upgrade pip
print_success "Virtual environment created"
# Step 8: Install Python packages
print_step "Installing Python packages..."
pip install \
paho-mqtt \
requests \
python-dotenv \
watchdog
print_success "Python packages installed"
# Step 9: Install Docker (optional, for testing containers)
print_step "Installing Docker..."
if ! command -v docker &> /dev/null; then
curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh get-docker.sh
sudo usermod -aG docker $USER
rm get-docker.sh
print_success "Docker installed (requires logout/login)"
else
print_success "Docker already installed"
fi
# Step 10: Configure Git (if not already configured)
print_step "Configuring Git..."
if [ -z "$(git config --global user.name 2>/dev/null)" ]; then
echo "Enter your Git username:"
read -r git_username
git config --global user.name "$git_username"
fi
if [ -z "$(git config --global user.email 2>/dev/null)" ]; then
echo "Enter your Git email:"
read -r git_email
git config --global user.email "$git_email"
fi
print_success "Git configured"
# Step 11: Clone your repository
print_step "Cloning infoscreen client repository..."
if [ ! -d "$PROJECT_DIR/src" ]; then
git clone https://github.com/RobbStarkAustria/infoscreen_client_2025.git "$PROJECT_DIR/src"
print_success "Repository cloned to $PROJECT_DIR/src"
# Copy environment template and create .env
if [ -f "$PROJECT_DIR/src/.env.template" ]; then
cp "$PROJECT_DIR/src/.env.template" "$PROJECT_DIR/.env"
print_success "Environment template copied to .env"
fi
else
print_warning "Source directory already exists"
fi
# Step 12: Customize environment file
print_step "Customizing environment file..."
if [ -f "$PROJECT_DIR/.env" ]; then
# Update MQTT broker IP if needed
echo "Current MQTT broker in .env: $(grep MQTT_BROKER $PROJECT_DIR/.env | cut -d'=' -f2)"
echo "If you need to change the MQTT broker IP, edit: nano $PROJECT_DIR/.env"
print_success "Environment file ready for customization"
else
print_warning "Environment file not found, you may need to create it manually"
fi
# Step 13: Create development scripts
print_step "Creating development helper scripts..."
# Start development script
cat > "$PROJECT_DIR/scripts/start-dev.sh" << 'EOF'
#!/bin/bash
cd "$(dirname "$0")/.."
source venv/bin/activate
export $(cat .env | xargs)
python3 src/simclient.py
EOF
chmod +x "$PROJECT_DIR/scripts/start-dev.sh"
# Screenshot test script
cat > "$PROJECT_DIR/scripts/test-screenshot.sh" << 'EOF'
#!/bin/bash
SCREENSHOT_DIR="$(dirname "$0")/../screenshots"
mkdir -p "$SCREENSHOT_DIR"
# Ensure DISPLAY is set for screenshot capture
if [ -z "$DISPLAY" ]; then
export DISPLAY=:0
fi
# Test screenshot capture
echo "Testing screenshot capture with DISPLAY=$DISPLAY"
if scrot "$SCREENSHOT_DIR/test_$(date +%Y%m%d_%H%M%S).png" 2>/dev/null; then
echo "✅ Screenshot captured successfully"
echo "📁 Screenshot saved to: $SCREENSHOT_DIR"
ls -la "$SCREENSHOT_DIR"/test_*.png | tail -1
else
echo "❌ Screenshot failed with scrot, trying imagemagick..."
if import -window root "$SCREENSHOT_DIR/test_$(date +%Y%m%d_%H%M%S).png" 2>/dev/null; then
echo "✅ Screenshot captured with imagemagick"
echo "📁 Screenshot saved to: $SCREENSHOT_DIR"
ls -la "$SCREENSHOT_DIR"/test_*.png | tail -1
else
echo "❌ Screenshot capture failed. Check DISPLAY variable and X11 access."
echo "💡 Try: export DISPLAY=:0"
echo "💡 Or run from local Pi terminal instead of SSH"
fi
fi
EOF
chmod +x "$PROJECT_DIR/scripts/test-screenshot.sh"
# MQTT test script
cat > "$PROJECT_DIR/scripts/test-mqtt.sh" << 'EOF'
#!/bin/bash
source "$(dirname "$0")/../.env"
echo "Testing MQTT connection to $MQTT_BROKER:$MQTT_PORT"
echo "Publishing test message..."
mosquitto_pub -h "$MQTT_BROKER" -p "$MQTT_PORT" -t "infoscreen/test" -m "Hello from Pi development setup"
echo "Subscribing to test topic (press Ctrl+C to stop)..."
mosquitto_sub -h "$MQTT_BROKER" -p "$MQTT_PORT" -t "infoscreen/test"
EOF
chmod +x "$PROJECT_DIR/scripts/test-mqtt.sh"
# Presentation test script
cat > "$PROJECT_DIR/scripts/test-presentation.sh" << 'EOF'
#!/bin/bash
PRES_DIR="$(dirname "$0")/../presentation"
mkdir -p "$PRES_DIR"
echo "Testing presentation capabilities..."
# Test LibreOffice
if command -v libreoffice &> /dev/null; then
echo "✅ LibreOffice available"
else
echo "❌ LibreOffice not found"
fi
# Test Chromium
if command -v chromium-browser &> /dev/null; then
echo "✅ Chromium available"
echo "Testing kiosk mode (will open for 5 seconds)..."
chromium-browser --kiosk --app=https://www.google.com &
CHROME_PID=$!
sleep 5
kill $CHROME_PID 2>/dev/null || true
else
echo "❌ Chromium not found"
fi
# Test VLC
if command -v vlc &> /dev/null; then
echo "✅ VLC available"
else
echo "❌ VLC not found"
fi
echo "Presentation test complete"
EOF
chmod +x "$PROJECT_DIR/scripts/test-presentation.sh"
print_success "Development scripts created"
# Step 14: Create systemd service for development (optional)
print_step "Creating systemd service template..."
sudo tee /etc/systemd/system/infoscreen-dev.service << EOF
[Unit]
Description=Infoscreen Development Client
After=network.target
[Service]
Type=simple
User=pi
WorkingDirectory=$PROJECT_DIR
Environment=PATH=$VENV_DIR/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
ExecStart=$VENV_DIR/bin/python $PROJECT_DIR/src/simclient.py
Restart=on-failure
RestartSec=5
[Install]
WantedBy=multi-user.target
EOF
print_success "Systemd service created (disabled by default)"
# Step 15: Set up remote development access
print_step "Configuring SSH for remote development..."
# Enable SSH if not already enabled
sudo systemctl enable ssh
sudo systemctl start ssh
# Create SSH key if it doesn't exist
if [ ! -f "$HOME/.ssh/id_rsa" ]; then
ssh-keygen -t rsa -b 4096 -f "$HOME/.ssh/id_rsa" -N ""
print_success "SSH key generated"
fi
print_success "SSH configured for remote access"
# Final summary
echo ""
echo -e "${GREEN}🎉 Development environment setup complete!${NC}"
echo ""
echo -e "${YELLOW}📂 Project structure:${NC}"
tree -L 2 "$PROJECT_DIR" 2>/dev/null || ls -la "$PROJECT_DIR"
echo ""
echo -e "${YELLOW}🚀 Quick start commands:${NC}"
echo " cd $PROJECT_DIR"
echo " source venv/bin/activate"
echo " ./scripts/start-dev.sh"
echo ""
echo -e "${YELLOW}🧪 Test commands:${NC}"
echo " ./scripts/test-screenshot.sh # Test screenshot capture"
echo " ./scripts/test-mqtt.sh # Test MQTT connection"
echo " ./scripts/test-presentation.sh # Test presentation tools"
echo ""
echo -e "${YELLOW}🔧 Development workflow:${NC}"
echo " 1. Edit code in: $PROJECT_DIR/src/"
echo " 2. Test with: ./scripts/start-dev.sh"
echo " 3. View logs in: $PROJECT_DIR/logs/"
echo ""
echo -e "${YELLOW}🌐 Remote development:${NC}"
echo " SSH: ssh pi@$(hostname -I | awk '{print $1}')"
echo " VS Code Remote-SSH recommended"
echo ""
if groups $USER | grep -q docker; then
echo -e "${GREEN}✅ Docker available for container testing${NC}"
else
echo -e "${YELLOW}⚠️ Logout and login again to use Docker${NC}"
fi

148
src/pi-setup.sh Normal file
View File

@@ -0,0 +1,148 @@
#!/bin/bash
# pi-setup.sh - Concise Raspberry Pi environment setup for Infoscreen Client
set -e
echo "🍓 Infoscreen Client Raspberry Pi setup starting..."
# Colors
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[38;5;81m' # Match pi-dev-setup-new.sh accent blue
RED='\033[0;31m'
NC='\033[0m'
log_step() { echo -e "${BLUE}📋 $1${NC}"; }
log_ok() { echo -e "${GREEN}$1${NC}"; }
log_warn() { echo -e "${YELLOW}⚠️ $1${NC}"; }
log_err() { echo -e "${RED}$1${NC}"; }
# Configuration
PROJECT_DIR="$HOME/infoscreen-dev"
REPO_URL="https://github.com/RobbStarkAustria/infoscreen-client-dev-2025.git" # Public HTTPS clone
VENV_DIR="$PROJECT_DIR/venv"
REQ_FILE="$PROJECT_DIR/src/requirements.txt"
# 1. Update system
log_step "Updating system packages..."
sudo apt update && sudo apt -y upgrade
log_ok "System updated"
# 2. Base development tools
log_step "Installing development tools..."
sudo apt install -y git vim nano htop curl wget tmux screen tree unzip
log_ok "Development tools installed"
# 3. Display / presentation dependencies
log_step "Installing presentation & display tools (incl. HDMI-CEC)..."
sudo apt install -y chromium-browser libreoffice vlc feh scrot imagemagick xdotool wmctrl cec-utils
log_ok "Presentation + HDMI-CEC tools installed (cec-utils)"
# 4. MQTT tools
log_step "Installing MQTT tools..."
sudo apt install -y mosquitto-clients
log_ok "MQTT tools installed"
# 5. Clone repository BEFORE creating venv (required for requirements.txt)
log_step "Cloning repository (if missing)..."
if [ ! -d "$PROJECT_DIR/.git" ]; then
if [ -d "$PROJECT_DIR" ] && [ "$(ls -A "$PROJECT_DIR" 2>/dev/null)" ]; then
log_warn "Directory $PROJECT_DIR exists and is not empty; skipping clone."
else
git clone "$REPO_URL" "$PROJECT_DIR"
log_ok "Repository cloned to $PROJECT_DIR"
fi
else
log_warn "Git repo already present; pulling latest..."
(cd "$PROJECT_DIR" && git pull --ff-only || log_warn "Git pull failed; continuing with existing code")
fi
# 6. Python + build essentials
log_step "Ensuring Python build prerequisites..."
sudo apt install -y python3 python3-pip python3-venv python3-dev build-essential
log_ok "Python prerequisites installed"
# 7. Create virtual environment
log_step "Creating virtual environment..."
python3 -m venv "$VENV_DIR"
source "$VENV_DIR/bin/activate"
python -m pip install --upgrade pip
log_ok "Virtual environment ready"
# 8. Install Python requirements from requirements.txt (no hardcoded list)
log_step "Installing Python requirements..."
if [ -f "$REQ_FILE" ]; then
pip install -r "$REQ_FILE"
log_ok "Requirements installed from $REQ_FILE"
else
log_err "Missing requirements file: $REQ_FILE"
exit 1
fi
# 9. Optional: Docker
log_step "Checking Docker installation..."
if ! command -v docker >/dev/null 2>&1; then
curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh get-docker.sh
sudo usermod -aG docker "$USER"
rm get-docker.sh
log_ok "Docker installed (logout/login required to activate group)"
else
log_ok "Docker already installed"
fi
# 10. Git user configuration (skip if already set)
log_step "Configuring Git (if needed)..."
if [ -z "$(git config --global user.name 2>/dev/null)" ]; then
read -rp "Enter your Git username: " git_username
git config --global user.name "$git_username"
fi
if [ -z "$(git config --global user.email 2>/dev/null)" ]; then
read -rp "Enter your Git email: " git_email
git config --global user.email "$git_email"
fi
log_ok "Git configuration complete"
# 11. Environment file hint
log_step "Checking .env configuration..."
if [ -f "$PROJECT_DIR/.env" ]; then
BROKER=$(grep -E '^MQTT_BROKER=' "$PROJECT_DIR/.env" | cut -d'=' -f2)
log_ok ".env found (MQTT_BROKER=${BROKER:-unset})"
else
log_warn ".env not found. Create one (refer to README)."
fi
# 12. Helper scripts (only ensure start-dev exists, keep minimal)
log_step "Creating minimal helper script (start-dev.sh)..."
mkdir -p "$PROJECT_DIR/scripts"
cat > "$PROJECT_DIR/scripts/start-dev.sh" <<'EOF'
#!/bin/bash
cd "$(dirname "$0")/.." || exit 1
if [ -f .env ]; then export $(grep -v '^#' .env | xargs); fi
source venv/bin/activate
python3 src/simclient.py
EOF
chmod +x "$PROJECT_DIR/scripts/start-dev.sh"
log_ok "start-dev.sh created"
# 13. SSH enable (for remote dev)
log_step "Ensuring SSH service enabled..."
sudo systemctl enable ssh >/dev/null 2>&1 || true
sudo systemctl start ssh >/dev/null 2>&1 || true
log_ok "SSH service active"
# 14. Summary
echo ""
echo -e "${GREEN}🎉 Setup complete!${NC}"
echo "Project: $PROJECT_DIR"
echo "Activate: source $VENV_DIR/bin/activate"
echo "Run: ./scripts/start-dev.sh"
echo "Logs: $PROJECT_DIR/logs/"
echo "Repo remote: $REPO_URL"
if groups "$USER" | grep -q docker; then
echo "Docker ready (if just added, re-login)."
else
echo "Docker group pending (logout/login to use)."
fi
exit 0

View File

@@ -1,7 +1,10 @@
paho-mqtt
dotenv
python-dotenv # renamed from 'dotenv' (actual PyPI package name)
requests
pygame>=2.0.0
pillow>=8.0.0
websocket-client>=1.6.0
python-vlc>=3.0.0
# Impressive runtime dependencies (needed even if not directly imported in our code)
pygame>=2.0.0
pillow>=8.0.0
# HDMI-CEC: uses system package `cec-utils` (apt install cec-utils); no PyPI dep required.
# PPTX→PDF now rendered server-side. No local LibreOffice or conversion library required.