1218 lines
37 KiB
Bash
1218 lines
37 KiB
Bash
#!/bin/bash
|
|
# MYP Installer Control Center - Vollständige Linux/Unix-Installation
|
|
# Zentrale Installationskonsole für die MYP-Plattform
|
|
# Version 3.0 - Konsolidiert alle Setup-Funktionen
|
|
|
|
# Farbdefinitionen
|
|
RED='\033[0;31m'
|
|
GREEN='\033[0;32m'
|
|
YELLOW='\033[0;33m'
|
|
BLUE='\033[0;34m'
|
|
CYAN='\033[0;36m'
|
|
WHITE='\033[1;37m'
|
|
NC='\033[0m' # No Color
|
|
|
|
# Überprüfen, ob das Skript als Root ausgeführt wird
|
|
is_root=0
|
|
if [ "$EUID" -eq 0 ]; then
|
|
is_root=1
|
|
fi
|
|
|
|
# Funktionen
|
|
show_header() {
|
|
local title="$1"
|
|
clear
|
|
echo -e "${CYAN}=============================================================${NC}"
|
|
echo -e "${CYAN} MYP INSTALLER CONTROL CENTER ${NC}"
|
|
echo -e "${CYAN} Version 3.0 ${NC}"
|
|
echo -e "${CYAN}=============================================================${NC}"
|
|
echo -e "${CYAN} $title${NC}"
|
|
echo -e "${CYAN}=============================================================${NC}"
|
|
|
|
if [ $is_root -eq 0 ]; then
|
|
echo -e "${YELLOW}HINWEIS: Dieses Skript läuft ohne Root-Rechte.${NC}"
|
|
echo -e "${YELLOW}Einige Funktionen sind möglicherweise eingeschränkt.${NC}"
|
|
echo -e "${CYAN}=============================================================${NC}"
|
|
fi
|
|
|
|
echo ""
|
|
}
|
|
|
|
check_command() {
|
|
command -v "$1" >/dev/null 2>&1
|
|
}
|
|
|
|
exec_command() {
|
|
local cmd="$1"
|
|
local description="$2"
|
|
|
|
echo -e "${BLUE}> $description...${NC}"
|
|
|
|
eval $cmd
|
|
|
|
if [ $? -eq 0 ]; then
|
|
echo -e "${GREEN}✓ Erfolgreich abgeschlossen!${NC}"
|
|
return 0
|
|
else
|
|
echo -e "${RED}✗ Fehler beim Ausführen des Befehls. Exit-Code: $?${NC}"
|
|
return 1
|
|
fi
|
|
}
|
|
|
|
get_local_ip() {
|
|
local ip=$(hostname -I | awk '{print $1}')
|
|
if [ -z "$ip" ]; then
|
|
ip="127.0.0.1"
|
|
fi
|
|
echo "$ip"
|
|
}
|
|
|
|
test_dependencies() {
|
|
show_header "Systemvoraussetzungen prüfen"
|
|
|
|
echo -e "${BLUE}Prüfe Abhängigkeiten...${NC}"
|
|
|
|
local all_installed=1
|
|
|
|
# Python
|
|
if check_command python3; then
|
|
echo -e "${GREEN}✓ Python 3 gefunden${NC}"
|
|
python_version=$(python3 --version 2>&1)
|
|
echo -e "${WHITE} Version: $python_version${NC}"
|
|
elif check_command python; then
|
|
echo -e "${GREEN}✓ Python gefunden${NC}"
|
|
python_version=$(python --version 2>&1)
|
|
echo -e "${WHITE} Version: $python_version${NC}"
|
|
else
|
|
echo -e "${RED}✗ Python nicht gefunden${NC}"
|
|
all_installed=0
|
|
fi
|
|
|
|
# Pip
|
|
if check_command pip3; then
|
|
echo -e "${GREEN}✓ Python Package Manager (pip3) gefunden${NC}"
|
|
elif check_command pip; then
|
|
echo -e "${GREEN}✓ Python Package Manager (pip) gefunden${NC}"
|
|
else
|
|
echo -e "${RED}✗ Python Package Manager (pip) nicht gefunden${NC}"
|
|
all_installed=0
|
|
fi
|
|
|
|
# Docker
|
|
if check_command docker; then
|
|
echo -e "${GREEN}✓ Docker gefunden${NC}"
|
|
docker_version=$(docker --version 2>&1)
|
|
echo -e "${WHITE} Version: $docker_version${NC}"
|
|
else
|
|
echo -e "${RED}✗ Docker nicht gefunden${NC}"
|
|
all_installed=0
|
|
fi
|
|
|
|
# Docker Compose
|
|
if check_command docker-compose; then
|
|
echo -e "${GREEN}✓ Docker Compose gefunden${NC}"
|
|
else
|
|
echo -e "${RED}✗ Docker Compose nicht gefunden${NC}"
|
|
all_installed=0
|
|
fi
|
|
|
|
# Node.js
|
|
if check_command node; then
|
|
echo -e "${GREEN}✓ Node.js gefunden${NC}"
|
|
node_version=$(node --version 2>&1)
|
|
echo -e "${WHITE} Version: $node_version${NC}"
|
|
else
|
|
echo -e "${RED}✗ Node.js nicht gefunden${NC}"
|
|
all_installed=0
|
|
fi
|
|
|
|
# npm
|
|
if check_command npm; then
|
|
echo -e "${GREEN}✓ Node Package Manager (npm) gefunden${NC}"
|
|
else
|
|
echo -e "${RED}✗ Node Package Manager (npm) nicht gefunden${NC}"
|
|
all_installed=0
|
|
fi
|
|
|
|
# OpenSSL
|
|
if check_command openssl; then
|
|
echo -e "${GREEN}✓ OpenSSL gefunden${NC}"
|
|
else
|
|
echo -e "${RED}✗ OpenSSL nicht gefunden${NC}"
|
|
all_installed=0
|
|
fi
|
|
|
|
# Git
|
|
if check_command git; then
|
|
echo -e "${GREEN}✓ Git gefunden${NC}"
|
|
else
|
|
echo -e "${RED}✗ Git nicht gefunden${NC}"
|
|
all_installed=0
|
|
fi
|
|
|
|
# curl
|
|
if check_command curl; then
|
|
echo -e "${GREEN}✓ cURL gefunden${NC}"
|
|
else
|
|
echo -e "${RED}✗ cURL nicht gefunden${NC}"
|
|
all_installed=0
|
|
fi
|
|
|
|
echo ""
|
|
if [ $all_installed -eq 1 ]; then
|
|
echo -e "${GREEN}✓ Alle Abhängigkeiten sind installiert!${NC}"
|
|
else
|
|
echo -e "${YELLOW}⚠ Einige Abhängigkeiten fehlen. Bitte installieren Sie diese vor der Verwendung.${NC}"
|
|
fi
|
|
|
|
echo ""
|
|
read -p "Drücken Sie ENTER, um fortzufahren..."
|
|
}
|
|
|
|
setup_hosts() {
|
|
show_header "Host-Konfiguration"
|
|
|
|
if [ $is_root -eq 0 ]; then
|
|
echo -e "${RED}Diese Funktion erfordert Root-Rechte.${NC}"
|
|
echo -e "${YELLOW}Bitte starten Sie das Skript mit sudo oder als Root neu.${NC}"
|
|
read -p "Drücken Sie ENTER, um fortzufahren..."
|
|
return 1
|
|
fi
|
|
|
|
local_ip=$(get_local_ip)
|
|
echo -e "${GREEN}Lokale IP-Adresse: $local_ip${NC}"
|
|
|
|
hosts_file="/etc/hosts"
|
|
echo -e "${BLUE}Hosts-Datei: $hosts_file${NC}"
|
|
|
|
# Prüfen, ob die Einträge bereits existieren
|
|
frontend_entry=$(grep "m040tbaraspi001.de040.corpintra.net" $hosts_file)
|
|
backend_entry=$(grep "raspberrypi" $hosts_file)
|
|
|
|
# Einträge in die Hosts-Datei schreiben
|
|
echo -e "${BLUE}Aktualisiere Hosts-Datei...${NC}"
|
|
|
|
if [ -z "$frontend_entry" ]; then
|
|
echo "" >> $hosts_file
|
|
echo "# MYP Frontend Host" >> $hosts_file
|
|
echo "$local_ip m040tbaraspi001.de040.corpintra.net m040tbaraspi001" >> $hosts_file
|
|
echo -e "${GREEN}Frontend-Hostname hinzugefügt${NC}"
|
|
else
|
|
echo -e "${YELLOW}Frontend-Hostname ist bereits konfiguriert${NC}"
|
|
fi
|
|
|
|
if [ -z "$backend_entry" ]; then
|
|
echo "" >> $hosts_file
|
|
echo "# MYP Backend Host" >> $hosts_file
|
|
echo "$local_ip raspberrypi" >> $hosts_file
|
|
echo -e "${GREEN}Backend-Hostname hinzugefügt${NC}"
|
|
else
|
|
echo -e "${YELLOW}Backend-Hostname ist bereits konfiguriert${NC}"
|
|
fi
|
|
|
|
echo -e "${GREEN}Konfiguration abgeschlossen!${NC}"
|
|
|
|
echo ""
|
|
echo -e "${BLUE}Folgende Hostnamen sind jetzt konfiguriert:${NC}"
|
|
echo -e "${WHITE} - Frontend: m040tbaraspi001.de040.corpintra.net${NC}"
|
|
echo -e "${WHITE} - Backend: raspberrypi${NC}"
|
|
|
|
echo ""
|
|
read -p "Drücken Sie ENTER, um fortzufahren..."
|
|
}
|
|
|
|
test_backend_connection() {
|
|
show_header "Backend-Verbindung prüfen"
|
|
|
|
echo -e "${BLUE}Welches Backend möchten Sie testen?${NC}"
|
|
echo -e "${WHITE}1. Lokales Backend (localhost:443)${NC}"
|
|
echo -e "${WHITE}2. Raspberry Pi Backend (192.168.0.105:5000)${NC}"
|
|
echo -e "${WHITE}3. Benutzerdefinierte URL${NC}"
|
|
|
|
read -p "Wählen Sie eine Option (1-3, Standard: 1): " choice
|
|
|
|
backend_url="https://localhost:443"
|
|
backend_host="localhost"
|
|
|
|
case $choice in
|
|
2)
|
|
backend_url="http://192.168.0.105:5000"
|
|
backend_host="192.168.0.105"
|
|
;;
|
|
3)
|
|
read -p "Backend-URL eingeben (z.B. https://raspberrypi:443): " backend_url
|
|
backend_host=$(echo "$backend_url" | sed -E 's|https?://([^:/]+).*|\1|')
|
|
;;
|
|
*)
|
|
backend_url="https://localhost:443"
|
|
backend_host="localhost"
|
|
;;
|
|
esac
|
|
|
|
echo ""
|
|
echo -e "${BLUE}Teste Backend: $backend_url${NC}"
|
|
echo ""
|
|
|
|
# 1. Netzwerk-Konnektivität prüfen
|
|
echo -e "${BLUE}1. Prüfe Netzwerk-Konnektivität zu $backend_host...${NC}"
|
|
if ping -c 1 -W 3 "$backend_host" >/dev/null 2>&1; then
|
|
echo -e "${GREEN}✓ Ping zu $backend_host erfolgreich${NC}"
|
|
else
|
|
echo -e "${RED}✗ Ping zu $backend_host fehlgeschlagen${NC}"
|
|
fi
|
|
|
|
# 2. Backend-Service prüfen
|
|
echo -e "${BLUE}2. Prüfe Backend-Service...${NC}"
|
|
health_url="$backend_url/health"
|
|
if curl -f --connect-timeout 5 "$health_url" >/dev/null 2>&1; then
|
|
echo -e "${GREEN}✓ Backend-Health-Check erfolgreich${NC}"
|
|
elif curl -f --connect-timeout 5 "$backend_url" >/dev/null 2>&1; then
|
|
echo -e "${YELLOW}⚠ Backend erreichbar, aber kein Health-Endpoint${NC}"
|
|
else
|
|
echo -e "${RED}✗ Backend-Service nicht erreichbar${NC}"
|
|
fi
|
|
|
|
# 3. API-Endpunkte prüfen
|
|
echo -e "${BLUE}3. Prüfe Backend-API-Endpunkte...${NC}"
|
|
for endpoint in "printers" "jobs" "users"; do
|
|
api_url="$backend_url/api/$endpoint"
|
|
if curl -f --connect-timeout 5 "$api_url" >/dev/null 2>&1; then
|
|
echo -e "${GREEN}✓ API-Endpunkt /$endpoint erreichbar${NC}"
|
|
else
|
|
echo -e "${YELLOW}⚠ API-Endpunkt /$endpoint nicht erreichbar${NC}"
|
|
fi
|
|
done
|
|
|
|
# 4. Frontend-Konfiguration prüfen
|
|
echo -e "${BLUE}4. Prüfe Frontend-Konfigurationsdateien...${NC}"
|
|
|
|
env_local_path="frontend/.env.local"
|
|
if [ -f "$env_local_path" ]; then
|
|
if grep -q "NEXT_PUBLIC_API_URL" "$env_local_path"; then
|
|
echo -e "${GREEN}✓ .env.local gefunden und konfiguriert${NC}"
|
|
else
|
|
echo -e "${YELLOW}⚠ .env.local existiert, aber Backend-URL fehlt${NC}"
|
|
fi
|
|
else
|
|
echo -e "${YELLOW}⚠ .env.local nicht gefunden${NC}"
|
|
fi
|
|
|
|
echo ""
|
|
read -p "Möchten Sie die Frontend-Konfiguration für dieses Backend aktualisieren? (j/n): " update_config
|
|
|
|
if [ "$update_config" = "j" ]; then
|
|
setup_backend_url "$backend_url"
|
|
fi
|
|
|
|
echo ""
|
|
read -p "Drücken Sie ENTER, um fortzufahren..."
|
|
}
|
|
|
|
setup_backend_url() {
|
|
local backend_url="$1"
|
|
|
|
show_header "Backend-URL konfigurieren"
|
|
|
|
if [ -z "$backend_url" ]; then
|
|
echo -e "${BLUE}Verfügbare Backend-Konfigurationen:${NC}"
|
|
echo -e "${WHITE}1. Lokale Entwicklung (https://localhost:443)${NC}"
|
|
echo -e "${WHITE}2. Raspberry Pi (http://192.168.0.105:5000)${NC}"
|
|
echo -e "${WHITE}3. Benutzerdefinierte URL${NC}"
|
|
|
|
read -p "Wählen Sie eine Option (1-3, Standard: 1): " choice
|
|
|
|
case $choice in
|
|
2)
|
|
backend_url="http://192.168.0.105:5000"
|
|
;;
|
|
3)
|
|
read -p "Backend-URL eingeben (z.B. https://raspberrypi:443): " backend_url
|
|
;;
|
|
*)
|
|
backend_url="https://localhost:443"
|
|
;;
|
|
esac
|
|
fi
|
|
|
|
echo -e "${BLUE}Konfiguriere Frontend für Backend: $backend_url${NC}"
|
|
|
|
# .env.local erstellen/aktualisieren
|
|
env_local_path="frontend/.env.local"
|
|
backend_host=$(echo "$backend_url" | sed -E 's|https?://([^:/]+).*|\1|')
|
|
backend_protocol=$(echo "$backend_url" | sed -E 's|^(https?)://.*|\1|')
|
|
|
|
cat > "$env_local_path" << EOF
|
|
# Backend API Konfiguration
|
|
NEXT_PUBLIC_API_URL=$backend_url
|
|
|
|
# Frontend-URL für OAuth Callback
|
|
NEXT_PUBLIC_FRONTEND_URL=http://localhost:3000
|
|
|
|
# OAuth Konfiguration
|
|
NEXT_PUBLIC_OAUTH_CALLBACK_URL=http://localhost:3000/auth/login/callback
|
|
|
|
# GitHub OAuth (hardcodiert)
|
|
GITHUB_CLIENT_ID=7c5d8bef1a5519ec1fdc
|
|
GITHUB_CLIENT_SECRET=5f1e586204358fbd53cf5fb7d418b3f06ccab8fd
|
|
|
|
# Entwicklungsumgebung
|
|
NODE_ENV=development
|
|
DEBUG=true
|
|
NEXT_DEBUG=true
|
|
|
|
# Backend Host
|
|
NEXT_PUBLIC_BACKEND_HOST=$backend_host
|
|
NEXT_PUBLIC_BACKEND_PROTOCOL=$backend_protocol
|
|
EOF
|
|
|
|
if [ $? -eq 0 ]; then
|
|
echo -e "${GREEN}✓ .env.local erfolgreich erstellt/aktualisiert${NC}"
|
|
else
|
|
echo -e "${RED}✗ Fehler beim Erstellen der .env.local${NC}"
|
|
fi
|
|
|
|
echo ""
|
|
echo -e "${GREEN}Frontend-Konfiguration abgeschlossen!${NC}"
|
|
echo -e "${WHITE}Backend: $backend_url${NC}"
|
|
echo -e "${WHITE}Frontend: http://localhost:3000${NC}"
|
|
|
|
echo ""
|
|
read -p "Drücken Sie ENTER, um fortzufahren..."
|
|
}
|
|
|
|
start_debug_server() {
|
|
show_header "Debug-Server starten"
|
|
|
|
echo -e "${BLUE}Welchen Debug-Server möchten Sie starten?${NC}"
|
|
echo -e "${WHITE}1. Frontend Debug-Server (Next.js)${NC}"
|
|
echo -e "${WHITE}2. Backend Debug-Server (Flask)${NC}"
|
|
echo -e "${WHITE}3. Beide Debug-Server${NC}"
|
|
echo -e "${WHITE}4. Frontend Debug-Server (einfacher HTTP-Server)${NC}"
|
|
|
|
read -p "Wählen Sie eine Option (1-4, Standard: 1): " choice
|
|
|
|
case $choice in
|
|
1)
|
|
echo -e "${BLUE}Starte Frontend Debug-Server...${NC}"
|
|
if [ -d "frontend" ] && check_command npm; then
|
|
(cd frontend && npm run dev) &
|
|
echo -e "${GREEN}✓ Frontend Debug-Server gestartet${NC}"
|
|
else
|
|
echo -e "${RED}✗ Frontend-Verzeichnis oder npm nicht gefunden${NC}"
|
|
fi
|
|
;;
|
|
2)
|
|
echo -e "${BLUE}Starte Backend Debug-Server...${NC}"
|
|
if [ -f "backend/app/app.py" ]; then
|
|
python_cmd=""
|
|
if check_command python3; then
|
|
python_cmd="python3"
|
|
elif check_command python; then
|
|
python_cmd="python"
|
|
fi
|
|
|
|
if [ -n "$python_cmd" ]; then
|
|
$python_cmd backend/app/app.py --debug &
|
|
echo -e "${GREEN}✓ Backend Debug-Server gestartet${NC}"
|
|
else
|
|
echo -e "${RED}✗ Python nicht gefunden${NC}"
|
|
fi
|
|
else
|
|
echo -e "${RED}✗ Backend-Anwendung nicht gefunden${NC}"
|
|
fi
|
|
;;
|
|
3)
|
|
echo -e "${BLUE}Starte beide Debug-Server...${NC}"
|
|
|
|
# Backend starten
|
|
if [ -f "backend/app/app.py" ]; then
|
|
python_cmd=""
|
|
if check_command python3; then
|
|
python_cmd="python3"
|
|
elif check_command python; then
|
|
python_cmd="python"
|
|
fi
|
|
|
|
if [ -n "$python_cmd" ]; then
|
|
$python_cmd backend/app/app.py --debug &
|
|
echo -e "${GREEN}✓ Backend Debug-Server gestartet${NC}"
|
|
fi
|
|
fi
|
|
|
|
# Frontend starten
|
|
if [ -d "frontend" ] && check_command npm; then
|
|
(cd frontend && npm run dev) &
|
|
echo -e "${GREEN}✓ Frontend Debug-Server gestartet${NC}"
|
|
fi
|
|
;;
|
|
4)
|
|
echo -e "${BLUE}Starte einfachen HTTP Debug-Server...${NC}"
|
|
debug_server_dir="frontend/debug-server"
|
|
|
|
if [ -d "$debug_server_dir" ] && check_command node; then
|
|
node "$debug_server_dir/src/app.js" &
|
|
echo -e "${GREEN}✓ Einfacher Debug-Server gestartet${NC}"
|
|
else
|
|
echo -e "${RED}✗ Debug-Server-Verzeichnis oder Node.js nicht gefunden${NC}"
|
|
fi
|
|
;;
|
|
*)
|
|
echo -e "${RED}Ungültige Option${NC}"
|
|
;;
|
|
esac
|
|
|
|
echo ""
|
|
echo -e "${BLUE}Debug-Server-URLs:${NC}"
|
|
echo -e "${WHITE}- Frontend: http://localhost:3000${NC}"
|
|
echo -e "${WHITE}- Backend: https://localhost:443${NC}"
|
|
echo -e "${WHITE}- Debug-Server: http://localhost:8080${NC}"
|
|
|
|
echo ""
|
|
read -p "Drücken Sie ENTER, um fortzufahren..."
|
|
}
|
|
|
|
show_ssl_status() {
|
|
show_header "SSL-Zertifikat-Status"
|
|
|
|
cert_paths=(
|
|
"backend/instance/ssl/myp.crt"
|
|
"backend/instance/ssl/myp.key"
|
|
"frontend/ssl/myp.crt"
|
|
"frontend/ssl/myp.key"
|
|
)
|
|
|
|
echo -e "${BLUE}Prüfe SSL-Zertifikate...${NC}"
|
|
echo ""
|
|
|
|
for cert_path in "${cert_paths[@]}"; do
|
|
if [ -f "$cert_path" ]; then
|
|
echo -e "${GREEN}✓ Gefunden: $cert_path${NC}"
|
|
|
|
# Zertifikatsinformationen anzeigen (falls OpenSSL verfügbar)
|
|
if check_command openssl && [[ "$cert_path" == *.crt ]]; then
|
|
cert_info=$(openssl x509 -in "$cert_path" -noout -subject -dates 2>/dev/null)
|
|
if [ -n "$cert_info" ]; then
|
|
echo -e "${WHITE} $cert_info${NC}"
|
|
fi
|
|
fi
|
|
else
|
|
echo -e "${RED}✗ Fehlt: $cert_path${NC}"
|
|
fi
|
|
done
|
|
|
|
echo ""
|
|
echo -e "${BLUE}SSL-Konfiguration in settings.py:${NC}"
|
|
settings_path="backend/app/config/settings.py"
|
|
if [ -f "$settings_path" ]; then
|
|
if grep -q "SSL_ENABLED.*=.*True" "$settings_path"; then
|
|
echo -e "${GREEN}✓ SSL ist aktiviert${NC}"
|
|
else
|
|
echo -e "${YELLOW}⚠ SSL ist deaktiviert${NC}"
|
|
fi
|
|
else
|
|
echo -e "${RED}✗ settings.py nicht gefunden${NC}"
|
|
fi
|
|
|
|
echo ""
|
|
read -p "Drücken Sie ENTER, um fortzufahren..."
|
|
}
|
|
|
|
install_myp_complete() {
|
|
show_header "Vollständige MYP-Installation"
|
|
|
|
echo -e "${BLUE}Diese Funktion führt eine vollständige MYP-Installation durch:${NC}"
|
|
echo -e "${WHITE}1. Systemvoraussetzungen prüfen${NC}"
|
|
echo -e "${WHITE}2. Python-Abhängigkeiten installieren${NC}"
|
|
echo -e "${WHITE}3. Node.js-Abhängigkeiten installieren${NC}"
|
|
echo -e "${WHITE}4. SSL-Zertifikate erstellen${NC}"
|
|
echo -e "${WHITE}5. Datenbank initialisieren${NC}"
|
|
echo -e "${WHITE}6. Konfigurationsdateien erstellen${NC}"
|
|
echo ""
|
|
|
|
read -p "Möchten Sie fortfahren? (j/n, Standard: j): " confirm
|
|
if [ "$confirm" = "n" ]; then
|
|
return
|
|
fi
|
|
|
|
# 1. Systemvoraussetzungen prüfen
|
|
echo -e "${BLUE}1. Prüfe Systemvoraussetzungen...${NC}"
|
|
python_cmd=""
|
|
pip_cmd=""
|
|
|
|
if check_command python3; then
|
|
python_cmd="python3"
|
|
elif check_command python; then
|
|
python_cmd="python"
|
|
else
|
|
echo -e "${RED}✗ Python nicht gefunden. Bitte installieren Sie Python 3.6+.${NC}"
|
|
return 1
|
|
fi
|
|
|
|
if check_command pip3; then
|
|
pip_cmd="pip3"
|
|
elif check_command pip; then
|
|
pip_cmd="pip"
|
|
else
|
|
echo -e "${RED}✗ pip nicht gefunden. Bitte installieren Sie pip.${NC}"
|
|
return 1
|
|
fi
|
|
|
|
# 2. Python-Abhängigkeiten installieren
|
|
echo -e "${BLUE}2. Installiere Python-Abhängigkeiten...${NC}"
|
|
if [ -f "backend/requirements.txt" ]; then
|
|
exec_command "$pip_cmd install -r backend/requirements.txt" "Installiere Backend-Abhängigkeiten"
|
|
else
|
|
echo -e "${YELLOW}⚠ requirements.txt nicht gefunden${NC}"
|
|
fi
|
|
|
|
# 3. Node.js-Abhängigkeiten installieren
|
|
if check_command node && check_command npm; then
|
|
echo -e "${BLUE}3. Installiere Node.js-Abhängigkeiten...${NC}"
|
|
if [ -f "frontend/package.json" ]; then
|
|
exec_command "cd frontend && npm install" "Installiere Frontend-Abhängigkeiten"
|
|
else
|
|
echo -e "${YELLOW}⚠ package.json nicht gefunden${NC}"
|
|
fi
|
|
else
|
|
echo -e "${YELLOW}3. Überspringe Node.js-Abhängigkeiten (Node.js/npm nicht gefunden)${NC}"
|
|
fi
|
|
|
|
# 4. SSL-Zertifikate erstellen
|
|
echo -e "${BLUE}4. Erstelle SSL-Zertifikate...${NC}"
|
|
create_ssl_certificates
|
|
|
|
# 5. Datenbank initialisieren
|
|
echo -e "${BLUE}5. Initialisiere Datenbank...${NC}"
|
|
if [ -f "backend/app/models.py" ]; then
|
|
exec_command "cd backend && $python_cmd -c 'from app.models import init_db, create_initial_admin; init_db(); create_initial_admin()'" "Initialisiere Datenbank"
|
|
fi
|
|
|
|
# 6. Konfigurationsdateien erstellen
|
|
echo -e "${BLUE}6. Erstelle Konfigurationsdateien...${NC}"
|
|
setup_backend_url "https://localhost:443"
|
|
|
|
echo ""
|
|
echo -e "${GREEN}✓ Vollständige MYP-Installation abgeschlossen!${NC}"
|
|
echo ""
|
|
echo -e "${BLUE}Nächste Schritte:${NC}"
|
|
echo -e "${WHITE}1. Backend starten: python backend/app/app.py${NC}"
|
|
echo -e "${WHITE}2. Frontend starten: cd frontend && npm run dev${NC}"
|
|
echo -e "${WHITE}3. Anwendung öffnen: https://localhost:443${NC}"
|
|
|
|
echo ""
|
|
read -p "Drücken Sie ENTER, um fortzufahren..."
|
|
}
|
|
|
|
create_ssl_certificates() {
|
|
show_header "SSL-Zertifikat-Generator"
|
|
|
|
# Parameter definieren
|
|
cert_dir="./backend/instance/ssl"
|
|
backend_cert_file="$cert_dir/myp.crt"
|
|
backend_key_file="$cert_dir/myp.key"
|
|
frontend_cert_file="$cert_dir/frontend.crt"
|
|
frontend_key_file="$cert_dir/frontend.key"
|
|
|
|
echo -e "${BLUE}Zertifikate werden für folgende Hostnamen erstellt:${NC}"
|
|
|
|
# Hostname-Auswahl
|
|
echo -e "${WHITE}1. Für lokale Entwicklung (localhost)${NC}"
|
|
echo -e "${WHITE}2. Für Raspberry Pi Deployment (raspberrypi)${NC}"
|
|
echo -e "${WHITE}3. Für Unternehmens-Setup (m040tbaraspi001.de040.corpintra.net)${NC}"
|
|
|
|
read -p "Wählen Sie eine Option (1-3, Standard: 1): " choice
|
|
|
|
backend_hostname="localhost"
|
|
frontend_hostname="localhost"
|
|
|
|
case $choice in
|
|
2)
|
|
backend_hostname="raspberrypi"
|
|
frontend_hostname="raspberrypi"
|
|
;;
|
|
3)
|
|
backend_hostname="raspberrypi"
|
|
frontend_hostname="m040tbaraspi001.de040.corpintra.net"
|
|
;;
|
|
*)
|
|
backend_hostname="localhost"
|
|
frontend_hostname="localhost"
|
|
;;
|
|
esac
|
|
|
|
echo -e "${BLUE}Backend-Hostname: $backend_hostname${NC}"
|
|
echo -e "${BLUE}Frontend-Hostname: $frontend_hostname${NC}"
|
|
echo ""
|
|
|
|
# Verzeichnis erstellen, falls es nicht existiert
|
|
if [ ! -d "$cert_dir" ]; then
|
|
echo -e "${BLUE}Erstelle Verzeichnis $cert_dir...${NC}"
|
|
mkdir -p "$cert_dir"
|
|
fi
|
|
|
|
# SSL-Zertifikate mit Python und cryptography erstellen
|
|
echo -e "${BLUE}Erstelle SSL-Zertifikate mit Python...${NC}"
|
|
|
|
# Überprüfen, ob Python verfügbar ist
|
|
python_cmd=""
|
|
if check_command python3; then
|
|
python_cmd="python3"
|
|
elif check_command python; then
|
|
python_cmd="python"
|
|
else
|
|
echo -e "${RED}Python nicht gefunden. SSL-Zertifikate können nicht erstellt werden.${NC}"
|
|
read -p "Drücken Sie ENTER, um fortzufahren..."
|
|
return 1
|
|
fi
|
|
|
|
# Überprüfen, ob cryptography installiert ist
|
|
cryptography_installed=$($python_cmd -c "try: import cryptography; print('True'); except ImportError: print('False')" 2>/dev/null)
|
|
|
|
if [ "$cryptography_installed" != "True" ]; then
|
|
echo -e "${YELLOW}Installiere Python-Abhängigkeit 'cryptography'...${NC}"
|
|
if check_command pip3; then
|
|
exec_command "pip3 install cryptography" "Installiere cryptography-Paket"
|
|
elif check_command pip; then
|
|
exec_command "pip install cryptography" "Installiere cryptography-Paket"
|
|
else
|
|
echo -e "${RED}pip nicht gefunden. Kann cryptography nicht installieren.${NC}"
|
|
read -p "Drücken Sie ENTER, um fortzufahren..."
|
|
return 1
|
|
fi
|
|
fi
|
|
|
|
# Python-Skript zur Zertifikatserstellung erstellen
|
|
cat > temp_cert_script.py << EOL
|
|
#!/usr/bin/env python3
|
|
import os
|
|
import datetime
|
|
import sys
|
|
|
|
try:
|
|
from cryptography import x509
|
|
from cryptography.x509.oid import NameOID
|
|
from cryptography.hazmat.primitives import hashes
|
|
from cryptography.hazmat.primitives.asymmetric import rsa
|
|
from cryptography.hazmat.primitives.serialization import Encoding, PrivateFormat, NoEncryption
|
|
import ipaddress
|
|
except ImportError as e:
|
|
print(f"Fehler: Paket nicht gefunden: {e}")
|
|
print("Bitte installieren Sie es mit: pip install cryptography")
|
|
sys.exit(1)
|
|
|
|
def create_self_signed_cert(cert_path, key_path, hostname="localhost"):
|
|
# Verzeichnis erstellen, falls es nicht existiert
|
|
cert_dir = os.path.dirname(cert_path)
|
|
if cert_dir and not os.path.exists(cert_dir):
|
|
os.makedirs(cert_dir, exist_ok=True)
|
|
|
|
# Privaten Schlüssel generieren
|
|
private_key = rsa.generate_private_key(
|
|
public_exponent=65537,
|
|
key_size=4096,
|
|
)
|
|
|
|
# Schlüsseldatei schreiben
|
|
with open(key_path, "wb") as key_file:
|
|
key_file.write(private_key.private_bytes(
|
|
encoding=Encoding.PEM,
|
|
format=PrivateFormat.TraditionalOpenSSL,
|
|
encryption_algorithm=NoEncryption()
|
|
))
|
|
|
|
# Aktuelles Datum und Ablaufdatum berechnen
|
|
now = datetime.datetime.now()
|
|
valid_until = now + datetime.timedelta(days=3650) # 10 Jahre gültig
|
|
|
|
# Name für das Zertifikat erstellen
|
|
subject = issuer = x509.Name([
|
|
x509.NameAttribute(NameOID.COMMON_NAME, hostname),
|
|
x509.NameAttribute(NameOID.ORGANIZATION_NAME, "Mercedes-Benz AG"),
|
|
x509.NameAttribute(NameOID.ORGANIZATIONAL_UNIT_NAME, "Werk 040 Berlin"),
|
|
x509.NameAttribute(NameOID.COUNTRY_NAME, "DE"),
|
|
x509.NameAttribute(NameOID.STATE_OR_PROVINCE_NAME, "Berlin"),
|
|
x509.NameAttribute(NameOID.LOCALITY_NAME, "Berlin")
|
|
])
|
|
|
|
# Zertifikat erstellen
|
|
cert = x509.CertificateBuilder().subject_name(
|
|
subject
|
|
).issuer_name(
|
|
issuer
|
|
).public_key(
|
|
private_key.public_key()
|
|
).serial_number(
|
|
x509.random_serial_number()
|
|
).not_valid_before(
|
|
now
|
|
).not_valid_after(
|
|
valid_until
|
|
).add_extension(
|
|
x509.SubjectAlternativeName([
|
|
x509.DNSName(hostname),
|
|
x509.DNSName("localhost"),
|
|
x509.IPAddress(ipaddress.IPv4Address("127.0.0.1"))
|
|
]),
|
|
critical=False,
|
|
).add_extension(
|
|
x509.BasicConstraints(ca=True, path_length=None), critical=True
|
|
).add_extension(
|
|
x509.KeyUsage(
|
|
digital_signature=True,
|
|
content_commitment=False,
|
|
key_encipherment=True,
|
|
data_encipherment=False,
|
|
key_agreement=False,
|
|
key_cert_sign=True,
|
|
crl_sign=True,
|
|
encipher_only=False,
|
|
decipher_only=False
|
|
), critical=True
|
|
).add_extension(
|
|
x509.ExtendedKeyUsage([
|
|
x509.oid.ExtendedKeyUsageOID.SERVER_AUTH,
|
|
x509.oid.ExtendedKeyUsageOID.CLIENT_AUTH
|
|
]), critical=False
|
|
).sign(private_key, hashes.SHA256())
|
|
|
|
# Zertifikatsdatei schreiben
|
|
with open(cert_path, "wb") as cert_file:
|
|
cert_file.write(cert.public_bytes(Encoding.PEM))
|
|
|
|
print(f"Selbstsigniertes SSL-Zertifikat für '{hostname}' erstellt:")
|
|
print(f"Zertifikat: {cert_path}")
|
|
print(f"Schlüssel: {key_path}")
|
|
print(f"Gültig für 10 Jahre.")
|
|
|
|
# Backend-Zertifikat erstellen
|
|
create_self_signed_cert('$backend_cert_file', '$backend_key_file', '$backend_hostname')
|
|
|
|
# Frontend-Zertifikat erstellen
|
|
create_self_signed_cert('$frontend_cert_file', '$frontend_key_file', '$frontend_hostname')
|
|
EOL
|
|
|
|
# Python-Skript ausführbar machen und ausführen
|
|
chmod +x temp_cert_script.py
|
|
|
|
if $python_cmd temp_cert_script.py; then
|
|
echo -e "${GREEN}SSL-Zertifikate erfolgreich erstellt!${NC}"
|
|
else
|
|
echo -e "${RED}Fehler beim Erstellen der SSL-Zertifikate.${NC}"
|
|
fi
|
|
|
|
# Temporäres Skript löschen
|
|
rm -f temp_cert_script.py
|
|
|
|
# Zertifikate im System installieren (optional)
|
|
if [ $is_root -eq 1 ]; then
|
|
read -p "Möchten Sie die Zertifikate im System installieren? (j/n, Standard: n): " install_certs
|
|
|
|
if [ "$install_certs" = "j" ]; then
|
|
if [ -f "$backend_cert_file" ]; then
|
|
echo -e "${BLUE}Installiere Backend-Zertifikat im System...${NC}"
|
|
|
|
# Debian/Ubuntu/Raspberry Pi OS
|
|
if [ -d "/usr/local/share/ca-certificates" ]; then
|
|
cp "$backend_cert_file" /usr/local/share/ca-certificates/myp-backend.crt
|
|
update-ca-certificates
|
|
# RHEL/CentOS/Fedora
|
|
elif [ -d "/etc/pki/ca-trust/source/anchors" ]; then
|
|
cp "$backend_cert_file" /etc/pki/ca-trust/source/anchors/myp-backend.crt
|
|
update-ca-trust extract
|
|
fi
|
|
fi
|
|
|
|
if [ -f "$frontend_cert_file" ]; then
|
|
echo -e "${BLUE}Installiere Frontend-Zertifikat im System...${NC}"
|
|
|
|
# Debian/Ubuntu/Raspberry Pi OS
|
|
if [ -d "/usr/local/share/ca-certificates" ]; then
|
|
cp "$frontend_cert_file" /usr/local/share/ca-certificates/myp-frontend.crt
|
|
update-ca-certificates
|
|
# RHEL/CentOS/Fedora
|
|
elif [ -d "/etc/pki/ca-trust/source/anchors" ]; then
|
|
cp "$frontend_cert_file" /etc/pki/ca-trust/source/anchors/myp-frontend.crt
|
|
update-ca-trust extract
|
|
fi
|
|
fi
|
|
fi
|
|
else
|
|
echo -e "${YELLOW}Hinweis: Um die Zertifikate im System zu installieren, starten Sie das Skript als Root.${NC}"
|
|
fi
|
|
|
|
# Frontend für HTTPS konfigurieren
|
|
echo ""
|
|
read -p "Möchten Sie das Frontend für HTTPS konfigurieren? (j/n, Standard: j): " configure_frontend
|
|
|
|
if [ "$configure_frontend" != "n" ]; then
|
|
echo -e "${BLUE}Konfiguriere Frontend für HTTPS...${NC}"
|
|
|
|
# Kopiere Zertifikate ins Frontend-Verzeichnis
|
|
frontend_ssl_dir="./frontend/ssl"
|
|
mkdir -p "$frontend_ssl_dir"
|
|
|
|
if [ -f "$backend_cert_file" ]; then
|
|
cp "$backend_cert_file" "$frontend_ssl_dir/myp.crt"
|
|
fi
|
|
|
|
if [ -f "$backend_key_file" ]; then
|
|
cp "$backend_key_file" "$frontend_ssl_dir/myp.key"
|
|
fi
|
|
|
|
echo -e "${GREEN}Zertifikate ins Frontend-Verzeichnis kopiert.${NC}"
|
|
|
|
# .env.local aktualisieren
|
|
env_local_path="./frontend/.env.local"
|
|
|
|
if [ -f "$env_local_path" ]; then
|
|
env_content=$(cat "$env_local_path")
|
|
else
|
|
env_content="# MYP Frontend Umgebungsvariablen"
|
|
fi
|
|
|
|
# SSL-Konfigurationen
|
|
ssl_configs=(
|
|
"NODE_TLS_REJECT_UNAUTHORIZED=0"
|
|
"HTTPS=true"
|
|
"SSL_CRT_FILE=./ssl/myp.crt"
|
|
"SSL_KEY_FILE=./ssl/myp.key"
|
|
"NEXT_PUBLIC_API_URL=https://$backend_hostname"
|
|
"NEXT_PUBLIC_BACKEND_HOST=$backend_hostname"
|
|
"NEXT_PUBLIC_BACKEND_PROTOCOL=https"
|
|
)
|
|
|
|
# Existierende Konfigurationen aktualisieren
|
|
for config in "${ssl_configs[@]}"; do
|
|
key=$(echo "$config" | cut -d'=' -f1)
|
|
|
|
if echo "$env_content" | grep -q "^$key="; then
|
|
# Update existierende Konfiguration
|
|
env_content=$(echo "$env_content" | sed "s/^$key=.*/$config/")
|
|
else
|
|
# Neue Konfiguration hinzufügen
|
|
env_content="$env_content\n$config"
|
|
fi
|
|
done
|
|
|
|
# Speichern der aktualisierten Umgebungsvariablen
|
|
echo -e "$env_content" > "$env_local_path"
|
|
echo -e "${GREEN}.env.local Datei mit SSL-Konfigurationen aktualisiert.${NC}"
|
|
fi
|
|
|
|
echo ""
|
|
echo -e "${BLUE}SSL-Zertifikate wurden in folgenden Pfaden gespeichert:${NC}"
|
|
echo -e "${WHITE}Backend: $backend_cert_file${NC}"
|
|
echo -e "${WHITE}Frontend: $frontend_cert_file${NC}"
|
|
|
|
echo ""
|
|
read -p "Drücken Sie ENTER, um fortzufahren..."
|
|
}
|
|
|
|
setup_environment() {
|
|
show_header "Umgebungs-Setup"
|
|
|
|
# Prüfen, ob Python und pip installiert sind
|
|
python_cmd=""
|
|
pip_cmd=""
|
|
|
|
if check_command python3; then
|
|
python_cmd="python3"
|
|
elif check_command python; then
|
|
python_cmd="python"
|
|
else
|
|
echo -e "${RED}Python ist nicht installiert. Bitte installieren Sie Python 3.6+ und versuchen Sie es erneut.${NC}"
|
|
read -p "Drücken Sie ENTER, um fortzufahren..."
|
|
return 1
|
|
fi
|
|
|
|
if check_command pip3; then
|
|
pip_cmd="pip3"
|
|
elif check_command pip; then
|
|
pip_cmd="pip"
|
|
else
|
|
echo -e "${RED}pip ist nicht installiert. Bitte installieren Sie pip und versuchen Sie es erneut.${NC}"
|
|
read -p "Drücken Sie ENTER, um fortzufahren..."
|
|
return 1
|
|
fi
|
|
|
|
# Python-Abhängigkeiten installieren
|
|
echo -e "${BLUE}Installiere Backend-Abhängigkeiten...${NC}"
|
|
exec_command "$pip_cmd install -r backend/requirements.txt" "Installiere Python-Abhängigkeiten"
|
|
|
|
# Prüfen, ob Node.js und npm installiert sind
|
|
if check_command node && check_command npm; then
|
|
# Frontend-Abhängigkeiten installieren
|
|
echo -e "${BLUE}Installiere Frontend-Abhängigkeiten...${NC}"
|
|
exec_command "cd frontend && npm install" "Installiere Node.js-Abhängigkeiten"
|
|
else
|
|
echo -e "${YELLOW}Node.js oder npm ist nicht installiert. Frontend-Abhängigkeiten werden übersprungen.${NC}"
|
|
fi
|
|
|
|
# Docker-Compose Datei aktualisieren
|
|
docker_compose_file="docker-compose.yml"
|
|
if [ -f "$docker_compose_file" ]; then
|
|
if ! grep -q -- "--dual-protocol" "$docker_compose_file"; then
|
|
# Backup erstellen
|
|
cp "$docker_compose_file" "${docker_compose_file}.bak"
|
|
|
|
# Konfiguration aktualisieren
|
|
sed -i 's/command: python -m app\.app/command: python -m app.app --dual-protocol/g' "$docker_compose_file"
|
|
|
|
echo -e "${GREEN}Docker-Compose-Datei wurde aktualisiert, um den dual-protocol-Modus zu aktivieren.${NC}"
|
|
else
|
|
echo -e "${GREEN}Docker-Compose-Datei ist bereits korrekt konfiguriert.${NC}"
|
|
fi
|
|
fi
|
|
|
|
# Datenbank initialisieren
|
|
echo -e "${BLUE}Initialisiere Datenbank...${NC}"
|
|
if [ -f "backend/app/models.py" ]; then
|
|
exec_command "cd backend && $python_cmd -c 'from app.models import init_db, create_initial_admin; init_db(); create_initial_admin()'" "Initialisiere Datenbank und Admin-Benutzer"
|
|
fi
|
|
|
|
echo ""
|
|
echo -e "${GREEN}Umgebungs-Setup abgeschlossen!${NC}"
|
|
|
|
echo ""
|
|
read -p "Drücken Sie ENTER, um fortzufahren..."
|
|
}
|
|
|
|
start_application() {
|
|
show_header "Anwendung starten"
|
|
|
|
echo -e "${BLUE}Wie möchten Sie die Anwendung starten?${NC}"
|
|
echo -e "${WHITE}1. Backend-Server starten (Python)${NC}"
|
|
echo -e "${WHITE}2. Frontend-Server starten (Node.js)${NC}"
|
|
echo -e "${WHITE}3. Beide Server starten (in separaten Terminals)${NC}"
|
|
echo -e "${WHITE}4. Mit Docker Compose starten${NC}"
|
|
echo -e "${WHITE}5. Vollständige Installation und Start${NC}"
|
|
echo -e "${WHITE}6. Debug-Server starten${NC}"
|
|
echo -e "${WHITE}7. Zurück zum Hauptmenü${NC}"
|
|
|
|
read -p "Wählen Sie eine Option (1-7): " choice
|
|
|
|
case $choice in
|
|
1)
|
|
echo -e "${BLUE}Starte Backend-Server...${NC}"
|
|
python_cmd=""
|
|
if check_command python3; then
|
|
python_cmd="python3"
|
|
elif check_command python; then
|
|
python_cmd="python"
|
|
fi
|
|
|
|
if [ -n "$python_cmd" ]; then
|
|
$python_cmd backend/app/app.py &
|
|
echo -e "${GREEN}Backend-Server läuft jetzt im Hintergrund.${NC}"
|
|
else
|
|
echo -e "${RED}Python nicht gefunden.${NC}"
|
|
fi
|
|
;;
|
|
2)
|
|
echo -e "${BLUE}Starte Frontend-Server...${NC}"
|
|
if check_command npm; then
|
|
(cd frontend && npm run dev) &
|
|
echo -e "${GREEN}Frontend-Server läuft jetzt im Hintergrund.${NC}"
|
|
else
|
|
echo -e "${RED}npm nicht gefunden.${NC}"
|
|
fi
|
|
;;
|
|
3)
|
|
echo -e "${BLUE}Starte Backend-Server...${NC}"
|
|
python_cmd=""
|
|
if check_command python3; then
|
|
python_cmd="python3"
|
|
elif check_command python; then
|
|
python_cmd="python"
|
|
fi
|
|
|
|
if [ -n "$python_cmd" ]; then
|
|
$python_cmd backend/app/app.py &
|
|
echo -e "${GREEN}Backend-Server gestartet.${NC}"
|
|
fi
|
|
|
|
echo -e "${BLUE}Starte Frontend-Server...${NC}"
|
|
if check_command npm; then
|
|
(cd frontend && npm run dev) &
|
|
echo -e "${GREEN}Frontend-Server gestartet.${NC}"
|
|
fi
|
|
|
|
echo -e "${GREEN}Beide Server laufen jetzt im Hintergrund.${NC}"
|
|
;;
|
|
4)
|
|
if check_command docker && check_command docker-compose; then
|
|
echo -e "${BLUE}Starte Anwendung mit Docker Compose...${NC}"
|
|
exec_command "docker-compose up -d" "Starte Docker Container"
|
|
echo -e "${GREEN}Docker Container wurden gestartet.${NC}"
|
|
else
|
|
echo -e "${RED}Docker oder Docker Compose ist nicht installiert.${NC}"
|
|
fi
|
|
;;
|
|
5)
|
|
install_myp_complete
|
|
;;
|
|
6)
|
|
start_debug_server
|
|
;;
|
|
7)
|
|
return
|
|
;;
|
|
*)
|
|
echo -e "${RED}Ungültige Option.${NC}"
|
|
;;
|
|
esac
|
|
|
|
echo ""
|
|
read -p "Drücken Sie ENTER, um fortzufahren..."
|
|
}
|
|
|
|
show_project_info() {
|
|
show_header "Projekt-Informationen"
|
|
|
|
echo -e "${CYAN}MYP (Mercedes-Benz Yard Printing) Platform${NC}"
|
|
echo -e "${BLUE}Version 3.0${NC}"
|
|
echo ""
|
|
echo -e "${BLUE}Beschreibung:${NC}"
|
|
echo -e "${WHITE}Eine vollständige 3D-Drucker-Management-Plattform für Mercedes-Benz Werk 040 Berlin.${NC}"
|
|
echo ""
|
|
echo -e "${BLUE}Komponenten:${NC}"
|
|
echo -e "${WHITE}- Backend: Flask-basierte REST API${NC}"
|
|
echo -e "${WHITE}- Frontend: Next.js React-Anwendung${NC}"
|
|
echo -e "${WHITE}- Datenbank: SQLite${NC}"
|
|
echo -e "${WHITE}- Authentifizierung: GitHub OAuth + lokale Benutzer${NC}"
|
|
echo -e "${WHITE}- SSL/TLS: Selbstsignierte Zertifikate${NC}"
|
|
echo ""
|
|
echo -e "${BLUE}Standard-Zugangsdaten:${NC}"
|
|
echo -e "${WHITE}- Admin E-Mail: admin@mercedes-benz.com${NC}"
|
|
echo -e "${WHITE}- Admin Passwort: 744563017196A${NC}"
|
|
echo -e "${WHITE}- Router Passwort: vT6Vsd^p${NC}"
|
|
echo ""
|
|
echo -e "${BLUE}URLs:${NC}"
|
|
echo -e "${WHITE}- Backend: https://localhost:443 oder https://raspberrypi:443${NC}"
|
|
echo -e "${WHITE}- Frontend: https://localhost:3000${NC}"
|
|
echo ""
|
|
echo -e "${YELLOW}Weitere Informationen finden Sie in der CREDENTIALS.md Datei.${NC}"
|
|
|
|
echo ""
|
|
read -p "Drücken Sie ENTER, um fortzufahren..."
|
|
}
|
|
|
|
clean_old_files() {
|
|
show_header "Alte Dateien bereinigen"
|
|
|
|
read -p "Möchten Sie alte Skriptdateien und temporäre Dateien löschen? (j/n): " clean_files
|
|
|
|
if [ "$clean_files" = "j" ]; then
|
|
files_to_delete=(
|
|
"setup_hosts.sh"
|
|
"setup_ssl.sh"
|
|
"generate_ssl_certs.sh"
|
|
"temp_cert_script.py"
|
|
"frontend/cleanup.sh"
|
|
"frontend/install.sh"
|
|
"frontend/https-setup.sh"
|
|
"frontend/start-debug-server.sh"
|
|
"frontend/start-frontend-server.sh"
|
|
"frontend/check-backend-connection.sh"
|
|
"frontend/setup-backend-url.sh"
|
|
"frontend/start-debug-server.bat"
|
|
"backend/setup_myp.sh"
|
|
"backend/install/create_ssl_cert.sh"
|
|
"backend/install/ssl_check.sh"
|
|
)
|
|
|
|
for file in "${files_to_delete[@]}"; do
|
|
if [ -f "$file" ]; then
|
|
rm -f "$file"
|
|
echo -e "${GREEN}✓ Gelöscht: $file${NC}"
|
|
fi
|
|
done
|
|
|
|
echo -e "${GREEN}Bereinigung abgeschlossen!${NC}"
|
|
else
|
|
echo -e "${BLUE}Bereinigung übersprungen.${NC}"
|
|
fi
|
|
|
|
echo ""
|
|
read -p "Drücken Sie ENTER, um fortzufahren..."
|
|
}
|
|
|
|
# Hauptmenü anzeigen
|
|
show_main_menu() {
|
|
show_header "Hauptmenü"
|
|
|
|
echo -e "${WHITE}1. Systemvoraussetzungen prüfen${NC}"
|
|
echo -e "${WHITE}2. Host-Konfiguration einrichten${NC}"
|
|
echo -e "${WHITE}3. SSL-Zertifikate erstellen${NC}"
|
|
echo -e "${WHITE}4. Umgebung einrichten (Abhängigkeiten installieren)${NC}"
|
|
echo -e "${WHITE}5. Anwendung starten${NC}"
|
|
echo -e "${WHITE}6. Backend-Verbindung testen${NC}"
|
|
echo -e "${WHITE}7. Backend-URL konfigurieren${NC}"
|
|
echo -e "${WHITE}8. SSL-Zertifikat-Status anzeigen${NC}"
|
|
echo -e "${WHITE}9. Vollständige MYP-Installation${NC}"
|
|
echo -e "${WHITE}10. Projekt-Informationen anzeigen${NC}"
|
|
echo -e "${WHITE}11. Alte Dateien bereinigen${NC}"
|
|
echo -e "${WHITE}12. Beenden${NC}"
|
|
echo ""
|
|
|
|
read -p "Wählen Sie eine Option (1-12): " choice
|
|
|
|
case $choice in
|
|
1)
|
|
test_dependencies
|
|
show_main_menu
|
|
;;
|
|
2)
|
|
setup_hosts
|
|
show_main_menu
|
|
;;
|
|
3)
|
|
create_ssl_certificates
|
|
show_main_menu
|
|
;;
|
|
4)
|
|
setup_environment
|
|
show_main_menu
|
|
;;
|
|
5)
|
|
start_application
|
|
show_main_menu
|
|
;;
|
|
6)
|
|
test_backend_connection
|
|
show_main_menu
|
|
;;
|
|
7)
|
|
setup_backend_url
|
|
show_main_menu
|
|
;;
|
|
8)
|
|
show_ssl_status
|
|
show_main_menu
|
|
;;
|
|
9)
|
|
install_myp_complete
|
|
show_main_menu
|
|
;;
|
|
10)
|
|
show_project_info
|
|
show_main_menu
|
|
;;
|
|
11)
|
|
clean_old_files
|
|
show_main_menu
|
|
;;
|
|
12)
|
|
echo -e "${GREEN}Auf Wiedersehen!${NC}"
|
|
exit 0
|
|
;;
|
|
*)
|
|
echo -e "${RED}Ungültige Option. Bitte versuchen Sie es erneut.${NC}"
|
|
sleep 2
|
|
show_main_menu
|
|
;;
|
|
esac
|
|
}
|
|
|
|
# Skript starten
|
|
show_main_menu |