"feat: Add new configuration options and scripts for backend settings"
This commit is contained in:
@@ -34,8 +34,8 @@ SESSION_LIFETIME = timedelta(days=7)
|
||||
|
||||
# SSL-Konfiguration
|
||||
SSL_ENABLED = True
|
||||
SSL_CERT_PATH = "app/instance/ssl/myp.crt"
|
||||
SSL_KEY_PATH = "app/instance/ssl/myp.key"
|
||||
SSL_CERT_PATH = "app/certs/myp.crt"
|
||||
SSL_KEY_PATH = "app/certs/myp.key"
|
||||
SSL_HOSTNAME = "raspberrypi"
|
||||
|
||||
# Scheduler-Konfiguration
|
||||
|
@@ -1,6 +1,7 @@
|
||||
# MYP Installer Control Center
|
||||
# Zentrale Installationskonsole für die MYP-Plattform
|
||||
# Kombiniert Setup-Funktionen für SSL, Hosts, Docker und mehr
|
||||
# Kombiniert alle Setup-Funktionen für SSL, Hosts, Docker und mehr
|
||||
# Version 2.0
|
||||
|
||||
# Farbdefinitionen für bessere Lesbarkeit
|
||||
$colors = @{
|
||||
@@ -358,6 +359,65 @@ create_self_signed_cert('$frontendCertFile', '$frontendKeyFile', '$frontendHostn
|
||||
Write-Host "Hinweis: Um die Zertifikate im System zu installieren, starten Sie das Skript als Administrator." -ForegroundColor $colors.Warning
|
||||
}
|
||||
|
||||
# Frontend für HTTPS konfigurieren
|
||||
Write-Host ""
|
||||
Write-Host "Möchten Sie das Frontend für HTTPS konfigurieren? (j/n, Standard: j)" -ForegroundColor $colors.Info
|
||||
$configureFrontend = Read-Host
|
||||
|
||||
if ($configureFrontend -ne "n") {
|
||||
Write-Host "Konfiguriere Frontend für HTTPS..." -ForegroundColor $colors.Info
|
||||
|
||||
# Kopiere Zertifikate ins Frontend-Verzeichnis
|
||||
$frontendSslDir = "./frontend/ssl"
|
||||
if (!(Test-Path $frontendSslDir)) {
|
||||
New-Item -ItemType Directory -Path $frontendSslDir -Force | Out-Null
|
||||
}
|
||||
|
||||
Copy-Item -Path $backendCertFile -Destination "$frontendSslDir/myp.crt" -Force
|
||||
Copy-Item -Path $backendKeyFile -Destination "$frontendSslDir/myp.key" -Force
|
||||
|
||||
Write-Host "Zertifikate ins Frontend-Verzeichnis kopiert." -ForegroundColor $colors.Success
|
||||
|
||||
# Prüfen, ob .env.local existiert und aktualisieren
|
||||
$envLocalPath = "./frontend/.env.local"
|
||||
$envContent = ""
|
||||
|
||||
if (Test-Path $envLocalPath) {
|
||||
$envContent = Get-Content -Path $envLocalPath -Raw
|
||||
} else {
|
||||
$envContent = "# MYP Frontend Umgebungsvariablen`n"
|
||||
}
|
||||
|
||||
# SSL-Konfigurationen
|
||||
$sslConfigs = @(
|
||||
"NODE_TLS_REJECT_UNAUTHORIZED=0",
|
||||
"HTTPS=true",
|
||||
"SSL_CRT_FILE=./ssl/myp.crt",
|
||||
"SSL_KEY_FILE=./ssl/myp.key",
|
||||
"NEXT_PUBLIC_API_URL=https://$backendHostname",
|
||||
"NEXT_PUBLIC_BACKEND_HOST=$backendHostname",
|
||||
"NEXT_PUBLIC_BACKEND_PROTOCOL=https"
|
||||
)
|
||||
|
||||
# Existierende Konfigurationen aktualisieren
|
||||
foreach ($config in $sslConfigs) {
|
||||
$key = $config.Split('=')[0]
|
||||
$regex = "(?m)^$key=.*$"
|
||||
|
||||
if ($envContent -match $regex) {
|
||||
# Update existierende Konfiguration
|
||||
$envContent = $envContent -replace $regex, $config
|
||||
} else {
|
||||
# Neue Konfiguration hinzufügen
|
||||
$envContent += "`n$config"
|
||||
}
|
||||
}
|
||||
|
||||
# Speichern der aktualisierten Umgebungsvariablen
|
||||
$envContent | Out-File -FilePath $envLocalPath -Encoding utf8
|
||||
Write-Host ".env.local Datei mit SSL-Konfigurationen aktualisiert." -ForegroundColor $colors.Success
|
||||
}
|
||||
|
||||
Write-Host ""
|
||||
Write-Host "SSL-Zertifikate wurden in folgenden Pfaden gespeichert:" -ForegroundColor $colors.Info
|
||||
Write-Host "Backend: $backendCertFile" -ForegroundColor $colors.Command
|
||||
@@ -396,6 +456,21 @@ function Setup-Environment {
|
||||
Write-Host "Node.js oder npm ist nicht installiert. Frontend-Abhängigkeiten werden übersprungen." -ForegroundColor $colors.Warning
|
||||
}
|
||||
|
||||
# Docker-Compose Datei aktualisieren
|
||||
$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 $colors.Success
|
||||
} else {
|
||||
Write-Host "Docker-Compose-Datei ist bereits korrekt konfiguriert." -ForegroundColor $colors.Success
|
||||
}
|
||||
}
|
||||
|
||||
Write-Host ""
|
||||
Write-Host "Umgebungs-Setup abgeschlossen!" -ForegroundColor $colors.Success
|
||||
|
||||
@@ -461,6 +536,50 @@ function Start-Application {
|
||||
$null = $Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
|
||||
}
|
||||
|
||||
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"
|
||||
)
|
||||
|
||||
Write-Host "Folgende Skripte werden gelöscht:" -ForegroundColor $colors.Info
|
||||
foreach ($script in $oldScripts) {
|
||||
if (Test-Path $script) {
|
||||
Write-Host " - $script" -ForegroundColor $colors.Command
|
||||
}
|
||||
}
|
||||
|
||||
Write-Host ""
|
||||
$confirm = Read-Host "Möchten Sie fortfahren? (j/n, Standard: j)"
|
||||
|
||||
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 {
|
||||
Write-Host "✗ Fehler beim Löschen von $script: $_" -ForegroundColor $colors.Error
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Write-Host ""
|
||||
Write-Host "Bereinigung abgeschlossen." -ForegroundColor $colors.Success
|
||||
} else {
|
||||
Write-Host "Bereinigung abgebrochen." -ForegroundColor $colors.Warning
|
||||
}
|
||||
|
||||
Write-Host ""
|
||||
Write-Host "Drücken Sie eine beliebige Taste, um fortzufahren..."
|
||||
$null = $Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
|
||||
}
|
||||
|
||||
# Hauptmenü anzeigen
|
||||
function Show-MainMenu {
|
||||
Show-Header "Hauptmenü"
|
||||
@@ -470,9 +589,10 @@ function Show-MainMenu {
|
||||
Write-Host "3. SSL-Zertifikate erstellen" -ForegroundColor $colors.Command
|
||||
Write-Host "4. Umgebung einrichten (Abhängigkeiten installieren)" -ForegroundColor $colors.Command
|
||||
Write-Host "5. Anwendung starten" -ForegroundColor $colors.Command
|
||||
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-5, Q): " -ForegroundColor $colors.Info -NoNewline
|
||||
Write-Host "Wählen Sie eine Option (1-6, Q): " -ForegroundColor $colors.Info -NoNewline
|
||||
|
||||
$choice = Read-Host
|
||||
|
||||
@@ -500,6 +620,10 @@ function Show-MainMenu {
|
||||
Start-Application
|
||||
Show-MainMenu
|
||||
}
|
||||
"6" {
|
||||
Clean-OldScripts
|
||||
Show-MainMenu
|
||||
}
|
||||
"Q" {
|
||||
exit
|
||||
}
|
||||
|
1
myp_installer.sh
Normal file
1
myp_installer.sh
Normal file
@@ -0,0 +1 @@
|
||||
|
Reference in New Issue
Block a user