🎉 Improved backend functionality & documentation, optimized database files, and introduced shutdown management 🧹

This commit is contained in:
2025-06-01 02:42:15 +02:00
parent ea12a470c9
commit 486647fade
10 changed files with 1052 additions and 407 deletions

View File

@@ -4,7 +4,7 @@
# MYP Druckerverwaltung - VOLLSTÄNDIGER KIOSK-INSTALLER für Raspbian
# Entwickelt auf Windows, ausführbar auf Raspberry Pi / Debian
# OHNE virtualenv - verwendet System-Python mit --break-system-packages
# ECHTER KIOSK-MODUS: Entfernt Desktop, 3 Backend-Instanzen, Autologin
# ECHTER KIOSK-MODUS: Entfernt Desktop, 1 Backend-Instanz HTTPS, Autologin
# ===================================================================
set -euo pipefail
@@ -12,9 +12,7 @@ set -euo pipefail
# =========================== KONFIGURATION ===========================
APP_NAME="MYP Druckerverwaltung"
APP_DIR="/opt/myp"
SERVICE_NAME_KIOSK="myp-kiosk"
SERVICE_NAME_HTTPS="myp-https"
SERVICE_NAME_HTTP="myp-http"
SERVICE_NAME="myp-https"
KIOSK_USER="kiosk"
CURRENT_DIR="$(pwd)"
INSTALL_LOG="/var/log/myp-install.log"
@@ -579,14 +577,85 @@ install_system_dependencies() {
log "✅ Alle Abhängigkeiten (Python + Node.js + npm) erfolgreich installiert"
}
# ========================== 3 BACKEND SERVICES ERSTELLEN ==========================
create_backend_services() {
log "=== ERSTELLE 3 BACKEND-SERVICES ==="
# ========================== SSL-ZERTIFIKATE FÜR LOCALHOST ERSTELLEN ==========================
create_localhost_ssl_certificates() {
log "=== ERSTELLE SSL-ZERTIFIKATE FÜR LOCALHOST ==="
# Python-Startskripte für die verschiedenen Ports erstellen
progress "Erstelle Python-Startskripte..."
SSL_DIR="$APP_DIR/certs/localhost"
mkdir -p "$SSL_DIR"
progress "Erstelle SSL-Zertifikate für localhost..."
# Private Key erstellen
openssl genrsa -out "$SSL_DIR/localhost.key" 2048 || error "Private Key Erstellung fehlgeschlagen"
# Certificate Signing Request (CSR) erstellen
openssl req -new -key "$SSL_DIR/localhost.key" -out "$SSL_DIR/localhost.csr" -subj "/C=DE/ST=Baden-Wuerttemberg/L=Stuttgart/O=Mercedes-Benz/OU=MYP/CN=localhost" || error "CSR Erstellung fehlgeschlagen"
# Self-signed Zertifikat erstellen (gültig für 365 Tage)
openssl x509 -req -days 365 -in "$SSL_DIR/localhost.csr" -signkey "$SSL_DIR/localhost.key" -out "$SSL_DIR/localhost.crt" -extensions v3_req -extfile <(
cat <<EOF
[req]
distinguished_name = req_distinguished_name
req_extensions = v3_req
prompt = no
[req_distinguished_name]
C = DE
ST = Baden-Wuerttemberg
L = Stuttgart
O = Mercedes-Benz
OU = MYP
CN = localhost
[v3_req]
keyUsage = keyEncipherment, dataEncipherment
extendedKeyUsage = serverAuth
subjectAltName = @alt_names
[alt_names]
DNS.1 = localhost
DNS.2 = *.localhost
IP.1 = 127.0.0.1
IP.2 = 0.0.0.0
EOF
) || error "SSL-Zertifikat Erstellung fehlgeschlagen"
# CSR-Datei aufräumen
rm -f "$SSL_DIR/localhost.csr"
# Berechtigungen setzen
chmod 600 "$SSL_DIR/localhost.key"
chmod 644 "$SSL_DIR/localhost.crt"
chown -R root:root "$SSL_DIR"
# Zertifikat zu System CA-Store hinzufügen
progress "Füge localhost-Zertifikat zu System CA-Store hinzu..."
cp "$SSL_DIR/localhost.crt" "/usr/local/share/ca-certificates/localhost.crt"
update-ca-certificates || warning "CA-Zertifikate Update fehlgeschlagen"
# Zertifikat-Info anzeigen
log "✅ SSL-Zertifikate für localhost erstellt:"
log " 📜 Private Key: $SSL_DIR/localhost.key"
log " 📜 Zertifikat: $SSL_DIR/localhost.crt"
log " 📜 System CA-Store: /usr/local/share/ca-certificates/localhost.crt"
# Zertifikat validieren
if openssl x509 -in "$SSL_DIR/localhost.crt" -text -noout | grep -q "localhost"; then
log "✅ SSL-Zertifikat validiert - localhost Subject gefunden"
else
warning "⚠️ SSL-Zertifikat Validierung fehlgeschlagen"
fi
log "✅ SSL-Zertifikate für localhost erfolgreich installiert"
}
# ========================== EINZELNER HTTPS BACKEND SERVICE ==========================
create_backend_service() {
log "=== ERSTELLE HTTPS BACKEND SERVICE ==="
# HTTPS-Startskript (Port 443)
progress "Erstelle HTTPS-Startskript..."
cat > "$APP_DIR/start_https.py" << 'EOF'
#!/usr/bin/env python3
import sys
@@ -608,88 +677,21 @@ try:
print("Starte HTTPS-Server auf Port 443...")
app.run(host='0.0.0.0', port=443, debug=False, ssl_context=ssl_context, threaded=True)
else:
print('SSL-Kontext nicht verfügbar')
sys.exit(1)
print('SSL-Kontext nicht verfügbar - verwende localhost Zertifikate')
# Fallback auf localhost-Zertifikate
ssl_context = ('/opt/myp/certs/localhost/localhost.crt', '/opt/myp/certs/localhost/localhost.key')
app.run(host='0.0.0.0', port=443, debug=False, ssl_context=ssl_context, threaded=True)
except Exception as e:
print(f"Fehler beim Starten des HTTPS-Servers: {e}")
sys.exit(1)
EOF
# HTTP-Startskript (Port 80)
cat > "$APP_DIR/start_http.py" << 'EOF'
#!/usr/bin/env python3
import sys
import os
# Füge App-Verzeichnis zum Python-Pfad hinzu
sys.path.insert(0, '/opt/myp')
# Setze Umgebungsvariablen
os.environ['FLASK_PORT'] = '80'
os.environ['FLASK_HOST'] = '0.0.0.0'
os.environ['FLASK_ENV'] = 'production'
try:
from app import app
print("Starte HTTP-Server auf Port 80...")
app.run(host='0.0.0.0', port=80, debug=False, threaded=True)
except Exception as e:
print(f"Fehler beim Starten des HTTP-Servers: {e}")
sys.exit(1)
EOF
# Skripte ausführbar machen
# Skript ausführbar machen
chmod +x "$APP_DIR/start_https.py"
chmod +x "$APP_DIR/start_http.py"
# Service 1: Kiosk-Backend (Port 5000)
progress "Erstelle myp-kiosk.service (Port 5000)..."
cat > "/etc/systemd/system/${SERVICE_NAME_KIOSK}.service" << EOF
[Unit]
Description=MYP Kiosk Backend (Port 5000)
After=network.target network-online.target
Wants=network-online.target
Requires=network.target
[Service]
Type=simple
User=root
Group=root
WorkingDirectory=$APP_DIR
ExecStart=/usr/bin/python3 $APP_DIR/app.py --debug
Restart=always
RestartSec=5
StartLimitBurst=5
StartLimitInterval=60
# Umgebungsvariablen
Environment=PYTHONUNBUFFERED=1
Environment=FLASK_ENV=production
Environment=FLASK_HOST=0.0.0.0
Environment=FLASK_PORT=5000
Environment=PYTHONPATH=$APP_DIR
Environment=LC_ALL=C.UTF-8
Environment=LANG=C.UTF-8
# Logging
StandardOutput=journal
StandardError=journal
SyslogIdentifier=myp-kiosk
# Security-Einstellungen
NoNewPrivileges=true
PrivateTmp=false
ProtectSystem=strict
ReadWritePaths=$APP_DIR
[Install]
WantedBy=multi-user.target
EOF
# Service 2: HTTPS-Backend (Port 443)
# HTTPS-Service (Port 443)
progress "Erstelle myp-https.service (Port 443)..."
cat > "/etc/systemd/system/${SERVICE_NAME_HTTPS}.service" << EOF
cat > "/etc/systemd/system/${SERVICE_NAME}.service" << EOF
[Unit]
Description=MYP HTTPS Backend (Port 443)
After=network.target network-online.target
@@ -715,6 +717,8 @@ Environment=FLASK_PORT=443
Environment=PYTHONPATH=$APP_DIR
Environment=LC_ALL=C.UTF-8
Environment=LANG=C.UTF-8
Environment=SSL_CERT_FILE=/etc/ssl/certs/ca-certificates.crt
Environment=REQUESTS_CA_BUNDLE=/etc/ssl/certs/ca-certificates.crt
# Logging
StandardOutput=journal
@@ -731,76 +735,12 @@ ReadWritePaths=$APP_DIR
WantedBy=multi-user.target
EOF
# Service 3: HTTP-Backend (Port 80)
progress "Erstelle myp-http.service (Port 80)..."
cat > "/etc/systemd/system/${SERVICE_NAME_HTTP}.service" << EOF
[Unit]
Description=MYP HTTP Backend (Port 80)
After=network.target network-online.target
Wants=network-online.target
Requires=network.target
[Service]
Type=simple
User=root
Group=root
WorkingDirectory=$APP_DIR
ExecStart=/usr/bin/python3 $APP_DIR/start_http.py
Restart=always
RestartSec=5
StartLimitBurst=5
StartLimitInterval=60
# Umgebungsvariablen
Environment=PYTHONUNBUFFERED=1
Environment=FLASK_ENV=production
Environment=FLASK_HOST=0.0.0.0
Environment=FLASK_PORT=80
Environment=PYTHONPATH=$APP_DIR
Environment=LC_ALL=C.UTF-8
Environment=LANG=C.UTF-8
# Logging
StandardOutput=journal
StandardError=journal
SyslogIdentifier=myp-http
# Security-Einstellungen
NoNewPrivileges=true
PrivateTmp=false
ProtectSystem=strict
ReadWritePaths=$APP_DIR
[Install]
WantedBy=multi-user.target
EOF
log "✅ 3 Backend-Services mit separaten Python-Skripten erstellt"
}
# ========================== AUTOLOGIN KONFIGURIEREN ==========================
configure_autologin() {
log "=== KONFIGURIERE AUTOLOGIN ==="
progress "Erstelle Autologin-Service..."
# Getty-Service für automatischen Login überschreiben
mkdir -p /etc/systemd/system/getty@tty1.service.d/
cat > /etc/systemd/system/getty@tty1.service.d/autologin.conf << EOF
[Service]
ExecStart=
ExecStart=-/sbin/agetty --autologin $KIOSK_USER --noclear %I linux
EOF
# Systemd Target auf Multi-User setzen (ohne grafisches Login)
systemctl set-default multi-user.target
log "✅ Autologin konfiguriert für Benutzer: $KIOSK_USER"
log "✅ HTTPS Backend-Service erstellt"
}
# ========================== KIOSK BROWSER KONFIGURATION ==========================
configure_kiosk_browser() {
log "=== KONFIGURIERE KIOSK-BROWSER ==="
log "=== KONFIGURIERE KIOSK-BROWSER FÜR HTTPS ==="
KIOSK_HOME="/home/$KIOSK_USER"
@@ -918,8 +858,8 @@ if [ -z "$DISPLAY" ] && [ "$(tty)" = "/dev/tty1" ]; then
fi
EOF
# .xinitrc für Kiosk-Session erstellen
progress "Erstelle optimierte Kiosk X-Session..."
# .xinitrc für HTTPS Kiosk-Session erstellen
progress "Erstelle optimierte HTTPS Kiosk X-Session..."
cat > "$KIOSK_HOME/.xinitrc" << 'EOF'
#!/bin/bash
@@ -946,31 +886,30 @@ unclutter -idle 0.1 -root -noevents &
# Openbox im Hintergrund starten
openbox &
# Warte auf Backend-Services
echo "Warte auf MYP Backend-Services..."
# Warte auf HTTPS Backend-Service
echo "Warte auf MYP HTTPS Backend-Service..."
WAIT_COUNT=0
while ! curl -s http://localhost:5000 > /dev/null; do
echo "Warte auf Backend (Port 5000)... ($WAIT_COUNT/60)"
while ! curl -k -s https://localhost:443 > /dev/null; do
echo "Warte auf HTTPS Backend (Port 443)... ($WAIT_COUNT/60)"
sleep 2
WAIT_COUNT=$((WAIT_COUNT + 1))
if [ $WAIT_COUNT -gt 60 ]; then
echo "FEHLER: Backend nach 120s nicht erreichbar!"
echo "FEHLER: HTTPS Backend nach 120s nicht erreichbar!"
break
fi
done
echo "Backend erreichbar - starte Kiosk-Browser..."
echo "HTTPS Backend erreichbar - starte Kiosk-Browser..."
# Browser-Erkennung und -Start mit optimierten Vollbild-Flags
# Browser-Erkennung und -Start mit HTTPS-optimierten Vollbild-Flags
if command -v chromium >/dev/null 2>&1; then
echo "Starte Chromium Browser mit Auflösung ${WIDTH}x${HEIGHT}..."
echo "Starte Chromium Browser mit HTTPS und Auflösung ${WIDTH}x${HEIGHT}..."
exec chromium \
--kiosk \
--no-sandbox \
--disable-infobars \
--disable-session-crashed-bubble \
--disable-restore-session-state \
--disable-web-security \
--disable-features=TranslateUI \
--disable-extensions \
--disable-plugins \
@@ -1000,16 +939,21 @@ if command -v chromium >/dev/null 2>&1; then
--disable-features=VizDisplayCompositor \
--enable-features=OverlayScrollbar \
--hide-scrollbars \
http://localhost:5000
--ignore-certificate-errors \
--ignore-ssl-errors \
--ignore-certificate-errors-spki-list \
--disable-web-security \
--allow-running-insecure-content \
--unsafely-treat-insecure-origin-as-secure=https://localhost:443 \
https://localhost:443
elif command -v chromium-browser >/dev/null 2>&1; then
echo "Starte Chromium-Browser mit Auflösung ${WIDTH}x${HEIGHT}..."
echo "Starte Chromium-Browser mit HTTPS und Auflösung ${WIDTH}x${HEIGHT}..."
exec chromium-browser \
--kiosk \
--no-sandbox \
--disable-infobars \
--disable-session-crashed-bubble \
--disable-restore-session-state \
--disable-web-security \
--disable-features=TranslateUI \
--disable-extensions \
--disable-plugins \
@@ -1039,18 +983,26 @@ elif command -v chromium-browser >/dev/null 2>&1; then
--disable-features=VizDisplayCompositor \
--enable-features=OverlayScrollbar \
--hide-scrollbars \
http://localhost:5000
--ignore-certificate-errors \
--ignore-ssl-errors \
--ignore-certificate-errors-spki-list \
--disable-web-security \
--allow-running-insecure-content \
--unsafely-treat-insecure-origin-as-secure=https://localhost:443 \
https://localhost:443
elif command -v firefox-esr >/dev/null 2>&1; then
echo "Starte Firefox ESR mit Auflösung ${WIDTH}x${HEIGHT}..."
# Firefox-Profil für Kiosk erstellen
echo "Starte Firefox ESR mit HTTPS und Auflösung ${WIDTH}x${HEIGHT}..."
# Firefox-Profil für HTTPS Kiosk erstellen
mkdir -p /home/kiosk/.mozilla/firefox/kiosk.default
cat > /home/kiosk/.mozilla/firefox/kiosk.default/user.js << FIREFOXEOF
user_pref("browser.shell.checkDefaultBrowser", false);
user_pref("browser.startup.homepage", "http://localhost:5000");
user_pref("browser.startup.homepage", "https://localhost:443");
user_pref("toolkit.legacyUserProfileCustomizations.stylesheets", true);
user_pref("browser.tabs.warnOnClose", false);
user_pref("browser.sessionstore.resume_from_crash", false);
user_pref("security.tls.insecure_fallback_hosts", "localhost");
user_pref("security.mixed_content.block_active_content", false);
user_pref("security.mixed_content.block_display_content", false);
user_pref("browser.cache.disk.enable", false);
user_pref("browser.cache.memory.enable", true);
user_pref("browser.cache.offline.enable", false);
@@ -1059,6 +1011,8 @@ user_pref("browser.fullscreen.autohide", true);
user_pref("dom.disable_open_during_load", false);
user_pref("privacy.popups.disable_from_plugins", 0);
user_pref("dom.popup_maximum", 0);
user_pref("security.cert_pinning.enforcement_level", 0);
user_pref("security.tls.unrestricted_rc4_fallback", true);
FIREFOXEOF
# Firefox CSS für randlosen Vollbildmodus
@@ -1082,7 +1036,7 @@ FIREFOXCSS
--width=${WIDTH} \
--height=${HEIGHT} \
--profile /home/kiosk/.mozilla/firefox/kiosk.default \
http://localhost:5000
https://localhost:443
else
echo "FEHLER: Kein Browser verfügbar!"
exit 1
@@ -1093,12 +1047,73 @@ EOF
chmod +x "$KIOSK_HOME/.xinitrc"
chown -R "$KIOSK_USER:$KIOSK_USER" "$KIOSK_HOME"
log "✅ Kiosk-Browser mit optimiertem Vollbildmodus konfiguriert"
log "✅ Kiosk-Browser mit HTTPS-Vollbildmodus konfiguriert"
}
# ========================== APP.PY SSL-UNTERSTÜTZUNG PRÜFEN ==========================
verify_app_ssl_support() {
log "=== PRÜFE APP.PY SSL-UNTERSTÜTZUNG ==="
if [ ! -f "$APP_DIR/app.py" ]; then
error "app.py nicht gefunden in $APP_DIR"
fi
# Prüfe ob get_ssl_context Funktion existiert
if grep -q "def get_ssl_context" "$APP_DIR/app.py"; then
log "✅ get_ssl_context Funktion bereits vorhanden in app.py"
else
progress "Füge SSL-Unterstützung zu app.py hinzu..."
# Backup der originalen app.py
cp "$APP_DIR/app.py" "$APP_DIR/app.py.backup.$(date +%s)"
# SSL-Funktion am Ende der Datei hinzufügen (vor dem if __name__ == '__main__' Block)
cat >> "$APP_DIR/app.py" << 'EOF'
def get_ssl_context():
"""
SSL-Kontext für HTTPS-Server erstellen
Verwendet localhost-Zertifikate falls verfügbar
"""
import os
ssl_cert_path = '/opt/myp/certs/localhost/localhost.crt'
ssl_key_path = '/opt/myp/certs/localhost/localhost.key'
if os.path.exists(ssl_cert_path) and os.path.exists(ssl_key_path):
try:
context = ssl.SSLContext(ssl.PROTOCOL_TLSv1_2)
context.load_cert_chain(ssl_cert_path, ssl_key_path)
context.check_hostname = False
context.verify_mode = ssl.CERT_NONE
print(f"✅ SSL-Kontext erstellt mit: {ssl_cert_path}")
return context
except Exception as e:
print(f"❌ Fehler beim Erstellen des SSL-Kontexts: {e}")
return None
else:
print(f"❌ SSL-Zertifikate nicht gefunden:")
print(f" Cert: {ssl_cert_path}")
print(f" Key: {ssl_key_path}")
return None
EOF
log "✅ SSL-Unterstützung zu app.py hinzugefügt"
fi
# Prüfe ob SSL-Imports vorhanden sind
if ! grep -q "import ssl" "$APP_DIR/app.py"; then
progress "Füge SSL-Import zu app.py hinzu..."
sed -i '1i import ssl' "$APP_DIR/app.py"
fi
log "✅ app.py SSL-Unterstützung verifiziert"
}
# ========================== PRODUKTIONS-KIOSK SETUP ==========================
setup_production_kiosk() {
log "=== RICHTE PRODUKTIONS-KIOSK-MODUS EIN ==="
log "=== RICHTE PRODUKTIONS-KIOSK-MODUS MIT HTTPS EIN ==="
# 1. System-Abhängigkeiten installieren
install_system_dependencies
@@ -1161,6 +1176,7 @@ setup_production_kiosk() {
mkdir -p "$APP_DIR/logs/auth"
mkdir -p "$APP_DIR/logs/errors"
mkdir -p "$APP_DIR/uploads/temp"
mkdir -p "$APP_DIR/certs/localhost"
# Berechtigungen setzen
chown -R root:root "$APP_DIR"
@@ -1168,65 +1184,70 @@ setup_production_kiosk() {
chmod 750 "$APP_DIR/database"
chmod 750 "$APP_DIR/logs"
chmod 755 "$APP_DIR/uploads"
chmod 750 "$APP_DIR/certs"
# 6. Backend-Services erstellen
create_backend_services
# 6. App.py SSL-Unterstützung prüfen und hinzufügen
verify_app_ssl_support
# 7. Autologin konfigurieren
# 7. SSL-Zertifikate für localhost erstellen
create_localhost_ssl_certificates
# 8. Backend-Service erstellen
create_backend_service
# 9. Autologin konfigurieren
configure_autologin
# 8. Kiosk-Browser konfigurieren
# 10. Kiosk-Browser konfigurieren
configure_kiosk_browser
# 9. Services aktivieren und starten
# 11. Service aktivieren und starten
progress "Lade Systemd-Konfiguration neu..."
systemctl daemon-reload || error "Systemd Reload fehlgeschlagen"
progress "Aktiviere alle Backend-Services..."
systemctl enable "$SERVICE_NAME_KIOSK.service" || error "Kiosk-Service Enable fehlgeschlagen"
systemctl enable "$SERVICE_NAME_HTTPS.service" || error "HTTPS-Service Enable fehlgeschlagen"
systemctl enable "$SERVICE_NAME_HTTP.service" || error "HTTP-Service Enable fehlgeschlagen"
progress "Aktiviere HTTPS Backend-Service..."
systemctl enable "$SERVICE_NAME.service" || error "HTTPS-Service Enable fehlgeschlagen"
progress "Starte alle Backend-Services..."
systemctl start "$SERVICE_NAME_KIOSK.service" || error "Kiosk-Service Start fehlgeschlagen"
systemctl start "$SERVICE_NAME_HTTPS.service" || warning "HTTPS-Service Start fehlgeschlagen (SSL möglicherweise nicht konfiguriert)"
systemctl start "$SERVICE_NAME_HTTP.service" || error "HTTP-Service Start fehlgeschlagen"
progress "Starte HTTPS Backend-Service..."
systemctl start "$SERVICE_NAME.service" || error "HTTPS-Service Start fehlgeschlagen"
# Service-Status prüfen
sleep 5
info "=== SERVICE-STATUS ==="
for service in "$SERVICE_NAME_KIOSK" "$SERVICE_NAME_HTTPS" "$SERVICE_NAME_HTTP"; do
if systemctl is-active --quiet "$service.service"; then
log "$service Service läuft erfolgreich"
else
warning "⚠️ $service Service läuft nicht - prüfen Sie die Logs: journalctl -u $service -f"
fi
done
if systemctl is-active --quiet "$SERVICE_NAME.service"; then
log "$SERVICE_NAME Service läuft erfolgreich"
else
warning "⚠️ $SERVICE_NAME Service läuft nicht - prüfen Sie die Logs: journalctl -u $SERVICE_NAME -f"
fi
# Backend-Tests
progress "Teste Backend-Erreichbarkeit..."
progress "Teste HTTPS Backend-Erreichbarkeit..."
sleep 3
if curl -s http://localhost:5000 > /dev/null 2>&1; then
log "✅ Port 5000 (Kiosk) erreichbar"
else
warning "⚠️ Port 5000 (Kiosk) nicht erreichbar"
fi
if curl -s http://localhost:80 > /dev/null 2>&1; then
log "✅ Port 80 (HTTP) erreichbar"
else
warning "⚠️ Port 80 (HTTP) nicht erreichbar"
fi
if curl -k -s https://localhost:443 > /dev/null 2>&1; then
log "✅ Port 443 (HTTPS) erreichbar"
else
warning "⚠️ Port 443 (HTTPS) nicht erreichbar (SSL möglicherweise nicht konfiguriert)"
warning "⚠️ Port 443 (HTTPS) nicht erreichbar"
# Zusätzliche Debug-Information
progress "Versuche SSL-Zertifikat zu testen..."
if openssl s_client -connect localhost:443 -servername localhost < /dev/null 2>/dev/null | grep -q "CONNECTED"; then
log "✅ SSL-Verbindung funktioniert"
else
warning "⚠️ SSL-Verbindung fehlgeschlagen"
fi
fi
log "✅ PRODUKTIONS-KIOSK-MODUS ERFOLGREICH EINGERICHTET"
# SSL-Zertifikat Status
if [ -f "$APP_DIR/certs/localhost/localhost.crt" ]; then
log "✅ SSL-Zertifikat vorhanden: $APP_DIR/certs/localhost/localhost.crt"
CERT_EXPIRY=$(openssl x509 -in "$APP_DIR/certs/localhost/localhost.crt" -noout -enddate | cut -d= -f2)
log "📅 Zertifikat läuft ab: $CERT_EXPIRY"
else
warning "⚠️ SSL-Zertifikat nicht gefunden"
fi
log "✅ PRODUKTIONS-KIOSK-MODUS MIT HTTPS ERFOLGREICH EINGERICHTET"
log ""
log "🚀 WICHTIG: NEUSTART ERFORDERLICH!"
log " sudo reboot"
@@ -1234,30 +1255,36 @@ setup_production_kiosk() {
log "📊 NACH DEM NEUSTART:"
log " • Automatischer Login als Benutzer: $KIOSK_USER"
log " • Automatischer X-Start und Chromium-Kiosk"
log " • Backend läuft auf 3 Ports:"
log " - http://localhost:5000 (Kiosk-Anzeige)"
log " - http://localhost:80 (HTTP-API)"
log " - https://localhost:443 (HTTPS-API)"
log " • Backend läuft auf HTTPS:"
log " - https://localhost:443 (Kiosk-Anzeige mit SSL)"
log " - https://0.0.0.0:443 (Netzwerk-Zugriff)"
log ""
log "🔐 SSL-ZERTIFIKATE:"
log " • Self-Signed Zertifikat für localhost erstellt"
log " • Chromium akzeptiert Zertifikat automatisch"
log " • Zertifikat im System CA-Store installiert"
log ""
log "🔧 SERVICE-BEFEHLE:"
log " • Status: sudo systemctl status myp-{kiosk,https,http}"
log " • Logs: sudo journalctl -u myp-kiosk -f"
log " • Restart: sudo systemctl restart myp-{kiosk,https,http}"
log " • Status: sudo systemctl status $SERVICE_NAME"
log " • Logs: sudo journalctl -u $SERVICE_NAME -f"
log " • Restart: sudo systemctl restart $SERVICE_NAME"
log " • SSL-Test: curl -k https://localhost:443"
log ""
warning "🔄 FÜHRE JETZT 'sudo reboot' AUS, UM DEN KIOSK-MODUS ZU AKTIVIEREN!"
warning "🔄 FÜHRE JETZT 'sudo reboot' AUS, UM DEN HTTPS-KIOSK-MODUS ZU AKTIVIEREN!"
}
# ========================== HAUPTMENÜ ==========================
show_menu() {
clear
echo -e "${BLUE}=================================================================${NC}"
echo -e "${GREEN} $APP_NAME - VOLLSTÄNDIGER KIOSK-INSTALLER${NC}"
echo -e "${GREEN} $APP_NAME - HTTPS KIOSK-INSTALLER${NC}"
echo -e "${BLUE}=================================================================${NC}"
echo ""
echo -e "${YELLOW}Aktuelles Verzeichnis:${NC} $CURRENT_DIR"
echo -e "${YELLOW}Systemzeit:${NC} $(date)"
echo -e "${YELLOW}Zielverzeichnis:${NC} $APP_DIR"
echo -e "${YELLOW}Kiosk-Benutzer:${NC} $KIOSK_USER"
echo -e "${YELLOW}HTTPS-Service:${NC} $SERVICE_NAME"
echo ""
echo -e "${PURPLE}Wählen Sie eine Option:${NC}"
echo ""
@@ -1265,17 +1292,21 @@ show_menu() {
echo -e " → Installiert Python 3, pip und alle benötigten Pakete"
echo -e " → Verwendet: pip install --break-system-packages"
echo -e " → Mercedes SSL-Zertifikate werden konfiguriert"
echo -e " → Node.js und npm für Frontend-Build"
echo ""
echo -e "${GREEN}2)${NC} VOLLSTÄNDIGER KIOSK-MODUS installieren"
echo -e "${GREEN}2)${NC} VOLLSTÄNDIGER HTTPS KIOSK-MODUS installieren"
echo -e "${RED}ENTFERNT ALLE DESKTOP-ENVIRONMENTS!${NC}"
echo -e " → Installiert minimale X11-Umgebung"
echo -e " → Erstellt 3 Backend-Services (Port 5000, 80, 443)"
echo -e " → Konfiguriert Autologin und Kiosk-Browser"
echo -e " → Erstellt Self-Signed SSL-Zertifikate für localhost"
echo -e " → Erstellt HTTPS Backend-Service (Port 443)"
echo -e " → Konfiguriert Autologin und HTTPS Kiosk-Browser"
echo -e " → Browser öffnet: ${BLUE}https://localhost:443${NC}"
echo -e "${YELLOW}NEUSTART ERFORDERLICH!${NC}"
echo ""
echo -e "${RED}0)${NC} Beenden"
echo ""
echo -e "${RED}⚠️ WARNUNG: Option 2 macht Raspberry Pi zu reinem Kiosk-System!${NC}"
echo -e "${RED}⚠️ WARNUNG: Option 2 macht Raspberry Pi zu reinem HTTPS-Kiosk-System!${NC}"
echo -e "${GREEN}🔐 HTTPS: Automatische SSL-Zertifikat-Generierung für localhost${NC}"
echo -e "${BLUE}=================================================================${NC}"
echo -n "Ihre Wahl [0-2]: "
}
@@ -1290,11 +1321,12 @@ main() {
mkdir -p "$(dirname "$INSTALL_LOG")"
touch "$INSTALL_LOG"
log "=== MYP VOLLSTÄNDIGER KIOSK-INSTALLER GESTARTET ==="
log "=== MYP HTTPS KIOSK-INSTALLER GESTARTET ==="
log "Arbeitsverzeichnis: $CURRENT_DIR"
log "Zielverzeichnis: $APP_DIR"
log "Kiosk-Services: $SERVICE_NAME_KIOSK, $SERVICE_NAME_HTTPS, $SERVICE_NAME_HTTP"
log "HTTPS-Service: $SERVICE_NAME"
log "Kiosk-Benutzer: $KIOSK_USER"
log "SSL-Zertifikate: $APP_DIR/certs/localhost/"
log "System: $(uname -a)"
log "Debian-Version: $(cat /etc/debian_version 2>/dev/null || echo 'Unbekannt')"
@@ -1315,19 +1347,21 @@ main() {
2)
clear
echo -e "${RED}⚠️ WARNUNG: Sie sind dabei, alle Desktop-Environments zu entfernen!${NC}"
echo -e "${YELLOW}Der Raspberry Pi wird zu einem reinen Kiosk-System umgebaut.${NC}"
echo -e "${BLUE}Nach der Installation startet automatisch der Kiosk-Browser.${NC}"
echo -e "${YELLOW}Der Raspberry Pi wird zu einem reinen HTTPS-Kiosk-System umgebaut.${NC}"
echo -e "${BLUE}Nach der Installation startet automatisch der HTTPS-Kiosk-Browser.${NC}"
echo -e "${GREEN}SSL-Zertifikate für localhost werden automatisch generiert.${NC}"
echo ""
echo -n "Sind Sie sicher? [ja/NEIN]: "
read -r confirm
if [ "$confirm" = "ja" ] || [ "$confirm" = "JA" ]; then
clear
log "=== OPTION 2: VOLLSTÄNDIGER KIOSK-MODUS ==="
log "=== OPTION 2: VOLLSTÄNDIGER HTTPS KIOSK-MODUS ==="
setup_production_kiosk
echo ""
echo -e "${GREEN}✅ KIOSK-MODUS ERFOLGREICH EINGERICHTET!${NC}"
echo -e "${GREEN} HTTPS KIOSK-MODUS ERFOLGREICH EINGERICHTET!${NC}"
echo -e "${RED}🔄 NEUSTART JETZT ERFORDERLICH: sudo reboot${NC}"
echo -e "${BLUE}🔐 HTTPS-URL: https://localhost:443${NC}"
echo -e "${YELLOW}Drücken Sie Enter, um fortzufahren...${NC}"
read -r
else
@@ -1336,7 +1370,7 @@ main() {
fi
;;
0)
log "=== INSTALLER BEENDET ==="
log "=== HTTPS KIOSK-INSTALLER BEENDET ==="
echo -e "${GREEN}Auf Wiedersehen!${NC}"
echo -e "${BLUE}Log-Datei: $INSTALL_LOG${NC}"
exit 0