Skip to content

Commit 0b5d7ab

Browse files
committed
Use some vars and cleanup tmp content
1 parent 361d029 commit 0b5d7ab

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

scripts/start-setupWorld

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
set -e
66
isDebugging && set -x
77

8+
worldDownload=/data/tmp/world.zip
9+
tmpWorldData=/data/tmp/world-data
10+
811
# support absolute directories
912
if [[ "${LEVEL:-world}" =~ ^\/.*$ ]]; then
1013
worldDest=${LEVEL}
@@ -27,24 +30,24 @@ if [[ "$WORLD" ]] && ( isTrue "${FORCE_WORLD_COPY}" || [ ! -d "$worldDest" ] );
2730
if isURL "$WORLD"; then
2831
log "Downloading world from $WORLD"
2932
mkdir -p /data/tmp
30-
if ! get -o /data/tmp/world.bin "$WORLD"; then
33+
if ! get -o ${worldDownload} "$WORLD"; then
3134
logError "Failed to download world from $WORLD"
3235
exit 1
3336
fi
34-
WORLD=/data/tmp/world.bin
37+
WORLD=${worldDownload}
3538
fi
3639

3740
if [ -f "$WORLD" ]; then
3841
log "Extracting world"
3942

4043
# Stage contents so that the correct subdirectory can be picked off
41-
mkdir -p /data/tmp/world-data
42-
if ! extract "$WORLD" /data/tmp/world-data; then
44+
mkdir -p ${tmpWorldData}
45+
if ! extract "$WORLD" ${tmpWorldData}; then
4346
logError "Extracting world from $WORLD"
4447
exit 1
4548
fi
4649

47-
baseDirs=$(find /data/tmp/world-data -name "level.dat" -exec dirname "{}" \;)
50+
baseDirs=$(find ${tmpWorldData} -name "level.dat" -exec dirname "{}" \;)
4851

4952
if ! [[ $baseDirs ]]; then
5053
logError "World content is not valid since level.dat could not be found"
@@ -129,4 +132,7 @@ if [[ "$WORLD" ]] && ( isTrue "${FORCE_WORLD_COPY}" || [ ! -d "$worldDest" ] );
129132
fi
130133
fi
131134

135+
[[ -f ${worldDownload} ]] && rm ${worldDownload}
136+
[[ -d ${tmpWorldData} ]] && rm -rf ${tmpWorldData}
137+
132138
exec "${SCRIPTS:-/}start-setupDatapack" "$@"

0 commit comments

Comments
 (0)