Skip to content

Commit 17ddaf5

Browse files
committed
Hytale: reinstate downloader creds error handling
1 parent 0ea18bb commit 17ddaf5

3 files changed

Lines changed: 5 additions & 5 deletions

File tree

hytale.kvp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ Meta.Prerequisites=[]
2121
Meta.ExtraContainerPackages=[]
2222
Meta.ConfigReleaseState=NotSpecified
2323
Meta.NoCommercialUsage=False
24-
Meta.ConfigVersion=16
24+
Meta.ConfigVersion=17
2525
Meta.ReleaseNotes=
2626
Meta.BreakingReleaseNotes=
2727
Meta.AppConfigId=36d2e805-a54d-4a40-acc9-c101c720ae05

hytaledownloaderscript.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ fi
246246

247247
echo "downloading latest (\"$PATCHLINE\" patchline) to \"$FILENAME\""
248248

249-
curl --progress-bar -o "$FILENAME" -X GET $ZIP_DOWNLOAD_URL
249+
curl --progress-bar --stderr /dev/stdout -o "$FILENAME" -X GET $ZIP_DOWNLOAD_URL
250250

251251
echo validating checksum...
252252
if ! shasum -sc -a 256 <<< "$SHA256 $FILENAME"; then

hytaleupdates.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
"UpdateSourceArch": "x86_64",
3333
"UpdateSource": "Executable",
3434
"UpdateSourceData": "/bin/bash",
35-
"UpdateSourceArgs": "-c \"cd \\\"{{$FullRootDir}}\\\" && chmod +x ./hytale-downloader-linux-amd64 && LatestVersion=$(timeout 5 wget -qO- https://maven.hytale.com/{{ServerBuildChannel}}/com/hypixel/hytale/Server/maven-metadata.xml | sed -n \\\"s/.*<latest>\\(.*\\)<\\/latest>.*/\\1/p\\\"); if [[ -n \\\"$LatestVersion\\\" ]] && [[ ! \\\"$LatestVersion\\\" =~ ^[0-9]{4}\\.[0-9]{2}\\.[0-9]{2}-[a-fA-F0-9]+$ ]]; then if [[ \\\"$LatestVersion\\\" =~ oauth2:\\ (\\\\\\\"invalid_(grant|request)\\\\\\\"|token\\ expired\\ and\\ refresh\\ token\\ is\\ not\\ set) ]] && [[ -f ./.hytale-downloader-credentials.json ]]; then rm -f ./.hytale-downloader-credentials.json; fi; LatestVersion=\\\"\\\"; fi; [[ -f ./Server/.installedversion ]] && { InstalledVersion=\\\"$(cat ./Server/.installedversion 2>/dev/null)\\\"; if [[ \\\"$InstalledVersion\\\" =~ ^[0-9]{4}\\.[0-9]{2}\\.[0-9]{2}-[a-fA-F0-9]+$ ]] && [[ \\\"$InstalledVersion\\\" == \\\"$LatestVersion\\\" ]]; then echo \\\"Latest Hytale {{ServerBuildChannel}} version $LatestVersion already installed. Skipping\\\"; exit 0; fi; }; ./hytale-downloader-linux-amd64 -patchline {{ServerBuildChannel}} -download-path ./server.zip || { echo \\\"Download failed from the Hytale CDN. This is a fault with the CDN or the download, not AMP. Aborting\\\"; exit 1; }; sleep 1 && if [[ -f ./server.zip ]]; then [[ -z \\\"${LatestVersion:-}\\\" ]] && LatestVersion=$(timeout 5 wget -qO- https://maven.hytale.com/{{ServerBuildChannel}}/com/hypixel/hytale/Server/maven-metadata.xml | sed -n \\\"s/.*<latest>\\(.*\\)<\\/latest>.*/\\1/p\\\"); unzip -oq ./server.zip && sleep 1 && printf \\\"%s\\\" \\\"$LatestVersion\\\" > ./Server/.installedversion && rm -f ./server.zip >/dev/null 2>&1; fi\"",
35+
"UpdateSourceArgs": "-c \"cd \\\"{{$FullRootDir}}\\\" && chmod +x ./hytale-downloader-linux-amd64 && LatestVersion=$(timeout 5 wget -qO- https://maven.hytale.com/{{ServerBuildChannel}}/com/hypixel/hytale/Server/maven-metadata.xml | sed -n \\\"s/.*<latest>\\(.*\\)<\\/latest>.*/\\1/p\\\"); if [[ -n \\\"$LatestVersion\\\" ]] && [[ ! \\\"$LatestVersion\\\" =~ ^[0-9]{4}\\.[0-9]{2}\\.[0-9]{2}-[a-fA-F0-9]+$ ]]; then LatestVersion=\\\"\\\"; fi; [[ -f ./Server/.installedversion ]] && { InstalledVersion=\\\"$(cat ./Server/.installedversion 2>/dev/null)\\\"; if [[ \\\"$InstalledVersion\\\" =~ ^[0-9]{4}\\.[0-9]{2}\\.[0-9]{2}-[a-fA-F0-9]+$ ]] && [[ \\\"$InstalledVersion\\\" == \\\"$LatestVersion\\\" ]]; then echo \\\"Latest Hytale {{ServerBuildChannel}} version $LatestVersion already installed. Skipping\\\"; exit 0; fi; }; exec 3>&1; for attempt in 1 2; do err=$(./hytale-downloader-linux-amd64 -patchline {{ServerBuildChannel}} -download-path ./server.zip 2>&1 1>&3) 3>&1; rc=$?; ((rc==0)) && break; ((attempt==1)) && [[ -n \\\"$err\\\" ]] && [[ -f ./.hytale-downloader-credentials.json ]] && rm -f ./.hytale-downloader-credentials.json && continue; break; done; exec 3>&-; ((rc!=0)) && { echo \\\"$err\\\" >&2; echo \\\"Download failed from the Hytale CDN. This is a fault with the CDN or the download, not AMP. Aborting\\\" >&2; exit 1; }; sleep 1 && if [[ -f ./server.zip ]]; then [[ -z \\\"${LatestVersion:-}\\\" ]] && LatestVersion=$(timeout 5 wget -qO- https://maven.hytale.com/{{ServerBuildChannel}}/com/hypixel/hytale/Server/maven-metadata.xml | sed -n \\\"s/.*<latest>\\(.*\\)<\\/latest>.*/\\1/p\\\"); unzip -oq ./server.zip && sleep 1 && printf \\\"%s\\\" \\\"$LatestVersion\\\" > ./Server/.installedversion && rm -f ./server.zip >/dev/null 2>&1; fi\"",
3636
"UpdateSourceConditionSetting": "disable-server-download",
3737
"UpdateSourceConditionValue": "false",
3838
"ProcessToolOutput": true,
@@ -44,7 +44,7 @@
4444
"UpdateSourceArch": "aarch64",
4545
"UpdateSource": "Executable",
4646
"UpdateSourceData": "/bin/bash",
47-
"UpdateSourceArgs": "-c \"cd \\\"{{$FullRootDir}}\\\" && chmod +x ./hytale-downloader-linux-arm64.sh && LatestVersion=$(timeout 5 wget -qO- https://maven.hytale.com/{{ServerBuildChannel}}/com/hypixel/hytale/Server/maven-metadata.xml | sed -n \\\"s/.*<latest>\\(.*\\)<\\/latest>.*/\\1/p\\\"); if [[ -n \\\"$LatestVersion\\\" ]] && [[ ! \\\"$LatestVersion\\\" =~ ^[0-9]{4}\\.[0-9]{2}\\.[0-9]{2}-[a-fA-F0-9]+$ ]]; then if [[ \\\"$LatestVersion\\\" =~ oauth2:\\ (\\\\\\\"invalid_(grant|request)\\\\\\\"|token\\ expired\\ and\\ refresh\\ token\\ is\\ not\\ set) ]] && [[ -f ./.hytale-downloader-credentials.json ]]; then rm -f ./.hytale-downloader-credentials.json; fi; LatestVersion=\\\"\\\"; fi; [[ -f ./Server/.installedversion ]] && { InstalledVersion=\\\"$(cat ./Server/.installedversion 2>/dev/null)\\\"; if [[ \\\"$InstalledVersion\\\" =~ ^[0-9]{4}\\.[0-9]{2}\\.[0-9]{2}-[a-fA-F0-9]+$ ]] && [[ \\\"$InstalledVersion\\\" == \\\"$LatestVersion\\\" ]]; then echo \\\"Latest Hytale {{ServerBuildChannel}} version $LatestVersion already installed. Skipping\\\"; exit 0; fi; }; ./hytale-downloader-linux-arm64.sh -patchline {{ServerBuildChannel}} -download-path ./server.zip || { echo \\\"Download failed from the Hytale CDN. This is a fault with the CDN or the download, not AMP. Aborting\\\"; exit 1; }; sleep 1 && if [[ -f ./server.zip ]]; then [[ -z \\\"${LatestVersion:-}\\\" ]] && LatestVersion=$(timeout 5 wget -qO- https://maven.hytale.com/{{ServerBuildChannel}}/com/hypixel/hytale/Server/maven-metadata.xml | sed -n \\\"s/.*<latest>\\(.*\\)<\\/latest>.*/\\1/p\\\"); unzip -oq ./server.zip && sleep 1 && printf \\\"%s\\\" \\\"$LatestVersion\\\" > ./Server/.installedversion && rm -f ./server.zip >/dev/null 2>&1; fi\"",
47+
"UpdateSourceArgs": "-c \"cd \\\"{{$FullRootDir}}\\\" && chmod +x ./hytale-downloader-linux-arm64.sh && LatestVersion=$(timeout 5 wget -qO- https://maven.hytale.com/{{ServerBuildChannel}}/com/hypixel/hytale/Server/maven-metadata.xml | sed -n \\\"s/.*<latest>\\(.*\\)<\\/latest>.*/\\1/p\\\"); if [[ -n \\\"$LatestVersion\\\" ]] && [[ ! \\\"$LatestVersion\\\" =~ ^[0-9]{4}\\.[0-9]{2}\\.[0-9]{2}-[a-fA-F0-9]+$ ]]; then LatestVersion=\\\"\\\"; fi; [[ -f ./Server/.installedversion ]] && { InstalledVersion=\\\"$(cat ./Server/.installedversion 2>/dev/null)\\\"; if [[ \\\"$InstalledVersion\\\" =~ ^[0-9]{4}\\.[0-9]{2}\\.[0-9]{2}-[a-fA-F0-9]+$ ]] && [[ \\\"$InstalledVersion\\\" == \\\"$LatestVersion\\\" ]]; then echo \\\"Latest Hytale {{ServerBuildChannel}} version $LatestVersion already installed. Skipping\\\"; exit 0; fi; }; exec 3>&1; for attempt in 1 2; do err=$(./hytale-downloader-linux-arm64.sh -patchline {{ServerBuildChannel}} -download-path ./server.zip 2>&1 1>&3) 3>&1; rc=$?; ((rc==0)) && break; ((attempt==1)) && [[ -n \\\"$err\\\" ]] && [[ -f ./.hytale-downloader-credentials.json ]] && rm -f ./.hytale-downloader-credentials.json && continue; break; done; exec 3>&-; ((rc!=0)) && { echo \\\"$err\\\" >&2; echo \\\"Download failed from the Hytale CDN. This is a fault with the CDN or the download, not AMP. Aborting\\\" >&2; exit 1; }; sleep 1 && if [[ -f ./server.zip ]]; then [[ -z \\\"${LatestVersion:-}\\\" ]] && LatestVersion=$(timeout 5 wget -qO- https://maven.hytale.com/{{ServerBuildChannel}}/com/hypixel/hytale/Server/maven-metadata.xml | sed -n \\\"s/.*<latest>\\(.*\\)<\\/latest>.*/\\1/p\\\"); unzip -oq ./server.zip && sleep 1 && printf \\\"%s\\\" \\\"$LatestVersion\\\" > ./Server/.installedversion && rm -f ./server.zip >/dev/null 2>&1; fi\"",
4848
"UpdateSourceConditionSetting": "disable-server-download",
4949
"UpdateSourceConditionValue": "false",
5050
"ProcessToolOutput": true,
@@ -55,7 +55,7 @@
5555
"UpdateSourcePlatform": "Windows",
5656
"UpdateSource": "Executable",
5757
"UpdateSourceData": "powershell.exe",
58-
"UpdateSourceArgs": "-NoProfile -Command \"$ProgressPreference='SilentlyContinue'; [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; Set-Location -Path '{{$FullRootDir}}'; $LatestVersion = (Invoke-RestMethod -UseBasicParsing -TimeoutSec 5 -ErrorAction Stop https://maven.hytale.com/{{ServerBuildChannel}}/com/hypixel/hytale/Server/maven-metadata.xml).metadata.versioning.latest; if (-not [string]::IsNullOrEmpty($LatestVersion) -and $LatestVersion -notmatch '^[0-9]{4}\\.[0-9]{2}\\.[0-9]{2}-[a-fA-F0-9]+$') { if ($LatestVersion -match 'oauth2: (\\\"invalid_(request|grant)\\\"|token expired and refresh token is not set)' -and (Test-Path -LiteralPath './.hytale-downloader-credentials.json' -PathType Leaf)) { Remove-Item -LiteralPath './.hytale-downloader-credentials.json' -Force -ErrorAction SilentlyContinue *> $null }; $LatestVersion = '' }; if (Test-Path -LiteralPath './Server/.installedversion' -PathType Leaf) { $InstalledVersion = Get-Content -LiteralPath './Server/.installedversion' -Raw -ErrorAction SilentlyContinue; if ($InstalledVersion -match '^[0-9]{4}\\.[0-9]{2}\\.[0-9]{2}-[a-fA-F0-9]+$' -and $InstalledVersion -eq $LatestVersion) { Write-Output \\\"Latest Hytale {{ServerBuildChannel}} version $LatestVersion already installed. Skipping\\\"; exit 0 } }; try { & ./hytale-downloader-windows-amd64.exe -patchline {{ServerBuildChannel}} -download-path ./server.zip } catch { Write-Output \\\"Download failed from the Hytale CDN. This is a fault with the CDN or the download, not AMP. Aborting\\\"; exit 1; }; Start-Sleep -Seconds 1; if (Test-Path -LiteralPath './server.zip' -PathType Leaf) { if ([string]::IsNullOrEmpty($LatestVersion)) { $LatestVersion = (Invoke-RestMethod -UseBasicParsing -TimeoutSec 5 -ErrorAction Stop https://maven.hytale.com/{{ServerBuildChannel}}/com/hypixel/hytale/Server/maven-metadata.xml).metadata.versioning.latest }; Expand-Archive -LiteralPath ./server.zip -DestinationPath . -Force 2> $null; Start-Sleep -Seconds 1; Set-Content -LiteralPath './Server/.installedversion' -Value $LatestVersion -Encoding UTF8 -NoNewline -Force; Remove-Item -LiteralPath ./server.zip -Force -ErrorAction SilentlyContinue *> $null }\"",
58+
"UpdateSourceArgs": "-NoProfile -Command \"$ProgressPreference='SilentlyContinue'; [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; Set-Location -Path '{{$FullRootDir}}'; $LatestVersion = (Invoke-RestMethod -UseBasicParsing -TimeoutSec 5 -ErrorAction Stop https://maven.hytale.com/{{ServerBuildChannel}}/com/hypixel/hytale/Server/maven-metadata.xml).metadata.versioning.latest; if (-not [string]::IsNullOrEmpty($LatestVersion) -and $LatestVersion -notmatch '^[0-9]{4}\\.[0-9]{2}\\.[0-9]{2}-[a-fA-F0-9]+$') { $LatestVersion = '' }; if (Test-Path -LiteralPath './Server/.installedversion' -PathType Leaf) { $InstalledVersion = Get-Content -LiteralPath './Server/.installedversion' -Raw -ErrorAction SilentlyContinue; if ($InstalledVersion -match '^[0-9]{4}\\.[0-9]{2}\\.[0-9]{2}-[a-fA-F0-9]+$' -and $InstalledVersion -eq $LatestVersion) { Write-Output \\\"Latest Hytale {{ServerBuildChannel}} version $LatestVersion already installed. Skipping\\\"; exit 0 } }; $err = ''; $rc = 1; for ($attempt = 1; $attempt -le 2; $attempt++) { $tmp = Join-Path $env:TEMP ([IO.Path]::GetRandomFileName()); $p = Start-Process -FilePath './hytale-downloader-windows-amd64.exe' -ArgumentList @('-patchline','{{ServerBuildChannel}}','-download-path','./server.zip') -NoNewWindow -Wait -PassThru -RedirectStandardError $tmp; $rc = $p.ExitCode; $err = (Get-Content -LiteralPath $tmp -Raw -ErrorAction SilentlyContinue); Remove-Item -LiteralPath $tmp -Force -ErrorAction SilentlyContinue *> $null; if ($rc -eq 0) { break }; if ($attempt -eq 1 -and -not [string]::IsNullOrEmpty($err) -and (Test-Path -LiteralPath './.hytale-downloader-credentials.json' -PathType Leaf)) { Remove-Item -LiteralPath './.hytale-downloader-credentials.json' -Force -ErrorAction SilentlyContinue *> $null; continue }; break }; if ($rc -ne 0) { Write-Output \\\"$err\\\"; Write-Output \\\"Download failed from the Hytale CDN. This is a fault with the CDN or the download, not AMP. Aborting\\\"; exit 1 }; Start-Sleep -Seconds 1; if (Test-Path -LiteralPath './server.zip' -PathType Leaf) { if ([string]::IsNullOrEmpty($LatestVersion)) { $LatestVersion = (Invoke-RestMethod -UseBasicParsing -TimeoutSec 5 -ErrorAction Stop https://maven.hytale.com/{{ServerBuildChannel}}/com/hypixel/hytale/Server/maven-metadata.xml).metadata.versioning.latest }; Expand-Archive -LiteralPath ./server.zip -DestinationPath . -Force 2> $null; Start-Sleep -Seconds 1; Set-Content -LiteralPath './Server/.installedversion' -Value $LatestVersion -Encoding UTF8 -NoNewline -Force; Remove-Item -LiteralPath ./server.zip -Force -ErrorAction SilentlyContinue *> $null }\"",
5959
"UpdateSourceConditionSetting": "disable-server-download",
6060
"UpdateSourceConditionValue": "false",
6161
"ProcessToolOutput": true,

0 commit comments

Comments
 (0)