MYP Control Center Integration: install.sh integriert, legacy Skripte markiert, README aktualisiert

This commit is contained in:
2025-05-26 22:23:48 +02:00
parent f719f74195
commit 1b829b2ed2
8 changed files with 2102 additions and 284 deletions

View File

@@ -81,6 +81,260 @@ get_local_ip() {
echo "$ip"
}
# ========================================================
# PRODUKTIONS-INSTALLER (Integration from install.sh)
# ========================================================
# Produktions-Log-Funktionen
prod_log_info() {
echo -e "${BLUE}[INFO]${NC} $1"
}
prod_log_success() {
echo -e "${GREEN}[SUCCESS]${NC} $1"
}
prod_log_warning() {
echo -e "${YELLOW}[WARNING]${NC} $1"
}
prod_log_error() {
echo -e "${RED}[ERROR]${NC} $1"
}
# Prüfung für Produktions-Abhängigkeiten
check_production_dependencies() {
local deps=("python3.11" "curl" "openssl")
for dep in "${deps[@]}"; do
if ! command -v "$dep" &> /dev/null; then
prod_log_error "Abhängigkeit '$dep' nicht gefunden!"
return 1
fi
done
return 0
}
# Produktions-Backend Installation
install_production_backend() {
prod_log_info "=== Produktions-Backend Installation ==="
cd "$PROJECT_DIR/backend"
# Python Virtual Environment erstellen
prod_log_info "Erstelle Python Virtual Environment..."
python3.11 -m venv venv
source venv/bin/activate
# Requirements installieren
prod_log_info "Installiere Python-Abhängigkeiten..."
pip install --upgrade pip
pip install -r requirements.txt
# Zertifikate kopieren
prod_log_info "Kopiere TLS-Zertifikate..."
mkdir -p app/certs
cp "$PROJECT_DIR/backend/app/certs/backend.crt" app/certs/
cp "$PROJECT_DIR/backend/app/certs/backend.key" app/certs/
chmod 600 app/certs/backend.key
chmod 644 app/certs/backend.crt
# Systemd Service installieren
if [ $is_root -eq 1 ]; then
prod_log_info "Installiere systemd Service..."
cp myp.service /etc/systemd/system/
systemctl daemon-reload
systemctl enable myp.service
else
prod_log_warning "systemd Service-Installation übersprungen (keine Root-Rechte)"
prod_log_info "Manuell ausführen: sudo cp backend/myp.service /etc/systemd/system/ && sudo systemctl daemon-reload && sudo systemctl enable myp.service"
fi
# Datenbank initialisieren
prod_log_info "Initialisiere Datenbank..."
cd app
python3.11 init_db.py
prod_log_success "Produktions-Backend Installation abgeschlossen!"
if [ $is_root -eq 1 ]; then
prod_log_info "Service starten mit: sudo systemctl start myp.service"
fi
}
# Produktions-Frontend Installation
install_production_frontend() {
prod_log_info "=== Produktions-Frontend Installation ==="
cd "$PROJECT_DIR/frontend"
# Docker prüfen
if ! command -v docker &> /dev/null; then
prod_log_error "Docker ist nicht installiert!"
return 1
fi
if ! command -v docker-compose &> /dev/null; then
prod_log_error "Docker Compose ist nicht installiert!"
return 1
fi
# Zertifikate kopieren
prod_log_info "Kopiere TLS-Zertifikate..."
mkdir -p certs
cp "$PROJECT_DIR/frontend/certs/frontend.crt" certs/
cp "$PROJECT_DIR/frontend/certs/frontend.key" certs/
chmod 600 certs/frontend.key
chmod 644 certs/frontend.crt
# Caddyfile Symlink erstellen
prod_log_info "Erstelle Caddyfile Symlink..."
mkdir -p docker/caddy
if [[ ! -L docker/caddy/Caddyfile ]]; then
ln -sf "$PROJECT_DIR/frontend/docker/caddy/Caddyfile" docker/caddy/Caddyfile
fi
# Docker Images bauen
prod_log_info "Baue Docker Images..."
docker-compose build
# Services starten
prod_log_info "Starte Frontend Services..."
docker-compose up -d
prod_log_success "Produktions-Frontend Installation abgeschlossen!"
prod_log_info "Frontend verfügbar unter: https://m040tbaraspi001.de040.corpintra.net"
}
# Backend Health Check
production_health_check_backend() {
prod_log_info "=== Backend Health Check ==="
local max_attempts=30
local attempt=1
while [[ $attempt -le $max_attempts ]]; do
prod_log_info "Versuche Backend-Verbindung (Versuch $attempt/$max_attempts)..."
if curl -k -s --max-time 5 https://raspberrypi/api/test > /dev/null 2>&1; then
prod_log_success "Backend ist erreichbar!"
return 0
fi
sleep 2
((attempt++))
done
prod_log_error "Backend Health Check fehlgeschlagen!"
return 1
}
# Frontend Health Check
production_health_check_frontend() {
prod_log_info "=== Frontend Health Check ==="
local max_attempts=30
local attempt=1
while [[ $attempt -le $max_attempts ]]; do
prod_log_info "Versuche Frontend-Verbindung (Versuch $attempt/$max_attempts)..."
if curl -k -s --max-time 5 https://m040tbaraspi001.de040.corpintra.net/ > /dev/null 2>&1; then
prod_log_success "Frontend ist erreichbar!"
return 0
fi
sleep 2
((attempt++))
done
prod_log_error "Frontend Health Check fehlgeschlagen!"
return 1
}
# Produktions-Installer Menü
show_production_installer_menu() {
show_header "🚀 Produktions-Installer (v3.2 Integration)"
echo -e "${WHITE}Schnelle Produktions-Installation (von install.sh)${NC}"
echo ""
echo -e "${WHITE}1. Backend installieren (Raspberry Pi)${NC}"
echo -e "${WHITE}2. Frontend installieren (Docker)${NC}"
echo -e "${WHITE}3. Backend + Health Check${NC}"
echo -e "${WHITE}4. Frontend + Health Check${NC}"
echo -e "${WHITE}5. Beide Komponenten + Health Check${NC}"
echo ""
echo -e "${WHITE}9. Zurück zum Hauptmenü${NC}"
echo -e "${WHITE}0. Beenden${NC}"
echo ""
read -p "Wählen Sie eine Option (0-5, 9): " choice
case $choice in
1)
if check_production_dependencies; then
install_production_backend
else
prod_log_error "Abhängigkeiten fehlen!"
fi
show_production_installer_menu
;;
2)
if check_production_dependencies; then
install_production_frontend
else
prod_log_error "Abhängigkeiten fehlen!"
fi
show_production_installer_menu
;;
3)
if check_production_dependencies; then
install_production_backend
production_health_check_backend
else
prod_log_error "Abhängigkeiten fehlen!"
fi
show_production_installer_menu
;;
4)
if check_production_dependencies; then
install_production_frontend
production_health_check_frontend
else
prod_log_error "Abhängigkeiten fehlen!"
fi
show_production_installer_menu
;;
5)
if check_production_dependencies; then
install_production_backend
production_health_check_backend
install_production_frontend
production_health_check_frontend
prod_log_success "Vollständige Produktions-Installation abgeschlossen!"
else
prod_log_error "Abhängigkeiten fehlen!"
fi
show_production_installer_menu
;;
9)
show_main_menu
;;
0)
echo -e "${GREEN}Auf Wiedersehen!${NC}"
exit 0
;;
*)
echo -e "${RED}Ungültige Option. Bitte versuchen Sie es erneut.${NC}"
sleep 2
show_production_installer_menu
;;
esac
}
# ========================================================
# ENDE PRODUKTIONS-INSTALLER
# ========================================================
# System-Abhängigkeiten installieren
install_system_dependencies() {
show_header "System-Abhängigkeiten installieren"
@@ -1069,7 +1323,7 @@ setup_backend_url() {
# Backend API Konfiguration
NEXT_PUBLIC_API_URL=$backend_url
# Frontend-URL für OAuth Callback
# Frontend-URL
NEXT_PUBLIC_FRONTEND_URL=http://localhost:3000
# OAuth Konfiguration
@@ -1178,7 +1432,7 @@ start_application() {
start_debug_server
;;
7)
return
show_main_menu
;;
*)
echo -e "${RED}Ungültige Option.${NC}"
@@ -1699,18 +1953,21 @@ show_main_menu() {
echo -e "${WHITE}2. Backend-Only Installation (Kiosk-ready)${NC}"
echo -e "${WHITE}3. Entwicklungs-Setup (Backend + Frontend)${NC}"
echo ""
echo -e "${WHITE}🎯 PRODUKTIONS-INSTALLER (v3.2):${NC}"
echo -e "${WHITE}4. Produktions-Installer (install.sh Integration)${NC}"
echo ""
echo -e "${WHITE}⚙️ GRANULARE INSTALLATION:${NC}"
echo -e "${WHITE}4. Granulare Installation & Konfiguration${NC}"
echo -e "${WHITE}5. Granulare Installation & Konfiguration${NC}"
echo ""
echo -e "${WHITE}🔧 SYSTEM & WARTUNG:${NC}"
echo -e "${WHITE}5. Systemvoraussetzungen prüfen${NC}"
echo -e "${WHITE}6. Anwendung starten${NC}"
echo -e "${WHITE}7. Projekt-Informationen${NC}"
echo -e "${WHITE}6. Systemvoraussetzungen prüfen${NC}"
echo -e "${WHITE}7. Anwendung starten${NC}"
echo -e "${WHITE}8. Projekt-Informationen${NC}"
echo ""
echo -e "${WHITE}0. Beenden${NC}"
echo ""
read -p "Wählen Sie eine Option (0-7): " choice
read -p "Wählen Sie eine Option (0-8): " choice
case $choice in
1)
@@ -1726,17 +1983,20 @@ show_main_menu() {
show_main_menu
;;
4)
show_installation_menu
show_production_installer_menu
;;
5)
show_installation_menu
;;
6)
test_dependencies
show_main_menu
;;
6)
7)
start_application
show_main_menu
;;
7)
8)
show_project_info
show_main_menu
;;