Add DIRECT_DOWNLOAD_URL environment variable (#523)

This commit is contained in:
meek2100 authored and GitHub committed 2025-06-12 20:14:00 -05:00
1 parent 25ce8187be
commit de15d694e5
2 files changed
+38 -18

No files matched your search

+2
View File
@@ -43,6 +43,8 @@ For Minecraft Java Edition you'll need to use this image instead:
bedrock server process bedrock server process
- `TZ` (no default): can be set to a specific timezone like `America/New_York`. This will set the timezone for the Docker container and therefore their logs. Addtionally, if you want to sync the time with the host, you can mount the `/etc/localtime` file from the host to the container like `/etc/localtime:/etc/localtime:ro`. - `TZ` (no default): can be set to a specific timezone like `America/New_York`. This will set the timezone for the Docker container and therefore their logs. Addtionally, if you want to sync the time with the host, you can mount the `/etc/localtime` file from the host to the container like `/etc/localtime:/etc/localtime:ro`.
- `PACKAGE_BACKUP_KEEP` (`2`) : how many package backups to keep - `PACKAGE_BACKUP_KEEP` (`2`) : how many package backups to keep
- `DIRECT_DOWNLOAD_URL` (no default): This environment variable can be used to provide a **direct download URL** for the Minecraft Bedrock server `.zip` file. When set, this URL will be used instead of attempting to automatically look up the download link from `minecraft.net`. This is particularly useful for CI/CD environments or when the automatic version lookup is temporarily broken due to website changes. Ensure the URL points directly to the `bedrock-server-VERSION.zip` file.
### Server Properties ### Server Properties
+36 -18
View File
@@ -81,26 +81,44 @@ if [[ ${EULA^^} != TRUE ]]; then
exit 1 exit 1
fi fi
case ${VERSION^^} in # Check for DIRECT_DOWNLOAD_URL override first
PREVIEW) if [[ -n "${DIRECT_DOWNLOAD_URL}" ]]; then
echo "Looking up latest preview version..." echo "Using direct download URL from DIRECT_DOWNLOAD_URL environment variable."
lookupVersion serverBedrockPreviewLinux DOWNLOAD_URL="${DIRECT_DOWNLOAD_URL}"
;; # If VERSION is not explicitly set, try to extract it from the URL
LATEST) if [[ -z "${VERSION}" ]]; then
echo "Looking up latest version..." if [[ "${DOWNLOAD_URL}" =~ bedrock-server-([0-9\.]+)\.zip ]]; then
lookupVersion serverBedrockLinux VERSION=${BASH_REMATCH[1]}
;; echo "Extracted VERSION=${VERSION} from DIRECT_DOWNLOAD_URL."
*)
# use the given version exactly
if isTrue "$PREVIEW"; then
echo "Using given preview version ${VERSION}"
lookupVersion serverBedrockPreviewLinux "${VERSION}"
else else
echo "Using given version ${VERSION}" echo "WARNING: Could not extract VERSION from DIRECT_DOWNLOAD_URL. Please ensure VERSION environment variable is set."
lookupVersion serverBedrockLinux "${VERSION}" # Optionally exit here if VERSION is strictly required, but for testing, often the test will fail later.
fi fi
;; else
esac echo "VERSION=${VERSION} is explicitly set, using it with DIRECT_DOWNLOAD_URL."
fi
else # Original logic: if DIRECT_DOWNLOAD_URL is NOT set, proceed with lookup
case ${VERSION^^} in
PREVIEW)
echo "Looking up latest preview version..."
lookupVersion serverBedrockPreviewLinux
;;
LATEST)
echo "Looking up latest version..."
lookupVersion serverBedrockLinux
;;
*)
# use the given version exactly
if isTrue "$PREVIEW"; then
echo "Using given preview version ${VERSION}"
lookupVersion serverBedrockPreviewLinux "${VERSION}"
else
echo "Using given version ${VERSION}"
lookupVersion serverBedrockLinux "${VERSION}"
fi
;;
esac
fi
if [[ ! -f "bedrock_server-${VERSION}" ]]; then if [[ ! -f "bedrock_server-${VERSION}" ]]; then