diff --git a/backend/app/MYP_Backend_Schulung.pptx b/backend/app/MYP_Backend_Schulung.pptx deleted file mode 100644 index 619dd73b..00000000 Binary files a/backend/app/MYP_Backend_Schulung.pptx and /dev/null differ diff --git a/backend/app/MYP_Backend_Schulung_Enhanced.pptx b/backend/app/MYP_Backend_Schulung_Enhanced.pptx deleted file mode 100644 index 9e5eef22..00000000 Binary files a/backend/app/MYP_Backend_Schulung_Enhanced.pptx and /dev/null differ diff --git a/backend/app/PRESENTATION_README.md b/backend/app/PRESENTATION_README.md deleted file mode 100644 index bb10491e..00000000 --- a/backend/app/PRESENTATION_README.md +++ /dev/null @@ -1,50 +0,0 @@ -# MYP Platform Schulungspräsentation - -Diese PowerPoint-Präsentation wurde erstellt, um einen umfassenden Überblick über die Backend-Komponente der MYP-Platform zu geben, einem 3D-Drucker-Reservierungssystem. - -## Verfügbare Präsentationen - -In diesem Verzeichnis finden Sie zwei PowerPoint-Präsentationen: - -1. **MYP_Backend_Schulung.pptx** - Grundlegende Version mit klarem, minimalem Design -2. **MYP_Backend_Schulung_Enhanced.pptx** - Verbesserte Version mit Bildern und farblichen Akzenten - -## Inhalt der Präsentation - -Die Präsentation deckt folgende Themen ab: - -- Systemüberblick und Hauptfunktionen -- Technologie-Stack und verwendete Bibliotheken -- Backend-Architektur und Modulstruktur -- Datenmodell und Datenbankdesign -- API-Endpunkte und Funktionalität -- Job-Scheduler und Automatisierung -- Logging-System und Fehlerbehandlung -- Sicherheitskonzepte und Best Practices - -## Tipps für die Präsentation - -1. **Vorbereitung:** Laden Sie die Präsentation vor Ihrer Schulung herunter und testen Sie sie auf Ihrem Gerät. -2. **Bildschirmauflösung:** Die Präsentation ist für eine 16:9-Auflösung optimiert. -3. **Notizen:** Ergänzen Sie gerne eigene Notizen zu den einzelnen Folien basierend auf Ihrer Erfahrung mit dem System. -4. **Live-Demo:** Erwägen Sie, die Präsentation mit einer Live-Demo des Systems zu ergänzen. - -## Anpassung der Präsentation - -Falls Sie die Präsentation anpassen möchten: - -1. Beide Präsentationen wurden mit den Python-Skripten `create_presentation.py` und `create_presentation_enhanced.py` erstellt. -2. Bearbeiten Sie die entsprechenden Skripte und führen Sie sie erneut aus, um angepasste Versionen zu erstellen. -3. Bildmaterial für die verbesserte Version wird in einem Unterordner `presentation_images` gespeichert. - -## Voraussetzungen für die Generierung - -Um die Präsentationsskripte selbst auszuführen, benötigen Sie: - -```bash -pip install python-pptx requests pillow -``` - -## Kontakt - -Bei Fragen zur Präsentation oder zum MYP-Platform-System wenden Sie sich bitte an das Entwicklungsteam. \ No newline at end of file diff --git a/backend/app/config/settings.py b/backend/app/config/settings.py index dff1f847..4118ea8f 100644 --- a/backend/app/config/settings.py +++ b/backend/app/config/settings.py @@ -34,8 +34,8 @@ SESSION_LIFETIME = timedelta(days=7) # SSL-Konfiguration SSL_ENABLED = True -SSL_CERT_PATH = "app/certs/myp.crt" -SSL_KEY_PATH = "app/certs/myp.key" +SSL_CERT_PATH = "../certs/myp.crt" +SSL_KEY_PATH = "../certs/myp.key" SSL_HOSTNAME = "raspberrypi" # Scheduler-Konfiguration diff --git a/backend/app/create_presentation.py b/backend/app/create_presentation.py deleted file mode 100644 index efc0d300..00000000 --- a/backend/app/create_presentation.py +++ /dev/null @@ -1,344 +0,0 @@ -import os -from pptx import Presentation -from pptx.util import Inches, Pt -from pptx.dml.color import RGBColor -from pptx.enum.text import PP_ALIGN - -# Stile und Konstanten -TITLE_FONT = 'Helvetica Neue' -BODY_FONT = 'Helvetica Neue' -PRIMARY_COLOR = RGBColor(0, 122, 255) # Apple Blau -DARK_TEXT = RGBColor(50, 50, 50) -LIGHT_TEXT = RGBColor(240, 240, 240) -BACKGROUND_COLOR = RGBColor(250, 250, 250) -SLIDE_WIDTH = Inches(13.333) -SLIDE_HEIGHT = Inches(7.5) - -# Ausgabepfad -output_dir = os.path.dirname(os.path.abspath(__file__)) -output_path = os.path.join(output_dir, 'MYP_Backend_Schulung.pptx') - -# Neue Präsentation erstellen -prs = Presentation() - -# Foliengröße auf 16:9 setzen -prs.slide_width = SLIDE_WIDTH -prs.slide_height = SLIDE_HEIGHT - -# Hilfsfunktion für einheitliche Formatierung -def apply_text_style(paragraph, font_size, bold=False, color=DARK_TEXT, alignment=PP_ALIGN.LEFT): - paragraph.alignment = alignment - run = paragraph.runs[0] - run.font.name = BODY_FONT - run.font.size = Pt(font_size) - run.font.bold = bold - run.font.color.rgb = color - -# Titelfolie -slide_layout = prs.slide_layouts[0] # Titelfolie -slide = prs.slides.add_slide(slide_layout) - -# Hintergrund anpassen (einfacher weißer Hintergrund für Apple-ähnlichen Look) -background = slide.background -fill = background.fill -fill.solid() -fill.fore_color.rgb = BACKGROUND_COLOR - -# Titel hinzufügen -title_shape = slide.shapes.title -title_shape.text = "MYP Platform" -title_paragraph = title_shape.text_frame.paragraphs[0] -apply_text_style(title_paragraph, 54, bold=True, color=PRIMARY_COLOR, alignment=PP_ALIGN.CENTER) - -# Untertitel hinzufügen -subtitle_shape = slide.placeholders[1] -subtitle_shape.text = "3D-Drucker Reservierungssystem\nBackend-Schulung" -subtitle_paragraph = subtitle_shape.text_frame.paragraphs[0] -apply_text_style(subtitle_paragraph, 32, color=DARK_TEXT, alignment=PP_ALIGN.CENTER) - -# Folie 2: Überblick -slide = prs.slides.add_slide(prs.slide_layouts[1]) -title = slide.shapes.title -title.text = "Systemüberblick" -title_paragraph = title.text_frame.paragraphs[0] -apply_text_style(title_paragraph, 44, bold=True, color=PRIMARY_COLOR, alignment=PP_ALIGN.LEFT) - -# Inhalt -content = slide.placeholders[1] -tf = content.text_frame - -p = tf.paragraphs[0] -p.text = "• Reservierungssystem für 3D-Drucker" -apply_text_style(p, 28) - -p = tf.add_paragraph() -p.text = "• Automatische Steuerung von Smart Plugs" -apply_text_style(p, 28) - -p = tf.add_paragraph() -p.text = "• Echtzeit-Überwachung von Druckaufträgen" -apply_text_style(p, 28) - -p = tf.add_paragraph() -p.text = "• Administrationsfunktionen" -apply_text_style(p, 28) - -p = tf.add_paragraph() -p.text = "• Statistik und Analyse" -apply_text_style(p, 28) - -# Folie 3: Technologie-Stack -slide = prs.slides.add_slide(prs.slide_layouts[1]) -title = slide.shapes.title -title.text = "Technologie-Stack" -title_paragraph = title.text_frame.paragraphs[0] -apply_text_style(title_paragraph, 44, bold=True, color=PRIMARY_COLOR, alignment=PP_ALIGN.LEFT) - -# Inhalt -content = slide.placeholders[1] -tf = content.text_frame - -p = tf.paragraphs[0] -p.text = "• Backend: Python 3.11 mit Flask" -apply_text_style(p, 28) - -p = tf.add_paragraph() -p.text = "• Frontend: HTML/CSS/JavaScript mit Tailwind CSS" -apply_text_style(p, 28) - -p = tf.add_paragraph() -p.text = "• Datenbank: SQLite mit SQLAlchemy ORM" -apply_text_style(p, 28) - -p = tf.add_paragraph() -p.text = "• Authentifizierung: Flask-Login" -apply_text_style(p, 28) - -p = tf.add_paragraph() -p.text = "• Hardware-Integration: PyP110 für Tapo Smart Plug Steuerung" -apply_text_style(p, 28) - -p = tf.add_paragraph() -p.text = "• Automatisierung: Integrierter Job-Scheduler" -apply_text_style(p, 28) - -# Folie 4: Architektur -slide = prs.slides.add_slide(prs.slide_layouts[1]) -title = slide.shapes.title -title.text = "Backend-Architektur" -title_paragraph = title.text_frame.paragraphs[0] -apply_text_style(title_paragraph, 44, bold=True, color=PRIMARY_COLOR, alignment=PP_ALIGN.LEFT) - -# Inhalt -content = slide.placeholders[1] -tf = content.text_frame - -p = tf.paragraphs[0] -p.text = "• Flask-App: Zentrale Anwendungslogik" -apply_text_style(p, 28) - -p = tf.add_paragraph() -p.text = "• Blueprints: Modulare Strukturierung (auth, user, kiosk)" -apply_text_style(p, 28) - -p = tf.add_paragraph() -p.text = "• Models: SQLAlchemy ORM für Datenbankkommunikation" -apply_text_style(p, 28) - -p = tf.add_paragraph() -p.text = "• Utils: Job-Scheduler, Logging, Template-Helpers" -apply_text_style(p, 28) - -p = tf.add_paragraph() -p.text = "• API: RESTful-Endpunkte für Frontend-Kommunikation" -apply_text_style(p, 28) - -# Folie 5: Datenmodell -slide = prs.slides.add_slide(prs.slide_layouts[1]) -title = slide.shapes.title -title.text = "Datenmodell" -title_paragraph = title.text_frame.paragraphs[0] -apply_text_style(title_paragraph, 44, bold=True, color=PRIMARY_COLOR, alignment=PP_ALIGN.LEFT) - -# Inhalt -content = slide.placeholders[1] -tf = content.text_frame - -p = tf.paragraphs[0] -p.text = "• User: Benutzer mit Rollen und Authentifizierung" -apply_text_style(p, 28) - -p = tf.add_paragraph() -p.text = "• Printer: 3D-Drucker mit Smart-Plug-Konfigurationen" -apply_text_style(p, 28) - -p = tf.add_paragraph() -p.text = "• Job: Druckaufträge mit Status und Zeitplanung" -apply_text_style(p, 28) - -p = tf.add_paragraph() -p.text = "• Stats: Systemstatistiken und Metriken" -apply_text_style(p, 28) - -# Folie 6: API-Endpunkte -slide = prs.slides.add_slide(prs.slide_layouts[1]) -title = slide.shapes.title -title.text = "API-Endpunkte" -title_paragraph = title.text_frame.paragraphs[0] -apply_text_style(title_paragraph, 44, bold=True, color=PRIMARY_COLOR, alignment=PP_ALIGN.LEFT) - -# Inhalt -content = slide.placeholders[1] -tf = content.text_frame - -p = tf.paragraphs[0] -p.text = "• /api/jobs: Druckaufträge verwalten" -apply_text_style(p, 28) - -p = tf.add_paragraph() -p.text = "• /api/printers: Drucker verwalten" -apply_text_style(p, 28) - -p = tf.add_paragraph() -p.text = "• /api/users: Benutzer verwalten" -apply_text_style(p, 28) - -p = tf.add_paragraph() -p.text = "• /api/stats: Statistiken abrufen" -apply_text_style(p, 28) - -p = tf.add_paragraph() -p.text = "• /api/scheduler: Scheduler steuern" -apply_text_style(p, 28) - -# Folie 7: Scheduler -slide = prs.slides.add_slide(prs.slide_layouts[1]) -title = slide.shapes.title -title.text = "Job-Scheduler" -title_paragraph = title.text_frame.paragraphs[0] -apply_text_style(title_paragraph, 44, bold=True, color=PRIMARY_COLOR, alignment=PP_ALIGN.LEFT) - -# Inhalt -content = slide.placeholders[1] -tf = content.text_frame - -p = tf.paragraphs[0] -p.text = "• Automatische Steuerung der Drucker" -apply_text_style(p, 28) - -p = tf.add_paragraph() -p.text = "• Einschalten bei Auftragsstart" -apply_text_style(p, 28) - -p = tf.add_paragraph() -p.text = "• Ausschalten bei Auftragsende" -apply_text_style(p, 28) - -p = tf.add_paragraph() -p.text = "• Statusüberwachung und -aktualisierung" -apply_text_style(p, 28) - -p = tf.add_paragraph() -p.text = "• Sammeln von Statistiken" -apply_text_style(p, 28) - -# Folie 8: Logging -slide = prs.slides.add_slide(prs.slide_layouts[1]) -title = slide.shapes.title -title.text = "Logging-System" -title_paragraph = title.text_frame.paragraphs[0] -apply_text_style(title_paragraph, 44, bold=True, color=PRIMARY_COLOR, alignment=PP_ALIGN.LEFT) - -# Inhalt -content = slide.placeholders[1] -tf = content.text_frame - -p = tf.paragraphs[0] -p.text = "• Separate Logs für verschiedene Bereiche:" -apply_text_style(p, 28) - -p = tf.add_paragraph() -p.text = " - App-Logs: Allgemeine Anwendungslogs" -apply_text_style(p, 28) - -p = tf.add_paragraph() -p.text = " - Auth-Logs: Authentifizierungsereignisse" -apply_text_style(p, 28) - -p = tf.add_paragraph() -p.text = " - Job-Logs: Druckauftragsoperationen" -apply_text_style(p, 28) - -p = tf.add_paragraph() -p.text = " - Printer-Logs: Druckerstatusänderungen" -apply_text_style(p, 28) - -p = tf.add_paragraph() -p.text = " - Scheduler-Logs: Automatisierungsaktionen" -apply_text_style(p, 28) - -# Folie 9: Sicherheit -slide = prs.slides.add_slide(prs.slide_layouts[1]) -title = slide.shapes.title -title.text = "Sicherheitskonzept" -title_paragraph = title.text_frame.paragraphs[0] -apply_text_style(title_paragraph, 44, bold=True, color=PRIMARY_COLOR, alignment=PP_ALIGN.LEFT) - -# Inhalt -content = slide.placeholders[1] -tf = content.text_frame - -p = tf.paragraphs[0] -p.text = "• Benutzerauthentifizierung mit bcrypt" -apply_text_style(p, 28) - -p = tf.add_paragraph() -p.text = "• Rollenbasierte Zugriffskontrolle" -apply_text_style(p, 28) - -p = tf.add_paragraph() -p.text = "• CSRF-Schutz bei Formularen" -apply_text_style(p, 28) - -p = tf.add_paragraph() -p.text = "• Besitzer-Check für Druckaufträge" -apply_text_style(p, 28) - -p = tf.add_paragraph() -p.text = "• Sichere HTTP-Header" -apply_text_style(p, 28) - -# Folie 10: Zusammenfassung -slide = prs.slides.add_slide(prs.slide_layouts[1]) -title = slide.shapes.title -title.text = "Zusammenfassung" -title_paragraph = title.text_frame.paragraphs[0] -apply_text_style(title_paragraph, 44, bold=True, color=PRIMARY_COLOR, alignment=PP_ALIGN.LEFT) - -# Inhalt -content = slide.placeholders[1] -tf = content.text_frame - -p = tf.paragraphs[0] -p.text = "• Vollständige Lösung für 3D-Drucker-Management" -apply_text_style(p, 28) - -p = tf.add_paragraph() -p.text = "• Modulare Architektur für einfache Erweiterbarkeit" -apply_text_style(p, 28) - -p = tf.add_paragraph() -p.text = "• Robuste Sicherheitskonzepte" -apply_text_style(p, 28) - -p = tf.add_paragraph() -p.text = "• Umfassendes Logging und Überwachung" -apply_text_style(p, 28) - -p = tf.add_paragraph() -p.text = "• Automatisierung von Routineaufgaben" -apply_text_style(p, 28) - -# Präsentation speichern -prs.save(output_path) -print(f"Präsentation wurde erstellt: {output_path}") \ No newline at end of file diff --git a/backend/app/create_presentation_enhanced.py b/backend/app/create_presentation_enhanced.py deleted file mode 100644 index 183d3dbc..00000000 --- a/backend/app/create_presentation_enhanced.py +++ /dev/null @@ -1,587 +0,0 @@ -import os -import io -import requests -from PIL import Image -from pptx import Presentation -from pptx.util import Inches, Pt -from pptx.dml.color import RGBColor -from pptx.enum.text import PP_ALIGN - -# Stile und Konstanten -TITLE_FONT = 'Helvetica Neue' -BODY_FONT = 'Helvetica Neue' -PRIMARY_COLOR = RGBColor(0, 122, 255) # Apple Blau -SECONDARY_COLOR = RGBColor(88, 86, 214) # Apple Lila -ACCENT_COLOR = RGBColor(255, 149, 0) # Apple Orange -DARK_TEXT = RGBColor(50, 50, 50) -LIGHT_TEXT = RGBColor(240, 240, 240) -BACKGROUND_COLOR = RGBColor(250, 250, 250) -SLIDE_WIDTH = Inches(13.333) -SLIDE_HEIGHT = Inches(7.5) - -# Ausgabepfad -output_dir = os.path.dirname(os.path.abspath(__file__)) -output_path = os.path.join(output_dir, 'MYP_Backend_Schulung_Enhanced.pptx') -images_dir = os.path.join(output_dir, 'presentation_images') - -# Verzeichnis für Bilder erstellen, falls es nicht existiert -os.makedirs(images_dir, exist_ok=True) - -# Funktion zum Herunterladen von Stock-Bildern (nur Beispiel, Sie können auch eigene Bilder verwenden) -def download_stock_image(url, filename): - try: - image_path = os.path.join(images_dir, filename) - # Wenn das Bild bereits existiert, nicht erneut herunterladen - if os.path.exists(image_path): - return image_path - - response = requests.get(url, stream=True) - if response.status_code == 200: - with open(image_path, 'wb') as f: - f.write(response.content) - return image_path - else: - print(f"Fehler beim Herunterladen des Bildes: {response.status_code}") - return None - except Exception as e: - print(f"Fehler: {e}") - return None - -# Platzhalterbilder für die Präsentation -# Im echten Einsatz würden Sie eigene Bilder oder lizenzfreie Bilder verwenden -image_urls = { - "header": "https://cdn.pixabay.com/photo/2017/08/10/02/05/tiles-shapes-2617112_1280.jpg", - "3d_printer": "https://cdn.pixabay.com/photo/2019/07/06/11/15/3d-printer-4320296_1280.jpg", - "backend": "https://cdn.pixabay.com/photo/2016/11/27/21/42/stock-1863880_1280.jpg", - "database": "https://cdn.pixabay.com/photo/2017/06/14/16/20/network-2402637_1280.jpg", - "api": "https://cdn.pixabay.com/photo/2018/05/04/20/01/website-3374825_1280.jpg", - "scheduler": "https://cdn.pixabay.com/photo/2018/01/17/07/06/laptop-3087585_1280.jpg", - "security": "https://cdn.pixabay.com/photo/2017/11/19/23/56/cyber-security-2965030_1280.jpg", - "summary": "https://cdn.pixabay.com/photo/2019/04/14/10/27/book-4126483_1280.jpg" -} - -# Bilder herunterladen -image_paths = {} -for key, url in image_urls.items(): - filename = f"{key}.jpg" - image_path = download_stock_image(url, filename) - if image_path: - image_paths[key] = image_path - else: - print(f"Konnte Bild {key} nicht herunterladen") - -# Neue Präsentation erstellen -prs = Presentation() - -# Foliengröße auf 16:9 setzen -prs.slide_width = SLIDE_WIDTH -prs.slide_height = SLIDE_HEIGHT - -# Hilfsfunktion für einheitliche Formatierung -def apply_text_style(paragraph, font_size, bold=False, color=DARK_TEXT, alignment=PP_ALIGN.LEFT): - paragraph.alignment = alignment - run = paragraph.runs[0] - run.font.name = BODY_FONT - run.font.size = Pt(font_size) - run.font.bold = bold - run.font.color.rgb = color - -# Hilfsfunktion zum Hinzufügen eines Bildes zu einer Folie -def add_image_to_slide(slide, image_path, left, top, width, height=None, keep_ratio=True): - if not os.path.exists(image_path): - print(f"Bildpfad existiert nicht: {image_path}") - return None - - img = Image.open(image_path) - width_inches = width - - if keep_ratio and height is None: - # Seitenverhältnis beibehalten - img_ratio = img.height / img.width - height_inches = width_inches * img_ratio - else: - height_inches = height - - return slide.shapes.add_picture(image_path, left, top, width=width_inches, height=height_inches) - -# Hilfsfunktion zum Erstellen eines abgerundeten Farbbereichs (als Ersatz für abgerundete Rechtecke) -def add_rectangle_to_slide(slide, left, top, width, height, color=PRIMARY_COLOR): - shape = slide.shapes.add_shape(1, left, top, width, height) # 1 = Rechteck - shape.fill.solid() - shape.fill.fore_color.rgb = color - shape.line.fill.solid() - shape.line.fill.fore_color.rgb = color - return shape - -# ------------- FOLIE 1: TITELFOLIE ------------- -slide_layout = prs.slide_layouts[0] # Titelfolie -slide = prs.slides.add_slide(slide_layout) - -# Hintergrund anpassen -background = slide.background -fill = background.fill -fill.solid() -fill.fore_color.rgb = BACKGROUND_COLOR - -# Hintergrundbild (wenn verfügbar) -if "header" in image_paths: - header_img = add_image_to_slide(slide, - image_paths["header"], - Inches(0), - Inches(0), - SLIDE_WIDTH, - SLIDE_HEIGHT, - keep_ratio=False) - # Bild in den Hintergrund - if header_img: - header_img.z_order = 0 - -# Halbtransparentes Overlay -overlay = add_rectangle_to_slide(slide, - Inches(0), - Inches(0), - SLIDE_WIDTH, - SLIDE_HEIGHT, - RGBColor(0, 0, 0)) -overlay.fill.transparency = 0.4 # 40% Transparenz -overlay.z_order = 1 - -# Titel hinzufügen -title_shape = slide.shapes.title -title_shape.text = "MYP Platform" -title_paragraph = title_shape.text_frame.paragraphs[0] -apply_text_style(title_paragraph, 64, bold=True, color=LIGHT_TEXT, alignment=PP_ALIGN.CENTER) -title_shape.z_order = 2 - -# Untertitel hinzufügen -subtitle_shape = slide.placeholders[1] -subtitle_shape.text = "3D-Drucker Reservierungssystem\nBackend-Schulung" -subtitle_paragraph = subtitle_shape.text_frame.paragraphs[0] -apply_text_style(subtitle_paragraph, 36, color=LIGHT_TEXT, alignment=PP_ALIGN.CENTER) -subtitle_shape.z_order = 2 - -# ------------- FOLIE 2: ÜBERBLICK ------------- -slide = prs.slides.add_slide(prs.slide_layouts[1]) - -# Hintergrund anpassen -background = slide.background -fill = background.fill -fill.solid() -fill.fore_color.rgb = BACKGROUND_COLOR - -title = slide.shapes.title -title.text = "Systemüberblick" -title_paragraph = title.text_frame.paragraphs[0] -apply_text_style(title_paragraph, 44, bold=True, color=PRIMARY_COLOR, alignment=PP_ALIGN.LEFT) - -# Inhalt -content = slide.placeholders[1] -tf = content.text_frame - -p = tf.paragraphs[0] -p.text = "• Reservierungssystem für 3D-Drucker" -apply_text_style(p, 28) - -p = tf.add_paragraph() -p.text = "• Automatische Steuerung von Smart Plugs" -apply_text_style(p, 28) - -p = tf.add_paragraph() -p.text = "• Echtzeit-Überwachung von Druckaufträgen" -apply_text_style(p, 28) - -p = tf.add_paragraph() -p.text = "• Administrationsfunktionen" -apply_text_style(p, 28) - -p = tf.add_paragraph() -p.text = "• Statistik und Analyse" -apply_text_style(p, 28) - -# Bild einfügen (wenn verfügbar) -if "3d_printer" in image_paths: - printer_img = add_image_to_slide(slide, - image_paths["3d_printer"], - Inches(7), - Inches(2), - Inches(5)) - -# ------------- FOLIE 3: TECHNOLOGIE-STACK ------------- -slide = prs.slides.add_slide(prs.slide_layouts[1]) - -# Hintergrund anpassen -background = slide.background -fill = background.fill -fill.solid() -fill.fore_color.rgb = BACKGROUND_COLOR - -title = slide.shapes.title -title.text = "Technologie-Stack" -title_paragraph = title.text_frame.paragraphs[0] -apply_text_style(title_paragraph, 44, bold=True, color=PRIMARY_COLOR, alignment=PP_ALIGN.LEFT) - -# Inhalt -content = slide.placeholders[1] -tf = content.text_frame - -p = tf.paragraphs[0] -p.text = "• Backend: Python 3.11 mit Flask" -apply_text_style(p, 28) -p.runs[0].font.color.rgb = SECONDARY_COLOR - -p = tf.add_paragraph() -p.text = "• Frontend: HTML/CSS/JavaScript mit Tailwind CSS" -apply_text_style(p, 28) - -p = tf.add_paragraph() -p.text = "• Datenbank: SQLite mit SQLAlchemy ORM" -apply_text_style(p, 28) -p.runs[0].font.color.rgb = ACCENT_COLOR - -p = tf.add_paragraph() -p.text = "• Authentifizierung: Flask-Login" -apply_text_style(p, 28) - -p = tf.add_paragraph() -p.text = "• Hardware-Integration: PyP110 für Tapo Smart Plug Steuerung" -apply_text_style(p, 28) - -p = tf.add_paragraph() -p.text = "• Automatisierung: Integrierter Job-Scheduler" -apply_text_style(p, 28) - -# Bild einfügen (wenn verfügbar) -if "backend" in image_paths: - backend_img = add_image_to_slide(slide, - image_paths["backend"], - Inches(7), - Inches(2), - Inches(5)) - -# ------------- FOLIE 4: ARCHITEKTUR ------------- -slide = prs.slides.add_slide(prs.slide_layouts[1]) - -# Hintergrund anpassen -background = slide.background -fill = background.fill -fill.solid() -fill.fore_color.rgb = BACKGROUND_COLOR - -title = slide.shapes.title -title.text = "Backend-Architektur" -title_paragraph = title.text_frame.paragraphs[0] -apply_text_style(title_paragraph, 44, bold=True, color=PRIMARY_COLOR, alignment=PP_ALIGN.LEFT) - -# Inhalt -content = slide.placeholders[1] -tf = content.text_frame - -p = tf.paragraphs[0] -p.text = "• Flask-App: Zentrale Anwendungslogik" -apply_text_style(p, 28) -p.runs[0].font.color.rgb = PRIMARY_COLOR - -p = tf.add_paragraph() -p.text = "• Blueprints: Modulare Strukturierung (auth, user, kiosk)" -apply_text_style(p, 28) - -p = tf.add_paragraph() -p.text = "• Models: SQLAlchemy ORM für Datenbankkommunikation" -apply_text_style(p, 28) -p.runs[0].font.color.rgb = ACCENT_COLOR - -p = tf.add_paragraph() -p.text = "• Utils: Job-Scheduler, Logging, Template-Helpers" -apply_text_style(p, 28) - -p = tf.add_paragraph() -p.text = "• API: RESTful-Endpunkte für Frontend-Kommunikation" -apply_text_style(p, 28) -p.runs[0].font.color.rgb = SECONDARY_COLOR - -# ------------- FOLIE 5: DATENMODELL ------------- -slide = prs.slides.add_slide(prs.slide_layouts[1]) - -# Hintergrund anpassen -background = slide.background -fill = background.fill -fill.solid() -fill.fore_color.rgb = BACKGROUND_COLOR - -title = slide.shapes.title -title.text = "Datenmodell" -title_paragraph = title.text_frame.paragraphs[0] -apply_text_style(title_paragraph, 44, bold=True, color=PRIMARY_COLOR, alignment=PP_ALIGN.LEFT) - -# Inhalt -content = slide.placeholders[1] -tf = content.text_frame - -p = tf.paragraphs[0] -p.text = "• User: Benutzer mit Rollen und Authentifizierung" -apply_text_style(p, 28) - -p = tf.add_paragraph() -p.text = "• Printer: 3D-Drucker mit Smart-Plug-Konfigurationen" -apply_text_style(p, 28) -p.runs[0].font.color.rgb = ACCENT_COLOR - -p = tf.add_paragraph() -p.text = "• Job: Druckaufträge mit Status und Zeitplanung" -apply_text_style(p, 28) -p.runs[0].font.color.rgb = SECONDARY_COLOR - -p = tf.add_paragraph() -p.text = "• Stats: Systemstatistiken und Metriken" -apply_text_style(p, 28) - -# Bild einfügen (wenn verfügbar) -if "database" in image_paths: - db_img = add_image_to_slide(slide, - image_paths["database"], - Inches(7), - Inches(2), - Inches(5)) - -# ------------- FOLIE 6: API-ENDPUNKTE ------------- -slide = prs.slides.add_slide(prs.slide_layouts[1]) - -# Hintergrund anpassen -background = slide.background -fill = background.fill -fill.solid() -fill.fore_color.rgb = BACKGROUND_COLOR - -title = slide.shapes.title -title.text = "API-Endpunkte" -title_paragraph = title.text_frame.paragraphs[0] -apply_text_style(title_paragraph, 44, bold=True, color=PRIMARY_COLOR, alignment=PP_ALIGN.LEFT) - -# Inhalt -content = slide.placeholders[1] -tf = content.text_frame - -p = tf.paragraphs[0] -p.text = "• /api/jobs: Druckaufträge verwalten" -apply_text_style(p, 28) -p.runs[0].font.color.rgb = SECONDARY_COLOR - -p = tf.add_paragraph() -p.text = "• /api/printers: Drucker verwalten" -apply_text_style(p, 28) -p.runs[0].font.color.rgb = ACCENT_COLOR - -p = tf.add_paragraph() -p.text = "• /api/users: Benutzer verwalten" -apply_text_style(p, 28) - -p = tf.add_paragraph() -p.text = "• /api/stats: Statistiken abrufen" -apply_text_style(p, 28) - -p = tf.add_paragraph() -p.text = "• /api/scheduler: Scheduler steuern" -apply_text_style(p, 28) -p.runs[0].font.color.rgb = PRIMARY_COLOR - -# Bild einfügen (wenn verfügbar) -if "api" in image_paths: - api_img = add_image_to_slide(slide, - image_paths["api"], - Inches(7), - Inches(2), - Inches(5)) - -# ------------- FOLIE 7: JOB-SCHEDULER ------------- -slide = prs.slides.add_slide(prs.slide_layouts[1]) - -# Hintergrund anpassen -background = slide.background -fill = background.fill -fill.solid() -fill.fore_color.rgb = BACKGROUND_COLOR - -title = slide.shapes.title -title.text = "Job-Scheduler" -title_paragraph = title.text_frame.paragraphs[0] -apply_text_style(title_paragraph, 44, bold=True, color=PRIMARY_COLOR, alignment=PP_ALIGN.LEFT) - -# Inhalt -content = slide.placeholders[1] -tf = content.text_frame - -p = tf.paragraphs[0] -p.text = "• Automatische Steuerung der Drucker" -apply_text_style(p, 28) - -p = tf.add_paragraph() -p.text = "• Einschalten bei Auftragsstart" -apply_text_style(p, 28) -p.runs[0].font.color.rgb = ACCENT_COLOR - -p = tf.add_paragraph() -p.text = "• Ausschalten bei Auftragsende" -apply_text_style(p, 28) -p.runs[0].font.color.rgb = ACCENT_COLOR - -p = tf.add_paragraph() -p.text = "• Statusüberwachung und -aktualisierung" -apply_text_style(p, 28) - -p = tf.add_paragraph() -p.text = "• Sammeln von Statistiken" -apply_text_style(p, 28) - -# Bild einfügen (wenn verfügbar) -if "scheduler" in image_paths: - scheduler_img = add_image_to_slide(slide, - image_paths["scheduler"], - Inches(7), - Inches(2), - Inches(5)) - -# ------------- FOLIE 8: LOGGING-SYSTEM ------------- -slide = prs.slides.add_slide(prs.slide_layouts[1]) - -# Hintergrund anpassen -background = slide.background -fill = background.fill -fill.solid() -fill.fore_color.rgb = BACKGROUND_COLOR - -title = slide.shapes.title -title.text = "Logging-System" -title_paragraph = title.text_frame.paragraphs[0] -apply_text_style(title_paragraph, 44, bold=True, color=PRIMARY_COLOR, alignment=PP_ALIGN.LEFT) - -# Inhalt -content = slide.placeholders[1] -tf = content.text_frame - -p = tf.paragraphs[0] -p.text = "• Separate Logs für verschiedene Bereiche:" -apply_text_style(p, 28) -p.runs[0].font.bold = True - -p = tf.add_paragraph() -p.text = " - App-Logs: Allgemeine Anwendungslogs" -apply_text_style(p, 28) - -p = tf.add_paragraph() -p.text = " - Auth-Logs: Authentifizierungsereignisse" -apply_text_style(p, 28) - -p = tf.add_paragraph() -p.text = " - Job-Logs: Druckauftragsoperationen" -apply_text_style(p, 28) -p.runs[0].font.color.rgb = SECONDARY_COLOR - -p = tf.add_paragraph() -p.text = " - Printer-Logs: Druckerstatusänderungen" -apply_text_style(p, 28) -p.runs[0].font.color.rgb = ACCENT_COLOR - -p = tf.add_paragraph() -p.text = " - Scheduler-Logs: Automatisierungsaktionen" -apply_text_style(p, 28) - -# ------------- FOLIE 9: SICHERHEITSKONZEPT ------------- -slide = prs.slides.add_slide(prs.slide_layouts[1]) - -# Hintergrund anpassen -background = slide.background -fill = background.fill -fill.solid() -fill.fore_color.rgb = BACKGROUND_COLOR - -title = slide.shapes.title -title.text = "Sicherheitskonzept" -title_paragraph = title.text_frame.paragraphs[0] -apply_text_style(title_paragraph, 44, bold=True, color=PRIMARY_COLOR, alignment=PP_ALIGN.LEFT) - -# Inhalt -content = slide.placeholders[1] -tf = content.text_frame - -p = tf.paragraphs[0] -p.text = "• Benutzerauthentifizierung mit bcrypt" -apply_text_style(p, 28) -p.runs[0].font.color.rgb = SECONDARY_COLOR - -p = tf.add_paragraph() -p.text = "• Rollenbasierte Zugriffskontrolle" -apply_text_style(p, 28) - -p = tf.add_paragraph() -p.text = "• CSRF-Schutz bei Formularen" -apply_text_style(p, 28) - -p = tf.add_paragraph() -p.text = "• Besitzer-Check für Druckaufträge" -apply_text_style(p, 28) -p.runs[0].font.color.rgb = ACCENT_COLOR - -p = tf.add_paragraph() -p.text = "• Sichere HTTP-Header" -apply_text_style(p, 28) - -# Bild einfügen (wenn verfügbar) -if "security" in image_paths: - security_img = add_image_to_slide(slide, - image_paths["security"], - Inches(7), - Inches(2), - Inches(5)) - -# ------------- FOLIE 10: ZUSAMMENFASSUNG ------------- -slide = prs.slides.add_slide(prs.slide_layouts[1]) - -# Hintergrund anpassen -background = slide.background -fill = background.fill -fill.solid() -fill.fore_color.rgb = BACKGROUND_COLOR - -title = slide.shapes.title -title.text = "Zusammenfassung" -title_paragraph = title.text_frame.paragraphs[0] -apply_text_style(title_paragraph, 44, bold=True, color=PRIMARY_COLOR, alignment=PP_ALIGN.LEFT) - -# Inhalt -content = slide.placeholders[1] -tf = content.text_frame - -p = tf.paragraphs[0] -p.text = "• Vollständige Lösung für 3D-Drucker-Management" -apply_text_style(p, 28) -p.runs[0].font.bold = True - -p = tf.add_paragraph() -p.text = "• Modulare Architektur für einfache Erweiterbarkeit" -apply_text_style(p, 28) - -p = tf.add_paragraph() -p.text = "• Robuste Sicherheitskonzepte" -apply_text_style(p, 28) -p.runs[0].font.color.rgb = SECONDARY_COLOR - -p = tf.add_paragraph() -p.text = "• Umfassendes Logging und Überwachung" -apply_text_style(p, 28) - -p = tf.add_paragraph() -p.text = "• Automatisierung von Routineaufgaben" -apply_text_style(p, 28) -p.runs[0].font.color.rgb = ACCENT_COLOR - -# Bild einfügen (wenn verfügbar) -if "summary" in image_paths: - summary_img = add_image_to_slide(slide, - image_paths["summary"], - Inches(7), - Inches(2), - Inches(5)) - -# Präsentation speichern -prs.save(output_path) -print(f"Verbesserte Präsentation wurde erstellt: {output_path}") \ No newline at end of file diff --git a/backend/app/presentation_images/api.jpg b/backend/app/presentation_images/api.jpg deleted file mode 100644 index bf94e305..00000000 Binary files a/backend/app/presentation_images/api.jpg and /dev/null differ diff --git a/backend/app/presentation_images/backend.jpg b/backend/app/presentation_images/backend.jpg deleted file mode 100644 index 87ce7f21..00000000 Binary files a/backend/app/presentation_images/backend.jpg and /dev/null differ diff --git a/backend/app/presentation_images/database.jpg b/backend/app/presentation_images/database.jpg deleted file mode 100644 index ebd6c7b7..00000000 Binary files a/backend/app/presentation_images/database.jpg and /dev/null differ diff --git a/backend/app/presentation_images/header.jpg b/backend/app/presentation_images/header.jpg deleted file mode 100644 index d6792345..00000000 Binary files a/backend/app/presentation_images/header.jpg and /dev/null differ diff --git a/backend/app/presentation_images/scheduler.jpg b/backend/app/presentation_images/scheduler.jpg deleted file mode 100644 index 5286ab54..00000000 Binary files a/backend/app/presentation_images/scheduler.jpg and /dev/null differ diff --git a/backend/app/presentation_images/summary.jpg b/backend/app/presentation_images/summary.jpg deleted file mode 100644 index a3b7663c..00000000 Binary files a/backend/app/presentation_images/summary.jpg and /dev/null differ diff --git a/generate_ssl_certs.ps1 b/generate_ssl_certs.ps1 deleted file mode 100644 index 43a9a650..00000000 --- a/generate_ssl_certs.ps1 +++ /dev/null @@ -1,123 +0,0 @@ -# MYP - SSL-Zertifikat-Generator für Windows -# Erstellt selbstsignierte Zertifikate für die HTTPS-Kommunikation - -# Überprüfen, ob das Skript als Administrator ausgeführt wird -$isAdmin = ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator) -if (-not $isAdmin) { - Write-Host "Hinweis: Dieses Skript wird ohne Administrator-Rechte ausgeführt." -ForegroundColor Yellow - Write-Host "Einige Funktionen könnten eingeschränkt sein." -ForegroundColor Yellow -} - -# Header anzeigen -Write-Host "================================================================" -ForegroundColor Blue -Write-Host " MYP - SSL-Zertifikat-Generator " -ForegroundColor Blue -Write-Host "================================================================" -ForegroundColor Blue -Write-Host "" - -# Parameter definieren -$certDir = "./backend/instance/ssl" -$backendCertFile = "$certDir/myp.crt" -$backendKeyFile = "$certDir/myp.key" -$frontendCertFile = "$certDir/frontend.crt" -$frontendKeyFile = "$certDir/frontend.key" -$backendHostname = "localhost" -$frontendHostname = "localhost" -$validityDays = 3650 # 10 Jahre - -# Verzeichnis erstellen, falls es nicht existiert -if (!(Test-Path $certDir)) { - Write-Host "Erstelle Verzeichnis $certDir..." -ForegroundColor Yellow - New-Item -ItemType Directory -Path $certDir -Force | Out-Null -} - -# Prüfen, ob OpenSSL installiert ist -$openSSLInstalled = $null -try { - $openSSLInstalled = Get-Command openssl -ErrorAction SilentlyContinue -} catch {} - -if ($null -eq $openSSLInstalled) { - Write-Host "OpenSSL konnte nicht gefunden werden!" -ForegroundColor Red - Write-Host "Bitte installieren Sie OpenSSL für Windows und stellen Sie sicher, dass es im PATH verfügbar ist." -ForegroundColor Yellow - Write-Host "Sie können OpenSSL von https://slproweb.com/products/Win32OpenSSL.html herunterladen." -ForegroundColor Yellow - Exit 1 -} - -# Funktion zum Erstellen eines selbstsignierten Zertifikats -function Create-SelfSignedCert { - param( - [string]$CertFile, - [string]$KeyFile, - [string]$Hostname, - [int]$Days - ) - - Write-Host "Erstelle selbstsigniertes SSL-Zertifikat für $Hostname..." -ForegroundColor Green - - # OpenSSL-Konfiguration erstellen - $configFile = "$certDir/openssl_$($Hostname.Split('.')[0]).cnf" - - $configContent = @" -[req] -default_bits = 2048 -prompt = no -default_md = sha256 -distinguished_name = req_distinguished_name -x509_extensions = v3_req - -[req_distinguished_name] -C = DE -ST = Berlin -L = Berlin -O = Mercedes-Benz AG -OU = Werk 040 Berlin -CN = $Hostname - -[v3_req] -keyUsage = critical, digitalSignature, keyAgreement -extendedKeyUsage = serverAuth -subjectAltName = @alt_names - -[alt_names] -DNS.1 = $Hostname -DNS.2 = localhost -IP.1 = 127.0.0.1 -"@ - - $configContent | Out-File -FilePath $configFile -Encoding ASCII - - # Zertifikat erstellen - openssl req -x509 -nodes -days $Days -newkey rsa:2048 -keyout $KeyFile -out $CertFile -config $configFile - - # Berechtigungen setzen - if (Test-Path $KeyFile) { - # Schlüsseldatei auf 'Nur-Lesen' setzen - Set-ItemProperty -Path $KeyFile -Name IsReadOnly -Value $true - } - - # Fingerprint anzeigen - $fingerprint = openssl x509 -noout -fingerprint -sha256 -in $CertFile - Write-Host "Zertifikat erstellt: $CertFile" -ForegroundColor Green - Write-Host "Fingerprint: $fingerprint" -ForegroundColor Yellow - Write-Host "" -} - -# Backend-Zertifikat erstellen -Create-SelfSignedCert -CertFile $backendCertFile -KeyFile $backendKeyFile -Hostname $backendHostname -Days $validityDays - -# Frontend-Zertifikat erstellen -Create-SelfSignedCert -CertFile $frontendCertFile -KeyFile $frontendKeyFile -Hostname $frontendHostname -Days $validityDays - -# Bestätigung und Hinweise -Write-Host "SSL-Zertifikate wurden erfolgreich erstellt!" -ForegroundColor Green -Write-Host "" -Write-Host "Backend-Zertifikat: $backendCertFile" -ForegroundColor Cyan -Write-Host "Frontend-Zertifikat: $frontendCertFile" -ForegroundColor Cyan -Write-Host "" -Write-Host "Hinweise zur Verwendung:" -ForegroundColor Yellow -Write-Host "1. Stellen Sie sicher, dass die Zertifikatpfade in den Konfigurationsdateien korrekt sind." -ForegroundColor White -Write-Host "2. Beim ersten Zugriff auf die Anwendung müssen Sie das Zertifikat im Browser akzeptieren." -ForegroundColor White -Write-Host "3. In einer Produktionsumgebung sollten Sie offiziell signierte Zertifikate verwenden." -ForegroundColor White -Write-Host "" -Write-Host "Starten Sie die Anwendung mit:" -ForegroundColor Blue -Write-Host "docker-compose up -d" -ForegroundColor White \ No newline at end of file diff --git a/generate_ssl_certs.sh b/generate_ssl_certs.sh deleted file mode 100644 index a50a858b..00000000 --- a/generate_ssl_certs.sh +++ /dev/null @@ -1,193 +0,0 @@ -#!/bin/bash -# MYP - SSL-Zertifikat-Generator für Linux/Unix -# Erstellt selbstsignierte Zertifikate für die HTTPS-Kommunikation - -# Fehlerabbruch aktivieren -set -e - -# Farben für bessere Lesbarkeit -RED='\033[0;31m' -GREEN='\033[0;32m' -YELLOW='\033[0;33m' -BLUE='\033[0;34m' -CYAN='\033[0;36m' -NC='\033[0m' # No Color - -# Funktion für Titel -print_header() { - echo -e "${BLUE}================================================================${NC}" - echo -e "${BLUE} MYP - SSL-Zertifikat-Generator ${NC}" - echo -e "${BLUE}================================================================${NC}" - echo "" -} - -# 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" -BACKEND_HOSTNAME="raspberrypi" -FRONTEND_HOSTNAME="m040tbaraspi001.de040.corpintra.net" -DAYS_VALID=3650 # 10 Jahre - -# Hilfe-Funktion -show_help() { - echo "Verwendung: $0 [Optionen]" - echo "" - echo "Optionen:" - echo " -d, --dir DIR Verzeichnis für Zertifikate (Standard: $CERT_DIR)" - echo " --backend-host NAME Hostname für das Backend-Zertifikat (Standard: $BACKEND_HOSTNAME)" - echo " --frontend-host NAME Hostname für das Frontend-Zertifikat (Standard: $FRONTEND_HOSTNAME)" - echo " -v, --valid TAGE Gültigkeitsdauer in Tagen (Standard: $DAYS_VALID)" - echo " --help Diese Hilfe anzeigen" - echo "" -} - -# Argumente verarbeiten -while [[ $# -gt 0 ]]; do - case $1 in - -d|--dir) - CERT_DIR="$2" - 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" - shift 2 - ;; - --backend-host) - BACKEND_HOSTNAME="$2" - shift 2 - ;; - --frontend-host) - FRONTEND_HOSTNAME="$2" - shift 2 - ;; - -v|--valid) - DAYS_VALID="$2" - shift 2 - ;; - --help) - show_help - exit 0 - ;; - *) - echo -e "${RED}Unbekannte Option: $1${NC}" - show_help - exit 1 - ;; - esac -done - -# Header anzeigen -print_header - -# Überprüfen, ob das Skript mit Root-Rechten ausgeführt wird -if [ "$EUID" -ne 0 ] && [ -n "$(which sudo)" ]; then - echo -e "${YELLOW}Dieses Skript sollte idealerweise mit Root-Rechten ausgeführt werden.${NC}" - echo -e "${YELLOW}Fahre trotzdem fort, aber es könnten Berechtigungsprobleme auftreten.${NC}" - echo "" -fi - -# Verzeichnis erstellen, falls es nicht existiert -if [ ! -d "$CERT_DIR" ]; then - echo -e "${YELLOW}Erstelle Verzeichnis $CERT_DIR...${NC}" - mkdir -p "$CERT_DIR" -fi - -# Überprüfen, ob openssl installiert ist -if ! command -v openssl &> /dev/null; then - echo -e "${RED}OpenSSL ist nicht installiert!${NC}" - echo -e "${YELLOW}Installiere OpenSSL...${NC}" - - # Paketmanager erkennen und OpenSSL installieren - if command -v apt-get &> /dev/null; then - sudo apt-get update && sudo apt-get install -y openssl - elif command -v yum &> /dev/null; then - sudo yum install -y openssl - elif command -v dnf &> /dev/null; then - sudo dnf install -y openssl - elif command -v pacman &> /dev/null; then - sudo pacman -S --noconfirm openssl - elif command -v zypper &> /dev/null; then - sudo zypper install -y openssl - else - echo -e "${RED}Konnte keinen bekannten Paketmanager finden. Bitte installieren Sie OpenSSL manuell.${NC}" - exit 1 - fi -fi - -# Funktion zum Erstellen eines selbstsignierten Zertifikats -create_self_signed_cert() { - local cert_file=$1 - local key_file=$2 - local hostname=$3 - local days=$4 - - echo -e "${GREEN}Erstelle selbstsigniertes SSL-Zertifikat für $hostname...${NC}" - - # OpenSSL-Konfiguration erstellen - local config_file="$CERT_DIR/openssl_$(echo $hostname | cut -d'.' -f1).cnf" - - cat > "$config_file" << EOF -[req] -default_bits = 2048 -prompt = no -default_md = sha256 -distinguished_name = req_distinguished_name -x509_extensions = v3_req - -[req_distinguished_name] -C = DE -ST = Berlin -L = Berlin -O = Mercedes-Benz AG -OU = Werk 040 Berlin -CN = $hostname - -[v3_req] -keyUsage = critical, digitalSignature, keyAgreement -extendedKeyUsage = serverAuth -subjectAltName = @alt_names - -[alt_names] -DNS.1 = $hostname -DNS.2 = localhost -IP.1 = 127.0.0.1 -EOF - - # Zertifikat erstellen - openssl req -x509 -nodes -days "$days" -newkey rsa:2048 \ - -keyout "$key_file" -out "$cert_file" \ - -config "$config_file" - - # Berechtigungen setzen - chmod 600 "$key_file" - chmod 644 "$cert_file" - - # Fingerprint anzeigen - local fingerprint=$(openssl x509 -noout -fingerprint -sha256 -in "$cert_file") - echo -e "${GREEN}Zertifikat erstellt: $cert_file${NC}" - echo -e "${YELLOW}Fingerprint: $fingerprint${NC}" - echo "" -} - -# Backend-Zertifikat erstellen -create_self_signed_cert "$BACKEND_CERT_FILE" "$BACKEND_KEY_FILE" "$BACKEND_HOSTNAME" "$DAYS_VALID" - -# Frontend-Zertifikat erstellen -create_self_signed_cert "$FRONTEND_CERT_FILE" "$FRONTEND_KEY_FILE" "$FRONTEND_HOSTNAME" "$DAYS_VALID" - -# Bestätigung und Hinweise -echo -e "${GREEN}SSL-Zertifikate wurden erfolgreich erstellt!${NC}" -echo "" -echo -e "${CYAN}Backend-Zertifikat: $BACKEND_CERT_FILE${NC}" -echo -e "${CYAN}Frontend-Zertifikat: $FRONTEND_CERT_FILE${NC}" -echo "" -echo -e "${YELLOW}Hinweise zur Verwendung:${NC}" -echo "1. Stellen Sie sicher, dass die Zertifikatpfade in den Konfigurationsdateien korrekt sind." -echo "2. Beim ersten Zugriff auf die Anwendung müssen Sie das Zertifikat im Browser akzeptieren." -echo "3. In einer Produktionsumgebung sollten Sie offiziell signierte Zertifikate verwenden." -echo "" -echo -e "${BLUE}Starten Sie die Anwendung mit:${NC}" -echo "docker-compose up -d" \ No newline at end of file diff --git a/generate_ssl_certs_copy.ps1 b/generate_ssl_certs_copy.ps1 deleted file mode 100644 index 71075255..00000000 --- a/generate_ssl_certs_copy.ps1 +++ /dev/null @@ -1,124 +0,0 @@ -# MYP - SSL-Zertifikat-Generator für Windows -# Erstellt selbstsignierte Zertifikate für die HTTPS-Kommunikation - -# Überprüfen, ob das Skript als Administrator ausgeführt wird -$isAdmin = ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator) -if (-not $isAdmin) { - Write-Host "Dieses Skript muss mit Administrator-Rechten ausgeführt werden." -ForegroundColor Red - Write-Host "Bitte starten Sie PowerShell als Administrator und führen Sie das Skript erneut aus." -ForegroundColor Yellow - Exit 1 -} - -# Header anzeigen -Write-Host "================================================================" -ForegroundColor Blue -Write-Host " MYP - SSL-Zertifikat-Generator " -ForegroundColor Blue -Write-Host "================================================================" -ForegroundColor Blue -Write-Host "" - -# Parameter definieren -$certDir = "./backend/instance/ssl" -$backendCertFile = "$certDir/myp.crt" -$backendKeyFile = "$certDir/myp.key" -$frontendCertFile = "$certDir/frontend.crt" -$frontendKeyFile = "$certDir/frontend.key" -$backendHostname = "raspberrypi" -$frontendHostname = "m040tbaraspi001.de040.corpintra.net" -$validityDays = 3650 # 10 Jahre - -# Verzeichnis erstellen, falls es nicht existiert -if (!(Test-Path $certDir)) { - Write-Host "Erstelle Verzeichnis $certDir..." -ForegroundColor Yellow - New-Item -ItemType Directory -Path $certDir -Force | Out-Null -} - -# Prüfen, ob OpenSSL installiert ist -$openSSLInstalled = $null -try { - $openSSLInstalled = Get-Command openssl -ErrorAction SilentlyContinue -} catch {} - -if ($null -eq $openSSLInstalled) { - Write-Host "OpenSSL konnte nicht gefunden werden!" -ForegroundColor Red - Write-Host "Bitte installieren Sie OpenSSL für Windows und stellen Sie sicher, dass es im PATH verfügbar ist." -ForegroundColor Yellow - Write-Host "Sie können OpenSSL von https://slproweb.com/products/Win32OpenSSL.html herunterladen." -ForegroundColor Yellow - Exit 1 -} - -# Funktion zum Erstellen eines selbstsignierten Zertifikats -function Create-SelfSignedCert { - param( - [string]$CertFile, - [string]$KeyFile, - [string]$Hostname, - [int]$Days - ) - - Write-Host "Erstelle selbstsigniertes SSL-Zertifikat für $Hostname..." -ForegroundColor Green - - # OpenSSL-Konfiguration erstellen - $configFile = "$certDir/openssl_$($Hostname.Split('.')[0]).cnf" - - $configContent = @" -[req] -default_bits = 2048 -prompt = no -default_md = sha256 -distinguished_name = req_distinguished_name -x509_extensions = v3_req - -[req_distinguished_name] -C = DE -ST = Berlin -L = Berlin -O = Mercedes-Benz AG -OU = Werk 040 Berlin -CN = $Hostname - -[v3_req] -keyUsage = critical, digitalSignature, keyAgreement -extendedKeyUsage = serverAuth -subjectAltName = @alt_names - -[alt_names] -DNS.1 = $Hostname -DNS.2 = localhost -IP.1 = 127.0.0.1 -"@ - - $configContent | Out-File -FilePath $configFile -Encoding ASCII - - # Zertifikat erstellen - openssl req -x509 -nodes -days $Days -newkey rsa:2048 -keyout $KeyFile -out $CertFile -config $configFile - - # Berechtigungen setzen - if (Test-Path $KeyFile) { - # Schlüsseldatei auf 'Nur-Lesen' setzen - Set-ItemProperty -Path $KeyFile -Name IsReadOnly -Value $true - } - - # Fingerprint anzeigen - $fingerprint = openssl x509 -noout -fingerprint -sha256 -in $CertFile - Write-Host "Zertifikat erstellt: $CertFile" -ForegroundColor Green - Write-Host "Fingerprint: $fingerprint" -ForegroundColor Yellow - Write-Host "" -} - -# Backend-Zertifikat erstellen -Create-SelfSignedCert -CertFile $backendCertFile -KeyFile $backendKeyFile -Hostname $backendHostname -Days $validityDays - -# Frontend-Zertifikat erstellen -Create-SelfSignedCert -CertFile $frontendCertFile -KeyFile $frontendKeyFile -Hostname $frontendHostname -Days $validityDays - -# Bestätigung und Hinweise -Write-Host "SSL-Zertifikate wurden erfolgreich erstellt!" -ForegroundColor Green -Write-Host "" -Write-Host "Backend-Zertifikat: $backendCertFile" -ForegroundColor Cyan -Write-Host "Frontend-Zertifikat: $frontendCertFile" -ForegroundColor Cyan -Write-Host "" -Write-Host "Hinweise zur Verwendung:" -ForegroundColor Yellow -Write-Host "1. Stellen Sie sicher, dass die Zertifikatpfade in den Konfigurationsdateien korrekt sind." -ForegroundColor White -Write-Host "2. Beim ersten Zugriff auf die Anwendung müssen Sie das Zertifikat im Browser akzeptieren." -ForegroundColor White -Write-Host "3. In einer Produktionsumgebung sollten Sie offiziell signierte Zertifikate verwenden." -ForegroundColor White -Write-Host "" -Write-Host "Starten Sie die Anwendung mit:" -ForegroundColor Blue -Write-Host "docker-compose up -d" -ForegroundColor White \ No newline at end of file diff --git a/myp_installer.ps1 b/myp_installer.ps1 index 913cc681..98d0756e 100644 --- a/myp_installer.ps1 +++ b/myp_installer.ps1 @@ -41,7 +41,8 @@ function Test-Command { try { Get-Command $Command -ErrorAction Stop | Out-Null return $true - } catch { + } + catch { return $false } } @@ -63,7 +64,8 @@ function Exec-Command { Write-Host "✗ Fehler beim Ausführen des Befehls. Exit-Code: $LASTEXITCODE" -ForegroundColor $colors.Error return $false } - } catch { + } + catch { Write-Host "✗ Fehler: $_" -ForegroundColor $colors.Error return $false } @@ -80,15 +82,14 @@ function Get-LocalIPAddress { function Test-Dependencies { Write-Host "Prüfe Abhängigkeiten..." -ForegroundColor $colors.Info - $dependencies = @{ - "python" = "Python (3.6+)" - "pip" = "Python Package Manager" - "docker" = "Docker" - "docker-compose" = "Docker Compose" - "node" = "Node.js" - "npm" = "Node Package Manager" - "openssl" = "OpenSSL" - } + $dependencies = @{} + $dependencies["python"] = "Python (3.6+)" + $dependencies["pip"] = "Python Package Manager" + $dependencies["docker"] = "Docker" + $dependencies["docker-compose"] = "Docker Compose" + $dependencies["node"] = "Node.js" + $dependencies["npm"] = "Node Package Manager" + $dependencies["openssl"] = "OpenSSL" $allInstalled = $true @@ -151,7 +152,8 @@ function Setup-Hosts { try { $hostsContent | Set-Content -Path $hostsFile -Force Write-Host "Konfiguration abgeschlossen!" -ForegroundColor $colors.Success - } catch { + } + catch { Write-Host "Fehler beim Schreiben der Hosts-Datei: $_" -ForegroundColor $colors.Error } @@ -330,9 +332,11 @@ create_self_signed_cert('$frontendCertFile', '$frontendKeyFile', '$frontendHostn try { python $tempScriptPath Write-Host "SSL-Zertifikate erfolgreich erstellt!" -ForegroundColor $colors.Success - } catch { + } + catch { Write-Host "Fehler beim Erstellen der SSL-Zertifikate: $_" -ForegroundColor $colors.Error - } finally { + } + finally { # Temporäres Skript löschen Remove-Item -Path $tempScriptPath -Force } @@ -544,7 +548,10 @@ function Clean-OldScripts { "setup_hosts.ps1", "setup_hosts_copy.ps1", "generate_ssl_certs.ps1", - "generate_ssl_certs_copy.ps1" + "generate_ssl_certs_copy.ps1", + "setup_ssl.sh", + "setup_hosts.sh", + "generate_ssl_certs.sh" ) Write-Host "Folgende Skripte werden gelöscht:" -ForegroundColor $colors.Info @@ -563,7 +570,8 @@ function Clean-OldScripts { try { Remove-Item -Path $script -Force Write-Host "✓ $script wurde gelöscht." -ForegroundColor $colors.Success - } catch { + } + catch { $errorMessage = $_.Exception.Message Write-Host "✗ Fehler beim Löschen von $script`: $errorMessage" -ForegroundColor $colors.Error } @@ -572,7 +580,8 @@ function Clean-OldScripts { Write-Host "" Write-Host "Bereinigung abgeschlossen." -ForegroundColor $colors.Success - } else { + } + else { Write-Host "Bereinigung abgebrochen." -ForegroundColor $colors.Warning } @@ -593,9 +602,8 @@ function Show-MainMenu { Write-Host "6. Alte Skripte bereinigen" -ForegroundColor $colors.Command Write-Host "Q. Beenden" -ForegroundColor $colors.Command Write-Host "" - Write-Host "Wählen Sie eine Option (1-6, Q):" -ForegroundColor $colors.Info -NoNewline - $choice = Read-Host " " + $choice = Read-Host "Wählen Sie eine Option (1-6, Q)" switch ($choice) { "1" { diff --git a/setup_hosts.ps1 b/setup_hosts.ps1 deleted file mode 100644 index 85ad6831..00000000 --- a/setup_hosts.ps1 +++ /dev/null @@ -1,73 +0,0 @@ -# MYP - Einrichtung der Hostnamen für die SSL-Konfiguration (Windows PowerShell Version) - -# Überprüfen, ob das Skript als Administrator ausgeführt wird -$isAdmin = ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator) -if (-not $isAdmin) { - Write-Host "Dieses Skript muss mit Administrator-Rechten ausgeführt werden." -ForegroundColor Red - Write-Host "Bitte starten Sie PowerShell als Administrator und führen Sie das Skript erneut aus." -ForegroundColor Yellow - Exit 1 -} - -# Header anzeigen -Write-Host "=================================================" -ForegroundColor Blue -Write-Host " MYP - Hostnamen-Konfiguration für SSL" -ForegroundColor Blue -Write-Host "=================================================" -ForegroundColor Blue -Write-Host "" - -# Lokale IP-Adresse ermitteln -$localIP = (Get-NetIPAddress | Where-Object { $_.AddressFamily -eq "IPv4" -and $_.PrefixOrigin -ne "WellKnown" } | Select-Object -First 1).IPAddress -if (-not $localIP) { - $localIP = "127.0.0.1" - Write-Host "Konnte lokale IP-Adresse nicht ermitteln, verwende $localIP" -ForegroundColor Yellow -} else { - Write-Host "Lokale IP-Adresse: $localIP" -ForegroundColor Green -} - -# Pfad zur Hosts-Datei -$hostsFile = "$env:windir\System32\drivers\etc\hosts" -Write-Host "Hosts-Datei: $hostsFile" -ForegroundColor Cyan - -# Prüfen, ob die Einträge bereits existieren -$frontendEntry = Select-String -Path $hostsFile -Pattern "m040tbaraspi001.de040.corpintra.net" -Quiet -$backendEntry = Select-String -Path $hostsFile -Pattern "raspberrypi" -Quiet - -# Einträge in die Hosts-Datei schreiben -Write-Host "Aktualisiere Hosts-Datei..." -ForegroundColor Blue - -$hostsContent = Get-Content -Path $hostsFile - -if (-not $frontendEntry) { - $hostsContent += "" - $hostsContent += "# MYP Frontend Host" - $hostsContent += "$localIP m040tbaraspi001.de040.corpintra.net m040tbaraspi001" - Write-Host "Frontend-Hostname hinzugefügt" -ForegroundColor Green -} else { - Write-Host "Frontend-Hostname ist bereits konfiguriert" -ForegroundColor Yellow -} - -if (-not $backendEntry) { - $hostsContent += "" - $hostsContent += "# MYP Backend Host" - $hostsContent += "$localIP raspberrypi" - Write-Host "Backend-Hostname hinzugefügt" -ForegroundColor Green -} else { - Write-Host "Backend-Hostname ist bereits konfiguriert" -ForegroundColor Yellow -} - -# Speichern der aktualisierten Hosts-Datei -try { - $hostsContent | Set-Content -Path $hostsFile -Force - Write-Host "" - Write-Host "Konfiguration abgeschlossen!" -ForegroundColor Green -} catch { - Write-Host "Fehler beim Schreiben der Hosts-Datei: $_" -ForegroundColor Red - Exit 1 -} - -Write-Host "Folgende Hostnamen sind jetzt konfiguriert:" -ForegroundColor Blue -Write-Host " - Frontend: m040tbaraspi001.de040.corpintra.net" -ForegroundColor Yellow -Write-Host " - Backend: raspberrypi" -ForegroundColor Yellow -Write-Host "" -Write-Host "Sie können nun die Anwendung mit folgendem Befehl starten:" -ForegroundColor Blue -Write-Host "docker-compose up -d" -ForegroundColor Yellow -Write-Host "" \ No newline at end of file diff --git a/setup_hosts.sh b/setup_hosts.sh deleted file mode 100644 index 4cbe292a..00000000 --- a/setup_hosts.sh +++ /dev/null @@ -1,70 +0,0 @@ -#!/bin/bash -# MYP - Einrichtung der Hostnamen für die SSL-Konfiguration - -# Farben für bessere Lesbarkeit -RESET='\033[0m' -RED='\033[0;31m' -GREEN='\033[0;32m' -YELLOW='\033[0;33m' -BLUE='\033[0;34m' - -echo -e "${BLUE}=================================================${RESET}" -echo -e "${BLUE} MYP - Hostnamen-Konfiguration für SSL${RESET}" -echo -e "${BLUE}=================================================${RESET}" -echo "" - -# Überprüfen, ob das Skript mit Admin-Rechten ausgeführt wird -if [ "$EUID" -ne 0 ]; then - echo -e "${RED}Dieses Skript muss mit Administrator-Rechten ausgeführt werden.${RESET}" - echo -e "${YELLOW}Bitte führen Sie es erneut mit 'sudo' aus.${RESET}" - exit 1 -fi - -# Lokale IP-Adresse ermitteln -LOCAL_IP=$(hostname -I | awk '{print $1}') -if [ -z "$LOCAL_IP" ]; then - LOCAL_IP="127.0.0.1" - echo -e "${YELLOW}Konnte lokale IP-Adresse nicht ermitteln, verwende ${LOCAL_IP}${RESET}" -else - echo -e "${GREEN}Lokale IP-Adresse: ${LOCAL_IP}${RESET}" -fi - -# Hosts-Datei Pfad je nach Betriebssystem -HOSTS_FILE="/etc/hosts" -if [[ "$OSTYPE" == "msys" || "$OSTYPE" == "win32" ]]; then - HOSTS_FILE="/c/Windows/System32/drivers/etc/hosts" - echo -e "${YELLOW}Windows-System erkannt, verwende ${HOSTS_FILE}${RESET}" -fi - -# Prüfen, ob die Einträge bereits existieren -FRONTEND_ENTRY=$(grep -c "m040tbaraspi001.de040.corpintra.net" ${HOSTS_FILE}) -BACKEND_ENTRY=$(grep -c "raspberrypi" ${HOSTS_FILE}) - -# Einträge in die Hosts-Datei schreiben -echo -e "${BLUE}Aktualisiere Hosts-Datei...${RESET}" - -if [ $FRONTEND_ENTRY -eq 0 ]; then - echo -e "\n# MYP Frontend Host" >> ${HOSTS_FILE} - echo "${LOCAL_IP} m040tbaraspi001.de040.corpintra.net m040tbaraspi001" >> ${HOSTS_FILE} - echo -e "${GREEN}Frontend-Hostname hinzugefügt${RESET}" -else - echo -e "${YELLOW}Frontend-Hostname ist bereits konfiguriert${RESET}" -fi - -if [ $BACKEND_ENTRY -eq 0 ]; then - echo -e "\n# MYP Backend Host" >> ${HOSTS_FILE} - echo "${LOCAL_IP} raspberrypi" >> ${HOSTS_FILE} - echo -e "${GREEN}Backend-Hostname hinzugefügt${RESET}" -else - echo -e "${YELLOW}Backend-Hostname ist bereits konfiguriert${RESET}" -fi - -echo "" -echo -e "${GREEN}Konfiguration abgeschlossen!${RESET}" -echo -e "${BLUE}Folgende Hostnamen sind jetzt konfiguriert:${RESET}" -echo -e " - Frontend: ${YELLOW}m040tbaraspi001.de040.corpintra.net${RESET}" -echo -e " - Backend: ${YELLOW}raspberrypi${RESET}" -echo "" -echo -e "${BLUE}Sie können nun die Anwendung mit folgendem Befehl starten:${RESET}" -echo -e "${YELLOW}docker-compose up -d${RESET}" -echo "" \ No newline at end of file diff --git a/setup_hosts_copy.ps1 b/setup_hosts_copy.ps1 deleted file mode 100644 index 85ad6831..00000000 --- a/setup_hosts_copy.ps1 +++ /dev/null @@ -1,73 +0,0 @@ -# MYP - Einrichtung der Hostnamen für die SSL-Konfiguration (Windows PowerShell Version) - -# Überprüfen, ob das Skript als Administrator ausgeführt wird -$isAdmin = ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator) -if (-not $isAdmin) { - Write-Host "Dieses Skript muss mit Administrator-Rechten ausgeführt werden." -ForegroundColor Red - Write-Host "Bitte starten Sie PowerShell als Administrator und führen Sie das Skript erneut aus." -ForegroundColor Yellow - Exit 1 -} - -# Header anzeigen -Write-Host "=================================================" -ForegroundColor Blue -Write-Host " MYP - Hostnamen-Konfiguration für SSL" -ForegroundColor Blue -Write-Host "=================================================" -ForegroundColor Blue -Write-Host "" - -# Lokale IP-Adresse ermitteln -$localIP = (Get-NetIPAddress | Where-Object { $_.AddressFamily -eq "IPv4" -and $_.PrefixOrigin -ne "WellKnown" } | Select-Object -First 1).IPAddress -if (-not $localIP) { - $localIP = "127.0.0.1" - Write-Host "Konnte lokale IP-Adresse nicht ermitteln, verwende $localIP" -ForegroundColor Yellow -} else { - Write-Host "Lokale IP-Adresse: $localIP" -ForegroundColor Green -} - -# Pfad zur Hosts-Datei -$hostsFile = "$env:windir\System32\drivers\etc\hosts" -Write-Host "Hosts-Datei: $hostsFile" -ForegroundColor Cyan - -# Prüfen, ob die Einträge bereits existieren -$frontendEntry = Select-String -Path $hostsFile -Pattern "m040tbaraspi001.de040.corpintra.net" -Quiet -$backendEntry = Select-String -Path $hostsFile -Pattern "raspberrypi" -Quiet - -# Einträge in die Hosts-Datei schreiben -Write-Host "Aktualisiere Hosts-Datei..." -ForegroundColor Blue - -$hostsContent = Get-Content -Path $hostsFile - -if (-not $frontendEntry) { - $hostsContent += "" - $hostsContent += "# MYP Frontend Host" - $hostsContent += "$localIP m040tbaraspi001.de040.corpintra.net m040tbaraspi001" - Write-Host "Frontend-Hostname hinzugefügt" -ForegroundColor Green -} else { - Write-Host "Frontend-Hostname ist bereits konfiguriert" -ForegroundColor Yellow -} - -if (-not $backendEntry) { - $hostsContent += "" - $hostsContent += "# MYP Backend Host" - $hostsContent += "$localIP raspberrypi" - Write-Host "Backend-Hostname hinzugefügt" -ForegroundColor Green -} else { - Write-Host "Backend-Hostname ist bereits konfiguriert" -ForegroundColor Yellow -} - -# Speichern der aktualisierten Hosts-Datei -try { - $hostsContent | Set-Content -Path $hostsFile -Force - Write-Host "" - Write-Host "Konfiguration abgeschlossen!" -ForegroundColor Green -} catch { - Write-Host "Fehler beim Schreiben der Hosts-Datei: $_" -ForegroundColor Red - Exit 1 -} - -Write-Host "Folgende Hostnamen sind jetzt konfiguriert:" -ForegroundColor Blue -Write-Host " - Frontend: m040tbaraspi001.de040.corpintra.net" -ForegroundColor Yellow -Write-Host " - Backend: raspberrypi" -ForegroundColor Yellow -Write-Host "" -Write-Host "Sie können nun die Anwendung mit folgendem Befehl starten:" -ForegroundColor Blue -Write-Host "docker-compose up -d" -ForegroundColor Yellow -Write-Host "" \ No newline at end of file diff --git a/setup_ssl.ps1 b/setup_ssl.ps1 deleted file mode 100644 index 330cf9de..00000000 --- a/setup_ssl.ps1 +++ /dev/null @@ -1,196 +0,0 @@ -# SSL-Konfiguration für MYP-Plattform -# Dieses Skript führt alle notwendigen Schritte zur SSL-Konfiguration durch - -# Titel anzeigen -Write-Host "====================================================" -ForegroundColor Cyan -Write-Host " SSL-Konfiguration für MYP-Plattform" -ForegroundColor Cyan -Write-Host "====================================================" -ForegroundColor Cyan -Write-Host "" - -# Prüfen, ob PowerShell als Administrator ausgeführt wird -$isAdmin = ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator) - -if (-not $isAdmin) { - Write-Host "WARNUNG: Dieses Skript sollte als Administrator ausgeführt werden, um Zertifikate im System zu installieren." -ForegroundColor Yellow - Write-Host "Einige Funktionen sind möglicherweise eingeschränkt." -ForegroundColor Yellow - Write-Host "" - - $continueAnyway = Read-Host "Möchten Sie trotzdem fortfahren? (j/n)" - if ($continueAnyway -ne "j") { - Write-Host "Installation abgebrochen." -ForegroundColor Red - exit - } -} - -# Funktion zum Ausführen von Befehlen mit Ausgabe -function Exec-Command { - param ( - [string]$Command, - [string]$Description - ) - - Write-Host "> $Description..." -ForegroundColor Yellow - try { - Invoke-Expression $Command - if ($LASTEXITCODE -eq 0 -or $null -eq $LASTEXITCODE) { - Write-Host "✓ Erfolgreich abgeschlossen!" -ForegroundColor Green - return $true - } else { - Write-Host "✗ Fehler beim Ausführen des Befehls. Exit-Code: $LASTEXITCODE" -ForegroundColor Red - return $false - } - } catch { - Write-Host "✗ Fehler: $_" -ForegroundColor Red - return $false - } -} - -# Prüfen, ob Python und Node.js installiert sind -$pythonInstalled = Get-Command python -ErrorAction SilentlyContinue -$nodeInstalled = Get-Command node -ErrorAction SilentlyContinue - -if (-not $pythonInstalled) { - Write-Host "✗ Python ist nicht installiert oder nicht im PATH. Bitte installieren Sie Python 3.6 oder höher." -ForegroundColor Red - exit 1 -} - -if (-not $nodeInstalled) { - Write-Host "✗ Node.js ist nicht installiert oder nicht im PATH. Bitte installieren Sie Node.js 14 oder höher." -ForegroundColor Red - exit 1 -} - -# 1. Prüfen, ob die notwendigen Abhängigkeiten installiert sind -Write-Host "1. Prüfe Abhängigkeiten..." -ForegroundColor Cyan - -# Python-Abhängigkeiten prüfen -$cryptographyInstalled = python -c "try: import cryptography; print('True'); except ImportError: print('False')" 2>$null -if ($cryptographyInstalled -ne "True") { - Write-Host "Installiere Python-Abhängigkeit 'cryptography'..." - Exec-Command "pip install cryptography" "Installiere cryptography-Paket" -} - -# 2. SSL-Zertifikat generieren -Write-Host "" -Write-Host "2. Generiere SSL-Zertifikat..." -ForegroundColor Cyan -$certGenSuccess = Exec-Command "cd backend && python generate_ssl_cert.py" "Generiere SSL-Zertifikat" - -if (-not $certGenSuccess) { - Write-Host "✗ Fehler bei der Zertifikatsgenerierung. Abbruch." -ForegroundColor Red - exit 1 -} - -# 3. Zertifikat im System installieren (nur wenn als Administrator ausgeführt) -Write-Host "" -Write-Host "3. Installiere Zertifikat im System..." -ForegroundColor Cyan - -if ($isAdmin) { - $certPath = Resolve-Path ".\backend\app\instance\ssl\myp.crt" - - Write-Host "Installiere Zertifikat im System-Zertifikatsspeicher..." - - # In Root-Zertifikatsspeicher installieren - Exec-Command "certutil -addstore -f 'ROOT' '$certPath'" "Installiere im Root-Zertifikatsspeicher" - - # In CA-Zertifikatsspeicher installieren - Exec-Command "certutil -addstore -f 'CA' '$certPath'" "Installiere im CA-Zertifikatsspeicher" - - # In Persönlichen Zertifikatsspeicher installieren - Exec-Command "certutil -addstore -f 'MY' '$certPath'" "Installiere im Persönlichen Zertifikatsspeicher" -} else { - Write-Host "Überspringen der System-Installation, da das Skript nicht als Administrator ausgeführt wird." -ForegroundColor Yellow - Write-Host "Sie können das Zertifikat später manuell installieren durch:" -ForegroundColor Yellow - Write-Host "certutil -addstore -f ROOT .\backend\app\instance\ssl\myp.crt" -ForegroundColor Gray -} - -# 4. Frontend konfigurieren -Write-Host "" -Write-Host "4. Konfiguriere Frontend..." -ForegroundColor Cyan -$frontendConfigSuccess = Exec-Command "cd frontend && node configure_ssl.js" "Konfiguriere Frontend" - -if (-not $frontendConfigSuccess) { - Write-Host "✗ Warnung: Frontend-Konfiguration konnte nicht vollständig durchgeführt werden." -ForegroundColor Yellow -} - -# 5. Docker-Compose Datei aktualisieren -Write-Host "" -Write-Host "5. Aktualisiere Docker-Compose-Konfiguration..." -ForegroundColor Cyan - -$dockerComposeFile = "docker-compose.yml" -if (Test-Path $dockerComposeFile) { - $dockerCompose = Get-Content $dockerComposeFile -Raw - - # Sicherstellen, dass dual-protocol aktiv ist - if (-not $dockerCompose.Contains("--dual-protocol")) { - $dockerCompose = $dockerCompose -replace "command: python -m app\.app", "command: python -m app.app --dual-protocol" - $dockerCompose | Set-Content $dockerComposeFile - Write-Host "✓ Docker-Compose-Datei wurde aktualisiert, um den dual-protocol-Modus zu aktivieren." -ForegroundColor Green - } else { - Write-Host "✓ Docker-Compose-Datei ist bereits korrekt konfiguriert." -ForegroundColor Green - } -} else { - Write-Host "✗ Docker-Compose-Datei nicht gefunden. Überspringe diese Konfiguration." -ForegroundColor Yellow -} - -# 6. Systemdienste aktualisieren (falls auf Raspberry Pi) -Write-Host "" -Write-Host "6. Möchten Sie die Konfiguration auf den Raspberry Pi übertragen?" -ForegroundColor Cyan -$raspberryConfig = Read-Host "Übertragen und konfigurieren (j/n)" - -if ($raspberryConfig -eq "j") { - Write-Host "Konfiguriere Raspberry Pi..." -ForegroundColor Yellow - - # Raspberry Pi-Konfiguration ausführen - $sshUser = Read-Host "Benutzername für SSH-Verbindung zum Raspberry Pi (Standard: pi)" - if (-not $sshUser) { $sshUser = "pi" } - - $sshHost = Read-Host "Hostname oder IP-Adresse des Raspberry Pi (Standard: raspberrypi)" - if (-not $sshHost) { $sshHost = "raspberrypi" } - - $sshDestDir = "/home/$sshUser/myp/ssl" - $systemCertDir = "/usr/local/share/ca-certificates" - - # Verzeichnis erstellen - Exec-Command "ssh $sshUser@$sshHost 'mkdir -p $sshDestDir'" "Erstelle Verzeichnis auf dem Raspberry Pi" - - # Dateien kopieren - $certPath = Resolve-Path ".\backend\app\instance\ssl\myp.crt" - $keyPath = Resolve-Path ".\backend\app\instance\ssl\myp.key" - - Exec-Command "scp '$certPath' $sshUser@$sshHost`:$sshDestDir/myp.crt" "Kopiere Zertifikat auf den Raspberry Pi" - Exec-Command "scp '$keyPath' $sshUser@$sshHost`:$sshDestDir/myp.key" "Kopiere Schlüssel auf den Raspberry Pi" - - # Berechtigungen setzen - Exec-Command "ssh $sshUser@$sshHost 'chmod 600 $sshDestDir/myp.key'" "Setze Berechtigungen für den Schlüssel" - - # Im System installieren - Exec-Command "ssh $sshUser@$sshHost 'sudo mkdir -p $systemCertDir && sudo cp $sshDestDir/myp.crt $systemCertDir/ && sudo update-ca-certificates'" "Installiere Zertifikat im System" - - # Docker-Container neu starten, falls vorhanden - Write-Host "Möchten Sie die Docker-Container auf dem Raspberry Pi neu starten?" -ForegroundColor Yellow - $restartDocker = Read-Host "Neu starten (j/n)" - - if ($restartDocker -eq "j") { - Exec-Command "ssh $sshUser@$sshHost 'cd /home/$sshUser/myp && docker-compose down && docker-compose up -d'" "Starte Docker-Container neu" - } -} - -# Abschluss -Write-Host "" -Write-Host "====================================================" -ForegroundColor Cyan -Write-Host " SSL-Konfiguration abgeschlossen" -ForegroundColor Cyan -Write-Host "====================================================" -ForegroundColor Cyan -Write-Host "" -Write-Host "Das SSL-Zertifikat wurde erfolgreich generiert und konfiguriert." -ForegroundColor Green -Write-Host "Sie können nun auf folgende Weise auf die Anwendung zugreifen:" -ForegroundColor Green -Write-Host "- Backend: https://raspberrypi:443" -ForegroundColor Green -Write-Host "- Frontend: https://localhost:3000" -ForegroundColor Green -Write-Host "" -Write-Host "Hinweis: Bei der ersten Verbindung müssen Sie möglicherweise" -ForegroundColor Yellow -Write-Host "das selbstsignierte Zertifikat in Ihrem Browser akzeptieren." -ForegroundColor Yellow -Write-Host "" - -# Pause, damit das Fenster nicht sofort geschlossen wird -if ($Host.Name -eq "ConsoleHost") { - Write-Host "Drücken Sie eine beliebige Taste, um fortzufahren..." - $null = $Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown") -} \ No newline at end of file diff --git a/setup_ssl.sh b/setup_ssl.sh deleted file mode 100644 index 1c8bfd3e..00000000 --- a/setup_ssl.sh +++ /dev/null @@ -1,280 +0,0 @@ -#!/bin/bash - -# MYP Installer für Linux/Unix-Systeme -# Dieses Skript wurde in das MYP Installer Control Center integriert -# und dient als Kompatibilitätslayer für Linux/Unix-Systeme - -# Farbdefinitionen -RED='\033[0;31m' -GREEN='\033[0;32m' -YELLOW='\033[0;33m' -BLUE='\033[0;34m' -CYAN='\033[0;36m' -NC='\033[0m' # No Color - -echo -e "${CYAN}=============================================================${NC}" -echo -e "${CYAN} MYP INSTALLER (UNIX/LINUX) ${NC}" -echo -e "${CYAN}=============================================================${NC}" -echo -e "${YELLOW}Dieses Skript ist ein Kompatibilitätslayer für Linux/Unix.${NC}" -echo -e "${YELLOW}Es wird empfohlen, das PowerShell-Skript myp_installer.ps1${NC}" -echo -e "${YELLOW}für eine vollständige Funktionalität zu verwenden. ${NC}" -echo -e "${CYAN}=============================================================${NC}" -echo "" - -# Überprüfen, ob das Skript als Root ausgeführt wird -if [ "$EUID" -ne 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 "" -fi - -# Hauptmenu anzeigen -echo "Wählen Sie eine Option:" -echo "1. SSL-Zertifikate erstellen" -echo "2. Hosts-Konfiguration einrichten" -echo "3. Abhängigkeiten installieren" -echo "4. Anwendung starten" -echo "5. Beenden" -echo "" -read -p "Option (1-5): " choice - -case $choice in - 1) - echo -e "${BLUE}SSL-Zertifikate werden erstellt...${NC}" - - # Verzeichnis erstellen - mkdir -p backend/instance/ssl - - # 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 -except ImportError: - print("Fehler: Paket 'cryptography' nicht gefunden.") - 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") - ]), - 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.") - -# Hostname wählen -print("Wählen Sie den Hostnamen für das Zertifikat:") -print("1. localhost (für lokale Entwicklung)") -print("2. raspberrypi (für Raspberry Pi)") -print("3. m040tbaraspi001.de040.corpintra.net (für Unternehmens-Setup)") -choice = input("Option (1-3, Standard: 1): ") - -hostname = "localhost" -if choice == "2": - hostname = "raspberrypi" -elif choice == "3": - hostname = "m040tbaraspi001.de040.corpintra.net" - -# Zertifikate erstellen -create_self_signed_cert("backend/instance/ssl/myp.crt", "backend/instance/ssl/myp.key", hostname) -create_self_signed_cert("backend/instance/ssl/frontend.crt", "backend/instance/ssl/frontend.key", hostname) -EOL - - # Python-Skript ausführbar machen und ausführen - chmod +x temp_cert_script.py - python3 temp_cert_script.py || python temp_cert_script.py - - # Temporäres Skript löschen - rm temp_cert_script.py - - echo -e "${GREEN}SSL-Zertifikate erstellt.${NC}" - ;; - - 2) - echo -e "${BLUE}Hosts-Konfiguration wird eingerichtet...${NC}" - - # Lokale IP-Adresse ermitteln - LOCAL_IP=$(hostname -I | awk '{print $1}') - if [ -z "$LOCAL_IP" ]; then - LOCAL_IP="127.0.0.1" - fi - - echo "Lokale IP-Adresse: $LOCAL_IP" - - # Hosts-Datei bearbeiten - if [ "$EUID" -eq 0 ]; then - # Check if entries already exist - if ! grep -q "m040tbaraspi001.de040.corpintra.net" /etc/hosts; then - echo "" >> /etc/hosts - echo "# MYP Frontend Host" >> /etc/hosts - echo "$LOCAL_IP m040tbaraspi001.de040.corpintra.net m040tbaraspi001" >> /etc/hosts - echo -e "${GREEN}Frontend-Hostname hinzugefügt${NC}" - else - echo -e "${YELLOW}Frontend-Hostname ist bereits konfiguriert${NC}" - fi - - if ! grep -q "raspberrypi" /etc/hosts; then - echo "" >> /etc/hosts - echo "# MYP Backend Host" >> /etc/hosts - echo "$LOCAL_IP raspberrypi" >> /etc/hosts - echo -e "${GREEN}Backend-Hostname hinzugefügt${NC}" - else - echo -e "${YELLOW}Backend-Hostname ist bereits konfiguriert${NC}" - fi - else - echo -e "${RED}Root-Rechte erforderlich, um die Hosts-Datei zu bearbeiten.${NC}" - echo -e "${YELLOW}Bitte führen Sie die folgenden Befehle manuell als Root aus:${NC}" - echo "echo \"\" >> /etc/hosts" - echo "echo \"# MYP Frontend Host\" >> /etc/hosts" - echo "echo \"$LOCAL_IP m040tbaraspi001.de040.corpintra.net m040tbaraspi001\" >> /etc/hosts" - echo "echo \"\" >> /etc/hosts" - echo "echo \"# MYP Backend Host\" >> /etc/hosts" - echo "echo \"$LOCAL_IP raspberrypi\" >> /etc/hosts" - fi - ;; - - 3) - echo -e "${BLUE}Abhängigkeiten werden installiert...${NC}" - - # Python-Abhängigkeiten - echo "Installiere Python-Abhängigkeiten..." - pip3 install -r backend/requirements.txt || pip install -r backend/requirements.txt - - # Frontend-Abhängigkeiten - if command -v npm &> /dev/null; then - echo "Installiere Frontend-Abhängigkeiten..." - (cd frontend && npm install) - else - echo -e "${YELLOW}npm nicht gefunden. Frontend-Abhängigkeiten werden übersprungen.${NC}" - fi - - echo -e "${GREEN}Abhängigkeiten installiert.${NC}" - ;; - - 4) - echo -e "${BLUE}Anwendung wird gestartet...${NC}" - echo "Wie möchten Sie die Anwendung starten?" - echo "1. Backend-Server starten (Python)" - echo "2. Frontend-Server starten (npm)" - echo "3. Mit Docker Compose starten" - read -p "Option (1-3): " start_choice - - case $start_choice in - 1) - echo "Starte Backend-Server..." - python3 backend/app/app.py || python backend/app/app.py & - echo -e "${GREEN}Backend-Server läuft im Hintergrund.${NC}" - ;; - 2) - echo "Starte Frontend-Server..." - (cd frontend && npm run dev) & - echo -e "${GREEN}Frontend-Server läuft im Hintergrund.${NC}" - ;; - 3) - echo "Starte Anwendung mit Docker Compose..." - docker-compose up -d - echo -e "${GREEN}Docker Container wurden gestartet.${NC}" - ;; - *) - echo -e "${RED}Ungültige Option.${NC}" - ;; - esac - ;; - - 5) - echo -e "${GREEN}Installation wird beendet.${NC}" - exit 0 - ;; - - *) - echo -e "${RED}Ungültige Option.${NC}" - ;; -esac - -echo "" -echo -e "${CYAN}Installation abgeschlossen. Drücken Sie ENTER, um fortzufahren...${NC}" -read \ No newline at end of file