feat: add DOWNLOAD_PROGRESS env var to show download progress (#607)
This commit is contained in:
1 parent
9fe61aa011
commit
bd09bdb3d9
2 files changed
+10
-4
No files matched your search
@@ -47,6 +47,7 @@ For Minecraft Java Edition you'll need to use this image instead:
|
||||
- `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`.
|
||||
- `PACKAGE_BACKUP_KEEP` (`2`) : how many package backups to keep
|
||||
- `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.
|
||||
- `DOWNLOAD_PROGRESS` (default is `false`) : When set to `true`, displays a progress bar during the Bedrock server download instead of running silently.
|
||||
- `ENABLE_SSH` (default is `false`) : Enable remote console over SSH on port 2222 if this environment variable is set to `true`.
|
||||
- `MC_PACK` (no default): Path inside the container to a single archive file (e.g. `.mcpack`, `.mcworld`, `.mctemplate`, `.mcaddon`, or any zip) or to a directory with the same layout. At startup the archive is unpacked (or the directory is read): top-level `behavior_packs/` is merged into `behavior_packs/`, top-level `resource_packs/` into `resource_packs/`, and all other content (when `level.dat` is present) into `worlds/{LEVEL_NAME}`. For `.mcaddon` archives, which use root-level `data/` (behavior) and `resources/` (resource) folders instead of `behavior_packs/` and `resource_packs/`, these are detected and installed automatically using the pack UUID from each manifest as the folder name.
|
||||
- `FORCE_WORLD_COPY` (default `false`): When `MC_PACK` contains a world (`level.dat`), set to `true` to remove and replace the existing `worlds/{LEVEL_NAME}` on every startup; otherwise the world is copied only when it does not exist.
|
||||
|
||||
+9
-4
@@ -11,6 +11,7 @@ set -eo pipefail
|
||||
: "${FORCE_PACK_COPY:=false}"
|
||||
: "${FORCE_WORLD_COPY:=false}"
|
||||
: "${LEVEL_NAME:=Bedrock level}"
|
||||
: "${DOWNLOAD_PROGRESS:=false}"
|
||||
|
||||
function isTrue() {
|
||||
[[ "${1,,}" =~ ^(true|on|1)$ ]] && return 0
|
||||
@@ -199,7 +200,11 @@ if [[ ! -f "$SERVER" ]]; then
|
||||
TMP_ZIP="$DOWNLOAD_DIR/$(basename "${DOWNLOAD_URL}")"
|
||||
|
||||
echo "Downloading Bedrock server version ${VERSION} ..."
|
||||
if ! curl "${debugCurlArgs[@]}" -o "${TMP_ZIP}" -A "itzg/minecraft-bedrock-server" -fsSL "${DOWNLOAD_URL}"; then
|
||||
curlProgressArgs=(-fsSL)
|
||||
if isTrue "$DOWNLOAD_PROGRESS"; then
|
||||
curlProgressArgs=(-fL --progress-bar)
|
||||
fi
|
||||
if ! curl "${debugCurlArgs[@]}" "${curlProgressArgs[@]}" -o "${TMP_ZIP}" -A "itzg/minecraft-bedrock-server" "${DOWNLOAD_URL}"; then
|
||||
logError " failed to download from ${DOWNLOAD_URL}
|
||||
Double check that the given VERSION is valid"
|
||||
exit 2
|
||||
@@ -272,13 +277,13 @@ if [[ -n "${MC_PACK:-}" ]]; then
|
||||
for subdir in data resources; do
|
||||
packManifestFile="$srcDir/$subdir/manifest.json"
|
||||
[[ -f "$packManifestFile" ]] || continue
|
||||
|
||||
|
||||
packId=$(jq -r '.header.uuid' "$packManifestFile")
|
||||
destName="behavior_packs"; [[ "$subdir" == "resources" ]] && destName="resource_packs"
|
||||
|
||||
|
||||
worldPacksFile="$srcDir/world_${destName}.json"
|
||||
worldPacksJson=$(jq -c '[{pack_id: .header.uuid, version: .header.version}]' "$packManifestFile")
|
||||
|
||||
|
||||
mkdir -p "$srcDir/$destName"
|
||||
mv "$srcDir/$subdir" "$srcDir/$destName/$packId"
|
||||
echo "$worldPacksJson" > "$worldPacksFile" && echo "Generated $worldPacksFile as $worldPacksJson"
|
||||
|
||||
Reference in new issue
Block a user