Allowed combining of REMOVE_OLD_MODS and SPIGET_RESOURCES with /plugins mount

#834
This commit is contained in:
Geoff Bourne
2021-04-24 14:06:31 -05:00
parent 65b3997e72
commit b1bb3f38f3
2 changed files with 10 additions and 19 deletions
+2 -15
View File
@@ -11,21 +11,8 @@ fi
CURSE_URL_BASE=${CURSE_URL_BASE:-https://minecraft.curseforge.com/projects} CURSE_URL_BASE=${CURSE_URL_BASE:-https://minecraft.curseforge.com/projects}
# Remove old mods/plugins # Remove old mods/plugins
if isTrue ${REMOVE_OLD_MODS}; then if isTrue ${REMOVE_OLD_MODS:-false}; then
remove_mods_dest="/data/mods" find /data/mods /data/plugins -mindepth 1 -maxdepth ${REMOVE_OLD_MODS_DEPTH:-16} -wholename "${REMOVE_OLD_MODS_INCLUDE:-*}" -not -wholename "${REMOVE_OLD_MODS_EXCLUDE}" -delete
case ${TYPE} in
SPIGOT|BUKKIT|PAPER)
remove_mods_dest="/data/plugins"
;;
esac
# only try to remove existing mods dir
if [ -d "$remove_mods_dest" ]; then
log "Removing old mods in $remove_mods_dest..."
find $remove_mods_dest -mindepth 1 -maxdepth ${REMOVE_OLD_MODS_DEPTH:-16} -wholename "${REMOVE_OLD_MODS_INCLUDE:-*}" -not -wholename "${REMOVE_OLD_MODS_EXCLUDE}" -delete
else
log "Directory $remove_mods_dest does not exist; removing nothing."
fi
fi fi
# If supplied with a URL for a modpack (simple zip of jars), download it and unpack # If supplied with a URL for a modpack (simple zip of jars), download it and unpack
+8 -4
View File
@@ -16,7 +16,7 @@ containsJars() {
if [[ $line =~ $pat ]]; then if [[ $line =~ $pat ]]; then
return 0 return 0
fi fi
done <<< $(unzip -l "$file") done <<<$(unzip -l "$file")
return 1 return 1
} }
@@ -46,10 +46,14 @@ getResourceFromSpiget() {
} }
if [[ ${SPIGET_RESOURCES} ]]; then if [[ ${SPIGET_RESOURCES} ]]; then
if isTrue ${REMOVE_OLD_MODS:-false}; then
rm -rf /data/plugins
REMOVE_OLD_MODS=false
fi
log "Getting plugins via Spiget" log "Getting plugins via Spiget"
IFS=',' read -r -a resources <<< "${SPIGET_RESOURCES}" IFS=',' read -r -a resources <<<"${SPIGET_RESOURCES}"
for resource in "${resources[@]}" for resource in "${resources[@]}"; do
do
getResourceFromSpiget "${resource}" getResourceFromSpiget "${resource}"
done done
fi fi