docker-minecraft-server/start-finalSetup01World
2020-06-19 11:05:32 -05:00

54 lines
1.5 KiB
Bash

#!/bin/bash
. ${SCRIPTS:-/}start-utils
set -e
isDebugging && set -x
if [ $TYPE = "FEED-THE-BEAST" ]; then
worldDest=$FTB_BASE_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 $@