284 lines
7.7 KiB
Markdown
284 lines
7.7 KiB
Markdown
# MYP im Kiosk-Modus
|
|
|
|
Diese Anleitung beschreibt, wie MYP (Manage Your Printer) auf einem Raspberry Pi 4 im Kiosk-Modus eingerichtet wird, sodass das System beim Booten automatisch startet.
|
|
|
|
## Voraussetzungen
|
|
|
|
- Raspberry Pi 4 (oder kompatibel) mit Raspbian/Raspberry Pi OS
|
|
- Internetverbindung für die Installation (nach der Installation wird keine Verbindung mehr benötigt)
|
|
- Bildschirm, Tastatur und Maus für die Einrichtung
|
|
- Mindestens 2GB freier Festplattenplatz
|
|
- Mindestens 512MB RAM (empfohlen: 1GB+)
|
|
|
|
## Komponenten des Kiosk-Modus
|
|
|
|
Die Kiosk-Einrichtung besteht aus mehreren Komponenten:
|
|
|
|
1. **MYP HTTPS-Backend-Dienst**: Systemd-Service zum Starten der MYP-Anwendung auf Port 5000
|
|
2. **Kiosk-Benutzer**: Separater Benutzer für den Browser-Betrieb
|
|
3. **Chromium im Kiosk-Modus**: Optimierte Browserinstanz mit erweiterten Kiosk-Features
|
|
4. **Watchdog-Services**: Mehrere Überwachungsdienste für Backend und Browser
|
|
5. **Firewall-Service**: Automatische Netzwerksicherheit
|
|
|
|
## Automatische Installation (Empfohlen)
|
|
|
|
Die automatische Installation erfolgt über das konsolidierte Setup-Script im Backend-Verzeichnis:
|
|
|
|
```bash
|
|
cd backend
|
|
sudo chmod +x setup.sh
|
|
sudo ./setup.sh
|
|
```
|
|
|
|
Das Setup-Script bietet folgende Features:
|
|
- **Robuste Installation** mit Retry-Mechanismen
|
|
- **Umfangreiches Logging** in `backend/logs/`
|
|
- **System-Validierung** vor Installation
|
|
- **Automatische Abhängigkeitsauflösung**
|
|
- **Konfiguration aller Services**
|
|
- **Firewall-Setup**
|
|
- **Automatischer Kiosk-Benutzer**
|
|
|
|
### Installation-Logs
|
|
|
|
Das Setup-Script erstellt detaillierte Logs:
|
|
- `backend/logs/install.log` - Vollständiges Installations-Log
|
|
- `backend/logs/errors.log` - Nur Fehler
|
|
- `backend/logs/warnings.log` - Nur Warnungen
|
|
- `backend/logs/debug.log` - Debug-Informationen
|
|
- `backend/logs/install-summary.txt` - Zusammenfassung
|
|
|
|
## Systemd-Services (Automatisch installiert)
|
|
|
|
Das Setup-Script installiert folgende Services:
|
|
|
|
### 1. MYP HTTPS-Backend (`myp-https.service`)
|
|
```ini
|
|
[Unit]
|
|
Description=MYP Druckerverwaltung HTTP Backend (Port 5000)
|
|
After=network-online.target
|
|
Wants=network-online.target
|
|
|
|
[Service]
|
|
Type=simple
|
|
User=root
|
|
WorkingDirectory=/opt/myp
|
|
ExecStart=/usr/bin/python3 /opt/myp/app.py --production
|
|
Restart=always
|
|
Environment=FLASK_ENV=production
|
|
Environment=FLASK_PORT=5000
|
|
Environment=KIOSK_MODE=true
|
|
|
|
[Install]
|
|
WantedBy=multi-user.target
|
|
```
|
|
|
|
### 2. Kiosk-Browser (`myp-kiosk.service`)
|
|
- Startet Chromium im optimierten Kiosk-Modus
|
|
- Wartet automatisch auf Backend-Verfügbarkeit
|
|
- Umfangreiche Browser-Optimierungen
|
|
- Automatischer Neustart bei Fehlern
|
|
|
|
### 3. Watchdog-Services
|
|
- `kiosk-watchdog.service` - Überwacht Browser und Backend
|
|
- `kiosk-watchdog-python.service` - Python-basierte Überwachung
|
|
|
|
### 4. Firewall-Service (`myp-firewall.service`)
|
|
- Automatische Netzwerksicherheit
|
|
- Port-Management
|
|
|
|
## Manuelle Installation (Nur bei Bedarf)
|
|
|
|
Falls die automatische Installation nicht verwendet werden kann:
|
|
|
|
### 1. Pakete installieren
|
|
```bash
|
|
sudo apt update
|
|
sudo apt install -y python3 python3-pip python3-venv chromium-browser \
|
|
unclutter xdotool curl git
|
|
```
|
|
|
|
### 2. MYP-Backend nach /opt/myp kopieren
|
|
```bash
|
|
sudo mkdir -p /opt/myp
|
|
sudo cp -r ./backend/* /opt/myp/
|
|
cd /opt/myp
|
|
sudo pip3 install -r requirements.txt --break-system-packages
|
|
```
|
|
|
|
### 3. Kiosk-Benutzer erstellen
|
|
```bash
|
|
sudo useradd -m -s /bin/bash kiosk
|
|
sudo usermod -a -G video,audio kiosk
|
|
```
|
|
|
|
### 4. Systemd-Services installieren
|
|
```bash
|
|
sudo cp /opt/myp/systemd/*.service /etc/systemd/system/
|
|
sudo systemctl daemon-reload
|
|
sudo systemctl enable myp-https.service
|
|
sudo systemctl enable myp-kiosk.service
|
|
sudo systemctl enable kiosk-watchdog.service
|
|
sudo systemctl enable myp-firewall.service
|
|
```
|
|
|
|
### 5. Automatischen Desktop-Login einschalten
|
|
```bash
|
|
sudo raspi-config
|
|
# 1 System Options → S5 Boot/Auto Login → B4 Desktop Autologin
|
|
```
|
|
|
|
## Ablauf beim Booten
|
|
|
|
1. **System-Start**: Raspberry Pi fährt bis zum Multi-User-Target hoch
|
|
2. **Backend-Start**: `myp-https.service` startet das Flask-Backend auf Port 5000
|
|
3. **Firewall-Start**: `myp-firewall.service` konfiguriert Netzwerksicherheit
|
|
4. **Desktop-Login**: LightDM startet und meldet den Benutzer automatisch an
|
|
5. **Kiosk-Start**: `myp-kiosk.service` wartet auf Backend und startet Chromium
|
|
6. **Watchdog-Aktivierung**: Überwachungsservices starten kontinuierliche Überwachung
|
|
|
|
## Browser-Optimierungen
|
|
|
|
Der Kiosk-Service startet Chromium mit umfangreichen Optimierungen:
|
|
|
|
### Performance-Optimierungen
|
|
- `--disable-gpu-sandbox`
|
|
- `--disable-software-rasterizer`
|
|
- `--enable-features=VaapiVideoDecoder`
|
|
- `--memory-pressure-off`
|
|
- `--max_old_space_size=512`
|
|
|
|
### Kiosk-spezifische Features
|
|
- `--kiosk` (Vollbild-Modus)
|
|
- `--hide-scrollbars`
|
|
- `--disable-pinch`
|
|
- `--no-first-run`
|
|
- `--autoplay-policy=no-user-gesture-required`
|
|
|
|
### Sicherheits-Anpassungen
|
|
- `--ignore-certificate-errors`
|
|
- `--disable-web-security` (für lokale Anwendung)
|
|
- `--no-sandbox`
|
|
|
|
## Fehlerbehebung
|
|
|
|
### Service-Status prüfen
|
|
```bash
|
|
# Backend-Status
|
|
sudo systemctl status myp-https.service
|
|
|
|
# Kiosk-Status
|
|
sudo systemctl status myp-kiosk.service
|
|
|
|
# Watchdog-Status
|
|
sudo systemctl status kiosk-watchdog.service
|
|
|
|
# Alle MYP-Services
|
|
sudo systemctl status myp-*
|
|
```
|
|
|
|
### Logs einsehen
|
|
```bash
|
|
# Backend-Logs
|
|
sudo journalctl -u myp-https.service -f
|
|
|
|
# Kiosk-Logs
|
|
sudo journalctl -u myp-kiosk.service -f
|
|
|
|
# System-Logs
|
|
tail -f /var/log/myp-kiosk.log
|
|
|
|
# Installation-Logs (falls verfügbar)
|
|
cat backend/logs/install-summary.txt
|
|
```
|
|
|
|
### Häufige Probleme
|
|
|
|
**Backend startet nicht:**
|
|
- Prüfen: `sudo systemctl status myp-https.service`
|
|
- Log: `sudo journalctl -u myp-https.service`
|
|
- Port-Konflikt: `sudo netstat -tulpn | grep :5000`
|
|
|
|
**Browser startet nicht:**
|
|
- X11-Display prüfen: `DISPLAY=:0 xset q`
|
|
- Kiosk-Benutzer prüfen: `id kiosk`
|
|
- Browser installiert: `which chromium-browser`
|
|
|
|
**Watchdog meldet Probleme:**
|
|
- Watchdog-Log: `sudo journalctl -u kiosk-watchdog.service`
|
|
- System-Ressourcen: `free -m && df -h`
|
|
|
|
## Konfiguration anpassen
|
|
|
|
### Backend-Port ändern
|
|
Bearbeiten Sie `/etc/systemd/system/myp-https.service`:
|
|
```ini
|
|
Environment=FLASK_PORT=8080
|
|
```
|
|
|
|
### Browser-Startseite ändern
|
|
Bearbeiten Sie `/etc/systemd/system/myp-kiosk.service` und ändern Sie:
|
|
```bash
|
|
TARGET_URL="http://localhost:5000"
|
|
```
|
|
|
|
### Watchdog-Intervall anpassen
|
|
Die Watchdog-Services können über ihre Konfigurationsdateien angepasst werden.
|
|
|
|
## Sicherheitshinweise
|
|
|
|
- Das System läuft mit root-Berechtigung für das Backend (für Druckerzugriff erforderlich)
|
|
- Der Browser läuft als separater `kiosk`-Benutzer
|
|
- Firewall ist automatisch konfiguriert
|
|
- Nur Port 5000 ist für lokale Verbindungen geöffnet
|
|
- HTTPS-Zertifikate werden automatisch generiert
|
|
|
|
## Performance-Optimierung
|
|
|
|
Für optimale Performance auf Raspberry Pi:
|
|
|
|
1. **GPU-Memory erhöhen:**
|
|
```bash
|
|
echo "gpu_mem=128" | sudo tee -a /boot/config.txt
|
|
```
|
|
|
|
2. **Swap verringern:**
|
|
```bash
|
|
echo "vm.swappiness=10" | sudo tee -a /etc/sysctl.conf
|
|
```
|
|
|
|
3. **I/O-Scheduler optimieren:**
|
|
```bash
|
|
echo "deadline" | sudo tee /sys/block/mmcblk0/queue/scheduler
|
|
```
|
|
|
|
## Updates
|
|
|
|
Updates der MYP-Anwendung:
|
|
```bash
|
|
cd /opt/myp
|
|
sudo git pull # falls Git-Repository
|
|
sudo systemctl restart myp-https.service
|
|
sudo systemctl restart myp-kiosk.service
|
|
```
|
|
|
|
## Deinstallation
|
|
|
|
Vollständige Entfernung:
|
|
```bash
|
|
sudo systemctl disable --now myp-https.service myp-kiosk.service
|
|
sudo systemctl disable --now kiosk-watchdog.service myp-firewall.service
|
|
sudo rm /etc/systemd/system/myp-*.service
|
|
sudo rm /etc/systemd/system/kiosk-*.service
|
|
sudo systemctl daemon-reload
|
|
sudo userdel -r kiosk
|
|
sudo rm -rf /opt/myp
|
|
```
|
|
|
|
## Support
|
|
|
|
Bei Problemen:
|
|
1. Prüfen Sie die Logs in `backend/logs/`
|
|
2. Verwenden Sie `sudo journalctl -u service-name` für Service-Logs
|
|
3. Stellen Sie sicher, dass alle Voraussetzungen erfüllt sind
|
|
4. Führen Sie das Setup-Script erneut aus bei Installations-Problemen |