Skip to content

Commit de15d69

Browse files
authored
Add DIRECT_DOWNLOAD_URL environment variable (#523)
1 parent 25ce818 commit de15d69

File tree

2 files changed

+38
-18
lines changed

2 files changed

+38
-18
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ For Minecraft Java Edition you'll need to use this image instead:
4343
bedrock server process
4444
- `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`.
4545
- `PACKAGE_BACKUP_KEEP` (`2`) : how many package backups to keep
46+
- `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.
47+
4648

4749
### Server Properties
4850

bedrock-entry.sh

Lines changed: 36 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -81,26 +81,44 @@ if [[ ${EULA^^} != TRUE ]]; then
8181
exit 1
8282
fi
8383

84-
case ${VERSION^^} in
85-
PREVIEW)
86-
echo "Looking up latest preview version..."
87-
lookupVersion serverBedrockPreviewLinux
88-
;;
89-
LATEST)
90-
echo "Looking up latest version..."
91-
lookupVersion serverBedrockLinux
92-
;;
93-
*)
94-
# use the given version exactly
95-
if isTrue "$PREVIEW"; then
96-
echo "Using given preview version ${VERSION}"
97-
lookupVersion serverBedrockPreviewLinux "${VERSION}"
84+
# Check for DIRECT_DOWNLOAD_URL override first
85+
if [[ -n "${DIRECT_DOWNLOAD_URL}" ]]; then
86+
echo "Using direct download URL from DIRECT_DOWNLOAD_URL environment variable."
87+
DOWNLOAD_URL="${DIRECT_DOWNLOAD_URL}"
88+
# If VERSION is not explicitly set, try to extract it from the URL
89+
if [[ -z "${VERSION}" ]]; then
90+
if [[ "${DOWNLOAD_URL}" =~ bedrock-server-([0-9\.]+)\.zip ]]; then
91+
VERSION=${BASH_REMATCH[1]}
92+
echo "Extracted VERSION=${VERSION} from DIRECT_DOWNLOAD_URL."
9893
else
99-
echo "Using given version ${VERSION}"
100-
lookupVersion serverBedrockLinux "${VERSION}"
94+
echo "WARNING: Could not extract VERSION from DIRECT_DOWNLOAD_URL. Please ensure VERSION environment variable is set."
95+
# Optionally exit here if VERSION is strictly required, but for testing, often the test will fail later.
10196
fi
102-
;;
103-
esac
97+
else
98+
echo "VERSION=${VERSION} is explicitly set, using it with DIRECT_DOWNLOAD_URL."
99+
fi
100+
else # Original logic: if DIRECT_DOWNLOAD_URL is NOT set, proceed with lookup
101+
case ${VERSION^^} in
102+
PREVIEW)
103+
echo "Looking up latest preview version..."
104+
lookupVersion serverBedrockPreviewLinux
105+
;;
106+
LATEST)
107+
echo "Looking up latest version..."
108+
lookupVersion serverBedrockLinux
109+
;;
110+
*)
111+
# use the given version exactly
112+
if isTrue "$PREVIEW"; then
113+
echo "Using given preview version ${VERSION}"
114+
lookupVersion serverBedrockPreviewLinux "${VERSION}"
115+
else
116+
echo "Using given version ${VERSION}"
117+
lookupVersion serverBedrockLinux "${VERSION}"
118+
fi
119+
;;
120+
esac
121+
fi
104122

105123
if [[ ! -f "bedrock_server-${VERSION}" ]]; then
106124

0 commit comments

Comments
 (0)