From 3c0566cb8750fa1be9e9ceb813678ba4797222fb Mon Sep 17 00:00:00 2001 From: Daniel Ramp <12480131+DanielRamp@users.noreply.github.com> Date: Thu, 15 Jul 2021 01:42:34 +0200 Subject: [PATCH] fix: SPIGET_RESOURCES not always download (#975) implemented to only re-download SPIGET resources with REMOVE_OLD_MODS enabled fixes #974 partially --- start-spiget | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/start-spiget b/start-spiget index 025edd20..92e0fac7 100644 --- a/start-spiget +++ b/start-spiget @@ -26,21 +26,28 @@ getResourceFromSpiget() { log "Downloading resource ${resource} ..." - tmpfile="/tmp/${resource}.zip" - url="https://api.spiget.org/v2/resources/${resource}/download" - if ! curl -o "${tmpfile}" -fsSL -H "User-Agent: itzg/minecraft-server" "${extraCurlArgs[@]}" "${url}"; then - log "ERROR failed to download resource '${resource}' from ${url}" - exit 2 - fi - mkdir -p /data/plugins - if containsJars "${tmpfile}"; then - log "Extracting contents of resource ${resource} into plugins" - unzip -o -q -d /data/plugins "${tmpfile}" - rm "${tmpfile}" + + if [ -f /data/plugins/.${resource} ]; then + log "Resource '${$resource}' already downloaded" else - log "Moving resource ${resource} into plugins" - mv "${tmpfile}" "/data/plugins/${resource}.jar" + tmpfile="/tmp/${resource}.zip" + url="https://api.spiget.org/v2/resources/${resource}/download" + if ! curl -o "${tmpfile}" -fsSL -H "User-Agent: itzg/minecraft-server" "${extraCurlArgs[@]}" "${url}"; then + log "ERROR failed to download resource '${resource}' from ${url}" + exit 2 + fi + + if containsJars "${tmpfile}"; then + log "Extracting contents of resource ${resource} into plugins" + unzip -o -q -d /data/plugins "${tmpfile}" + touch "/data/plugins/.${resource}" + rm "${tmpfile}" + else + log "Moving resource ${resource} into plugins" + mv "${tmpfile}" "/data/plugins/${resource}.jar" + touch "/data/plugins/.${resource}" + fi fi }