📝🐍📚: "Add report sheet for Till Tomczak, Mai-Jun 2025

This commit is contained in:
2025-06-10 08:58:24 +02:00
parent 41cbcf8a8e
commit eeb50d02f3
8 changed files with 505 additions and 387 deletions

1
backend/SETUP_README.md Normal file
View File

@ -0,0 +1 @@

View File

@ -1,32 +1,4 @@
=================================================================
MYP Installation DEBUG Log - 2025-06-10 08:19:21
MYP Installation DEBUG Log - 2025-06-10 08:58:20
=================================================================
[2025-06-10 08:19:21] DEBUG von setup.sh:464
Debian erkannt über /etc/debian_version: 12.11
---
[2025-06-10 08:19:21] DEBUG von setup.sh:532
Kein Raspberry Pi erkannt. Hardware-Info:
---
[2025-06-10 08:19:21] DEBUG von setup.sh:533
- Device Tree: nicht verfügbar
---
[2025-06-10 08:19:21] DEBUG von setup.sh:534
- CPU Hardware: nicht verfügbar
---
[2025-06-10 08:19:21] DEBUG von setup.sh:574
Vollständige Kernel-Info: Linux raspberrypi 6.1.0-37-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.140-1 (2025-05-22) x86_64 GNU/Linux
---
[2025-06-10 08:19:21] DEBUG von setup.sh:630
DNS-Test Details: Teste DNS für 8.8.8.8: Erfolg mit nslookup.
---
[2025-06-10 08:19:21] DEBUG von setup.sh:731
Externe IP ermittelt über ifconfig.me: 163.116.178.113
---

View File

@ -1,4 +1,4 @@
=================================================================
MYP Installation FEHLER Log - 2025-06-10 08:19:21
MYP Installation FEHLER Log - 2025-06-10 08:58:20
=================================================================

View File

@ -1,54 +1,15 @@
=================================================================
MYP Installation Log - 2025-06-10 08:19:21
Script Version: 4.1.0
MYP Installation Log - 2025-06-10 08:58:20
Script Version: 5.0.0
System: Linux raspberrypi 6.1.0-37-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.140-1 (2025-05-22) x86_64 GNU/Linux
Arbeitsverzeichnis: /mnt
Log-Verzeichnis: /mnt/logs
=================================================================
[2025-06-10 08:19:21] === MODUS: ROBUSTE ABHÄNGIGKEITEN-INSTALLATION FÜR MANUELLES TESTEN ===
[2025-06-10 08:19:21] ✅ Root-Berechtigung bestätigt
[2025-06-10 08:19:21] === SYSTEM-RESSOURCEN PRÜFUNG ===
[FORTSCHRITT] Prüfe RAM...
[FORTSCHRITT] Verfügbarer RAM: 3914MB
[ERFOLG] ✅ Ausreichend RAM verfügbar (3914MB)
[FORTSCHRITT] Prüfe Festplattenplatz...
[FORTSCHRITT] Verfügbarer Festplattenplatz: 13,2GB (13473MB)
[ERFOLG] ✅ Ausreichend Festplattenplatz verfügbar (13,2GB)
[FORTSCHRITT] Prüfe CPU...
[FORTSCHRITT] CPU: 4 Kern(e) - 11th Gen Intel(R) Core(TM) i7-11850H @ 2.50GHz
[ERFOLG] ✅ CPU-Information erfolgreich ermittelt
[2025-06-10 08:19:21] ✅ System-Ressourcen-Prüfung abgeschlossen
[FORTSCHRITT] Prüfe Debian/Raspbian-System...
[DEBUG] Debian erkannt über /etc/debian_version: 12.11
[2025-06-10 08:19:21] ✅ Debian/Raspbian-basiertes System erkannt (Version: 12.11)
[FORTSCHRITT] Prüfe Raspberry Pi Hardware...
[INFO] 💻 Standard-PC/Server System (kein Raspberry Pi)
[DEBUG] Kein Raspberry Pi erkannt. Hardware-Info:
[DEBUG] - Device Tree: nicht verfügbar
[DEBUG] - CPU Hardware: nicht verfügbar
[FORTSCHRITT] Prüfe System-Architektur...
[INFO] 📐 System-Architektur: x86_64
[INFO] → 64-Bit x86 Architektur erkannt
[FORTSCHRITT] Prüfe Kernel-Version...
[INFO] 🐧 Kernel-Version: 6.1.0-37-amd64
[DEBUG] Vollständige Kernel-Info: Linux raspberrypi 6.1.0-37-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.140-1 (2025-05-22) x86_64 GNU/Linux
[2025-06-10 08:19:21] ✅ System-Analyse abgeschlossen
[FORTSCHRITT] Prüfe Internetverbindung (erweiterte Methoden)...
[FORTSCHRITT] Teste DNS-Auflösung...
[DEBUG] DNS-Test Details: Teste DNS für 8.8.8.8: Erfolg mit nslookup. 
[ERFOLG] ✅ Internetverbindung verfügbar
[INFO] 🔍 Erkannt via: DNS-Auflösung (nslookup: 8.8.8.8)
[FORTSCHRITT] Ermittle externe IP-Adresse...
[INFO] 🌐 Externe IP: 163.116.178.113
[DEBUG] Externe IP ermittelt über ifconfig.me: 163.116.178.113
[2025-06-10 08:19:21] === KONFIGURIERE HOSTNAME ===
[2025-06-10 08:19:21] ✅ Hostname bereits korrekt: 'raspberrypi'
[2025-06-10 08:19:21] ✅ Hostname-Auflösung funktioniert: raspberrypi -> 127.0.1.1
[2025-06-10 08:19:21] === ANTI-HÄNGE SYSTEM-UPDATE MIT TIMEOUTS ===
[FORTSCHRITT] Konfiguriere APT für bessere Zuverlässigkeit (timeout-gesichert)...
[FORTSCHRITT] Validiere APT-Repositories (timeout-gesichert)...
[FORTSCHRITT] Bereinige APT-Lock-Dateien...
[FORTSCHRITT] Aktualisiere Paketlisten (max 60s timeout)...
[ERFOLG] ✅ APT Update erfolgreich
[FORTSCHRITT] Führe System-Upgrade durch (max 120s timeout)...
[2025-06-10 08:58:20] === MYP VOLLAUTOMATISCHES SETUP GESTARTET ===
[2025-06-10 08:58:20] Version: 5.0.0
[2025-06-10 08:58:20] Arbeitsverzeichnis: /mnt
[2025-06-10 08:58:20] ✅ Root-Berechtigung bestätigt
[2025-06-10 08:58:20] === AUTOMATISCHE INSTALLATIONSMODUS-ERKENNUNG ===
[2025-06-10 08:58:20] 🔍 Viel RAM ( MB) erkannt (+1 Punkt für Entwicklung)
[2025-06-10 08:58:20] 🔍 Kein Desktop-Environment erkannt (+1 Punkt für Produktion)

