diff --git a/README.md b/README.md index 0568238..ab89c7f 100644 --- a/README.md +++ b/README.md @@ -43,6 +43,8 @@ For Minecraft Java Edition you'll need to use this image instead: 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`. - `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 diff --git a/bedrock-entry.sh b/bedrock-entry.sh index 9335500..a166411 100755 --- a/bedrock-entry.sh +++ b/bedrock-entry.sh @@ -81,26 +81,44 @@ if [[ ${EULA^^} != TRUE ]]; then exit 1 fi -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}" +# Check for DIRECT_DOWNLOAD_URL override first +if [[ -n "${DIRECT_DOWNLOAD_URL}" ]]; then + echo "Using direct download URL from DIRECT_DOWNLOAD_URL environment variable." + DOWNLOAD_URL="${DIRECT_DOWNLOAD_URL}" + # If VERSION is not explicitly set, try to extract it from the URL + if [[ -z "${VERSION}" ]]; then + if [[ "${DOWNLOAD_URL}" =~ bedrock-server-([0-9\.]+)\.zip ]]; then + VERSION=${BASH_REMATCH[1]} + echo "Extracted VERSION=${VERSION} from DIRECT_DOWNLOAD_URL." else - echo "Using given version ${VERSION}" - lookupVersion serverBedrockLinux "${VERSION}" + echo "WARNING: Could not extract VERSION from DIRECT_DOWNLOAD_URL. Please ensure VERSION environment variable is set." + # Optionally exit here if VERSION is strictly required, but for testing, often the test will fail later. fi - ;; -esac + else + 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