diff --git a/backend/app/database/myp.db-shm b/backend/app/database/myp.db-shm index 02044429..a3e50774 100644 Binary files a/backend/app/database/myp.db-shm and b/backend/app/database/myp.db-shm differ diff --git a/backend/app/database/myp.db-wal b/backend/app/database/myp.db-wal index c92a0359..2f0f6dfe 100644 Binary files a/backend/app/database/myp.db-wal and b/backend/app/database/myp.db-wal differ diff --git a/backend/app/installer.sh b/backend/app/installer.sh index 0ebccddf..c72d523b 100644 --- a/backend/app/installer.sh +++ b/backend/app/installer.sh @@ -60,6 +60,73 @@ check_debian_system() { log "✅ Debian/Raspbian-System erkannt" } +# ========================== MERCEDES ZERTIFIKATE ========================== +install_mercedes_certificates() { + log "=== INSTALLIERE MERCEDES SSL-ZERTIFIKATE ===" + + progress "Aktualisiere CA-Zertifikate..." + + # CA-Zertifikate Paket installieren/aktualisieren + apt-get install -y ca-certificates curl || error "CA-Zertifikate Installation fehlgeschlagen" + + # Standard CA-Bundle aktualisieren + update-ca-certificates || warning "CA-Zertifikate Update teilweise fehlgeschlagen" + + # Mercedes Corporate Zertifikate installieren (falls vorhanden) + if [ -d "$CURRENT_DIR/certs/mercedes" ] && [ "$(ls -A $CURRENT_DIR/certs/mercedes 2>/dev/null)" ]; then + progress "Installiere Mercedes Corporate Zertifikate..." + + # Alle .crt und .pem Dateien kopieren + find "$CURRENT_DIR/certs/mercedes" -type f \( -name "*.crt" -o -name "*.pem" -o -name "*.cer" \) -exec cp {} /usr/local/share/ca-certificates/ \; 2>/dev/null || true + + # Zertifikate aktualisieren + update-ca-certificates || warning "Mercedes Zertifikate Update fehlgeschlagen" + + log "✅ Mercedes Zertifikate installiert" + else + info "Keine Mercedes Zertifikate gefunden - verwende Standard CA-Bundle" + fi + + # Python SSL-Konfiguration optimieren + progress "Konfiguriere Python SSL-Einstellungen..." + + # pip Konfiguration für SSL + mkdir -p /root/.pip + cat > /root/.pip/pip.conf << EOF +[global] +trusted-host = pypi.org + pypi.python.org + files.pythonhosted.org +cert = /etc/ssl/certs/ca-certificates.crt +timeout = 60 +retries = 3 + +[install] +trusted-host = pypi.org + pypi.python.org + files.pythonhosted.org +EOF + + # Python HTTPS-Konfiguration + export SSL_CERT_FILE="/etc/ssl/certs/ca-certificates.crt" + export REQUESTS_CA_BUNDLE="/etc/ssl/certs/ca-certificates.crt" + export CURL_CA_BUNDLE="/etc/ssl/certs/ca-certificates.crt" + + # Pip auf neueste Version aktualisieren + progress "Aktualisiere pip auf neueste Version..." + python3 -m pip install --upgrade pip --break-system-packages --trusted-host pypi.org --trusted-host pypi.python.org --trusted-host files.pythonhosted.org || warning "pip Update fehlgeschlagen" + + # SSL-Test durchführen + progress "Teste SSL-Verbindung zu PyPI..." + if python3 -c "import ssl, urllib.request; urllib.request.urlopen('https://pypi.org')" 2>/dev/null; then + log "✅ SSL-Verbindung zu PyPI erfolgreich" + else + warning "⚠️ SSL-Verbindung zu PyPI problematisch - Installation wird dennoch versucht" + fi + + log "✅ Mercedes SSL-Zertifikate und Python-Konfiguration abgeschlossen" +} + # ========================== ABHÄNGIGKEITEN INSTALLIEREN ========================== install_system_dependencies() { log "=== INSTALLIERE SYSTEM-ABHÄNGIGKEITEN ===" @@ -91,38 +158,44 @@ install_system_dependencies() { sqlite3 \ || error "System-Pakete Installation fehlgeschlagen" - progress "Installiere Python-Abhängigkeiten mit --break-system-packages..." + # WICHTIG: Mercedes Zertifikate vor Python-Paketen installieren + install_mercedes_certificates + + progress "Installiere Python-Abhängigkeiten mit Mercedes SSL-Konfiguration..." + + # SSL-freundliche pip-Installation mit Fallback-Optionen + PIP_OPTS="--break-system-packages --trusted-host pypi.org --trusted-host pypi.python.org --trusted-host files.pythonhosted.org --timeout 60 --retries 3" # Core Flask Framework - pip3 install --break-system-packages Flask==3.1.1 || error "Flask Installation fehlgeschlagen" - pip3 install --break-system-packages Flask-Login==0.6.3 || error "Flask-Login Installation fehlgeschlagen" - pip3 install --break-system-packages Flask-WTF==1.2.1 || error "Flask-WTF Installation fehlgeschlagen" + pip3 install $PIP_OPTS Flask==3.1.1 || pip3 install $PIP_OPTS Flask || error "Flask Installation fehlgeschlagen" + pip3 install $PIP_OPTS Flask-Login==0.6.3 || pip3 install $PIP_OPTS Flask-Login || error "Flask-Login Installation fehlgeschlagen" + pip3 install $PIP_OPTS Flask-WTF==1.2.1 || pip3 install $PIP_OPTS Flask-WTF || error "Flask-WTF Installation fehlgeschlagen" # Datenbank - pip3 install --break-system-packages SQLAlchemy==2.0.36 || error "SQLAlchemy Installation fehlgeschlagen" + pip3 install $PIP_OPTS SQLAlchemy==2.0.36 || pip3 install $PIP_OPTS SQLAlchemy || error "SQLAlchemy Installation fehlgeschlagen" # Sicherheit - pip3 install --break-system-packages bcrypt==4.2.1 || error "bcrypt Installation fehlgeschlagen" - pip3 install --break-system-packages cryptography==44.0.0 || error "cryptography Installation fehlgeschlagen" - pip3 install --break-system-packages Werkzeug==3.1.3 || error "Werkzeug Installation fehlgeschlagen" + pip3 install $PIP_OPTS bcrypt==4.2.1 || pip3 install $PIP_OPTS bcrypt || error "bcrypt Installation fehlgeschlagen" + pip3 install $PIP_OPTS cryptography==44.0.0 || pip3 install $PIP_OPTS cryptography || error "cryptography Installation fehlgeschlagen" + pip3 install $PIP_OPTS Werkzeug==3.1.3 || pip3 install $PIP_OPTS Werkzeug || error "Werkzeug Installation fehlgeschlagen" # Smart Plug Steuerung - pip3 install --break-system-packages PyP100 || warning "PyP100 Installation fehlgeschlagen (optional)" + pip3 install $PIP_OPTS PyP100 || warning "PyP100 Installation fehlgeschlagen (optional)" # HTTP Requests - pip3 install --break-system-packages requests==2.32.3 || error "requests Installation fehlgeschlagen" + pip3 install $PIP_OPTS requests==2.32.3 || pip3 install $PIP_OPTS requests || error "requests Installation fehlgeschlagen" # System Monitoring - pip3 install --break-system-packages psutil==6.1.1 || error "psutil Installation fehlgeschlagen" + pip3 install $PIP_OPTS psutil==6.1.1 || pip3 install $PIP_OPTS psutil || error "psutil Installation fehlgeschlagen" # Redis (optional) - pip3 install --break-system-packages redis==5.2.1 || warning "redis Installation fehlgeschlagen (optional)" + pip3 install $PIP_OPTS redis==5.2.1 || warning "redis Installation fehlgeschlagen (optional)" # Weitere Core-Abhängigkeiten - pip3 install --break-system-packages MarkupSafe==3.0.2 || error "MarkupSafe Installation fehlgeschlagen" + pip3 install $PIP_OPTS MarkupSafe==3.0.2 || pip3 install $PIP_OPTS MarkupSafe || error "MarkupSafe Installation fehlgeschlagen" # Produktions-Server - pip3 install --break-system-packages gunicorn==23.0.0 || error "gunicorn Installation fehlgeschlagen" + pip3 install $PIP_OPTS gunicorn==23.0.0 || pip3 install $PIP_OPTS gunicorn || error "gunicorn Installation fehlgeschlagen" log "✅ Alle Abhängigkeiten erfolgreich installiert" }