"feat: Update configuration settings in backend/app/config/settings.py and installer script"
This commit is contained in:
@@ -4,7 +4,7 @@ from datetime import timedelta
|
|||||||
|
|
||||||
# Hardcodierte Konfiguration
|
# Hardcodierte Konfiguration
|
||||||
SECRET_KEY = "7445630171969DFAC92C53CEC92E67A9CB2E00B3CB2F"
|
SECRET_KEY = "7445630171969DFAC92C53CEC92E67A9CB2E00B3CB2F"
|
||||||
DATABASE_PATH = "database/myp.db"
|
DATABASE_PATH = "../database/myp.db"
|
||||||
TAPO_USERNAME = "till.tomczak@mercedes-benz.com"
|
TAPO_USERNAME = "till.tomczak@mercedes-benz.com"
|
||||||
TAPO_PASSWORD = "744563017196A"
|
TAPO_PASSWORD = "744563017196A"
|
||||||
|
|
||||||
|
@@ -1,17 +1,14 @@
|
|||||||
# MYP Installer Control Center
|
# MYP Installer Control Center
|
||||||
# Zentrale Installationskonsole für die MYP-Plattform
|
# Zentrale Installationskonsole für die MYP-Plattform
|
||||||
# Kombiniert alle Setup-Funktionen für SSL, Hosts, Docker und mehr
|
|
||||||
# Version 2.0
|
# Version 2.0
|
||||||
|
|
||||||
# Farbdefinitionen für bessere Lesbarkeit
|
# Farbdefinitionen für bessere Lesbarkeit
|
||||||
$colors = @{
|
$ColorTitle = "Cyan"
|
||||||
Title = "Cyan"
|
$ColorSuccess = "Green"
|
||||||
Success = "Green"
|
$ColorError = "Red"
|
||||||
Error = "Red"
|
$ColorWarning = "Yellow"
|
||||||
Warning = "Yellow"
|
$ColorInfo = "Blue"
|
||||||
Info = "Blue"
|
$ColorCommand = "White"
|
||||||
Command = "White"
|
|
||||||
}
|
|
||||||
|
|
||||||
# Überprüfen, ob das Skript als Administrator ausgeführt wird
|
# Überprüfen, ob das Skript als Administrator ausgeführt wird
|
||||||
$isAdmin = ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)
|
$isAdmin = ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)
|
||||||
@@ -20,22 +17,22 @@ function Show-Header {
|
|||||||
param ([string]$Title)
|
param ([string]$Title)
|
||||||
|
|
||||||
Clear-Host
|
Clear-Host
|
||||||
Write-Host "=============================================================" -ForegroundColor $colors.Title
|
Write-Host "=============================================================" -ForegroundColor $ColorTitle
|
||||||
Write-Host " MYP INSTALLER CONTROL CENTER" -ForegroundColor $colors.Title
|
Write-Host " MYP INSTALLER CONTROL CENTER" -ForegroundColor $ColorTitle
|
||||||
Write-Host "=============================================================" -ForegroundColor $colors.Title
|
Write-Host "=============================================================" -ForegroundColor $ColorTitle
|
||||||
Write-Host " $Title" -ForegroundColor $colors.Title
|
Write-Host " $Title" -ForegroundColor $ColorTitle
|
||||||
Write-Host "=============================================================" -ForegroundColor $colors.Title
|
Write-Host "=============================================================" -ForegroundColor $ColorTitle
|
||||||
|
|
||||||
if (-not $isAdmin) {
|
if (-not $isAdmin) {
|
||||||
Write-Host "HINWEIS: Dieses Skript läuft ohne Administrator-Rechte." -ForegroundColor $colors.Warning
|
Write-Host "HINWEIS: Dieses Skript läuft ohne Administrator-Rechte." -ForegroundColor $ColorWarning
|
||||||
Write-Host "Einige Funktionen sind möglicherweise eingeschränkt." -ForegroundColor $colors.Warning
|
Write-Host "Einige Funktionen sind möglicherweise eingeschränkt." -ForegroundColor $ColorWarning
|
||||||
Write-Host "=============================================================" -ForegroundColor $colors.Title
|
Write-Host "=============================================================" -ForegroundColor $ColorTitle
|
||||||
}
|
}
|
||||||
|
|
||||||
Write-Host ""
|
Write-Host ""
|
||||||
}
|
}
|
||||||
|
|
||||||
function Test-Command {
|
function Test-CommandExists {
|
||||||
param ([string]$Command)
|
param ([string]$Command)
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -53,20 +50,21 @@ function Exec-Command {
|
|||||||
[string]$Description
|
[string]$Description
|
||||||
)
|
)
|
||||||
|
|
||||||
Write-Host "> $Description..." -ForegroundColor $colors.Info
|
Write-Host "> $Description..." -ForegroundColor $ColorInfo
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Invoke-Expression $Command | Out-Host
|
Invoke-Expression $Command | Out-Host
|
||||||
if ($LASTEXITCODE -eq 0 -or $null -eq $LASTEXITCODE) {
|
if ($LASTEXITCODE -eq 0 -or $null -eq $LASTEXITCODE) {
|
||||||
Write-Host "✓ Erfolgreich abgeschlossen!" -ForegroundColor $colors.Success
|
Write-Host "✓ Erfolgreich abgeschlossen!" -ForegroundColor $ColorSuccess
|
||||||
return $true
|
return $true
|
||||||
} else {
|
} else {
|
||||||
Write-Host "✗ Fehler beim Ausführen des Befehls. Exit-Code: $LASTEXITCODE" -ForegroundColor $colors.Error
|
Write-Host "✗ Fehler beim Ausführen des Befehls. Exit-Code: $LASTEXITCODE" -ForegroundColor $ColorError
|
||||||
return $false
|
return $false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch {
|
catch {
|
||||||
Write-Host "✗ Fehler: $_" -ForegroundColor $colors.Error
|
$errorMessage = $_.Exception.Message
|
||||||
|
Write-Host "✗ Fehler: $errorMessage" -ForegroundColor $ColorError
|
||||||
return $false
|
return $false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -80,53 +78,82 @@ function Get-LocalIPAddress {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function Test-Dependencies {
|
function Test-Dependencies {
|
||||||
Write-Host "Prüfe Abhängigkeiten..." -ForegroundColor $colors.Info
|
Show-Header "Systemvoraussetzungen prüfen"
|
||||||
|
|
||||||
$dependencies = @{}
|
Write-Host "Prüfe Abhängigkeiten..." -ForegroundColor $ColorInfo
|
||||||
$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
|
$pythonInstalled = Test-CommandExists "python"
|
||||||
|
if ($pythonInstalled) {
|
||||||
foreach ($dep in $dependencies.GetEnumerator()) {
|
Write-Host "✓ Python gefunden" -ForegroundColor $ColorSuccess
|
||||||
$installed = Test-Command $dep.Key
|
} else {
|
||||||
if ($installed) {
|
Write-Host "✗ Python nicht gefunden" -ForegroundColor $ColorError
|
||||||
Write-Host "✓ $($dep.Value) gefunden" -ForegroundColor $colors.Success
|
|
||||||
} else {
|
|
||||||
Write-Host "✗ $($dep.Value) nicht gefunden" -ForegroundColor $colors.Error
|
|
||||||
$allInstalled = $false
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $allInstalled
|
$pipInstalled = Test-CommandExists "pip"
|
||||||
|
if ($pipInstalled) {
|
||||||
|
Write-Host "✓ Pip gefunden" -ForegroundColor $ColorSuccess
|
||||||
|
} else {
|
||||||
|
Write-Host "✗ Pip nicht gefunden" -ForegroundColor $ColorError
|
||||||
|
}
|
||||||
|
|
||||||
|
$dockerInstalled = Test-CommandExists "docker"
|
||||||
|
if ($dockerInstalled) {
|
||||||
|
Write-Host "✓ Docker gefunden" -ForegroundColor $ColorSuccess
|
||||||
|
} else {
|
||||||
|
Write-Host "✗ Docker nicht gefunden" -ForegroundColor $ColorError
|
||||||
|
}
|
||||||
|
|
||||||
|
$dockerComposeInstalled = Test-CommandExists "docker-compose"
|
||||||
|
if ($dockerComposeInstalled) {
|
||||||
|
Write-Host "✓ Docker Compose gefunden" -ForegroundColor $ColorSuccess
|
||||||
|
} else {
|
||||||
|
Write-Host "✗ Docker Compose nicht gefunden" -ForegroundColor $ColorError
|
||||||
|
}
|
||||||
|
|
||||||
|
$nodeInstalled = Test-CommandExists "node"
|
||||||
|
if ($nodeInstalled) {
|
||||||
|
Write-Host "✓ Node.js gefunden" -ForegroundColor $ColorSuccess
|
||||||
|
} else {
|
||||||
|
Write-Host "✗ Node.js nicht gefunden" -ForegroundColor $ColorError
|
||||||
|
}
|
||||||
|
|
||||||
|
$npmInstalled = Test-CommandExists "npm"
|
||||||
|
if ($npmInstalled) {
|
||||||
|
Write-Host "✓ NPM gefunden" -ForegroundColor $ColorSuccess
|
||||||
|
} else {
|
||||||
|
Write-Host "✗ NPM nicht gefunden" -ForegroundColor $ColorError
|
||||||
|
}
|
||||||
|
|
||||||
|
Write-Host ""
|
||||||
|
Write-Host "Drücken Sie eine beliebige Taste, um fortzufahren..."
|
||||||
|
$null = $Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
|
||||||
}
|
}
|
||||||
|
|
||||||
function Setup-Hosts {
|
function Setup-Hosts {
|
||||||
Show-Header "Host-Konfiguration"
|
Show-Header "Host-Konfiguration"
|
||||||
|
|
||||||
if (-not $isAdmin) {
|
if (-not $isAdmin) {
|
||||||
Write-Host "Diese Funktion erfordert Administrator-Rechte." -ForegroundColor $colors.Error
|
Write-Host "Diese Funktion erfordert Administrator-Rechte." -ForegroundColor $ColorError
|
||||||
Write-Host "Bitte starten Sie das Skript als Administrator neu." -ForegroundColor $colors.Warning
|
Write-Host "Bitte starten Sie das Skript als Administrator neu." -ForegroundColor $ColorWarning
|
||||||
|
|
||||||
|
Write-Host ""
|
||||||
|
Write-Host "Drücken Sie eine beliebige Taste, um fortzufahren..."
|
||||||
|
$null = $Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
$localIP = Get-LocalIPAddress
|
$localIP = Get-LocalIPAddress
|
||||||
Write-Host "Lokale IP-Adresse: $localIP" -ForegroundColor $colors.Success
|
Write-Host "Lokale IP-Adresse: $localIP" -ForegroundColor $ColorSuccess
|
||||||
|
|
||||||
$hostsFile = "$env:windir\System32\drivers\etc\hosts"
|
$hostsFile = "$env:windir\System32\drivers\etc\hosts"
|
||||||
Write-Host "Hosts-Datei: $hostsFile" -ForegroundColor $colors.Info
|
Write-Host "Hosts-Datei: $hostsFile" -ForegroundColor $ColorInfo
|
||||||
|
|
||||||
# Prüfen, ob die Einträge bereits existieren
|
# Prüfen, ob die Einträge bereits existieren
|
||||||
$frontendEntry = Select-String -Path $hostsFile -Pattern "m040tbaraspi001.de040.corpintra.net" -Quiet
|
$frontendEntry = Select-String -Path $hostsFile -Pattern "m040tbaraspi001.de040.corpintra.net" -Quiet
|
||||||
$backendEntry = Select-String -Path $hostsFile -Pattern "raspberrypi" -Quiet
|
$backendEntry = Select-String -Path $hostsFile -Pattern "raspberrypi" -Quiet
|
||||||
|
|
||||||
# Einträge in die Hosts-Datei schreiben
|
# Einträge in die Hosts-Datei schreiben
|
||||||
Write-Host "Aktualisiere Hosts-Datei..." -ForegroundColor $colors.Info
|
Write-Host "Aktualisiere Hosts-Datei..." -ForegroundColor $ColorInfo
|
||||||
|
|
||||||
$hostsContent = Get-Content -Path $hostsFile
|
$hostsContent = Get-Content -Path $hostsFile
|
||||||
|
|
||||||
@@ -134,33 +161,34 @@ function Setup-Hosts {
|
|||||||
$hostsContent += ""
|
$hostsContent += ""
|
||||||
$hostsContent += "# MYP Frontend Host"
|
$hostsContent += "# MYP Frontend Host"
|
||||||
$hostsContent += "$localIP m040tbaraspi001.de040.corpintra.net m040tbaraspi001"
|
$hostsContent += "$localIP m040tbaraspi001.de040.corpintra.net m040tbaraspi001"
|
||||||
Write-Host "Frontend-Hostname hinzugefügt" -ForegroundColor $colors.Success
|
Write-Host "Frontend-Hostname hinzugefügt" -ForegroundColor $ColorSuccess
|
||||||
} else {
|
} else {
|
||||||
Write-Host "Frontend-Hostname ist bereits konfiguriert" -ForegroundColor $colors.Warning
|
Write-Host "Frontend-Hostname ist bereits konfiguriert" -ForegroundColor $ColorWarning
|
||||||
}
|
}
|
||||||
|
|
||||||
if (-not $backendEntry) {
|
if (-not $backendEntry) {
|
||||||
$hostsContent += ""
|
$hostsContent += ""
|
||||||
$hostsContent += "# MYP Backend Host"
|
$hostsContent += "# MYP Backend Host"
|
||||||
$hostsContent += "$localIP raspberrypi"
|
$hostsContent += "$localIP raspberrypi"
|
||||||
Write-Host "Backend-Hostname hinzugefügt" -ForegroundColor $colors.Success
|
Write-Host "Backend-Hostname hinzugefügt" -ForegroundColor $ColorSuccess
|
||||||
} else {
|
} else {
|
||||||
Write-Host "Backend-Hostname ist bereits konfiguriert" -ForegroundColor $colors.Warning
|
Write-Host "Backend-Hostname ist bereits konfiguriert" -ForegroundColor $ColorWarning
|
||||||
}
|
}
|
||||||
|
|
||||||
# Speichern der aktualisierten Hosts-Datei
|
# Speichern der aktualisierten Hosts-Datei
|
||||||
try {
|
try {
|
||||||
$hostsContent | Set-Content -Path $hostsFile -Force
|
$hostsContent | Set-Content -Path $hostsFile -Force
|
||||||
Write-Host "Konfiguration abgeschlossen!" -ForegroundColor $colors.Success
|
Write-Host "Konfiguration abgeschlossen!" -ForegroundColor $ColorSuccess
|
||||||
}
|
}
|
||||||
catch {
|
catch {
|
||||||
Write-Host "Fehler beim Schreiben der Hosts-Datei: $_" -ForegroundColor $colors.Error
|
$errorMessage = $_.Exception.Message
|
||||||
|
Write-Host "Fehler beim Schreiben der Hosts-Datei: $errorMessage" -ForegroundColor $ColorError
|
||||||
}
|
}
|
||||||
|
|
||||||
Write-Host ""
|
Write-Host ""
|
||||||
Write-Host "Folgende Hostnamen sind jetzt konfiguriert:" -ForegroundColor $colors.Info
|
Write-Host "Folgende Hostnamen sind jetzt konfiguriert:" -ForegroundColor $ColorInfo
|
||||||
Write-Host " - Frontend: m040tbaraspi001.de040.corpintra.net" -ForegroundColor $colors.Command
|
Write-Host " - Frontend: m040tbaraspi001.de040.corpintra.net" -ForegroundColor $ColorCommand
|
||||||
Write-Host " - Backend: raspberrypi" -ForegroundColor $colors.Command
|
Write-Host " - Backend: raspberrypi" -ForegroundColor $ColorCommand
|
||||||
|
|
||||||
Write-Host ""
|
Write-Host ""
|
||||||
Write-Host "Drücken Sie eine beliebige Taste, um fortzufahren..."
|
Write-Host "Drücken Sie eine beliebige Taste, um fortzufahren..."
|
||||||
@@ -177,50 +205,47 @@ function Create-SSLCertificates {
|
|||||||
$frontendCertFile = "$certDir/frontend.crt"
|
$frontendCertFile = "$certDir/frontend.crt"
|
||||||
$frontendKeyFile = "$certDir/frontend.key"
|
$frontendKeyFile = "$certDir/frontend.key"
|
||||||
|
|
||||||
Write-Host "Zertifikate werden für folgende Hostnamen erstellt:" -ForegroundColor $colors.Info
|
Write-Host "Zertifikate werden für folgende Hostnamen erstellt:" -ForegroundColor $ColorInfo
|
||||||
|
|
||||||
# Hostname-Auswahl
|
# Hostname-Auswahl
|
||||||
Write-Host "1. Für lokale Entwicklung (localhost)" -ForegroundColor $colors.Command
|
Write-Host "1. Für lokale Entwicklung (localhost)" -ForegroundColor $ColorCommand
|
||||||
Write-Host "2. Für Raspberry Pi Deployment (raspberrypi)" -ForegroundColor $colors.Command
|
Write-Host "2. Für Raspberry Pi Deployment (raspberrypi)" -ForegroundColor $ColorCommand
|
||||||
Write-Host "3. Für Unternehmens-Setup (m040tbaraspi001.de040.corpintra.net)" -ForegroundColor $colors.Command
|
Write-Host "3. Für Unternehmens-Setup (m040tbaraspi001.de040.corpintra.net)" -ForegroundColor $ColorCommand
|
||||||
|
|
||||||
$choice = Read-Host "Wählen Sie eine Option (1-3, Standard: 1)"
|
$choice = Read-Host "Wählen Sie eine Option (1-3, Standard: 1)"
|
||||||
|
|
||||||
switch ($choice) {
|
$backendHostname = "localhost"
|
||||||
"2" {
|
$frontendHostname = "localhost"
|
||||||
$backendHostname = "raspberrypi"
|
|
||||||
$frontendHostname = "raspberrypi"
|
if ($choice -eq "2") {
|
||||||
}
|
$backendHostname = "raspberrypi"
|
||||||
"3" {
|
$frontendHostname = "raspberrypi"
|
||||||
$backendHostname = "raspberrypi"
|
}
|
||||||
$frontendHostname = "m040tbaraspi001.de040.corpintra.net"
|
elseif ($choice -eq "3") {
|
||||||
}
|
$backendHostname = "raspberrypi"
|
||||||
default {
|
$frontendHostname = "m040tbaraspi001.de040.corpintra.net"
|
||||||
$backendHostname = "localhost"
|
|
||||||
$frontendHostname = "localhost"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Write-Host "Backend-Hostname: $backendHostname" -ForegroundColor $colors.Info
|
Write-Host "Backend-Hostname: $backendHostname" -ForegroundColor $ColorInfo
|
||||||
Write-Host "Frontend-Hostname: $frontendHostname" -ForegroundColor $colors.Info
|
Write-Host "Frontend-Hostname: $frontendHostname" -ForegroundColor $ColorInfo
|
||||||
Write-Host ""
|
Write-Host ""
|
||||||
|
|
||||||
# Verzeichnis erstellen, falls es nicht existiert
|
# Verzeichnis erstellen, falls es nicht existiert
|
||||||
if (!(Test-Path $certDir)) {
|
if (!(Test-Path $certDir)) {
|
||||||
Write-Host "Erstelle Verzeichnis $certDir..." -ForegroundColor $colors.Info
|
Write-Host "Erstelle Verzeichnis $certDir..." -ForegroundColor $ColorInfo
|
||||||
New-Item -ItemType Directory -Path $certDir -Force | Out-Null
|
New-Item -ItemType Directory -Path $certDir -Force | Out-Null
|
||||||
}
|
}
|
||||||
|
|
||||||
# SSL-Zertifikate mit Python und cryptography erstellen
|
# SSL-Zertifikate mit Python und cryptography erstellen
|
||||||
Write-Host "Erstelle SSL-Zertifikate mit Python..." -ForegroundColor $colors.Info
|
Write-Host "Erstelle SSL-Zertifikate mit Python..." -ForegroundColor $ColorInfo
|
||||||
|
|
||||||
$pythonInstalled = Test-Command "python"
|
$pythonInstalled = Test-CommandExists "python"
|
||||||
if ($pythonInstalled) {
|
if ($pythonInstalled) {
|
||||||
# Überprüfen, ob cryptography installiert ist
|
# Überprüfen, ob cryptography installiert ist
|
||||||
$cryptographyInstalled = python -c "try: import cryptography; print('True'); except ImportError: print('False')" 2>$null
|
$cryptographyInstalled = python -c "try: import cryptography; print('True'); except ImportError: print('False')" 2>$null
|
||||||
|
|
||||||
if ($cryptographyInstalled -ne "True") {
|
if ($cryptographyInstalled -ne "True") {
|
||||||
Write-Host "Installiere Python-Abhängigkeit 'cryptography'..." -ForegroundColor $colors.Warning
|
Write-Host "Installiere Python-Abhängigkeit 'cryptography'..." -ForegroundColor $ColorWarning
|
||||||
Exec-Command "pip install cryptography" "Installiere cryptography-Paket"
|
Exec-Command "pip install cryptography" "Installiere cryptography-Paket"
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -331,17 +356,20 @@ create_self_signed_cert('$frontendCertFile', '$frontendKeyFile', '$frontendHostn
|
|||||||
# Python-Skript ausführen
|
# Python-Skript ausführen
|
||||||
try {
|
try {
|
||||||
python $tempScriptPath
|
python $tempScriptPath
|
||||||
Write-Host "SSL-Zertifikate erfolgreich erstellt!" -ForegroundColor $colors.Success
|
Write-Host "SSL-Zertifikate erfolgreich erstellt!" -ForegroundColor $ColorSuccess
|
||||||
}
|
}
|
||||||
catch {
|
catch {
|
||||||
Write-Host "Fehler beim Erstellen der SSL-Zertifikate: $_" -ForegroundColor $colors.Error
|
$errorMessage = $_.Exception.Message
|
||||||
|
Write-Host "Fehler beim Erstellen der SSL-Zertifikate: $errorMessage" -ForegroundColor $ColorError
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
# Temporäres Skript löschen
|
# Temporäres Skript löschen
|
||||||
Remove-Item -Path $tempScriptPath -Force
|
if (Test-Path $tempScriptPath) {
|
||||||
|
Remove-Item -Path $tempScriptPath -Force
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Write-Host "Python nicht gefunden. SSL-Zertifikate können nicht erstellt werden." -ForegroundColor $colors.Error
|
Write-Host "Python nicht gefunden. SSL-Zertifikate können nicht erstellt werden." -ForegroundColor $ColorError
|
||||||
}
|
}
|
||||||
|
|
||||||
# Zertifikate im System installieren (optional)
|
# Zertifikate im System installieren (optional)
|
||||||
@@ -350,26 +378,26 @@ create_self_signed_cert('$frontendCertFile', '$frontendKeyFile', '$frontendHostn
|
|||||||
|
|
||||||
if ($installCerts -eq "j") {
|
if ($installCerts -eq "j") {
|
||||||
if (Test-Path $backendCertFile) {
|
if (Test-Path $backendCertFile) {
|
||||||
Write-Host "Installiere Backend-Zertifikat im System..." -ForegroundColor $colors.Info
|
Write-Host "Installiere Backend-Zertifikat im System..." -ForegroundColor $ColorInfo
|
||||||
Exec-Command "certutil -addstore -f 'ROOT' '$backendCertFile'" "Installiere im Root-Zertifikatsspeicher"
|
Exec-Command "certutil -addstore -f 'ROOT' '$backendCertFile'" "Installiere im Root-Zertifikatsspeicher"
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Test-Path $frontendCertFile) {
|
if (Test-Path $frontendCertFile) {
|
||||||
Write-Host "Installiere Frontend-Zertifikat im System..." -ForegroundColor $colors.Info
|
Write-Host "Installiere Frontend-Zertifikat im System..." -ForegroundColor $ColorInfo
|
||||||
Exec-Command "certutil -addstore -f 'ROOT' '$frontendCertFile'" "Installiere im Root-Zertifikatsspeicher"
|
Exec-Command "certutil -addstore -f 'ROOT' '$frontendCertFile'" "Installiere im Root-Zertifikatsspeicher"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Write-Host "Hinweis: Um die Zertifikate im System zu installieren, starten Sie das Skript als Administrator." -ForegroundColor $colors.Warning
|
Write-Host "Hinweis: Um die Zertifikate im System zu installieren, starten Sie das Skript als Administrator." -ForegroundColor $ColorWarning
|
||||||
}
|
}
|
||||||
|
|
||||||
# Frontend für HTTPS konfigurieren
|
# Frontend für HTTPS konfigurieren
|
||||||
Write-Host ""
|
Write-Host ""
|
||||||
Write-Host "Möchten Sie das Frontend für HTTPS konfigurieren? (j/n, Standard: j)" -ForegroundColor $colors.Info
|
Write-Host "Möchten Sie das Frontend für HTTPS konfigurieren? (j/n, Standard: j)" -ForegroundColor $ColorInfo
|
||||||
$configureFrontend = Read-Host
|
$configureFrontend = Read-Host
|
||||||
|
|
||||||
if ($configureFrontend -ne "n") {
|
if ($configureFrontend -ne "n") {
|
||||||
Write-Host "Konfiguriere Frontend für HTTPS..." -ForegroundColor $colors.Info
|
Write-Host "Konfiguriere Frontend für HTTPS..." -ForegroundColor $ColorInfo
|
||||||
|
|
||||||
# Kopiere Zertifikate ins Frontend-Verzeichnis
|
# Kopiere Zertifikate ins Frontend-Verzeichnis
|
||||||
$frontendSslDir = "./frontend/ssl"
|
$frontendSslDir = "./frontend/ssl"
|
||||||
@@ -377,10 +405,15 @@ create_self_signed_cert('$frontendCertFile', '$frontendKeyFile', '$frontendHostn
|
|||||||
New-Item -ItemType Directory -Path $frontendSslDir -Force | Out-Null
|
New-Item -ItemType Directory -Path $frontendSslDir -Force | Out-Null
|
||||||
}
|
}
|
||||||
|
|
||||||
Copy-Item -Path $backendCertFile -Destination "$frontendSslDir/myp.crt" -Force
|
if (Test-Path $backendCertFile) {
|
||||||
Copy-Item -Path $backendKeyFile -Destination "$frontendSslDir/myp.key" -Force
|
Copy-Item -Path $backendCertFile -Destination "$frontendSslDir/myp.crt" -Force
|
||||||
|
}
|
||||||
|
|
||||||
Write-Host "Zertifikate ins Frontend-Verzeichnis kopiert." -ForegroundColor $colors.Success
|
if (Test-Path $backendKeyFile) {
|
||||||
|
Copy-Item -Path $backendKeyFile -Destination "$frontendSslDir/myp.key" -Force
|
||||||
|
}
|
||||||
|
|
||||||
|
Write-Host "Zertifikate ins Frontend-Verzeichnis kopiert." -ForegroundColor $ColorSuccess
|
||||||
|
|
||||||
# Prüfen, ob .env.local existiert und aktualisieren
|
# Prüfen, ob .env.local existiert und aktualisieren
|
||||||
$envLocalPath = "./frontend/.env.local"
|
$envLocalPath = "./frontend/.env.local"
|
||||||
@@ -419,13 +452,13 @@ create_self_signed_cert('$frontendCertFile', '$frontendKeyFile', '$frontendHostn
|
|||||||
|
|
||||||
# Speichern der aktualisierten Umgebungsvariablen
|
# Speichern der aktualisierten Umgebungsvariablen
|
||||||
$envContent | Out-File -FilePath $envLocalPath -Encoding utf8
|
$envContent | Out-File -FilePath $envLocalPath -Encoding utf8
|
||||||
Write-Host ".env.local Datei mit SSL-Konfigurationen aktualisiert." -ForegroundColor $colors.Success
|
Write-Host ".env.local Datei mit SSL-Konfigurationen aktualisiert." -ForegroundColor $ColorSuccess
|
||||||
}
|
}
|
||||||
|
|
||||||
Write-Host ""
|
Write-Host ""
|
||||||
Write-Host "SSL-Zertifikate wurden in folgenden Pfaden gespeichert:" -ForegroundColor $colors.Info
|
Write-Host "SSL-Zertifikate wurden in folgenden Pfaden gespeichert:" -ForegroundColor $ColorInfo
|
||||||
Write-Host "Backend: $backendCertFile" -ForegroundColor $colors.Command
|
Write-Host "Backend: $backendCertFile" -ForegroundColor $ColorCommand
|
||||||
Write-Host "Frontend: $frontendCertFile" -ForegroundColor $colors.Command
|
Write-Host "Frontend: $frontendCertFile" -ForegroundColor $ColorCommand
|
||||||
|
|
||||||
Write-Host ""
|
Write-Host ""
|
||||||
Write-Host "Drücken Sie eine beliebige Taste, um fortzufahren..."
|
Write-Host "Drücken Sie eine beliebige Taste, um fortzufahren..."
|
||||||
@@ -436,28 +469,32 @@ function Setup-Environment {
|
|||||||
Show-Header "Umgebungs-Setup"
|
Show-Header "Umgebungs-Setup"
|
||||||
|
|
||||||
# Prüfen, ob Python und pip installiert sind
|
# Prüfen, ob Python und pip installiert sind
|
||||||
$pythonInstalled = Test-Command "python"
|
$pythonInstalled = Test-CommandExists "python"
|
||||||
$pipInstalled = Test-Command "pip"
|
$pipInstalled = Test-CommandExists "pip"
|
||||||
|
|
||||||
if (-not $pythonInstalled -or -not $pipInstalled) {
|
if (-not $pythonInstalled -or -not $pipInstalled) {
|
||||||
Write-Host "Python oder pip ist nicht installiert. Bitte installieren Sie Python 3.6+ und versuchen Sie es erneut." -ForegroundColor $colors.Error
|
Write-Host "Python oder pip ist nicht installiert. Bitte installieren Sie Python 3.6+ und versuchen Sie es erneut." -ForegroundColor $ColorError
|
||||||
|
|
||||||
|
Write-Host ""
|
||||||
|
Write-Host "Drücken Sie eine beliebige Taste, um fortzufahren..."
|
||||||
|
$null = $Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
# Python-Abhängigkeiten installieren
|
# Python-Abhängigkeiten installieren
|
||||||
Write-Host "Installiere Backend-Abhängigkeiten..." -ForegroundColor $colors.Info
|
Write-Host "Installiere Backend-Abhängigkeiten..." -ForegroundColor $ColorInfo
|
||||||
Exec-Command "pip install -r backend/requirements.txt" "Installiere Python-Abhängigkeiten"
|
Exec-Command "pip install -r backend/requirements.txt" "Installiere Python-Abhängigkeiten"
|
||||||
|
|
||||||
# Prüfen, ob Node.js und npm installiert sind
|
# Prüfen, ob Node.js und npm installiert sind
|
||||||
$nodeInstalled = Test-Command "node"
|
$nodeInstalled = Test-CommandExists "node"
|
||||||
$npmInstalled = Test-Command "npm"
|
$npmInstalled = Test-CommandExists "npm"
|
||||||
|
|
||||||
if ($nodeInstalled -and $npmInstalled) {
|
if ($nodeInstalled -and $npmInstalled) {
|
||||||
# Frontend-Abhängigkeiten installieren
|
# Frontend-Abhängigkeiten installieren
|
||||||
Write-Host "Installiere Frontend-Abhängigkeiten..." -ForegroundColor $colors.Info
|
Write-Host "Installiere Frontend-Abhängigkeiten..." -ForegroundColor $ColorInfo
|
||||||
Exec-Command "cd frontend && npm install" "Installiere Node.js-Abhängigkeiten"
|
Exec-Command "cd frontend && npm install" "Installiere Node.js-Abhängigkeiten"
|
||||||
} else {
|
} else {
|
||||||
Write-Host "Node.js oder npm ist nicht installiert. Frontend-Abhängigkeiten werden übersprungen." -ForegroundColor $colors.Warning
|
Write-Host "Node.js oder npm ist nicht installiert. Frontend-Abhängigkeiten werden übersprungen." -ForegroundColor $ColorWarning
|
||||||
}
|
}
|
||||||
|
|
||||||
# Docker-Compose Datei aktualisieren
|
# Docker-Compose Datei aktualisieren
|
||||||
@@ -469,14 +506,14 @@ function Setup-Environment {
|
|||||||
if (-not $dockerCompose.Contains("--dual-protocol")) {
|
if (-not $dockerCompose.Contains("--dual-protocol")) {
|
||||||
$dockerCompose = $dockerCompose -replace "command: python -m app\.app", "command: python -m app.app --dual-protocol"
|
$dockerCompose = $dockerCompose -replace "command: python -m app\.app", "command: python -m app.app --dual-protocol"
|
||||||
$dockerCompose | Set-Content $dockerComposeFile
|
$dockerCompose | Set-Content $dockerComposeFile
|
||||||
Write-Host "Docker-Compose-Datei wurde aktualisiert, um den dual-protocol-Modus zu aktivieren." -ForegroundColor $colors.Success
|
Write-Host "Docker-Compose-Datei wurde aktualisiert, um den dual-protocol-Modus zu aktivieren." -ForegroundColor $ColorSuccess
|
||||||
} else {
|
} else {
|
||||||
Write-Host "Docker-Compose-Datei ist bereits korrekt konfiguriert." -ForegroundColor $colors.Success
|
Write-Host "Docker-Compose-Datei ist bereits korrekt konfiguriert." -ForegroundColor $ColorSuccess
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Write-Host ""
|
Write-Host ""
|
||||||
Write-Host "Umgebungs-Setup abgeschlossen!" -ForegroundColor $colors.Success
|
Write-Host "Umgebungs-Setup abgeschlossen!" -ForegroundColor $ColorSuccess
|
||||||
|
|
||||||
Write-Host ""
|
Write-Host ""
|
||||||
Write-Host "Drücken Sie eine beliebige Taste, um fortzufahren..."
|
Write-Host "Drücken Sie eine beliebige Taste, um fortzufahren..."
|
||||||
@@ -486,103 +523,51 @@ function Setup-Environment {
|
|||||||
function Start-Application {
|
function Start-Application {
|
||||||
Show-Header "Anwendung starten"
|
Show-Header "Anwendung starten"
|
||||||
|
|
||||||
Write-Host "Wie möchten Sie die Anwendung starten?" -ForegroundColor $colors.Info
|
Write-Host "Wie möchten Sie die Anwendung starten?" -ForegroundColor $ColorInfo
|
||||||
Write-Host "1. Backend-Server starten (Python)" -ForegroundColor $colors.Command
|
Write-Host "1. Backend-Server starten (Python)" -ForegroundColor $ColorCommand
|
||||||
Write-Host "2. Frontend-Server starten (Node.js)" -ForegroundColor $colors.Command
|
Write-Host "2. Frontend-Server starten (Node.js)" -ForegroundColor $ColorCommand
|
||||||
Write-Host "3. Beide Server starten (in separaten Fenstern)" -ForegroundColor $colors.Command
|
Write-Host "3. Beide Server starten (in separaten Fenstern)" -ForegroundColor $ColorCommand
|
||||||
Write-Host "4. Mit Docker Compose starten" -ForegroundColor $colors.Command
|
Write-Host "4. Mit Docker Compose starten" -ForegroundColor $ColorCommand
|
||||||
Write-Host "5. Zurück zum Hauptmenü" -ForegroundColor $colors.Command
|
Write-Host "5. Zurück zum Hauptmenü" -ForegroundColor $ColorCommand
|
||||||
|
|
||||||
$choice = Read-Host "Wählen Sie eine Option (1-5)"
|
$choice = Read-Host "Wählen Sie eine Option (1-5)"
|
||||||
|
|
||||||
switch ($choice) {
|
if ($choice -eq "1") {
|
||||||
"1" {
|
Write-Host "Starte Backend-Server..." -ForegroundColor $ColorInfo
|
||||||
Write-Host "Starte Backend-Server..." -ForegroundColor $colors.Info
|
Start-Process -FilePath "python" -ArgumentList "backend/app/app.py" -NoNewWindow
|
||||||
Start-Process -FilePath "python" -ArgumentList "backend/app/app.py" -NoNewWindow
|
Write-Host "Backend-Server läuft jetzt im Hintergrund." -ForegroundColor $ColorSuccess
|
||||||
Write-Host "Backend-Server läuft jetzt im Hintergrund." -ForegroundColor $colors.Success
|
|
||||||
}
|
|
||||||
"2" {
|
|
||||||
Write-Host "Starte Frontend-Server..." -ForegroundColor $colors.Info
|
|
||||||
Start-Process -FilePath "npm" -ArgumentList "run dev" -WorkingDirectory "frontend" -NoNewWindow
|
|
||||||
Write-Host "Frontend-Server läuft jetzt im Hintergrund." -ForegroundColor $colors.Success
|
|
||||||
}
|
|
||||||
"3" {
|
|
||||||
Write-Host "Starte Backend-Server..." -ForegroundColor $colors.Info
|
|
||||||
Start-Process -FilePath "python" -ArgumentList "backend/app/app.py" -NoNewWindow
|
|
||||||
|
|
||||||
Write-Host "Starte Frontend-Server..." -ForegroundColor $colors.Info
|
|
||||||
Start-Process -FilePath "npm" -ArgumentList "run dev" -WorkingDirectory "frontend" -NoNewWindow
|
|
||||||
|
|
||||||
Write-Host "Beide Server laufen jetzt im Hintergrund." -ForegroundColor $colors.Success
|
|
||||||
}
|
|
||||||
"4" {
|
|
||||||
$dockerInstalled = Test-Command "docker"
|
|
||||||
$dockerComposeInstalled = Test-Command "docker-compose"
|
|
||||||
|
|
||||||
if ($dockerInstalled -and $dockerComposeInstalled) {
|
|
||||||
Write-Host "Starte Anwendung mit Docker Compose..." -ForegroundColor $colors.Info
|
|
||||||
Exec-Command "docker-compose up -d" "Starte Docker Container"
|
|
||||||
Write-Host "Docker Container wurden gestartet." -ForegroundColor $colors.Success
|
|
||||||
} else {
|
|
||||||
Write-Host "Docker oder Docker Compose ist nicht installiert." -ForegroundColor $colors.Error
|
|
||||||
}
|
|
||||||
}
|
|
||||||
"5" {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
default {
|
|
||||||
Write-Host "Ungültige Option." -ForegroundColor $colors.Error
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
elseif ($choice -eq "2") {
|
||||||
Write-Host ""
|
Write-Host "Starte Frontend-Server..." -ForegroundColor $ColorInfo
|
||||||
Write-Host "Drücken Sie eine beliebige Taste, um fortzufahren..."
|
Start-Process -FilePath "npm" -ArgumentList "run dev" -WorkingDirectory "frontend" -NoNewWindow
|
||||||
$null = $Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
|
Write-Host "Frontend-Server läuft jetzt im Hintergrund." -ForegroundColor $ColorSuccess
|
||||||
}
|
|
||||||
|
|
||||||
function Clean-OldScripts {
|
|
||||||
Show-Header "Alte Skripte bereinigen"
|
|
||||||
|
|
||||||
$oldScripts = @(
|
|
||||||
"setup_ssl.ps1",
|
|
||||||
"setup_hosts.ps1",
|
|
||||||
"setup_hosts_copy.ps1",
|
|
||||||
"generate_ssl_certs.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
|
|
||||||
foreach ($script in $oldScripts) {
|
|
||||||
if (Test-Path $script) {
|
|
||||||
Write-Host " - $script" -ForegroundColor $colors.Command
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
elseif ($choice -eq "3") {
|
||||||
Write-Host ""
|
Write-Host "Starte Backend-Server..." -ForegroundColor $ColorInfo
|
||||||
$confirm = Read-Host "Möchten Sie fortfahren? (j/n, Standard: j)"
|
Start-Process -FilePath "python" -ArgumentList "backend/app/app.py" -NoNewWindow
|
||||||
|
|
||||||
if ($confirm -ne "n") {
|
|
||||||
foreach ($script in $oldScripts) {
|
|
||||||
if (Test-Path $script) {
|
|
||||||
try {
|
|
||||||
Remove-Item -Path $script -Force
|
|
||||||
Write-Host "✓ $script wurde gelöscht." -ForegroundColor $colors.Success
|
|
||||||
}
|
|
||||||
catch {
|
|
||||||
$errorMessage = $_.Exception.Message
|
|
||||||
Write-Host "✗ Fehler beim Löschen von $script`: $errorMessage" -ForegroundColor $colors.Error
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Write-Host ""
|
Write-Host "Starte Frontend-Server..." -ForegroundColor $ColorInfo
|
||||||
Write-Host "Bereinigung abgeschlossen." -ForegroundColor $colors.Success
|
Start-Process -FilePath "npm" -ArgumentList "run dev" -WorkingDirectory "frontend" -NoNewWindow
|
||||||
}
|
|
||||||
|
Write-Host "Beide Server laufen jetzt im Hintergrund." -ForegroundColor $ColorSuccess
|
||||||
|
}
|
||||||
|
elseif ($choice -eq "4") {
|
||||||
|
$dockerInstalled = Test-CommandExists "docker"
|
||||||
|
$dockerComposeInstalled = Test-CommandExists "docker-compose"
|
||||||
|
|
||||||
|
if ($dockerInstalled -and $dockerComposeInstalled) {
|
||||||
|
Write-Host "Starte Anwendung mit Docker Compose..." -ForegroundColor $ColorInfo
|
||||||
|
Exec-Command "docker-compose up -d" "Starte Docker Container"
|
||||||
|
Write-Host "Docker Container wurden gestartet." -ForegroundColor $ColorSuccess
|
||||||
|
} else {
|
||||||
|
Write-Host "Docker oder Docker Compose ist nicht installiert." -ForegroundColor $ColorError
|
||||||
|
}
|
||||||
|
}
|
||||||
|
elseif ($choice -eq "5") {
|
||||||
|
return
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
Write-Host "Bereinigung abgebrochen." -ForegroundColor $colors.Warning
|
Write-Host "Ungültige Option." -ForegroundColor $ColorError
|
||||||
}
|
}
|
||||||
|
|
||||||
Write-Host ""
|
Write-Host ""
|
||||||
@@ -594,56 +579,43 @@ function Clean-OldScripts {
|
|||||||
function Show-MainMenu {
|
function Show-MainMenu {
|
||||||
Show-Header "Hauptmenü"
|
Show-Header "Hauptmenü"
|
||||||
|
|
||||||
Write-Host "1. Systemvoraussetzungen prüfen" -ForegroundColor $colors.Command
|
Write-Host "1. Systemvoraussetzungen prüfen" -ForegroundColor $ColorCommand
|
||||||
Write-Host "2. Host-Konfiguration einrichten" -ForegroundColor $colors.Command
|
Write-Host "2. Host-Konfiguration einrichten" -ForegroundColor $ColorCommand
|
||||||
Write-Host "3. SSL-Zertifikate erstellen" -ForegroundColor $colors.Command
|
Write-Host "3. SSL-Zertifikate erstellen" -ForegroundColor $ColorCommand
|
||||||
Write-Host "4. Umgebung einrichten (Abhängigkeiten installieren)" -ForegroundColor $colors.Command
|
Write-Host "4. Umgebung einrichten (Abhängigkeiten installieren)" -ForegroundColor $ColorCommand
|
||||||
Write-Host "5. Anwendung starten" -ForegroundColor $colors.Command
|
Write-Host "5. Anwendung starten" -ForegroundColor $ColorCommand
|
||||||
Write-Host "6. Alte Skripte bereinigen" -ForegroundColor $colors.Command
|
Write-Host "6. Beenden" -ForegroundColor $ColorCommand
|
||||||
Write-Host "Q. Beenden" -ForegroundColor $colors.Command
|
|
||||||
Write-Host ""
|
Write-Host ""
|
||||||
|
|
||||||
$choice = Read-Host "Wählen Sie eine Option (1-6, Q)"
|
$choice = Read-Host "Wählen Sie eine Option (1-6)"
|
||||||
|
|
||||||
switch ($choice) {
|
if ($choice -eq "1") {
|
||||||
"1" {
|
Test-Dependencies
|
||||||
Test-Dependencies
|
Show-MainMenu
|
||||||
Write-Host ""
|
}
|
||||||
Write-Host "Drücken Sie eine beliebige Taste, um fortzufahren..."
|
elseif ($choice -eq "2") {
|
||||||
$null = $Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
|
Setup-Hosts
|
||||||
Show-MainMenu
|
Show-MainMenu
|
||||||
}
|
}
|
||||||
"2" {
|
elseif ($choice -eq "3") {
|
||||||
Setup-Hosts
|
Create-SSLCertificates
|
||||||
Show-MainMenu
|
Show-MainMenu
|
||||||
}
|
}
|
||||||
"3" {
|
elseif ($choice -eq "4") {
|
||||||
Create-SSLCertificates
|
Setup-Environment
|
||||||
Show-MainMenu
|
Show-MainMenu
|
||||||
}
|
}
|
||||||
"4" {
|
elseif ($choice -eq "5") {
|
||||||
Setup-Environment
|
Start-Application
|
||||||
Show-MainMenu
|
Show-MainMenu
|
||||||
}
|
}
|
||||||
"5" {
|
elseif ($choice -eq "6") {
|
||||||
Start-Application
|
exit
|
||||||
Show-MainMenu
|
}
|
||||||
}
|
else {
|
||||||
"6" {
|
Write-Host "Ungültige Option. Bitte versuchen Sie es erneut." -ForegroundColor $ColorError
|
||||||
Clean-OldScripts
|
Start-Sleep -Seconds 2
|
||||||
Show-MainMenu
|
Show-MainMenu
|
||||||
}
|
|
||||||
"Q" {
|
|
||||||
exit
|
|
||||||
}
|
|
||||||
"q" {
|
|
||||||
exit
|
|
||||||
}
|
|
||||||
default {
|
|
||||||
Write-Host "Ungültige Option. Bitte versuchen Sie es erneut." -ForegroundColor $colors.Error
|
|
||||||
Start-Sleep -Seconds 2
|
|
||||||
Show-MainMenu
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user