🎉 Refactor backend: Remove unnecessary files & update documentation 📚, 🔧 Clean up node_modules & static assets 🗑️, 📝 Update README.md & related docs 📚, 🚀 Deploy new frontend images 📦.

This commit is contained in:
2025-05-31 22:51:37 +02:00
parent df8fb197c0
commit fae594014d
34 changed files with 681 additions and 2628 deletions

View File

@@ -192,7 +192,7 @@ install_mercedes_certificates() {
progress "Aktualisiere CA-Zertifikate..."
# CA-Zertifikate Paket installieren/aktualisieren
apt-get install -y ca-certificates curl || error "CA-Zertifikate Installation fehlgeschlagen"
apt-get install -y ca-certificates curl openssl || error "CA-Zertifikate Installation fehlgeschlagen"
# Standard CA-Bundle aktualisieren
update-ca-certificates || warning "CA-Zertifikate Update teilweise fehlgeschlagen"
@@ -201,21 +201,104 @@ install_mercedes_certificates() {
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
# Erstelle temporäres Verzeichnis für Zertifikat-Verarbeitung
TEMP_CERT_DIR="/tmp/mercedes_certs"
mkdir -p "$TEMP_CERT_DIR"
# Zertifikate aktualisieren
# Alle Zertifikatsdateien verarbeiten (.crt, .pem, .cer)
find "$CURRENT_DIR/certs/mercedes" -type f \( -name "*.crt" -o -name "*.pem" -o -name "*.cer" \) | while read cert_file; do
cert_basename=$(basename "$cert_file")
cert_name="${cert_basename%.*}"
progress "Verarbeite Mercedes-Zertifikat: $cert_basename"
# .cer Dateien in .crt konvertieren (falls nötig)
if [[ "$cert_file" == *.cer ]]; then
progress "Konvertiere .cer zu .crt: $cert_basename"
# Überprüfe ob es sich um DER- oder PEM-Format handelt
if openssl x509 -in "$cert_file" -text -noout >/dev/null 2>&1; then
# PEM-Format - direkt kopieren mit .crt Endung
cp "$cert_file" "$TEMP_CERT_DIR/${cert_name}.crt"
elif openssl x509 -in "$cert_file" -inform DER -text -noout >/dev/null 2>&1; then
# DER-Format - zu PEM konvertieren
openssl x509 -in "$cert_file" -inform DER -out "$TEMP_CERT_DIR/${cert_name}.crt" -outform PEM
else
warning "Unbekanntes Zertifikatformat: $cert_file"
continue
fi
else
# .crt oder .pem - direkt kopieren
cp "$cert_file" "$TEMP_CERT_DIR/"
fi
# Zertifikat validieren
if openssl x509 -in "$TEMP_CERT_DIR/${cert_name}.crt" -text -noout >/dev/null 2>&1; then
log "✅ Zertifikat validiert: ${cert_name}.crt"
# In CA-Zertifikate-Verzeichnis kopieren
cp "$TEMP_CERT_DIR/${cert_name}.crt" "/usr/local/share/ca-certificates/"
else
warning "⚠️ Ungültiges Zertifikat übersprungen: $cert_file"
fi
done
# Spezielle Mercedes-Zertifikate verarbeiten
if [ -f "$CURRENT_DIR/certs/mercedes/Corp-Pri-Root-CA.cer" ]; then
progress "Installiere Mercedes Corporate Primary Root CA..."
# Versuche DER-zu-PEM Konvertierung
if openssl x509 -in "$CURRENT_DIR/certs/mercedes/Corp-Pri-Root-CA.cer" -inform DER -out "/usr/local/share/ca-certificates/Mercedes-Corp-Pri-Root-CA.crt" -outform PEM 2>/dev/null; then
log "✅ Corp-Pri-Root-CA.cer erfolgreich als DER konvertiert"
# Versuche direkte PEM-Kopie
elif openssl x509 -in "$CURRENT_DIR/certs/mercedes/Corp-Pri-Root-CA.cer" -text -noout >/dev/null 2>&1; then
cp "$CURRENT_DIR/certs/mercedes/Corp-Pri-Root-CA.cer" "/usr/local/share/ca-certificates/Mercedes-Corp-Pri-Root-CA.crt"
log "✅ Corp-Pri-Root-CA.cer direkt als PEM kopiert"
else
warning "⚠️ Corp-Pri-Root-CA.cer Format nicht erkannt - übersprungen"
fi
fi
if [ -f "$CURRENT_DIR/certs/mercedes/Corp-Root-CA-G2.cer" ]; then
progress "Installiere Mercedes Corporate Root CA G2..."
# Versuche DER-zu-PEM Konvertierung
if openssl x509 -in "$CURRENT_DIR/certs/mercedes/Corp-Root-CA-G2.cer" -inform DER -out "/usr/local/share/ca-certificates/Mercedes-Corp-Root-CA-G2.crt" -outform PEM 2>/dev/null; then
log "✅ Corp-Root-CA-G2.cer erfolgreich als DER konvertiert"
# Versuche direkte PEM-Kopie
elif openssl x509 -in "$CURRENT_DIR/certs/mercedes/Corp-Root-CA-G2.cer" -text -noout >/dev/null 2>&1; then
cp "$CURRENT_DIR/certs/mercedes/Corp-Root-CA-G2.cer" "/usr/local/share/ca-certificates/Mercedes-Corp-Root-CA-G2.crt"
log "✅ Corp-Root-CA-G2.cer direkt als PEM kopiert"
else
warning "⚠️ Corp-Root-CA-G2.cer Format nicht erkannt - übersprungen"
fi
fi
# Temporäres Verzeichnis aufräumen
rm -rf "$TEMP_CERT_DIR"
# CA-Zertifikate aktualisieren
update-ca-certificates || warning "Mercedes Zertifikate Update fehlgeschlagen"
log "✅ Mercedes Zertifikate installiert"
# Installierte Mercedes-Zertifikate auflisten
MERCEDES_CERTS=$(ls /usr/local/share/ca-certificates/*Mercedes* 2>/dev/null | wc -l)
if [ "$MERCEDES_CERTS" -gt 0 ]; then
log "$MERCEDES_CERTS Mercedes-Zertifikate erfolgreich installiert"
ls /usr/local/share/ca-certificates/*Mercedes* 2>/dev/null | while read cert; do
log " 📜 $(basename "$cert")"
done
else
warning "⚠️ Keine Mercedes-Zertifikate installiert"
fi
else
info "Keine Mercedes Zertifikate gefunden - verwende Standard CA-Bundle"
info "Keine Mercedes-Zertifikate gefunden - verwende Standard CA-Bundle"
fi
# Python SSL-Konfiguration optimieren
progress "Konfiguriere Python SSL-Einstellungen..."
# pip Konfiguration für SSL
# pip Konfiguration für SSL mit erweiterten Optionen
mkdir -p /root/.pip
cat > /root/.pip/pip.conf << EOF
[global]
@@ -225,31 +308,58 @@ trusted-host = pypi.org
cert = /etc/ssl/certs/ca-certificates.crt
timeout = 60
retries = 3
no-cache-dir = true
[install]
trusted-host = pypi.org
pypi.python.org
files.pythonhosted.org
no-warn-script-location = true
EOF
# Python HTTPS-Konfiguration
# Python HTTPS-Konfiguration mit Mercedes-Support
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"
export PYTHONHTTPSVERIFY=1
# Node.js SSL-Konfiguration hinzufügen
export NODE_TLS_REJECT_UNAUTHORIZED=1
export NODE_EXTRA_CA_CERTS="/etc/ssl/certs/ca-certificates.crt"
# npm SSL-Konfiguration mit verbesserter Fehlerbehandlung
progress "Konfiguriere npm SSL-Einstellungen..."
npm config set ca "" 2>/dev/null || true
npm config set cafile "/etc/ssl/certs/ca-certificates.crt" 2>/dev/null || true
npm config set strict-ssl true 2>/dev/null || true
npm config set registry "https://registry.npmjs.org/" 2>/dev/null || true
# 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..."
# SSL-Tests durchführen
progress "Teste SSL-Verbindungen..."
# Test 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"
warning "⚠️ SSL-Verbindung zu PyPI problematisch"
fi
log "✅ Mercedes SSL-Zertifikate und Python-Konfiguration abgeschlossen"
# Test npm Registry
if npm ping --registry https://registry.npmjs.org >/dev/null 2>&1; then
log "✅ SSL-Verbindung zu npm Registry erfolgreich"
else
warning "⚠️ SSL-Verbindung zu npm Registry problematisch"
fi
# Zeige installierte CA-Zertifikate-Anzahl
CA_COUNT=$(ls /etc/ssl/certs/*.pem 2>/dev/null | wc -l)
log "✅ Insgesamt $CA_COUNT CA-Zertifikate im System verfügbar"
log "✅ Mercedes SSL-Zertifikate und System-Konfiguration abgeschlossen"
}
# ========================== ABHÄNGIGKEITEN INSTALLIEREN ==========================
@@ -286,21 +396,35 @@ install_system_dependencies() {
# ========================== NODE.JS UND NPM INSTALLATION ==========================
progress "Installiere Node.js und npm..."
# NodeSource Repository für neueste LTS Version hinzufügen
progress "Füge NodeSource Repository hinzu..."
curl -fsSL https://deb.nodesource.com/setup_lts.x | bash - || {
warning "NodeSource Repository konnte nicht hinzugefügt werden - verwende Debian-Pakete"
apt-get install -y nodejs npm || error "Node.js Installation aus Debian-Repository fehlgeschlagen"
# Alte Node.js-Installationen entfernen
progress "Entferne alte Node.js-Installationen..."
apt-get remove --purge -y nodejs npm 2>/dev/null || true
apt-get autoremove -y 2>/dev/null || true
# NodeSource Repository für Node.js LTS 20.x hinzufügen
progress "Füge NodeSource Repository für Node.js 20.x LTS hinzu..."
curl -fsSL https://deb.nodesource.com/setup_20.x | bash - || {
warning "NodeSource Repository konnte nicht hinzugefügt werden"
# Fallback: Manueller Download und Installation
progress "Fallback: Installiere Node.js aus Debian-Repository..."
apt-get update -y
apt-get install -y nodejs npm || {
error "Node.js Installation komplett fehlgeschlagen"
}
}
# Node.js aus NodeSource Repository installieren (falls Repository erfolgreich hinzugefügt)
if [ -f /etc/apt/sources.list.d/nodesource.list ]; then
progress "Installiere Node.js LTS aus NodeSource Repository..."
progress "Installiere Node.js 20.x LTS aus NodeSource Repository..."
apt-get update -y
apt-get install -y nodejs || error "Node.js Installation aus NodeSource fehlgeschlagen"
apt-get install -y nodejs || {
warning "NodeSource Installation fehlgeschlagen - verwende Fallback"
apt-get install -y nodejs npm || error "Node.js Fallback Installation fehlgeschlagen"
}
fi
# Überprüfe Node.js und npm Installation
# Überprüfe Node.js Installation
if command -v node >/dev/null 2>&1; then
NODE_VERSION=$(node --version)
log "✅ Node.js erfolgreich installiert: $NODE_VERSION"
@@ -308,25 +432,32 @@ install_system_dependencies() {
error "❌ Node.js Installation fehlgeschlagen"
fi
# npm sollte automatisch mit Node.js mitgeliefert werden
if command -v npm >/dev/null 2>&1; then
NPM_VERSION=$(npm --version)
log "✅ npm erfolgreich installiert: $NPM_VERSION"
log "✅ npm automatisch installiert: $NPM_VERSION"
# npm auf neueste Version aktualisieren
progress "Aktualisiere npm auf neueste Version..."
npm install -g npm@latest || warning "npm Update fehlgeschlagen"
NPM_VERSION_NEW=$(npm --version)
log "✅ npm aktualisiert: $NPM_VERSION_NEW"
# VORSICHTIG: npm NUR aktualisieren wenn Node.js >= 18
NODE_MAJOR_VERSION=$(node --version | cut -d'.' -f1 | sed 's/v//')
if [ "$NODE_MAJOR_VERSION" -ge 18 ]; then
progress "Node.js $NODE_MAJOR_VERSION erkannt - npm-Update möglich..."
npm install -g npm@latest --force 2>/dev/null || {
warning "npm-Update fehlgeschlagen - verwende bestehende Version $NPM_VERSION"
}
NPM_VERSION_NEW=$(npm --version)
log "✅ npm Version: $NPM_VERSION_NEW"
else
warning "⚠️ Node.js < 18 - npm-Update übersprungen für Kompatibilität"
fi
else
error "❌ npm Installation fehlgeschlagen"
error "❌ npm nicht verfügbar"
fi
# npm-Konfiguration für bessere Performance und Sicherheit
# npm-Konfiguration für bessere Performance
progress "Konfiguriere npm-Einstellungen..."
npm config set fund false
npm config set audit-level moderate
npm config set package-lock true
npm config set save-exact true
npm config set fund false 2>/dev/null || true
npm config set audit-level moderate 2>/dev/null || true
npm config set package-lock true 2>/dev/null || true
# WICHTIG: Mercedes Zertifikate vor Python-Paketen installieren
install_mercedes_certificates
@@ -377,12 +508,30 @@ install_system_dependencies() {
# npm install OHNE --production um auch devDependencies (TailwindCSS) zu installieren
progress "Installiere alle npm-Abhängigkeiten (inklusive devDependencies für TailwindCSS)..."
npm install --no-optional --no-audit --no-fund || {
warning "npm install fehlgeschlagen - versuche mit --legacy-peer-deps"
npm install --no-optional --no-audit --no-fund --legacy-peer-deps || error "npm install komplett fehlgeschlagen"
}
log "✅ npm-Abhängigkeiten erfolgreich installiert:"
# Erste Versuche: Standard-Installation
if npm install --no-optional --no-audit --no-fund 2>/dev/null; then
log "✅ npm install erfolgreich (Standard)"
# Zweiter Versuch: Mit legacy-peer-deps
elif npm install --no-optional --no-audit --no-fund --legacy-peer-deps 2>/dev/null; then
log "✅ npm install erfolgreich (mit --legacy-peer-deps)"
# Dritter Versuch: Mit force Flag
elif npm install --no-optional --no-audit --no-fund --force 2>/dev/null; then
log "✅ npm install erfolgreich (mit --force)"
# Vierter Versuch: Mit allen Flags
elif npm install --no-optional --no-audit --no-fund --legacy-peer-deps --force 2>/dev/null; then
log "✅ npm install erfolgreich (mit allen Flags)"
else
warning "⚠️ npm install fehlgeschlagen - versuche manuelle Paket-Installation..."
# Manuelle Installation der wichtigsten Pakete
npm install tailwindcss --no-audit --no-fund --force 2>/dev/null || warning "TailwindCSS Installation fehlgeschlagen"
npm install @tailwindcss/forms --no-audit --no-fund --force 2>/dev/null || warning "@tailwindcss/forms Installation fehlgeschlagen"
npm install chart.js --no-audit --no-fund --force 2>/dev/null || warning "Chart.js Installation fehlgeschlagen"
npm install @fortawesome/fontawesome-free --no-audit --no-fund --force 2>/dev/null || warning "FontAwesome Installation fehlgeschlagen"
fi
log "✅ npm-Abhängigkeiten-Installation abgeschlossen:"
log " 📦 Dependencies: FontAwesome, FullCalendar, Chart.js, Vite"
log " 🛠️ DevDependencies: TailwindCSS, PostCSS, Autoprefixer"
@@ -390,19 +539,28 @@ install_system_dependencies() {
if npx tailwindcss --help >/dev/null 2>&1; then
log "✅ TailwindCSS erfolgreich installiert und verfügbar"
else
error "❌ TailwindCSS nicht verfügbar - Build wird fehlschlagen"
warning "❌ TailwindCSS nicht verfügbar - versuche globale Installation..."
npm install -g tailwindcss --force 2>/dev/null || error "TailwindCSS Installation komplett fehlgeschlagen"
fi
# Überprüfe auf Build-Scripts und führe sie aus
if npm run | grep -q "build:css"; then
progress "CSS-Build-Script gefunden - führe npm run build:css aus..."
npm run build:css || error "npm run build:css fehlgeschlagen - TailwindCSS Build nicht möglich"
log "✅ TailwindCSS Build abgeschlossen - CSS-Dateien generiert"
if npm run build:css 2>/dev/null; then
log "✅ TailwindCSS Build erfolgreich abgeschlossen"
else
warning "⚠️ npm run build:css fehlgeschlagen - versuche direkten npx-Aufruf..."
if npx tailwindcss -i ./static/css/input.css -o ./static/css/tailwind.min.css --minify 2>/dev/null; then
log "✅ TailwindCSS mit npx erfolgreich kompiliert"
else
error "❌ TailwindCSS Build komplett fehlgeschlagen"
fi
fi
fi
if npm run | grep -q "build" && ! npm run | grep -q "build:css"; then
progress "Haupt-Build-Script gefunden - führe npm run build aus..."
npm run build || warning "npm run build fehlgeschlagen"
npm run build 2>/dev/null || warning "npm run build fehlgeschlagen"
log "✅ Frontend-Build abgeschlossen"
fi