From 2cabd4f2ee1cfadbe142bbafdd9b11a2a03ea1e0 Mon Sep 17 00:00:00 2001 From: Tom Abnett Date: Mon, 4 Jan 2021 21:44:45 +0000 Subject: [PATCH] Issues with downloading new server version - suggested fix (#126) * Sort existing server versions reverse numerically * Display restify's stderr on failed download with existing servers * Add retries Fixes #123 --- bedrock-entry.sh | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/bedrock-entry.sh b/bedrock-entry.sh index 802bf13..fa595ab 100755 --- a/bedrock-entry.sh +++ b/bedrock-entry.sh @@ -40,16 +40,19 @@ case ${VERSION^^} in ;; LATEST) for a in data-bi-prtid data-platform; do - DOWNLOAD_URL=$(restify --attribute=${a}=serverBedrockLinux ${downloadPage} 2> restify.err | jq -r '.[0].href' || echo '') - if [[ ${DOWNLOAD_URL} ]]; then - break - fi + for i in {1..3}; do + DOWNLOAD_URL=$(restify --attribute=${a}=serverBedrockLinux ${downloadPage} 2> restify.err | jq -r '.[0].href' || echo '') + if [[ ${DOWNLOAD_URL} ]]; then + break 2 + fi + done done if [[ ${DOWNLOAD_URL} =~ http.*/.*-(.*)\.zip ]]; then VERSION=${BASH_REMATCH[1]} - elif [[ $(ls bedrock_server-* 2> /dev/null|head -1) =~ bedrock_server-(.*) ]]; then + elif [[ $(ls -rv bedrock_server-* 2> /dev/null|head -1) =~ bedrock_server-(.*) ]]; then VERSION=${BASH_REMATCH[1]} echo "WARN Minecraft download page failed, so using existing download of $VERSION" + cat restify.err else echo "Failed to extract download URL '${DOWNLOAD_URL}' from ${downloadPage}" cat restify.err