mirror of
https://github.com/itzg/docker-minecraft-server.git
synced 2026-07-26 02:14:53 +00:00
Implement GTNH daily build support (#4190)
Co-authored-by: SgtMate <SgtMate@users.noreply.github.com>
This commit is contained in:
co-authored by
SgtMate
parent
99d4481c01
commit
0459532398
+92
-29
@@ -7,11 +7,13 @@
|
||||
function getGTNHdownloadPath(){
|
||||
gtnh_download_path=""
|
||||
local release_object=""
|
||||
local current_java_version=""
|
||||
current_java_version=$(mc-image-helper java-release)
|
||||
|
||||
# Select release JSON object
|
||||
if [ "$GTNH_PACK_VERSION" == "latest-dev" ]; then
|
||||
# latest-dev will be removed in the future, but is still supported for now.
|
||||
if [ "$GTNH_PACK_VERSION" == "latest-dev" ] || [ "$GTNH_PACK_VERSION" == "latest-beta" ]; then
|
||||
if [ "$GTNH_PACK_VERSION" == "latest-dev" ]; then
|
||||
logWarning "GTNH_PACK_VERSION=latest-dev is deprecated and will be removed in the future."
|
||||
fi
|
||||
if ! release_object="$(
|
||||
curl -fsSL "https://downloads.gtnewhorizons.com/versions.json" \
|
||||
| jq -r '(.versions // .)|to_entries|sort_by(.value.releaseDate)|map(select(.value.title=="Beta release"))|.[-1]'
|
||||
@@ -46,23 +48,18 @@ function getGTNHdownloadPath(){
|
||||
fi
|
||||
|
||||
# Select compatible server files for java version
|
||||
if (( current_java_version == 8 )); then
|
||||
if (( java_version == 8 )); then
|
||||
gtnh_download_path=$(jq -r '.value.server.java8Url' <<< "$release_object")
|
||||
log "Use GTNH Server Java 8 release."
|
||||
|
||||
elif (( current_java_version >= 17 )); then
|
||||
if (( current_java_version > $(jq '.value.maxJavaVersion' <<< "$release_object") )); then
|
||||
logError "Container Java version $current_java_version is not supported by GTNH. Try an older release."
|
||||
elif (( java_version >= 17 )); then
|
||||
if (( java_version > $(jq '.value.maxJavaVersion' <<< "$release_object") )); then
|
||||
logError "Container Java version $java_version is not supported by GTNH. Try an older release."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
gtnh_download_path=$(jq -r '.value.server.java17_2XUrl' <<< "$release_object")
|
||||
log "Use GTNH Server Java 17+ release."
|
||||
|
||||
else
|
||||
logError "Container Java version $current_java_version is not supported by GTNH."
|
||||
exit 1
|
||||
|
||||
fi
|
||||
|
||||
if [[ -z $gtnh_download_path ]]; then
|
||||
@@ -73,6 +70,56 @@ function getGTNHdownloadPath(){
|
||||
|
||||
}
|
||||
|
||||
function getGTNHdownloadOptions(){
|
||||
# Used for GTNH daily build downloads, to pass additional options to the download command.
|
||||
gtnh_download_options=()
|
||||
# Used for dryrun check
|
||||
gtnh_download_path=""
|
||||
|
||||
# Check if GH_TOKEN is set for daily builds
|
||||
if [ -z "$GH_TOKEN" ]; then
|
||||
logError "GH_TOKEN environment variable must be set to use daily builds."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
gtnh_download_options+=( --output-filename )
|
||||
|
||||
# prepare download options as an array to safely append patterns
|
||||
if [ "$GTNH_PACK_VERSION" == "latest" ] || [ "$GTNH_PACK_VERSION" == "latest-dev" ]; then
|
||||
if [ "$GTNH_PACK_VERSION" == "latest-dev" ]; then
|
||||
logWarning "GTNH_PACK_VERSION=latest-dev is deprecated and will be removed in the future."
|
||||
fi
|
||||
gtnh_download_options+=( --workflow=daily-modpack-build.yml )
|
||||
log "Using latest daily build for GTNH server files."
|
||||
elif [ "$GTNH_PACK_VERSION" == "latest-beta" ]; then
|
||||
gtnh_download_options+=( --workflow=daily-modpack-build.yml )
|
||||
logWarning "Using daily build instead of latest beta release for GTNH server files. If this is not intended, set GTNH_USE_DAILY_BUILD=false to use the latest beta release instead."
|
||||
else
|
||||
gtnh_download_options+=( --run-id="$GTNH_PACK_VERSION" )
|
||||
log "Using specific daily build run ID $GTNH_PACK_VERSION for GTNH server files."
|
||||
fi
|
||||
|
||||
# Select compatible server files for java version
|
||||
if (( java_version == 8 )); then
|
||||
log "Use GTNH Server Java 8 release."
|
||||
gtnh_download_options+=( --artifact-pattern='GTNH-daily-\d{4}-\d{2}-\d{2}\+\d+-server-java8\.zip' )
|
||||
|
||||
elif (( java_version >= 17 )); then
|
||||
log "Use GTNH Server Java 17+ release."
|
||||
gtnh_download_options+=( --artifact-pattern='GTNH-daily-\d{4}-\d{2}-\d{2}\+\d+-server-java17-\d{2}\.zip' )
|
||||
fi
|
||||
|
||||
debug "GTNH daily build download options: ${gtnh_download_options[*]}"
|
||||
|
||||
if ! gtnh_download_path=$(mc-image-helper github download-artifact --no-download "${gtnh_download_options[@]}" GTNewHorizons/DreamAssemblerXXL); then
|
||||
logError "Failed to find a matching daily build for GTNH server files with the specified options."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
debug "GTNH daily build download path: $gtnh_download_path"
|
||||
|
||||
}
|
||||
|
||||
function deleteGTNHbackup(){
|
||||
log "Start deleting all config backups"
|
||||
if ! find . -maxdepth 1 -type d -name 'gtnh-upgrade-*' -exec rm -rf {} + ; then
|
||||
@@ -81,24 +128,33 @@ function deleteGTNHbackup(){
|
||||
}
|
||||
|
||||
function downloadGTNH(){
|
||||
local gtnh_download=""
|
||||
gtnh_download=""
|
||||
base_dir=/data/.tmp/gtnh_base
|
||||
|
||||
debug "Creating temporary /data/.tmp/packs folder for GTNH download"
|
||||
mkdir -p /data/.tmp/packs
|
||||
trap 'rm -rf /data/.tmp' EXIT
|
||||
|
||||
log "Downloading $gtnh_download_path."
|
||||
if ! gtnh_download=$(mc-image-helper get -o /data/.tmp/packs --output-filename --skip-up-to-date "$gtnh_download_path"); then
|
||||
logError "Failed to download $gtnh_download_path"
|
||||
exit 1
|
||||
fi
|
||||
debug "Downloaded GTNH server files to $gtnh_download"
|
||||
|
||||
# Unpacking Server files into temporary directory
|
||||
log "Unpacking Server Files into $base_dir"
|
||||
mkdir -p "${base_dir}"
|
||||
extract "${gtnh_download}" "${base_dir}"
|
||||
|
||||
if isTrue "$GTNH_USE_DAILY_BUILD"; then
|
||||
log "Downloading Daily Build for GTNH server files."
|
||||
# gtnh_download_options is injecting download parameters -> (--workflow or --run-id) and --artifact-pattern
|
||||
if ! gtnh_download=$(mc-image-helper github download-artifact -o=$base_dir --unzip "${gtnh_download_options[@]}" GTNewHorizons/DreamAssemblerXXL); then
|
||||
logError "Failed to download Daily Build for GTNH server files."
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
log "Downloading $gtnh_download_path."
|
||||
if ! gtnh_download=$(mc-image-helper get -o /data/.tmp/packs --output-filename --skip-up-to-date "$gtnh_download_path"); then
|
||||
logError "Failed to download $gtnh_download_path"
|
||||
exit 1
|
||||
fi
|
||||
debug "Downloaded GTNH server files to $gtnh_download"
|
||||
|
||||
# Unpacking Server files into temporary directory
|
||||
log "Unpacking Server Files into $base_dir"
|
||||
extract "${gtnh_download}" "${base_dir}"
|
||||
fi
|
||||
|
||||
# Remove any eula file since container manages it
|
||||
debug "Removing eula.txt from $base_dir"
|
||||
@@ -209,16 +265,23 @@ function handleGTNH() {
|
||||
: "${GTNH_PACK_VERSION:=latest}"
|
||||
: "${GTNH_DELETE_BACKUPS:=false}"
|
||||
: "${SKIP_GTNH_UPDATE_CHECK:=false}"
|
||||
debug "GTNH VAR CHECK: GTNH_DELETE_BACKUPS=$GTNH_DELETE_BACKUPS, GTNH_PACK_VERSION=$GTNH_PACK_VERSION, TYPE=$TYPE, SKIP_GTNH_UPDATE_CHECK=$SKIP_GTNH_UPDATE_CHECK"
|
||||
: "${GTNH_USE_DAILY_BUILD:=false}"
|
||||
|
||||
debug "GTNH VAR CHECK: GTNH_DELETE_BACKUPS=$GTNH_DELETE_BACKUPS, GTNH_PACK_VERSION=$GTNH_PACK_VERSION, TYPE=$TYPE, SKIP_GTNH_UPDATE_CHECK=$SKIP_GTNH_UPDATE_CHECK, GTNH_USE_DAILY_BUILD=$GTNH_USE_DAILY_BUILD"
|
||||
|
||||
if isTrue "$GTNH_DELETE_BACKUPS"; then
|
||||
deleteGTNHbackup
|
||||
fi
|
||||
|
||||
if [[ -n "$GTNH_PACK_VERSION" ]] && isFalse "$SKIP_GTNH_UPDATE_CHECK" ; then
|
||||
if [[ -n "$GTNH_PACK_VERSION" ]] && isFalse "$SKIP_GTNH_UPDATE_CHECK"; then
|
||||
|
||||
getGTNHdownloadPath
|
||||
log "Server files located! Will proceed update $gtnh_download_path."
|
||||
if isFalse "$GTNH_USE_DAILY_BUILD"; then
|
||||
getGTNHdownloadPath
|
||||
log "Server files located! Will proceed update $gtnh_download_path."
|
||||
else
|
||||
getGTNHdownloadOptions
|
||||
log "Will proceed update with daily build options: ${gtnh_download_options[*]}."
|
||||
fi
|
||||
|
||||
|
||||
# Decide if update or install is needed or not.
|
||||
@@ -239,7 +302,7 @@ function handleGTNH() {
|
||||
fi
|
||||
|
||||
# Update .gtnh-version
|
||||
basename "$gtnh_download_path" > /data/.gtnh-version
|
||||
basename "$gtnh_download" > /data/.gtnh-version
|
||||
|
||||
# Cleaning up temporary files
|
||||
rm -rf /data/.tmp
|
||||
|
||||
Reference in New Issue
Block a user