diff --git a/VServerSetup.ps1 b/VServerSetup.ps1 index 4358336..cb29f2b 100644 --- a/VServerSetup.ps1 +++ b/VServerSetup.ps1 @@ -140,19 +140,44 @@ if (Test-Path $winrarPath) { } } -# 4. G-EARTH (nach WinRAR, damit wir entpacken koennen) +# 4. G-EARTH (von Gitea - nach WinRAR, damit wir entpacken koennen) Write-Host "" Write-Host "[4/$totalSteps] G-Earth..." -ForegroundColor Yellow if (Test-Path "$desktopPath\G-Earth") { Write-Host " Bereits vorhanden - ueberspringe." -ForegroundColor Gray } else { - $gearthUrl = "https://streamerware.de/G-earth.rar" - $gearthRar = "$tempDir\G-earth.rar" - if (Download-File -Url $gearthUrl -Output $gearthRar) { - Write-Host " Entpacke G-Earth auf Desktop..." -ForegroundColor Gray - if (Unrar-File -RarPath $gearthRar -DestPath $desktopPath) { - Write-Host " G-Earth installiert!" -ForegroundColor Green + try { + Write-Host " Hole neueste Version von Gitea..." -ForegroundColor Gray + $releaseApi = "https://git.24-music.de/api/v1/repos/Administrator/G-Earth/releases?limit=1" + $wc = New-Object System.Net.WebClient + $wc.Headers.Add("User-Agent", "Mozilla/5.0") + $release = ($wc.DownloadString($releaseApi) | ConvertFrom-Json) + $rarAsset = $release[0].assets | Where-Object { $_.name -like "*.rar" } | Select-Object -First 1 + if ($rarAsset) { + $gearthRar = "$tempDir\$($rarAsset.name)" + Write-Host " Version: $($release[0].tag_name)" -ForegroundColor Gray + if (Download-File -Url $rarAsset.browser_download_url -Output $gearthRar) { + Write-Host " Entpacke G-Earth auf Desktop..." -ForegroundColor Gray + # In temp entpacken, dann nach G-Earth umbenennen (RAR-Ordnername aendert sich je Version) + $gearthTemp = "$tempDir\G-Earth-extract" + New-Item -ItemType Directory -Force -Path $gearthTemp | Out-Null + if (Unrar-File -RarPath $gearthRar -DestPath $gearthTemp) { + # Finde den entpackten Ordner (z.B. "G-Earth 1.5.4") + $extracted = Get-ChildItem -Path $gearthTemp -Directory | Where-Object { $_.Name -like "G-Earth*" } | Select-Object -First 1 + if ($extracted) { + Move-Item -Path $extracted.FullName -Destination "$desktopPath\G-Earth" -Force + } else { + # Falls die Dateien direkt im Ordner liegen + Move-Item -Path $gearthTemp -Destination "$desktopPath\G-Earth" -Force + } + Write-Host " G-Earth installiert!" -ForegroundColor Green + } + } + } else { + Write-Host " FEHLER: Kein .rar-Asset im Release gefunden" -ForegroundColor Red } + } catch { + Write-Host " FEHLER beim Abrufen der Gitea-Release: $_" -ForegroundColor Red } }