docker-minecraft-server/start-finalSetup01World
Kamaroth92 9c6047e3fc
Updated worldDest to use FTB_DIR in order to deal with nested FTB modpacks (#571)
Co-authored-by: Tane Barriball <tanebarriball@gmail.com>
2020-07-01 18:48:41 -05:00

55 lines
1.5 KiB
Bash

#!/bin/bash
. ${SCRIPTS:-/}start-utils
set -e
isDebugging && set -x
if [ $TYPE = "FEED-THE-BEAST" ]; then
worldDest=$FTB_DIR/$LEVEL
else
worldDest=/data/$LEVEL
fi
if [[ "$WORLD" ]] && [ ! -d "$worldDest" ]; then
if isURL $WORLD; then
curl -fsSL "$WORLD" -o /tmp/world.zip
zipSrc=/tmp/world.zip
elif [[ "$WORLD" =~ .*\.zip ]]; then
zipSrc="$WORLD"
fi
if [[ "$zipSrc" ]]; then
log "Unzipping world"
# Stage contents so that the correct subdirectory can be picked off
mkdir -p /tmp/world-data
(cd /tmp/world-data && unzip -o -q "$zipSrc")
baseDirs=$(find /tmp/world-data -name "level.dat" -exec dirname "{}" \;)
count=$(echo "$baseDirs" | wc -l)
if [[ $count -gt 1 ]]; then
baseDir="$(echo "$baseDirs" | sed -n ${WORLD_INDEX:-1}p)"
baseName=$(basename "$baseDir")
log "WARN multiple levels found, picking: $baseName"
elif [[ $count -gt 0 ]]; then
baseDir="$baseDirs"
else
log "ERROR invalid world content"
exit 1
fi
mv "$baseDir" "$worldDest"
else
log "Cloning world directory from $WORLD ..."
cp -r "$WORLD" "$worldDest"
fi
if [ "$TYPE" = "SPIGOT" ]; then
# Reorganise if a Spigot server
log "Moving End and Nether maps to Spigot location"
[ -d "$worldDest/DIM1" ] && mv -f "$worldDest/DIM1" "/data/${LEVEL}_the_end"
[ -d "$worldDest/DIM-1" ] && mv -f "$worldDest/DIM-1" "/data/${LEVEL}_nether"
fi
fi
exec ${SCRIPTS:-/}start-finalSetup02Modpack $@