Skip to content

Commit 95952cd

Browse files
authored
DOWNLOAD_LINKS_URL is now configurable and fallback to mc-bds-helper (#531)
1 parent 2fa056e commit 95952cd

File tree

1 file changed

+22
-6
lines changed

1 file changed

+22
-6
lines changed

bedrock-entry.sh

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ set -eo pipefail
44

55
: "${DOWNLOAD_DIR:=${PWD}/.downloads}"
66
: "${PREVIEW:=false}"
7+
# Both net and net-secondary hostnames work
8+
: "${DOWNLOAD_LINKS_URL:=https://net-secondary.web.minecraft-services.net/api/v1.0/download/links}"
79

810
function isTrue() {
911
[[ "${1,,}" =~ ^(true|on|1)$ ]] && return 0
@@ -25,8 +27,8 @@ function lookupVersion() {
2527
platform=${1:?Missing required platform indicator}
2628
customVersion=${2:-}
2729

28-
DOWNLOAD_URL=$(
29-
curl -fsSL "${getUrlPage}" |
30+
if ! DOWNLOAD_URL=$(
31+
curl -fsSL "${DOWNLOAD_LINKS_URL}" |
3032
jq --arg platform "$platform" -rR '
3133
try(fromjson) catch({}) |
3234
.result.links // halt_error(1) |
@@ -45,7 +47,24 @@ function lookupVersion() {
4547
)
4648
end
4749
'
48-
)
50+
); then
51+
case "$platform" in
52+
serverBedrockLinux)
53+
type=latest
54+
;;
55+
serverBedrockPreviewLinux)
56+
type=preview
57+
;;
58+
*)
59+
echo "ERROR invalid platform $platform"
60+
exit 2
61+
esac
62+
63+
if ! DOWNLOAD_URL=$(curl -fsSL "https://mc-bds-helper.vercel.app/api/$type"); then
64+
echo "ERROR failed to lookup Bedrock version and download URL"
65+
exit 1
66+
fi
67+
fi
4968

5069
if [[ -n "${customVersion}" && -n "${DOWNLOAD_URL}" ]]; then
5170
DOWNLOAD_URL=$(replace_version_in_url "${DOWNLOAD_URL}" "${customVersion}")
@@ -73,9 +92,6 @@ fi
7392

7493
export HOME="${PWD}"
7594

76-
# Looks like both net and net-secondary hostnames work
77-
getUrlPage=https://net-secondary.web.minecraft-services.net/api/v1.0/download/links
78-
7995
if [[ ${EULA^^} != TRUE ]]; then
8096
echo
8197
echo "EULA must be set to TRUE to indicate agreement with the Minecraft End User License"

0 commit comments

Comments
 (0)