🎉 Updated file structure for deprecated modules, moved 'app_backup.py' to 'deprecated/app_backup.py'. Also updated 'install_raspberry_pi.sh'. 📚
This commit is contained in:
parent
c7297bfbc8
commit
62f227dc78
@ -1991,6 +1991,15 @@ greeter-show-manual-login=false
|
||||
autologin-in-background=false
|
||||
# Session-Setup
|
||||
session-setup-script=/usr/share/lightdm/setup-kiosk-session.sh
|
||||
|
||||
[SeatDefaults]
|
||||
# Zusätzliche Sicherheitseinstellungen
|
||||
autologin-user=$KIOSK_USER
|
||||
autologin-user-timeout=0
|
||||
autologin-session=openbox
|
||||
greeter-hide-users=true
|
||||
greeter-show-manual-login=false
|
||||
allow-user-switching=false
|
||||
EOF
|
||||
|
||||
progress "Erstelle Session-Setup-Skript..."
|
||||
@ -2029,6 +2038,35 @@ ExecStart=-/sbin/agetty --autologin $KIOSK_USER --noclear %I \$TERM
|
||||
Type=simple
|
||||
EOF
|
||||
|
||||
# Aktiviere getty@tty1 Service für automatischen Login
|
||||
systemctl enable getty@tty1.service
|
||||
|
||||
progress "Konfiguriere systemd für automatischen grafischen Start..."
|
||||
|
||||
# Setze graphical.target als Standard
|
||||
systemctl set-default graphical.target
|
||||
|
||||
# Erstelle systemd-Override für LightDM
|
||||
mkdir -p "/etc/systemd/system/lightdm.service.d"
|
||||
cat > "/etc/systemd/system/lightdm.service.d/autologin-override.conf" << EOF
|
||||
[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'
|
||||
EOF
|
||||
|
||||
# Aktiviere LightDM Service
|
||||
systemctl enable lightdm.service
|
||||
|
||||
progress "Erstelle Desktop-Session für Openbox..."
|
||||
|
||||
# Desktop-Session-Datei für Openbox
|
||||
@ -2083,13 +2121,48 @@ unclutter -idle 0.5 -root &
|
||||
exec openbox-session
|
||||
EOF
|
||||
|
||||
# Log-Dateiberechtigungen sind bereits korrekt gesetzt (root:root)
|
||||
info "Log-Dateiberechtigungen erfolgreich konfiguriert"
|
||||
chmod +x "$KIOSK_HOME/.xsessionrc"
|
||||
chmod +x "$KIOSK_HOME/.xinitrc"
|
||||
|
||||
# Konfiguriere PAM für automatischen Login
|
||||
progress "Konfiguriere PAM für automatischen Login..."
|
||||
|
||||
# PAM-Konfiguration für LightDM autologin
|
||||
cat > "/etc/pam.d/lightdm-autologin" << EOF
|
||||
# PAM configuration for LightDM autologin
|
||||
auth required pam_env.so
|
||||
auth required pam_permit.so
|
||||
@include common-account
|
||||
session required pam_limits.so
|
||||
@include common-session
|
||||
@include common-password
|
||||
EOF
|
||||
|
||||
# Zusätzliche Autostart-Mechanismen für maximale Zuverlässigkeit
|
||||
progress "Konfiguriere mehrfache Autostart-Absicherung..."
|
||||
|
||||
# 1. BASHRC AUTOSTART
|
||||
cat >> "$KIOSK_HOME/.bashrc" << 'EOF'
|
||||
|
||||
# ===== KIOSK AUTOSTART (BASHRC) =====
|
||||
if [ -z "$SSH_CLIENT" ] && [ -z "$SSH_TTY" ] && [ -z "$KIOSK_STARTED" ]; then
|
||||
export KIOSK_STARTED=1
|
||||
|
||||
# Prüfe ob wir auf tty1 sind und X noch nicht läuft
|
||||
if [ "$(tty)" = "/dev/tty1" ] && [ -z "$DISPLAY" ]; then
|
||||
echo "Starte X-Session automatisch..."
|
||||
exec startx
|
||||
fi
|
||||
|
||||
# Falls X läuft aber Kiosk-App nicht, starte sie
|
||||
if [ -n "$DISPLAY" ] && ! pgrep -f "chromium.*kiosk" > /dev/null; then
|
||||
echo "Starte Kiosk-Anwendung..."
|
||||
exec $HOME/start-kiosk.sh
|
||||
fi
|
||||
fi
|
||||
EOF
|
||||
|
||||
# 3. PROFILE AUTOSTART
|
||||
progress "Konfiguriere .profile autostart..."
|
||||
# 2. PROFILE AUTOSTART
|
||||
cat >> "$KIOSK_HOME/.profile" << 'EOF'
|
||||
|
||||
# ===== KIOSK AUTOSTART (PROFILE) =====
|
||||
@ -2104,7 +2177,7 @@ if [ -z "$SSH_CLIENT" ] && [ -z "$SSH_TTY" ] && [ -z "$KIOSK_STARTED" ]; then
|
||||
fi
|
||||
EOF
|
||||
|
||||
# 4. DESKTOP AUTOSTART
|
||||
# 3. DESKTOP AUTOSTART
|
||||
progress "Konfiguriere XDG autostart..."
|
||||
sudo -u "$KIOSK_USER" mkdir -p "$KIOSK_HOME/.config/autostart"
|
||||
|
||||
@ -2122,29 +2195,39 @@ EOF
|
||||
|
||||
chown "$KIOSK_USER:$KIOSK_USER" "$KIOSK_HOME/.config/autostart/kiosk-app.desktop"
|
||||
|
||||
# 5. CRON AUTOSTART (ÜBERWACHUNG)
|
||||
# 4. CRON AUTOSTART (ÜBERWACHUNG)
|
||||
progress "Konfiguriere Cron-Überwachung..."
|
||||
cat > "/etc/cron.d/kiosk-watchdog" << EOF
|
||||
# Kiosk-Überwachung: Startet Kiosk neu falls nicht läuft
|
||||
*/2 * * * * $KIOSK_USER /bin/bash -c 'if ! pgrep -f "chromium.*kiosk" > /dev/null; then echo "\$(date): Kiosk-Watchdog startet Anwendung neu" >> /var/log/kiosk-watchdog.log; DISPLAY=:0 $HOME/start-kiosk.sh & fi'
|
||||
EOF
|
||||
|
||||
# 6. RC.LOCAL FALLBACK
|
||||
# 5. RC.LOCAL FALLBACK
|
||||
progress "Konfiguriere rc.local Fallback..."
|
||||
cat > "/etc/rc.local" << EOF
|
||||
#!/bin/bash
|
||||
# rc.local - Kiosk-Fallback
|
||||
|
||||
# Warte auf System-Initialisierung
|
||||
sleep 10
|
||||
|
||||
# Starte Kiosk-Services falls nicht läuft
|
||||
if ! systemctl is-active --quiet lightdm; then
|
||||
systemctl start lightdm
|
||||
fi
|
||||
sleep 15
|
||||
|
||||
# Starte Backend-Service falls nicht läuft
|
||||
if ! systemctl is-active --quiet myp-druckerverwaltung; then
|
||||
systemctl start myp-druckerverwaltung
|
||||
sleep 5
|
||||
fi
|
||||
|
||||
# Starte LightDM falls nicht läuft
|
||||
if ! systemctl is-active --quiet lightdm; then
|
||||
systemctl start lightdm
|
||||
sleep 3
|
||||
fi
|
||||
|
||||
# Prüfe ob Kiosk-Benutzer angemeldet ist, falls nicht, starte LightDM neu
|
||||
sleep 10
|
||||
if ! pgrep -u $KIOSK_USER > /dev/null; then
|
||||
echo "\$(date): Kiosk-Benutzer nicht angemeldet - starte LightDM neu" >> /var/log/kiosk-fallback.log
|
||||
systemctl restart lightdm
|
||||
fi
|
||||
|
||||
# Logge Start
|
||||
@ -2155,17 +2238,18 @@ EOF
|
||||
|
||||
chmod +x "/etc/rc.local"
|
||||
|
||||
# 7. SYSTEMD SERVICE ÜBERWACHUNG
|
||||
# 6. SYSTEMD SERVICE ÜBERWACHUNG
|
||||
progress "Konfiguriere Service-Überwachung..."
|
||||
cat > "/etc/systemd/system/kiosk-watchdog.service" << EOF
|
||||
[Unit]
|
||||
Description=Kiosk Watchdog Service
|
||||
After=multi-user.target
|
||||
After=multi-user.target lightdm.service
|
||||
Wants=lightdm.service
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
User=root
|
||||
ExecStart=/bin/bash -c 'while true; do if ! systemctl is-active --quiet myp-kiosk; then systemctl start myp-kiosk; fi; sleep 30; done'
|
||||
ExecStart=/bin/bash -c 'while true; do if ! systemctl is-active --quiet lightdm; then echo "\$(date): LightDM nicht aktiv - starte neu" >> /var/log/kiosk-watchdog.log; systemctl start lightdm; fi; if ! pgrep -u $KIOSK_USER > /dev/null; then echo "\$(date): Kiosk-Benutzer nicht angemeldet - starte LightDM neu" >> /var/log/kiosk-watchdog.log; systemctl restart lightdm; fi; sleep 30; done'
|
||||
Restart=always
|
||||
RestartSec=10
|
||||
|
||||
@ -2175,228 +2259,47 @@ EOF
|
||||
|
||||
systemctl enable kiosk-watchdog.service
|
||||
|
||||
# 7. BOOT-PARAMETER OPTIMIERUNG
|
||||
progress "Optimiere Boot-Parameter für automatischen Start..."
|
||||
|
||||
# Raspberry Pi spezifische Boot-Konfiguration
|
||||
if [ -f "/boot/config.txt" ]; then
|
||||
# GPU Memory für bessere Grafik-Performance
|
||||
if ! grep -q "gpu_mem=" /boot/config.txt; then
|
||||
echo "gpu_mem=128" >> /boot/config.txt
|
||||
fi
|
||||
|
||||
# Disable Boot-Splash für schnelleren Start
|
||||
if ! grep -q "disable_splash=" /boot/config.txt; then
|
||||
echo "disable_splash=1" >> /boot/config.txt
|
||||
fi
|
||||
|
||||
# Boot-Delay reduzieren
|
||||
if ! grep -q "boot_delay=" /boot/config.txt; then
|
||||
echo "boot_delay=0" >> /boot/config.txt
|
||||
fi
|
||||
fi
|
||||
|
||||
# Kernel-Parameter für schnelleren Boot
|
||||
if [ -f "/boot/cmdline.txt" ]; then
|
||||
# Entferne Boot-Splash und füge quiet hinzu
|
||||
sed -i 's/splash//g' /boot/cmdline.txt
|
||||
if ! grep -q "quiet" /boot/cmdline.txt; then
|
||||
sed -i 's/$/ quiet/' /boot/cmdline.txt
|
||||
fi
|
||||
if ! grep -q "loglevel=3" /boot/cmdline.txt; then
|
||||
sed -i 's/$/ loglevel=3/' /boot/cmdline.txt
|
||||
fi
|
||||
fi
|
||||
|
||||
# Berechtigungen finalisieren
|
||||
chown -R "$KIOSK_USER:$KIOSK_USER" "$KIOSK_HOME/.config"
|
||||
chown -R "$KIOSK_USER:$KIOSK_USER" "$KIOSK_HOME/.config"
|
||||
chown "$KIOSK_USER:$KIOSK_USER" "$KIOSK_HOME/.bashrc"
|
||||
chown "$KIOSK_USER:$KIOSK_USER" "$KIOSK_HOME/.profile"
|
||||
chown "$KIOSK_USER:$KIOSK_USER" "$KIOSK_HOME/.xsessionrc"
|
||||
chown "$KIOSK_USER:$KIOSK_USER" "$KIOSK_HOME/.xinitrc"
|
||||
|
||||
log "✅ Mehrfache Autostart-Absicherung implementiert"
|
||||
}
|
||||
|
||||
# ========================== AUTOSTART KONFIGURATION ==========================
|
||||
configure_autostart() {
|
||||
log "=== PHASE 7: AUTOSTART-KONFIGURATION ==="
|
||||
|
||||
# Systemd Service für Anwendung
|
||||
progress "Erstelle Systemd-Service für Anwendung..."
|
||||
cat > "/etc/systemd/system/myp-druckerverwaltung.service" << EOF
|
||||
[Unit]
|
||||
Description=MYP Druckerverwaltung Flask Application
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
User=$APP_USER
|
||||
Group=$APP_USER
|
||||
WorkingDirectory=$APP_DIR
|
||||
Environment=PATH=/usr/local/bin:/usr/bin:/bin
|
||||
Environment=PYTHONPATH=$APP_DIR
|
||||
ExecStart=/usr/bin/python3 $APP_DIR/app.py
|
||||
Restart=always
|
||||
RestartSec=10
|
||||
StandardOutput=journal
|
||||
StandardError=journal
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
EOF
|
||||
|
||||
# Systemd Service für LightDM Management (ersetzt den alten X-Server Service)
|
||||
progress "Erstelle Systemd-Service für Display Manager..."
|
||||
cat > "/etc/systemd/system/myp-display.service" << EOF
|
||||
[Unit]
|
||||
Description=MYP Display Manager Service
|
||||
After=myp-druckerverwaltung.service network.target
|
||||
Requires=myp-druckerverwaltung.service
|
||||
Wants=myp-druckerverwaltung.service
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
RemainAfterExit=yes
|
||||
ExecStartPre=/bin/bash -c 'while ! curl -s http://localhost:5000 > /dev/null; do sleep 2; done'
|
||||
ExecStart=/bin/systemctl start lightdm
|
||||
ExecStop=/bin/systemctl stop lightdm
|
||||
StandardOutput=journal
|
||||
StandardError=journal
|
||||
|
||||
[Install]
|
||||
WantedBy=graphical.target
|
||||
EOF
|
||||
|
||||
# Systemd Service für Kiosk-Überwachung
|
||||
progress "Erstelle erweiterten Kiosk-Überwachungs-Service..."
|
||||
cat > "/etc/systemd/system/myp-kiosk-monitor.service" << EOF
|
||||
[Unit]
|
||||
Description=MYP Kiosk Monitor und Recovery Service
|
||||
After=graphical.target lightdm.service
|
||||
Requires=myp-druckerverwaltung.service
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
User=root
|
||||
ExecStart=/bin/bash -c '
|
||||
while true; do
|
||||
# Prüfe ob Anwendung läuft
|
||||
if ! curl -s http://localhost:5000 > /dev/null; then
|
||||
echo "\$(date): Anwendung nicht erreichbar - starte neu" >> /var/log/kiosk-monitor.log
|
||||
systemctl restart myp-druckerverwaltung
|
||||
sleep 10
|
||||
fi
|
||||
|
||||
# Prüfe ob LightDM läuft
|
||||
if ! systemctl is-active --quiet lightdm; then
|
||||
echo "\$(date): LightDM nicht aktiv - starte neu" >> /var/log/kiosk-monitor.log
|
||||
systemctl start lightdm
|
||||
sleep 5
|
||||
fi
|
||||
|
||||
# Prüfe ob Kiosk-Benutzer angemeldet ist
|
||||
if ! pgrep -u $KIOSK_USER > /dev/null; then
|
||||
echo "\$(date): Kiosk-Benutzer nicht angemeldet - starte LightDM neu" >> /var/log/kiosk-monitor.log
|
||||
systemctl restart lightdm
|
||||
sleep 10
|
||||
fi
|
||||
|
||||
# Prüfe ob Chromium im Kiosk-Modus läuft
|
||||
if ! pgrep -u $KIOSK_USER -f "chromium.*kiosk" > /dev/null; then
|
||||
echo "\$(date): Chromium-Kiosk nicht gefunden - starte Kiosk-Session neu" >> /var/log/kiosk-monitor.log
|
||||
# Versuche Kiosk-Neustart als Kiosk-Benutzer
|
||||
sudo -u $KIOSK_USER DISPLAY=:0 /home/$KIOSK_USER/start-kiosk.sh &
|
||||
fi
|
||||
|
||||
sleep 30
|
||||
done
|
||||
'
|
||||
Restart=always
|
||||
RestartSec=10
|
||||
|
||||
[Install]
|
||||
WantedBy=graphical.target
|
||||
EOF
|
||||
|
||||
# Nginx-Proxy-Konfiguration
|
||||
progress "Konfiguriere Nginx..."
|
||||
cat > "/etc/nginx/sites-available/myp-kiosk" << EOF
|
||||
server {
|
||||
listen 80 default_server;
|
||||
listen [::]:80 default_server;
|
||||
|
||||
server_name _;
|
||||
|
||||
# Security Headers
|
||||
add_header X-Frame-Options DENY always;
|
||||
add_header X-Content-Type-Options nosniff always;
|
||||
add_header X-XSS-Protection "1; mode=block" always;
|
||||
add_header Referrer-Policy "no-referrer-when-downgrade" always;
|
||||
add_header Content-Security-Policy "default-src 'self'; script-src 'self' 'unsafe-inline'; style-src 'self' 'unsafe-inline'; img-src 'self' data:; font-src 'self';" always;
|
||||
|
||||
location / {
|
||||
proxy_pass http://127.0.0.1:5000;
|
||||
proxy_set_header Host \$host;
|
||||
proxy_set_header X-Real-IP \$remote_addr;
|
||||
proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto \$scheme;
|
||||
|
||||
# WebSocket-Support
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade \$http_upgrade;
|
||||
proxy_set_header Connection "upgrade";
|
||||
|
||||
# Timeout-Konfiguration
|
||||
proxy_connect_timeout 60s;
|
||||
proxy_send_timeout 60s;
|
||||
proxy_read_timeout 60s;
|
||||
}
|
||||
|
||||
# Statische Dateien
|
||||
location /static/ {
|
||||
alias $APP_DIR/static/;
|
||||
expires 1y;
|
||||
add_header Cache-Control "public, immutable";
|
||||
}
|
||||
}
|
||||
EOF
|
||||
|
||||
# Nginx-Site aktivieren
|
||||
rm -f /etc/nginx/sites-enabled/default
|
||||
ln -sf /etc/nginx/sites-available/myp-kiosk /etc/nginx/sites-enabled/
|
||||
|
||||
# Erstelle systemd-logind Konfiguration für besseres Session-Management
|
||||
progress "Konfiguriere systemd-logind für Kiosk..."
|
||||
cat > "/etc/systemd/logind.conf.d/kiosk.conf" << EOF
|
||||
[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
|
||||
EOF
|
||||
|
||||
# Erstelle PAM-Konfiguration für Auto-Login
|
||||
progress "Konfiguriere PAM für Auto-Login..."
|
||||
cat > "/etc/pam.d/lightdm-autologin" << EOF
|
||||
# PAM configuration for LightDM autologin
|
||||
auth required pam_env.so
|
||||
auth required pam_permit.so
|
||||
@include common-account
|
||||
session required pam_limits.so
|
||||
@include common-session
|
||||
@include common-password
|
||||
EOF
|
||||
|
||||
# Services aktivieren
|
||||
progress "Aktiviere Services..."
|
||||
systemctl daemon-reload
|
||||
systemctl enable myp-druckerverwaltung
|
||||
systemctl enable nginx
|
||||
systemctl enable myp-display
|
||||
systemctl enable myp-kiosk-monitor
|
||||
|
||||
# SSH standardmäßig deaktivieren für Sicherheit
|
||||
systemctl disable ssh || true
|
||||
|
||||
# Sicherstellen dass graphical.target Standard ist
|
||||
systemctl set-default graphical.target
|
||||
|
||||
# Erstelle systemd override für bessere Kiosk-Integration
|
||||
progress "Erstelle systemd-Overrides..."
|
||||
mkdir -p "/etc/systemd/system/lightdm.service.d"
|
||||
cat > "/etc/systemd/system/lightdm.service.d/kiosk-override.conf" << EOF
|
||||
[Unit]
|
||||
After=myp-druckerverwaltung.service
|
||||
|
||||
[Service]
|
||||
# Automatischer Restart bei Fehlern
|
||||
Restart=always
|
||||
RestartSec=5
|
||||
|
||||
# Umgebungsvariablen für Kiosk
|
||||
Environment=DISPLAY=:0
|
||||
Environment=KIOSK_MODE=1
|
||||
EOF
|
||||
|
||||
log "✅ Autostart konfiguriert mit LightDM-Integration"
|
||||
log "✅ Mehrfache Autostart-Absicherung mit Boot-Optimierung implementiert"
|
||||
}
|
||||
|
||||
# ========================== SICHERHEIT ==========================
|
||||
|
Loading…
x
Reference in New Issue
Block a user