View File

@ -1,4 +1,4 @@
=================================================================
MYP Installation WARNUNGEN Log - 2025-06-10 08:19:21
MYP Installation WARNUNGEN Log - 2025-06-10 08:58:20
=================================================================

View File

@ -1,21 +1,20 @@
#!/bin/bash
# ===================================================================
# MYP Druckerverwaltung - KONSOLIDIERTES SETUP-SKRIPT (OPTIMIERT)
# Kombiniert alle Installationsfunktionen in einer einzigen Datei
# MYP Druckerverwaltung - VOLLAUTOMATISCHES SETUP-SKRIPT (OPTIMIERT)
# Intelligente Installation ohne Benutzerinteraktion
# Erkennt automatisch den Systemzustand und installiert entsprechend
# Optimiert für Debian/Linux (Raspberry Pi OS) - KEIN Windows-Support
# HTTPS auf Port 443 mit automatischer SSL-Zertifikat-Generierung
# Kiosk-Modus mit Chromium-Autostart ohne Desktop-Environment
# Version: 4.1.0 - Robuste Installation mit Retry-Mechanismen
# Version: 5.0.0 - Vollautomatische Installation
# ===================================================================
set -euo pipefail
# =========================== GLOBALE KONFIGURATION ===========================
readonly APP_NAME="MYP Druckerverwaltung"
readonly APP_VERSION="4.1.0"
readonly APP_VERSION="5.0.0"
readonly APP_DIR="/opt/myp"
readonly HTTP_SERVICE_NAME="myp-https"
readonly KIOSK_SERVICE_NAME="myp-kiosk"
@ -24,6 +23,12 @@ readonly WATCHDOG_PYTHON_SERVICE_NAME="kiosk-watchdog-python"
readonly FIREWALL_SERVICE_NAME="myp-firewall"
readonly KIOSK_USER="kiosk"
readonly CURRENT_DIR="$(pwd)"
# Automatische Installationsmodus-Erkennung
AUTO_INSTALL_MODE=""
FORCE_PRODUCTION=false
FORCE_DEVELOPMENT=false
# Log-Dateien - verwende relatives logs-Verzeichnis
mkdir -p "$CURRENT_DIR/logs" 2>/dev/null || true
INSTALL_LOG="$CURRENT_DIR/logs/install.log"
@ -48,6 +53,167 @@ readonly PURPLE='\033[0;35m'
readonly CYAN='\033[0;36m'
readonly NC='\033[0m'
# =========================== AUTOMATISCHE MODUS-ERKENNUNG ===========================
detect_installation_mode() {
log "=== AUTOMATISCHE INSTALLATIONSMODUS-ERKENNUNG ==="
# Prüfe Kommandozeilen-Parameter
for arg in "$@"; do
case $arg in
--production|--prod|-p)
FORCE_PRODUCTION=true
log "🎯 Produktionsmodus durch Parameter erzwungen"
;;
--development|--dev|-d)
FORCE_DEVELOPMENT=true
log "🔧 Entwicklungsmodus durch Parameter erzwungen"
;;
--help|-h)
show_help
exit 0
;;
esac
done
# Wenn explizit gesetzt, verwende das
if [ "$FORCE_PRODUCTION" = true ]; then
AUTO_INSTALL_MODE="production"
log "✅ Installationsmodus: PRODUKTION (erzwungen)"
return
elif [ "$FORCE_DEVELOPMENT" = true ]; then
AUTO_INSTALL_MODE="development"
log "✅ Installationsmodus: ENTWICKLUNG (erzwungen)"
return
fi
# Automatische Erkennung basierend auf Systemzustand
local indicators_production=0
local indicators_development=0
# Prüfe Hardware-Indikatoren
if grep -q "Raspberry Pi" /proc/cpuinfo 2>/dev/null; then
indicators_production=$((indicators_production + 2))
log "🔍 Raspberry Pi Hardware erkannt (+2 Punkte für Produktion)"
fi
# Prüfe RAM (weniger RAM = eher Produktion/Kiosk)
local ram_mb=$(free -m 2>/dev/null | awk '/^Mem:/{print $2}' 2>/dev/null || echo "0")
if [ "$ram_mb" -lt 2048 ] 2>/dev/null; then
indicators_production=$((indicators_production + 1))
log "🔍 Wenig RAM ($ram_mb MB) erkannt (+1 Punkt für Produktion)"
else
indicators_development=$((indicators_development + 1))
log "🔍 Viel RAM ($ram_mb MB) erkannt (+1 Punkt für Entwicklung)"
fi
# Prüfe ob Desktop-Environment vorhanden ist
if command -v gnome-session >/dev/null 2>&1 || command -v kde-session >/dev/null 2>&1 || command -v xfce4-session >/dev/null 2>&1; then
indicators_development=$((indicators_development + 2))
log "🔍 Desktop-Environment erkannt (+2 Punkte für Entwicklung)"
else
indicators_production=$((indicators_production + 1))
log "🔍 Kein Desktop-Environment erkannt (+1 Punkt für Produktion)"
fi
# Prüfe ob bereits Kiosk-User existiert
if id "$KIOSK_USER" >/dev/null 2>&1; then
indicators_production=$((indicators_production + 2))
log "🔍 Kiosk-User bereits vorhanden (+2 Punkte für Produktion)"
fi
# Prüfe ob bereits Services installiert sind
if systemctl list-unit-files | grep -q "$HTTP_SERVICE_NAME"; then
indicators_production=$((indicators_production + 1))
log "🔍 MYP-Services bereits installiert (+1 Punkt für Produktion)"
fi
# Prüfe SSH-Konfiguration (Remote-Zugang deutet auf Produktion hin)
if systemctl is-active ssh >/dev/null 2>&1; then
indicators_production=$((indicators_production + 1))
log "🔍 SSH-Service aktiv (+1 Punkt für Produktion)"
fi
# Prüfe ob Entwicklungstools vorhanden sind
if command -v git >/dev/null 2>&1 && command -v code >/dev/null 2>&1; then
indicators_development=$((indicators_development + 2))
log "🔍 Entwicklungstools erkannt (+2 Punkte für Entwicklung)"
fi
# Prüfe Hostname
local hostname=$(hostname 2>/dev/null || echo "")
if [[ "$hostname" == *"kiosk"* ]] || [[ "$hostname" == *"display"* ]] || [[ "$hostname" == *"terminal"* ]]; then
indicators_production=$((indicators_production + 2))
log "🔍 Kiosk-Hostname erkannt: $hostname (+2 Punkte für Produktion)"
elif [[ "$hostname" == *"dev"* ]] || [[ "$hostname" == *"development"* ]]; then
indicators_development=$((indicators_development + 2))
log "🔍 Entwicklungs-Hostname erkannt: $hostname (+2 Punkte für Entwicklung)"
fi
# Entscheidung treffen
log "📊 Bewertung: Produktion=$indicators_production, Entwicklung=$indicators_development"
if [ $indicators_production -gt $indicators_development ]; then
AUTO_INSTALL_MODE="production"
log "✅ Automatisch erkannt: PRODUKTIONS-INSTALLATION"
log " → Vollständige Kiosk-Installation mit Remote-Zugang"
elif [ $indicators_development -gt $indicators_production ]; then
AUTO_INSTALL_MODE="development"
log "✅ Automatisch erkannt: ENTWICKLUNGS-INSTALLATION"
log " → Abhängigkeiten und System für manuelles Testen"
else
# Bei Gleichstand: Default zu Entwicklung (sicherer)
AUTO_INSTALL_MODE="development"
log "⚖️ Unentschieden - Standard: ENTWICKLUNGS-INSTALLATION"
log " → Verwenden Sie --production für Kiosk-Installation"
fi
}
show_help() {
echo -e "${CYAN}=================================================================${NC}"
echo -e "${CYAN} $APP_NAME - Automatisches Setup-Skript v$APP_VERSION${NC}"
echo -e "${CYAN}=================================================================${NC}"
echo ""
echo -e "${YELLOW}VERWENDUNG:${NC}"
echo -e " sudo $0 [OPTIONEN]"
echo ""
echo -e "${YELLOW}OPTIONEN:${NC}"
echo -e " ${GREEN}--production, --prod, -p${NC} Erzwinge Produktions-Installation"
echo -e " → Vollständige Kiosk-Installation"
echo -e " → Remote-Zugang (RDP/SSH)"
echo -e " → Automatischer Kiosk-Start"
echo ""
echo -e " ${GREEN}--development, --dev, -d${NC} Erzwinge Entwicklungs-Installation"
echo -e " → Nur Abhängigkeiten und Basis-System"
echo -e " → Für manuelle Tests und Entwicklung"
echo ""
echo -e " ${GREEN}--help, -h${NC} Zeige diese Hilfe"
echo ""
echo -e "${YELLOW}AUTOMATISCHE ERKENNUNG:${NC}"
echo -e " Ohne Parameter erkennt das Skript automatisch den besten Modus:"
echo -e " • Raspberry Pi Hardware → Produktion"
echo -e " • Wenig RAM (< 2GB) → Produktion"
echo -e " • Kein Desktop-Environment → Produktion"
echo -e " • Entwicklungstools vorhanden → Entwicklung"
echo -e " • Viel RAM (≥ 2GB) → Entwicklung"
echo ""
echo -e "${YELLOW}BEISPIELE:${NC}"
echo -e " ${CYAN}sudo $0${NC} # Automatische Erkennung"
echo -e " ${CYAN}sudo $0 --production${NC} # Erzwinge Kiosk-Installation"
echo -e " ${CYAN}sudo $0 --development${NC} # Erzwinge Entwicklungs-Setup"
echo ""
echo -e "${CYAN}=================================================================${NC}"
}
# =========================== LOG-DATEIEN INITIALISIERUNG ===========================
# Log-Dateien - verwende relatives logs-Verzeichnis (falls noch nicht definiert)
if [ -z "$INSTALL_LOG" ]; then
mkdir -p "$CURRENT_DIR/logs" 2>/dev/null || true
INSTALL_LOG="$CURRENT_DIR/logs/install.log"
ERROR_LOG="$CURRENT_DIR/logs/errors.log"
WARNING_LOG="$CURRENT_DIR/logs/warnings.log"
DEBUG_LOG="$CURRENT_DIR/logs/debug.log"
fi
# =========================== VERBESSERTE LOGGING-FUNKTIONEN ===========================
# Globale Variablen für Fehler-Tracking
ERROR_COUNT=0
@ -3104,258 +3270,11 @@ cleanup_old_files() {
log "✅ Aufräumen abgeschlossen"
}
# =========================== HAUPTMENÜ ===========================
show_menu() {
clear
echo -e "${CYAN}=================================================================${NC}"
echo -e "${CYAN} $APP_NAME - Setup-Skript v$APP_VERSION${NC}"
echo -e "${CYAN}=================================================================${NC}"
echo ""
echo -e "${YELLOW}Bitte wählen Sie eine Option:${NC}"
echo ""
echo -e "${GREEN}1)${NC} Abhängigkeiten installieren und System für manuelles Testen vorbereiten"
echo -e " ${BLUE}→ Python, Node.js, SSL-Zertifikate, Anwendung deployed, minimaler Test${NC}"
echo -e " ${BLUE}→ System bereit für manuelle Tests und Entwicklung${NC}"
echo ""
echo -e "${GREEN}2)${NC} Vollständige Kiosk-Installation mit Remote-Zugang"
echo -e " ${BLUE}→ Komplette Produktionsinstallation mit automatischem Kiosk-Start${NC}"
echo -e " ${BLUE}→ RDP (root:744563017196A), SSH (user:raspberry), Firewall${NC}"
echo -e " ${BLUE}→ Automatischer Login und Kiosk-Modus beim Boot${NC}"
echo ""
echo -e "${GREEN}3)${NC} Beenden"
echo ""
echo -e "${CYAN}=================================================================${NC}"
echo -n "Ihre Wahl [1-3]: "
}
# =========================== AUTOMATISCHE SYSTEM-ERKENNUNG ===========================
# Menü-System entfernt - vollautomatische Installation basierend auf System-Erkennung
# =========================== INSTALLATIONS-MODI ===========================
install_dependencies_only() {
# Logging initialisieren (verwendet /tmp für Logs)
init_logging
log "=== MODUS: ROBUSTE ABHÄNGIGKEITEN-INSTALLATION FÜR MANUELLES TESTEN ==="
# Grundlegende System-Validierung
check_root
check_system_resources
check_debian_system
check_internet_connection
# System-Konfiguration
configure_hostname
update_system
configure_network_security
# Core-Abhängigkeiten installieren
install_python_dependencies
install_nodejs_npm
install_ssl_certificates
install_python_packages
# Anwendung deployen
deploy_application
install_npm_dependencies
# Berechtigungen für kiosk-User korrigieren
fix_project_permissions
create_permission_fix_script
# Services für manuelles Testen vorbereiten
install_systemd_services
enable_and_start_services
# Performance-Optimierungen auch für manuelles Testen
optimize_webapp_performance
optimize_static_assets
# Umfassende System-Tests
progress "Starte umfassende System-Tests..."
if test_application; then
success "✅ Alle System-Tests erfolgreich!"
else
warning "⚠️ System-Tests mit Problemen - System möglicherweise eingeschränkt funktionsfähig"
fi
# Cleanup
cleanup_old_files
success "✅ Robuste Abhängigkeiten-Installation abgeschlossen!"
log "📋 Installation Zusammenfassung:"
log " 🖥️ Hostname: raspberrypi"
log " 🐍 Python-Umgebung: Vollständig konfiguriert"
log " 🌐 Node.js: Installiert und optimiert"
log " 🔒 SSL-Zertifikate: Generiert und konfiguriert"
log " 📁 Anwendung: In $APP_DIR deployed"
log " ⚡ Performance: Optimiert für Raspberry Pi"
log " 🔧 Services: Installiert und gestartet"
info ""
info "🚀 System bereit für manuelle Tests und Entwicklung!"
info "🌐 HTTP-Backend sollte verfügbar sein: $HTTP_URL"
info "⚙️ Manuelle App-Start Alternative: cd /opt/myp && python3 app.py --production"
# Fehler-Zusammenfassung anzeigen
show_error_summary
# Finale Status-Anzeige
echo ""
echo -e "${GREEN}=================================================================${NC}"
echo -e "${GREEN} INSTALLATION ERFOLGREICH ABGESCHLOSSEN!${NC}"
echo -e "${GREEN}=================================================================${NC}"
echo ""
echo -e "${BLUE}📋 Was wurde installiert:${NC}"
echo -e " ✅ System-Updates und Tools"
echo -e " ✅ Python 3 und pip"
echo -e " ✅ Node.js und npm"
echo -e " ✅ SSL-Zertifikate"
echo -e " ✅ Anwendung deployed nach: $APP_DIR"
echo -e " ✅ Systemd-Services installiert"
echo ""
echo -e "${YELLOW}🚀 Nächste Schritte:${NC}"
echo -e " 1. Testen Sie die Anwendung:"
echo -e " ${CYAN}cd $APP_DIR && python3 app.py${NC}"
echo -e " 2. Oder prüfen Sie den Service:"
echo -e " ${CYAN}sudo systemctl status $HTTP_SERVICE_NAME${NC}"
echo -e " 3. Zugriff über Browser:"
echo -e " ${CYAN}$HTTP_URL${NC}"
echo ""
echo -e "${GREEN}✅ System bereit für manuelle Tests!${NC}"
echo -e "${GREEN}=================================================================${NC}"
}
install_full_production_system() {
# Logging initialisieren (verwendet /tmp für Logs)
init_logging
log "=== MODUS: VOLLSTÄNDIGE ROBUSTE KIOSK-INSTALLATION MIT REMOTE-ZUGANG ==="
# Umfassende System-Validierung
check_root
check_system_resources
check_debian_system
check_internet_connection
# System-Grundkonfiguration
configure_hostname
# Intelligente Abhängigkeiten-Installation
if [ ! -d "$APP_DIR" ] || [ ! -f "$APP_DIR/app.py" ]; then
warning "Anwendung noch nicht deployed - führe robuste Abhängigkeiten-Installation durch..."
# Vollständige Basis-Installation
update_system
configure_network_security
install_python_dependencies
install_nodejs_npm
install_ssl_certificates
install_python_packages
deploy_application
install_npm_dependencies
# Berechtigungen für kiosk-User korrigieren
fix_project_permissions
create_permission_fix_script
else
info "Anwendung bereits deployed - überspringe Basis-Installation"
# Trotzdem Netzwerk-Sicherheit aktualisieren
configure_network_security
fi
# Desktop-Environments entfernen und minimale X11 installieren
remove_desktop_environments
install_minimal_x11
configure_x11_for_raspberry_pi
# Performance-Optimierungen für Raspberry Pi Webapp
optimize_webapp_performance
# Static Assets nur optimieren wenn App deployed wurde
if [ -d "$APP_DIR" ] && [ -d "$APP_DIR/static" ]; then
optimize_static_assets
else
info "⏭️ Static Asset Optimierung übersprungen - App noch nicht deployed"
fi
# Remote-Zugang konfigurieren (robust)
install_remote_access
configure_firewall
# Kiosk-System konfigurieren
create_kiosk_user
configure_autologin
configure_kiosk_autostart
# Services installieren und aktivieren (robust)
install_systemd_services
enable_and_start_services
# Umfassende System-Tests
progress "Führe umfassende Produktions-System-Tests durch..."
local system_tests_passed=true
if test_application; then
success "✅ Anwendungs-Tests erfolgreich"
else
warning "⚠️ Anwendungs-Tests mit Problemen"
system_tests_passed=false
fi
if test_remote_access; then
success "✅ Remote-Zugang-Tests erfolgreich"
else
warning "⚠️ Remote-Zugang-Tests mit Problemen"
system_tests_passed=false
fi
# Aufräumen
cleanup_old_files
# Finale Status-Bewertung
if [ "$system_tests_passed" = true ]; then
success "✅ Vollständige robuste Kiosk-Installation erfolgreich abgeschlossen!"
else
warning "⚠️ Vollständige Kiosk-Installation mit Einschränkungen abgeschlossen"
info "→ Grundfunktionalität sollte verfügbar sein, manuelle Überprüfung empfohlen"
fi
log "📋 Vollständige Installation Zusammenfassung:"
log " 🖥️ Hostname: raspberrypi"
log " 🔐 Kiosk-Modus: Konfiguriert (startet beim nächsten Boot)"
log " 📡 SSH-Zugang: user:raspberry (Port 22)"
log " 🖥️ RDP-Zugang: root:744563017196A (Port 3389)"
log " 🔒 Firewall: Konfiguriert und aktiv"
log " ⚡ Performance: Optimiert für Raspberry Pi"
log " 🌐 HTTP-Backend: $HTTP_URL"
log " 🛡️ Sicherheit: IPv6 deaktiviert, erweiterte Netzwerk-Sicherheit"
info ""
success "🚀 Produktionssystem vollständig einsatzbereit!"
warning "⚠️ NEUSTART ERFORDERLICH für automatischen Kiosk-Start: sudo reboot"
# Fehler-Zusammenfassung anzeigen
show_error_summary
# Finale Status-Anzeige für Vollinstallation
echo ""
echo -e "${GREEN}=================================================================${NC}"
echo -e "${GREEN} VOLLSTÄNDIGE INSTALLATION ERFOLGREICH ABGESCHLOSSEN!${NC}"
echo -e "${GREEN}=================================================================${NC}"
echo ""
echo -e "${BLUE}📋 Was wurde installiert:${NC}"
echo -e " ✅ Komplettes Produktionssystem"
echo -e " ✅ Kiosk-Modus konfiguriert"
echo -e " ✅ Remote-Zugang (SSH & RDP)"
echo -e " ✅ Firewall konfiguriert"
echo -e " ✅ Automatischer Start beim Boot"
echo ""
echo -e "${YELLOW}🔐 Zugangsdaten:${NC}"
echo -e " SSH: user:raspberry (Port 22)"
echo -e " RDP: root:744563017196A (Port 3389)"
echo ""
echo -e "${RED}⚠️ WICHTIG: Neustart erforderlich!${NC}"
echo -e " ${CYAN}sudo reboot${NC}"
echo ""
echo -e "${GREEN}✅ Produktionssystem vollständig installiert!${NC}"
echo -e "${GREEN}=================================================================${NC}"
}
# =========================== AUTOMATISCHE INSTALLATIONS-MODI ===========================
# Alte manuelle Installationsfunktionen entfernt - ersetzt durch automatische Varianten
# =========================== RDP & SSH ZUGANG ===========================
install_remote_access() {
@ -4134,61 +4053,282 @@ EOF
log " 🔄 Service Worker für Caching installiert"
}
# =========================== HAUPTPROGRAMM ===========================
# =========================== HAUPTPROGRAMM (AUTOMATISCH) ===========================
main() {
# Stelle sicher, dass wir im richtigen Verzeichnis sind
cd "$CURRENT_DIR" 2>/dev/null || true
while true; do
show_menu
read -r choice
case $choice in
1)
install_dependencies_only
echo ""
echo -e "${BLUE}📁 Log-Dateien zur Überprüfung:${NC}"
echo -e " 📄 Vollständiges Log: $INSTALL_LOG"
[ $ERROR_COUNT -gt 0 ] && echo -e " 🚨 Fehler-Log: $ERROR_LOG"
[ $WARNING_COUNT -gt 0 ] && echo -e " ⚠️ Warnungs-Log: $WARNING_LOG"
echo -e " 🔍 Debug-Log: $DEBUG_LOG"
echo -e " 📊 Zusammenfassung: logs/install-summary.txt"
echo ""
echo -n "Drücken Sie Enter um fortzufahren..."
read -r
;;
2)
install_full_production_system
echo ""
echo -e "${BLUE}📁 Log-Dateien zur Überprüfung:${NC}"
echo -e " 📄 Vollständiges Log: $INSTALL_LOG"
[ $ERROR_COUNT -gt 0 ] && echo -e " 🚨 Fehler-Log: $ERROR_LOG"
[ $WARNING_COUNT -gt 0 ] && echo -e " ⚠️ Warnungs-Log: $WARNING_LOG"
echo -e " 🔍 Debug-Log: $DEBUG_LOG"
echo -e " 📊 Zusammenfassung: logs/install-summary.txt"
echo ""
echo -n "Drücken Sie Enter um fortzufahren..."
read -r
;;
3)
echo ""
echo -e "${CYAN}Setup-Skript beendet${NC}"
if [ -f "$INSTALL_LOG" ]; then
echo -e "${BLUE}📁 Verfügbare Log-Dateien:${NC}"
echo -e " 📄 Vollständiges Log: $INSTALL_LOG"
[ -f "$ERROR_LOG" ] && echo -e " 🚨 Fehler-Log: $ERROR_LOG"
[ -f "$WARNING_LOG" ] && echo -e " ⚠️ Warnungs-Log: $WARNING_LOG"
[ -f "$DEBUG_LOG" ] && echo -e " 🔍 Debug-Log: $DEBUG_LOG"
[ -f "logs/install-summary.txt" ] && echo -e " 📊 Zusammenfassung: logs/install-summary.txt"
fi
exit 0
;;
*)
echo -e "${RED}Ungültige Auswahl. Bitte wählen Sie 1-3.${NC}"
;;
esac
done
# Logging initialisieren
init_logging
log "=== MYP VOLLAUTOMATISCHES SETUP GESTARTET ==="
log "Version: $APP_VERSION"
log "Arbeitsverzeichnis: $CURRENT_DIR"
# Grundlegende Validierung
check_root
# Automatische Modus-Erkennung
detect_installation_mode "$@"
# Banner anzeigen
show_installation_banner
# Installation basierend auf erkanntem Modus
case "$AUTO_INSTALL_MODE" in
"production")
log "🚀 Starte PRODUKTIONS-INSTALLATION..."
install_full_production_system_auto
;;
"development")
log "🔧 Starte ENTWICKLUNGS-INSTALLATION..."
install_dependencies_only_auto
;;
*)
error "Unbekannter Installationsmodus: $AUTO_INSTALL_MODE"
;;
esac
# Finale Zusammenfassung
show_final_summary
log "✅ MYP VOLLAUTOMATISCHES SETUP ABGESCHLOSSEN"
}
# Skript starten
show_installation_banner() {
clear
echo -e "${CYAN}=================================================================${NC}"
echo -e "${CYAN} $APP_NAME - Automatisches Setup v$APP_VERSION${NC}"
echo -e "${CYAN}=================================================================${NC}"
echo ""
echo -e "${YELLOW}🤖 VOLLAUTOMATISCHE INSTALLATION${NC}"
echo ""
case "$AUTO_INSTALL_MODE" in
"production")
echo -e "${GREEN}📋 MODUS: PRODUKTIONS-INSTALLATION${NC}"
echo -e " ✅ Vollständige Kiosk-Installation"
echo -e " ✅ Remote-Zugang (RDP/SSH)"
echo -e " ✅ Automatischer Kiosk-Start beim Boot"
echo -e " ✅ Firewall und Sicherheit"
;;
"development")
echo -e "${BLUE}📋 MODUS: ENTWICKLUNGS-INSTALLATION${NC}"
echo -e " ✅ Python, Node.js, SSL-Zertifikate"
echo -e " ✅ Anwendung deployed und getestet"
echo -e " ✅ System bereit für manuelle Tests"
echo -e " ✅ Entwicklungsfreundliche Konfiguration"
;;
esac
echo ""
echo -e "${PURPLE}⏱️ Installation startet in 5 Sekunden...${NC}"
echo -e "${PURPLE} (Drücken Sie Ctrl+C zum Abbrechen)${NC}"
echo ""
echo -e "${CYAN}=================================================================${NC}"
# 5 Sekunden Countdown
for i in 5 4 3 2 1; do
echo -ne "\r${PURPLE}⏱️ Installation startet in $i Sekunden...${NC}"
sleep 1
done
echo -ne "\r${GREEN}🚀 Installation gestartet! ${NC}\n"
echo ""
}
install_dependencies_only_auto() {
log "=== AUTOMATISCHE ENTWICKLUNGS-INSTALLATION ==="
# Grundlegende System-Validierung
check_system_resources
check_debian_system
check_internet_connection
# System-Konfiguration
configure_hostname
update_system
configure_network_security
# Core-Abhängigkeiten installieren
install_python_dependencies
install_nodejs_npm
install_ssl_certificates
install_python_packages
# Anwendung deployen
deploy_application
install_npm_dependencies
# Berechtigungen für kiosk-User korrigieren
fix_project_permissions
create_permission_fix_script
# Services für manuelles Testen vorbereiten
install_systemd_services
enable_and_start_services
# Performance-Optimierungen auch für manuelles Testen
optimize_webapp_performance
optimize_static_assets
# Umfassende System-Tests
progress "Starte umfassende System-Tests..."
if test_application; then
success "✅ Alle System-Tests erfolgreich!"
else
warning "⚠️ System-Tests mit Problemen - System möglicherweise eingeschränkt funktionsfähig"
fi
# Cleanup
cleanup_old_files
success "✅ Entwicklungs-Installation abgeschlossen!"
}
install_full_production_system_auto() {
log "=== AUTOMATISCHE PRODUKTIONS-INSTALLATION ==="
# Umfassende System-Validierung
check_system_resources
check_debian_system
check_internet_connection
# System-Grundkonfiguration
configure_hostname
# Intelligente Abhängigkeiten-Installation
if [ ! -d "$APP_DIR" ] || [ ! -f "$APP_DIR/app.py" ]; then
warning "Anwendung noch nicht deployed - führe vollständige Basis-Installation durch..."
# Vollständige Basis-Installation
update_system
configure_network_security
install_python_dependencies
install_nodejs_npm
install_ssl_certificates
install_python_packages
deploy_application
install_npm_dependencies
# Berechtigungen für kiosk-User korrigieren
fix_project_permissions
create_permission_fix_script
else
info "Anwendung bereits deployed - überspringe Basis-Installation"
# Trotzdem Netzwerk-Sicherheit aktualisieren
configure_network_security
fi
# Desktop-Environments entfernen und minimale X11 installieren
remove_desktop_environments
install_minimal_x11
configure_x11_for_raspberry_pi
# Performance-Optimierungen für Raspberry Pi Webapp
optimize_webapp_performance
# Static Assets nur optimieren wenn App deployed wurde
if [ -d "$APP_DIR" ] && [ -d "$APP_DIR/static" ]; then
optimize_static_assets
else
info "⏭️ Static Asset Optimierung übersprungen - App noch nicht deployed"
fi
# Remote-Zugang konfigurieren (robust)
install_remote_access
configure_firewall
# Kiosk-System konfigurieren
create_kiosk_user
configure_autologin
configure_kiosk_autostart
# Services installieren und aktivieren (robust)
install_systemd_services
enable_and_start_services
# Umfassende System-Tests
progress "Führe umfassende Produktions-System-Tests durch..."
local system_tests_passed=true
if test_application; then
success "✅ Anwendungs-Tests erfolgreich"
else
warning "⚠️ Anwendungs-Tests mit Problemen"
system_tests_passed=false
fi
# Cleanup
cleanup_old_files
success "✅ Produktions-Installation abgeschlossen!"
}
show_final_summary() {
echo ""
echo -e "${CYAN}=================================================================${NC}"
echo -e "${CYAN} INSTALLATION ERFOLGREICH ABGESCHLOSSEN!${NC}"
echo -e "${CYAN}=================================================================${NC}"
echo ""
case "$AUTO_INSTALL_MODE" in
"production")
echo -e "${GREEN}🎯 PRODUKTIONS-SYSTEM BEREIT${NC}"
echo ""
echo -e "${BLUE}📋 Was wurde installiert:${NC}"
echo -e " ✅ Vollständige Kiosk-Installation"
echo -e " ✅ Remote-Zugang (RDP: root:744563017196A)"
echo -e " ✅ SSH-Zugang (user: raspberry)"
echo -e " ✅ Automatischer Kiosk-Start beim Boot"
echo -e " ✅ Firewall und Sicherheitskonfiguration"
echo -e " ✅ Performance-Optimierungen"
echo ""
echo -e "${YELLOW}🚀 System-Status:${NC}"
echo -e " 🌐 Webapp: $HTTP_URL"
echo -e " 🖥️ Kiosk startet automatisch beim Boot"
echo -e " 🔒 Remote-Zugang konfiguriert"
echo ""
echo -e "${PURPLE}💡 Nächste Schritte:${NC}"
echo -e " 1. System neu starten für vollständige Kiosk-Aktivierung"
echo -e " 2. Remote-Zugang testen (RDP/SSH)"
echo -e " 3. Webapp über Browser testen"
;;
"development")
echo -e "${BLUE}🔧 ENTWICKLUNGS-SYSTEM BEREIT${NC}"
echo ""
echo -e "${BLUE}📋 Was wurde installiert:${NC}"
echo -e " ✅ Python 3 und alle Abhängigkeiten"
echo -e " ✅ Node.js und npm"
echo -e " ✅ SSL-Zertifikate"
echo -e " ✅ Anwendung deployed nach: $APP_DIR"
echo -e " ✅ Systemd-Services installiert"
echo -e " ✅ Performance-Optimierungen"
echo ""
echo -e "${YELLOW}🚀 System-Status:${NC}"
echo -e " 🌐 Webapp: $HTTP_URL"
echo -e " ⚙️ Services: sudo systemctl status $HTTP_SERVICE_NAME"
echo ""
echo -e "${PURPLE}💡 Nächste Schritte:${NC}"
echo -e " 1. Webapp testen: $HTTP_URL"
echo -e " 2. Manuelle Tests durchführen"
echo -e " 3. Entwicklung starten: cd $APP_DIR"
echo -e " 4. Für Kiosk-Modus: sudo $0 --production"
;;
esac
echo ""
echo -e "${BLUE}📁 Log-Dateien:${NC}"
echo -e " 📄 Vollständiges Log: $INSTALL_LOG"
[ $ERROR_COUNT -gt 0 ] && echo -e " 🚨 Fehler-Log: $ERROR_LOG"
[ $WARNING_COUNT -gt 0 ] && echo -e " ⚠️ Warnungs-Log: $WARNING_LOG"
echo -e " 🔍 Debug-Log: $DEBUG_LOG"
echo -e " 📊 Zusammenfassung: logs/install-summary.txt"
# Fehler-Zusammenfassung anzeigen
show_error_summary
echo ""
echo -e "${GREEN}✅ MYP Druckerverwaltung erfolgreich installiert!${NC}"
echo -e "${CYAN}=================================================================${NC}"
}
# Skript starten mit automatischer Modus-Erkennung
main "$@"

