From 68fa2d6fbf3e50a9699809b729cdfa11e9ac0e1a Mon Sep 17 00:00:00 2001 From: Geoff Bourne Date: Sun, 12 Jun 2022 12:29:09 -0500 Subject: [PATCH] Download bedrock zip into temp directory under /data (#251) --- bedrock-entry.sh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/bedrock-entry.sh b/bedrock-entry.sh index 3a343ba..5a5d175 100755 --- a/bedrock-entry.sh +++ b/bedrock-entry.sh @@ -2,10 +2,13 @@ set -eo pipefail +: "${TMP_DIR:=/data/tmp}" + if [[ ${DEBUG^^} = TRUE ]]; then set -x curlArgs=(-v) echo "DEBUG: running as $(id -a) with $(ls -ld /data)" + echo " current directory is $(pwd)" fi downloadPage=https://www.minecraft.net/en-us/download/server/bedrock @@ -84,7 +87,8 @@ if [ ! -f "bedrock_server-${VERSION}" ]; then DOWNLOAD_URL=https://minecraft.azureedge.net/bin-linux/bedrock-server-${VERSION}.zip fi - TMP_ZIP=/tmp/$(basename "${DOWNLOAD_URL}") + [[ $TMP_DIR != /tmp ]] && mkdir -p "$TMP_DIR" + TMP_ZIP="$TMP_DIR/$(basename "${DOWNLOAD_URL}")" echo "Downloading Bedrock server version ${VERSION} ..." if ! curl "${curlArgs[@]}" -o ${TMP_ZIP} -fsSL ${DOWNLOAD_URL}; then @@ -120,7 +124,7 @@ if [ ! -f "bedrock_server-${VERSION}" ]; then # Do not overwrite existing files, which means the cleanup above needs to account for things # that MUST be replaced on upgrade unzip -q -n ${TMP_ZIP} - rm ${TMP_ZIP} + [[ $TMP_DIR != /tmp ]] && rm -rf "$TMP_DIR" chmod +x bedrock_server mv bedrock_server bedrock_server-${VERSION}