🎉 Refactor and reorganize backend files for improved structure and maintainability:
This commit is contained in:
424
backend/app/docs/AUTOMATISCHER_START_OHNE_ANMELDUNG.md
Normal file
424
backend/app/docs/AUTOMATISCHER_START_OHNE_ANMELDUNG.md
Normal file
@@ -0,0 +1,424 @@
|
||||
# Automatischer Start ohne Benutzeranmeldung
|
||||
|
||||
## Übersicht
|
||||
|
||||
Das MYP Druckerverwaltungssystem ist so konfiguriert, dass der Raspberry Pi automatisch ohne Benutzeranmeldung startet und direkt in den Kiosk-Modus wechselt. Diese Dokumentation beschreibt die implementierten Mechanismen und Troubleshooting-Optionen.
|
||||
|
||||
## Implementierte Auto-Login-Mechanismen
|
||||
|
||||
### 1. LightDM Display Manager
|
||||
|
||||
**Konfigurationsdatei:** `/etc/lightdm/lightdm.conf`
|
||||
|
||||
```ini
|
||||
[Seat:*]
|
||||
# Automatischer Login für Kiosk-Benutzer
|
||||
autologin-user=kiosk
|
||||
autologin-user-timeout=0
|
||||
autologin-session=openbox
|
||||
user-session=openbox
|
||||
session-wrapper=/etc/X11/Xsession
|
||||
greeter-session=lightdm-gtk-greeter
|
||||
allow-guest=false
|
||||
# Kein Benutzer-Wechsel möglich
|
||||
greeter-hide-users=true
|
||||
greeter-show-manual-login=false
|
||||
# Automatischer Start ohne Verzögerung
|
||||
autologin-in-background=false
|
||||
# Session-Setup
|
||||
session-setup-script=/usr/share/lightdm/setup-kiosk-session.sh
|
||||
|
||||
[SeatDefaults]
|
||||
# Zusätzliche Sicherheitseinstellungen
|
||||
autologin-user=kiosk
|
||||
autologin-user-timeout=0
|
||||
autologin-session=openbox
|
||||
greeter-hide-users=true
|
||||
greeter-show-manual-login=false
|
||||
allow-user-switching=false
|
||||
```
|
||||
|
||||
**Systemd-Override:** `/etc/systemd/system/lightdm.service.d/autologin-override.conf`
|
||||
|
||||
```ini
|
||||
[Unit]
|
||||
After=multi-user.target network.target myp-druckerverwaltung.service
|
||||
Wants=myp-druckerverwaltung.service
|
||||
|
||||
[Service]
|
||||
# Automatischer Restart bei Fehlern
|
||||
Restart=always
|
||||
RestartSec=3
|
||||
# Umgebungsvariablen für Kiosk
|
||||
Environment=DISPLAY=:0
|
||||
Environment=KIOSK_MODE=1
|
||||
# Verzögerung für Backend-Start
|
||||
ExecStartPre=/bin/bash -c 'for i in {1..30}; do if curl -s http://localhost:5000 >/dev/null 2>&1; then break; fi; sleep 2; done'
|
||||
```
|
||||
|
||||
### 2. Getty Auto-Login (Fallback)
|
||||
|
||||
**Konfigurationsdatei:** `/etc/systemd/system/getty@tty1.service.d/autologin.conf`
|
||||
|
||||
```ini
|
||||
[Service]
|
||||
ExecStart=
|
||||
ExecStart=-/sbin/agetty --autologin kiosk --noclear %I $TERM
|
||||
Type=simple
|
||||
Restart=always
|
||||
RestartSec=3
|
||||
```
|
||||
|
||||
### 3. Benutzer-Profile Auto-Start
|
||||
|
||||
**Bashrc-Autostart:** `/home/kiosk/.bashrc`
|
||||
|
||||
```bash
|
||||
# ===== VERSTÄRKTER KIOSK AUTOSTART =====
|
||||
if [ -z "$SSH_CLIENT" ] && [ -z "$SSH_TTY" ] && [ -z "$KIOSK_STARTED" ]; then
|
||||
export KIOSK_STARTED=1
|
||||
|
||||
# Logge Autostart-Versuch
|
||||
echo "$(date): Bashrc Autostart-Versuch auf $(tty)" >> /var/log/kiosk-autostart.log
|
||||
|
||||
# Prüfe ob wir auf tty1 sind und X noch nicht läuft
|
||||
if [ "$(tty)" = "/dev/tty1" ] && [ -z "$DISPLAY" ]; then
|
||||
echo "$(date): Starte X-Session automatisch via bashrc" >> /var/log/kiosk-autostart.log
|
||||
exec startx
|
||||
fi
|
||||
|
||||
# Falls X läuft aber Kiosk-App nicht, starte sie
|
||||
if [ -n "$DISPLAY" ] && ! pgrep -f "chromium.*kiosk" > /dev/null; then
|
||||
echo "$(date): Starte Kiosk-Anwendung via bashrc" >> /var/log/kiosk-autostart.log
|
||||
exec $HOME/start-kiosk.sh
|
||||
fi
|
||||
fi
|
||||
```
|
||||
|
||||
**Profile-Autostart:** `/home/kiosk/.profile`
|
||||
|
||||
```bash
|
||||
# ===== VERSTÄRKTER KIOSK AUTOSTART (PROFILE) =====
|
||||
if [ -z "$SSH_CLIENT" ] && [ -z "$SSH_TTY" ] && [ -z "$KIOSK_STARTED" ]; then
|
||||
export KIOSK_STARTED=1
|
||||
|
||||
# Logge Profile-Autostart
|
||||
echo "$(date): Profile Autostart-Versuch auf $(tty)" >> /var/log/kiosk-autostart.log
|
||||
|
||||
# Starte X-Session falls nicht vorhanden
|
||||
if [ -z "$DISPLAY" ] && [ -z "$WAYLAND_DISPLAY" ] && [ "$(tty)" = "/dev/tty1" ]; then
|
||||
echo "$(date): Starte X-Session via profile" >> /var/log/kiosk-autostart.log
|
||||
exec startx
|
||||
fi
|
||||
fi
|
||||
```
|
||||
|
||||
### 4. Desktop Autostart
|
||||
|
||||
**XDG Autostart:** `/home/kiosk/.config/autostart/kiosk-app.desktop`
|
||||
|
||||
```ini
|
||||
[Desktop Entry]
|
||||
Type=Application
|
||||
Name=MYP Kiosk Application
|
||||
Comment=Startet die MYP Kiosk-Anwendung automatisch
|
||||
Exec=/home/kiosk/start-kiosk.sh
|
||||
Hidden=false
|
||||
NoDisplay=false
|
||||
X-GNOME-Autostart-enabled=true
|
||||
StartupNotify=false
|
||||
Terminal=false
|
||||
```
|
||||
|
||||
### 5. Systemd-Watchdog Services
|
||||
|
||||
**Enhanced Watchdog:** `/etc/systemd/system/kiosk-watchdog-enhanced.service`
|
||||
|
||||
Überwacht kontinuierlich:
|
||||
- Backend-Service Status
|
||||
- Backend-Erreichbarkeit (HTTP)
|
||||
- LightDM Status
|
||||
- Kiosk-Benutzer Session
|
||||
- Chromium Kiosk-Prozess
|
||||
- X-Server Status
|
||||
|
||||
### 6. Cron-Überwachung
|
||||
|
||||
**Cron-Watchdog:** `/etc/cron.d/kiosk-watchdog-enhanced`
|
||||
|
||||
```bash
|
||||
# Verstärkter Kiosk-Watchdog: Prüft alle 2 Minuten
|
||||
*/2 * * * * kiosk /bin/bash -c 'if ! pgrep -f "chromium.*kiosk" > /dev/null; then echo "$(date): Cron-Watchdog startet Kiosk neu" >> /var/log/kiosk-cron-watchdog.log; DISPLAY=:0 $HOME/start-kiosk.sh & fi'
|
||||
|
||||
# System-Watchdog: Prüft Services alle 5 Minuten
|
||||
*/5 * * * * root /bin/bash -c 'if ! systemctl is-active --quiet lightdm; then echo "$(date): Cron startet LightDM neu" >> /var/log/system-cron-watchdog.log; systemctl start lightdm; fi'
|
||||
```
|
||||
|
||||
### 7. RC.Local Fallback
|
||||
|
||||
**Boot-Fallback:** `/etc/rc.local`
|
||||
|
||||
```bash
|
||||
#!/bin/bash
|
||||
# Verstärkter rc.local - Kiosk-Fallback
|
||||
|
||||
# Logge Start
|
||||
echo "$(date): rc.local gestartet" >> /var/log/kiosk-fallback.log
|
||||
|
||||
# Warte auf System-Initialisierung
|
||||
sleep 20
|
||||
|
||||
# Starte Backend-Service falls nicht läuft
|
||||
if ! systemctl is-active --quiet myp-druckerverwaltung; then
|
||||
echo "$(date): Starte Backend-Service" >> /var/log/kiosk-fallback.log
|
||||
systemctl start myp-druckerverwaltung
|
||||
sleep 10
|
||||
fi
|
||||
|
||||
# Warte auf Backend-Verfügbarkeit
|
||||
for i in {1..30}; do
|
||||
if curl -s http://localhost:5000 >/dev/null 2>&1; then
|
||||
echo "$(date): Backend verfügbar nach $i Versuchen" >> /var/log/kiosk-fallback.log
|
||||
break
|
||||
fi
|
||||
sleep 2
|
||||
done
|
||||
|
||||
# Starte LightDM falls nicht läuft
|
||||
if ! systemctl is-active --quiet lightdm; then
|
||||
echo "$(date): Starte LightDM" >> /var/log/kiosk-fallback.log
|
||||
systemctl start lightdm
|
||||
sleep 5
|
||||
fi
|
||||
|
||||
# Prüfe nach 30 Sekunden ob Kiosk-Benutzer angemeldet ist
|
||||
sleep 30
|
||||
if ! pgrep -u kiosk > /dev/null; then
|
||||
echo "$(date): Kiosk-Benutzer nicht angemeldet - starte LightDM neu" >> /var/log/kiosk-fallback.log
|
||||
systemctl restart lightdm
|
||||
fi
|
||||
|
||||
echo "$(date): rc.local Kiosk-Fallback abgeschlossen" >> /var/log/kiosk-fallback.log
|
||||
|
||||
exit 0
|
||||
```
|
||||
|
||||
## Boot-Optimierungen
|
||||
|
||||
### Raspberry Pi Boot-Konfiguration
|
||||
|
||||
**Boot-Config:** `/boot/config.txt`
|
||||
|
||||
```ini
|
||||
# GPU Memory für bessere Performance
|
||||
gpu_mem=128
|
||||
|
||||
# Disable Boot-Splash für schnelleren Start
|
||||
disable_splash=1
|
||||
|
||||
# Boot-Delay reduzieren
|
||||
boot_delay=0
|
||||
|
||||
# HDMI-Hotplug für bessere Display-Erkennung
|
||||
hdmi_force_hotplug=1
|
||||
|
||||
# Disable Rainbow-Splash
|
||||
disable_overscan=1
|
||||
```
|
||||
|
||||
**Kernel-Parameter:** `/boot/cmdline.txt`
|
||||
|
||||
```
|
||||
# Zusätzliche Parameter für schnelleren Boot
|
||||
quiet loglevel=3 logo.nologo vt.global_cursor_default=0
|
||||
```
|
||||
|
||||
### Systemd-Konfiguration
|
||||
|
||||
**Standard-Target:** `graphical.target`
|
||||
|
||||
```bash
|
||||
systemctl set-default graphical.target
|
||||
```
|
||||
|
||||
**Logind-Konfiguration:** `/etc/systemd/logind.conf.d/kiosk.conf`
|
||||
|
||||
```ini
|
||||
[Login]
|
||||
# Verhindere dass System bei Inaktivität heruntergefahren wird
|
||||
IdleAction=ignore
|
||||
IdleActionSec=infinity
|
||||
|
||||
# Verhindere Suspend/Hibernate
|
||||
HandlePowerKey=ignore
|
||||
HandleSuspendKey=ignore
|
||||
HandleHibernateKey=ignore
|
||||
HandleLidSwitch=ignore
|
||||
|
||||
# Session-Einstellungen für Kiosk
|
||||
KillUserProcesses=no
|
||||
UserStopDelaySec=10
|
||||
|
||||
# Automatic VT allocation
|
||||
ReserveVT=1
|
||||
```
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
### 1. System startet nicht automatisch
|
||||
|
||||
**Diagnose:**
|
||||
```bash
|
||||
# Prüfe systemd default target
|
||||
systemctl get-default
|
||||
|
||||
# Prüfe LightDM Status
|
||||
systemctl status lightdm
|
||||
|
||||
# Prüfe Getty Service
|
||||
systemctl status getty@tty1
|
||||
```
|
||||
|
||||
**Lösung:**
|
||||
```bash
|
||||
# Setze graphical target
|
||||
sudo systemctl set-default graphical.target
|
||||
|
||||
# Aktiviere Services
|
||||
sudo systemctl enable lightdm
|
||||
sudo systemctl enable getty@tty1
|
||||
```
|
||||
|
||||
### 2. Kiosk-Benutzer meldet sich nicht automatisch an
|
||||
|
||||
**Diagnose:**
|
||||
```bash
|
||||
# Prüfe LightDM Konfiguration
|
||||
cat /etc/lightdm/lightdm.conf | grep autologin
|
||||
|
||||
# Prüfe PAM Konfiguration
|
||||
cat /etc/pam.d/lightdm-autologin
|
||||
|
||||
# Prüfe Benutzer-Sessions
|
||||
who
|
||||
```
|
||||
|
||||
**Lösung:**
|
||||
```bash
|
||||
# LightDM neu konfigurieren
|
||||
sudo dpkg-reconfigure lightdm
|
||||
|
||||
# Service neustarten
|
||||
sudo systemctl restart lightdm
|
||||
```
|
||||
|
||||
### 3. X-Session startet nicht
|
||||
|
||||
**Diagnose:**
|
||||
```bash
|
||||
# Prüfe X-Server Logs
|
||||
cat /var/log/Xorg.0.log
|
||||
|
||||
# Prüfe Session-Logs
|
||||
cat /var/log/kiosk-session.log
|
||||
|
||||
# Prüfe Autostart-Logs
|
||||
cat /var/log/kiosk-autostart.log
|
||||
```
|
||||
|
||||
**Lösung:**
|
||||
```bash
|
||||
# X-Server manuell starten
|
||||
sudo -u kiosk DISPLAY=:0 startx
|
||||
|
||||
# Openbox neu installieren
|
||||
sudo apt-get install --reinstall openbox
|
||||
```
|
||||
|
||||
### 4. Kiosk-Anwendung startet nicht
|
||||
|
||||
**Diagnose:**
|
||||
```bash
|
||||
# Prüfe Backend-Service
|
||||
systemctl status myp-druckerverwaltung
|
||||
|
||||
# Prüfe Backend-Erreichbarkeit
|
||||
curl -s http://localhost:5000
|
||||
|
||||
# Prüfe Chromium-Prozesse
|
||||
pgrep -f chromium
|
||||
```
|
||||
|
||||
**Lösung:**
|
||||
```bash
|
||||
# Backend neustarten
|
||||
sudo systemctl restart myp-druckerverwaltung
|
||||
|
||||
# Kiosk-Anwendung manuell starten
|
||||
sudo -u kiosk DISPLAY=:0 /home/kiosk/start-kiosk.sh
|
||||
```
|
||||
|
||||
## Wartungskommandos
|
||||
|
||||
### System-Status prüfen
|
||||
```bash
|
||||
sudo myp-maintenance status
|
||||
```
|
||||
|
||||
### Services neustarten
|
||||
```bash
|
||||
sudo myp-maintenance restart
|
||||
```
|
||||
|
||||
### Logs anzeigen
|
||||
```bash
|
||||
sudo myp-maintenance logs
|
||||
sudo myp-maintenance kiosk-logs
|
||||
```
|
||||
|
||||
### Kiosk-Modus beenden (für Wartung)
|
||||
```bash
|
||||
sudo myp-maintenance exit-kiosk
|
||||
```
|
||||
|
||||
### SSH für Remote-Wartung aktivieren
|
||||
```bash
|
||||
sudo myp-maintenance enable-ssh
|
||||
```
|
||||
|
||||
## Log-Dateien
|
||||
|
||||
### Wichtige Log-Dateien für Diagnose
|
||||
|
||||
- `/var/log/kiosk-autostart.log` - Autostart-Versuche
|
||||
- `/var/log/kiosk-session.log` - X-Session Events
|
||||
- `/var/log/kiosk-fallback.log` - RC.Local Fallback
|
||||
- `/var/log/kiosk-watchdog-enhanced.log` - Watchdog-Service
|
||||
- `/var/log/kiosk-cron-watchdog.log` - Cron-Watchdog
|
||||
- `/var/log/system-cron-watchdog.log` - System-Cron-Watchdog
|
||||
- `/var/log/Xorg.0.log` - X-Server Logs
|
||||
- `journalctl -u lightdm` - LightDM Service Logs
|
||||
- `journalctl -u myp-druckerverwaltung` - Backend Service Logs
|
||||
|
||||
## Optimierung nach Installation
|
||||
|
||||
Für bereits installierte Systeme kann die Schnellstart-Optimierung ausgeführt werden:
|
||||
|
||||
```bash
|
||||
sudo ./schnellstart_raspberry_pi.sh
|
||||
sudo reboot
|
||||
```
|
||||
|
||||
Dieses Skript verstärkt alle Auto-Login-Mechanismen und optimiert die Boot-Performance.
|
||||
|
||||
## Sicherheitshinweise
|
||||
|
||||
- SSH ist standardmäßig deaktiviert für bessere Sicherheit
|
||||
- Console-Zugang über Strg+Alt+F1 bis F6 möglich
|
||||
- Root-Passwort: `744563017196A` (für Notfall-Wartung)
|
||||
- Kiosk-Benutzer hat keine sudo-Berechtigung
|
||||
- Automatische Updates sind konfiguriert
|
||||
|
||||
## Fazit
|
||||
|
||||
Das System ist mit mehrfachen redundanten Mechanismen ausgestattet, um einen zuverlässigen automatischen Start ohne Benutzeranmeldung zu gewährleisten. Bei Problemen stehen umfangreiche Diagnose- und Wartungstools zur Verfügung.
|
Reference in New Issue
Block a user