From deb98268f633b1dffc7cb63ffdd77a4e00ef8a2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20=C4=8Cern=C3=BD?= Date: Sun, 2 Jul 2017 01:32:24 +0200 Subject: [PATCH] Added option REMOVE_OLD_MODS --- minecraft-server/README.md | 14 ++++++++++++++ minecraft-server/start-minecraft.sh | 6 ++++++ 2 files changed, 20 insertions(+) diff --git a/minecraft-server/README.md b/minecraft-server/README.md index 3d5eac95..681c61e1 100644 --- a/minecraft-server/README.md +++ b/minecraft-server/README.md @@ -672,6 +672,20 @@ To use this option pass the environment variable `MODPACK`, such as top level of the zip archive. Make sure the jars are compatible with the particular `TYPE` of server you are running. +### Remove old mods/plugins + +When the option above is specified (`MODPACK`) you can also instruct script to +delete old mods/plugins prior to installing new ones. This behaviour is desirable +in case you want to upgrade mods/plugins from downloaded zip file. +To use this option pass the environment variable `REMOVE_OLD_MODS="TRUE"`, such as + + docker run -d -e REMOVE_OLD_MODS="TRUE" -e MODPACK=http://www.example.com/mods/modpack.zip ... + +**NOTE:** This option will be taken into account only when option `MODPACK` is also used. + +**WARNING:** All content of the `mods` or `plugins` directory will be deleted +before unpacking new content from the zip file. + ### Online mode By default, server checks connecting players against Minecraft's account database. If you want to create an offline server or your server is not connected to the internet, you can disable the server to try connecting to minecraft.net to authenticate players with environment variable `ONLINE_MODE`, like this diff --git a/minecraft-server/start-minecraft.sh b/minecraft-server/start-minecraft.sh index bc2f9ce5..dfc92d79 100755 --- a/minecraft-server/start-minecraft.sh +++ b/minecraft-server/start-minecraft.sh @@ -403,9 +403,15 @@ case "X$MODPACK" in echo " from $MODPACK ..." curl -sSL -o /tmp/modpack.zip "$MODPACK" if [ "$TYPE" = "SPIGOT" ]; then + if [ "$REMOVE_OLD_MODS" = "TRUE" ]; then + rm -rf /data/plugins/* + fi mkdir -p /data/plugins unzip -o -d /data/plugins /tmp/modpack.zip else + if [ "$REMOVE_OLD_MODS" = "TRUE" ]; then + rm -rf /data/mods/* + fi mkdir -p /data/mods unzip -o -d /data/mods /tmp/modpack.zip fi