Skip to content

Commit e85b9f9

Browse files
committed
Added fallback mechanism for latest version lookup
#155
1 parent 6bcd4bf commit e85b9f9

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

bedrock-entry.sh

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,27 +42,35 @@ case ${VERSION^^} in
4242
LATEST)
4343
echo "Looking up latest version..."
4444
for a in data-platform ; do
45-
for i in {1..5}; do
45+
for i in {1..3}; do
4646
DOWNLOAD_URL=$(restify --user-agent=itzg/minecraft-bedrock-server --headers "accept-language:*" --attribute=${a}=serverBedrockLinux ${downloadPage} 2> restify.err | jq -r '.[0].href' || echo '')
4747
if [[ ${DOWNLOAD_URL} ]]; then
4848
break 2
4949
fi
5050
sleep 1
5151
done
5252
done
53+
if [[ -z ${DOWNLOAD_URL} ]]; then
54+
DOWNLOAD_URL=$(curl -s https://mc-bds-helper.vercel.app/api/latest)
55+
fi
56+
5357
if [[ ${DOWNLOAD_URL} =~ http.*/.*-(.*)\.zip ]]; then
5458
VERSION=${BASH_REMATCH[1]}
5559
elif [[ $(ls -rv bedrock_server-* 2> /dev/null|head -1) =~ bedrock_server-(.*) ]]; then
5660
VERSION=${BASH_REMATCH[1]}
5761
echo "WARN Minecraft download page failed, so using existing download of $VERSION"
5862
cat restify.err
5963
else
60-
echo "Failed to extract download URL '${DOWNLOAD_URL}' from ${downloadPage}"
61-
cat restify.err
62-
rm restify.err
64+
if [[ -f restify.err ]]; then
65+
echo "Failed to extract download URL '${DOWNLOAD_URL}' from ${downloadPage}"
66+
cat restify.err
67+
rm restify.err
68+
else
69+
echo "Failed to lookup download URL: ${DOWNLOAD_URL}"
70+
fi
6371
exit 2
6472
fi
65-
rm restify.err
73+
rm -f restify.err
6674
;;
6775
*)
6876
# use the given version exactly

0 commit comments

Comments
 (0)