Fix loading world from compressed tar archives (#1304)

This commit is contained in:
Luc Ritchie 2022-01-25 17:19:15 -05:00 committed by GitHub
parent d02bbb798e
commit 8a42dfe232
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
14 changed files with 60 additions and 10 deletions

View file

@ -20,6 +20,7 @@ RUN apt-get update \
rsync \
nano \
unzip \
zstd \
knockd \
ttf-dejavu \
&& apt-get clean

View file

@ -195,12 +195,16 @@ function extract() {
destDir=${2?}
type=$(file -b --mime-type "${src}")
if [[ $type == application/zip ]]; then
unzip -q -d "${destDir}" "${src}"
elif [[ $type == application/x-tar ]]; then
tar -C "${destDir}" -xf "${src}"
else
log "ERROR: unsupported archive type: $type"
return 1
fi
}
case "${type}" in
application/zip)
unzip -q -d "${destDir}" "${src}"
;;
application/x-tar|application/gzip|application/x-bzip2|application/zstd)
tar -C "${destDir}" -xf "${src}"
;;
*)
log "ERROR: unsupported archive type: $type"
return 1
;;
esac
}

View file

@ -8,7 +8,7 @@ services:
EULA: "TRUE"
SETUP_ONLY: "TRUE"
VERSION: ${MINECRAFT_VERSION:-LATEST}
WORLD: /worlds/world-for-testing.tgz
WORLD: /worlds/world-for-testing.tar
volumes:
- ./worlds:/worlds:ro
- ./data:/data

View file

@ -0,0 +1,14 @@
version: "3"
services:
mc:
restart: "no"
image: ${IMAGE_TO_TEST:-itzg/minecraft-server}
environment:
EULA: "TRUE"
SETUP_ONLY: "TRUE"
VERSION: ${MINECRAFT_VERSION:-LATEST}
WORLD: /worlds/world-for-testing.tar.bz2
volumes:
- ./worlds:/worlds:ro
- ./data:/data

View file

@ -0,0 +1 @@
mc-image-helper assert fileExists world/level.dat

View file

@ -0,0 +1,14 @@
version: "3"
services:
mc:
restart: "no"
image: ${IMAGE_TO_TEST:-itzg/minecraft-server}
environment:
EULA: "TRUE"
SETUP_ONLY: "TRUE"
VERSION: ${MINECRAFT_VERSION:-LATEST}
WORLD: /worlds/world-for-testing.tar.gz
volumes:
- ./worlds:/worlds:ro
- ./data:/data

View file

@ -0,0 +1 @@
mc-image-helper assert fileExists world/level.dat

View file

@ -0,0 +1,14 @@
version: "3"
services:
mc:
restart: "no"
image: ${IMAGE_TO_TEST:-itzg/minecraft-server}
environment:
EULA: "TRUE"
SETUP_ONLY: "TRUE"
VERSION: ${MINECRAFT_VERSION:-LATEST}
WORLD: /worlds/world-for-testing.tar.zst
volumes:
- ./worlds:/worlds:ro
- ./data:/data

View file

@ -0,0 +1 @@
mc-image-helper assert fileExists world/level.dat