2017-11-01 05:42:44 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
2020-06-19 16:05:32 +00:00
|
|
|
. ${SCRIPTS:-/}start-utils
|
2020-06-07 01:41:09 +00:00
|
|
|
set -e
|
|
|
|
isDebugging && set -x
|
2020-03-06 15:52:17 +00:00
|
|
|
|
2021-02-07 23:52:42 +00:00
|
|
|
: ${LEVEL:=world}
|
|
|
|
export LEVEL
|
|
|
|
|
2021-04-26 13:19:50 +00:00
|
|
|
if [ $TYPE = "CURSEFORGE" ]; then
|
2020-07-01 23:48:41 +00:00
|
|
|
worldDest=$FTB_DIR/$LEVEL
|
2019-01-09 00:28:34 +00:00
|
|
|
else
|
|
|
|
worldDest=/data/$LEVEL
|
|
|
|
fi
|
2018-09-12 01:38:54 +00:00
|
|
|
|
2020-07-11 18:09:48 +00:00
|
|
|
if [[ "$WORLD" ]] && ( isTrue "${FORCE_WORLD_COPY}" || [ ! -d "$worldDest" ] ); then
|
2021-03-30 02:14:21 +00:00
|
|
|
if isTrue "${FORCE_WORLD_COPY}"; then
|
|
|
|
log "Removing existing world data in $worldDest ${worldDest}_nether ${worldDest}_the_end"
|
|
|
|
rm -rf "$worldDest" \
|
|
|
|
"${worldDest}_nether" \
|
|
|
|
"${worldDest}_the_end"
|
|
|
|
fi
|
|
|
|
|
2020-06-07 01:41:09 +00:00
|
|
|
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
|
2020-03-06 15:52:17 +00:00
|
|
|
log "Unzipping world"
|
2020-06-07 01:41:09 +00:00
|
|
|
|
|
|
|
# Stage contents so that the correct subdirectory can be picked off
|
|
|
|
mkdir -p /tmp/world-data
|
|
|
|
(cd /tmp/world-data && unzip -o -q "$zipSrc")
|
|
|
|
|
2020-12-12 14:26:32 +00:00
|
|
|
if [ "$TYPE" = "SPIGOT" ]; then
|
2020-12-12 17:10:13 +00:00
|
|
|
baseDirs=$(find /tmp/world-data -name "level.dat" -not -path "*_nether*" -not -path "*_the_end*" -exec dirname "{}" \;)
|
2020-12-12 14:26:32 +00:00
|
|
|
else
|
|
|
|
baseDirs=$(find /tmp/world-data -name "level.dat" -exec dirname "{}" \;)
|
|
|
|
fi
|
|
|
|
|
2020-06-07 01:41:09 +00:00
|
|
|
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"
|
2018-09-12 01:38:54 +00:00
|
|
|
else
|
2020-06-07 01:41:09 +00:00
|
|
|
log "ERROR invalid world content"
|
2020-04-06 23:59:26 +00:00
|
|
|
exit 1
|
2018-09-12 01:38:54 +00:00
|
|
|
fi
|
2020-07-10 22:06:47 +00:00
|
|
|
rsync --remove-source-files --recursive --delete "$baseDir/" "$worldDest"
|
2020-12-12 14:26:32 +00:00
|
|
|
if [ "$TYPE" = "SPIGOT" ]; then
|
|
|
|
log "Copying end and nether ..."
|
|
|
|
[ -d "${baseDir}_nether" ] && rsync --remove-source-files --recursive --delete "${baseDir}_nether/" "${worldDest}_nether"
|
|
|
|
[ -d "${baseDir}_the_end" ] && rsync --remove-source-files --recursive --delete "${baseDir}_the_end/" "${worldDest}_the_end"
|
|
|
|
fi
|
2020-06-07 01:41:09 +00:00
|
|
|
else
|
|
|
|
log "Cloning world directory from $WORLD ..."
|
2020-07-10 22:06:47 +00:00
|
|
|
rsync --recursive --delete "${WORLD%/}"/ "$worldDest"
|
2020-06-07 01:41:09 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "$TYPE" = "SPIGOT" ]; then
|
|
|
|
# Reorganise if a Spigot server
|
|
|
|
log "Moving End and Nether maps to Spigot location"
|
2021-03-30 02:14:21 +00:00
|
|
|
[ -d "$worldDest/DIM1" ] && mv -f "$worldDest/DIM1" "${worldDest}_the_end"
|
|
|
|
[ -d "$worldDest/DIM-1" ] && mv -f "$worldDest/DIM-1" "${worldDest}_nether"
|
2020-06-07 01:41:09 +00:00
|
|
|
fi
|
2017-11-01 05:42:44 +00:00
|
|
|
fi
|
|
|
|
|
2021-09-16 02:27:48 +00:00
|
|
|
exec ${SCRIPTS:-/}start-setupModpack $@
|