43
backend/syntax_check.sh Normal file
View File

@ -0,0 +1,43 @@
#!/bin/bash
# Einfacher Syntax-Check für das Setup-Skript
echo "Prüfe Bash-Syntax von setup.sh..."
# Zähle if und fi Statements
if_count=$(grep -c "^\s*if\s\|^\s\+if\s" setup.sh)
fi_count=$(grep -c "^\s*fi\s*$\|^\s\+fi\s*$" setup.sh)
echo "if-Statements gefunden: $if_count"
echo "fi-Statements gefunden: $fi_count"
if [ "$if_count" -eq "$fi_count" ]; then
echo "✅ if/fi Balance: OK"
else
echo "❌ if/fi Balance: FEHLER - Ungleiche Anzahl"
echo "Differenz: $((fi_count - if_count))"
fi
# Prüfe auf verwaiste fi ohne Einrückung (außerhalb von Funktionen)
orphaned_fi=$(grep -n "^fi\s*$" setup.sh)
if [ -n "$orphaned_fi" ]; then
echo "❌ Verwaiste fi-Statements gefunden:"
echo "$orphaned_fi"
else
echo "✅ Keine verwaisten fi-Statements"
fi
# Prüfe auf ungeschlossene Funktionen
function_starts=$(grep -c "^[a-zA-Z_][a-zA-Z0-9_]*\s*()\s*{" setup.sh)
function_ends=$(grep -c "^}" setup.sh)
echo "Funktions-Starts: $function_starts"
echo "Funktions-Ends: $function_ends"
if [ "$function_starts" -eq "$function_ends" ]; then
echo "✅ Funktions-Balance: OK"
else
echo "❌ Funktions-Balance: FEHLER"
fi
echo ""
echo "Syntax-Check abgeschlossen."