From 3854526389232841bf281c4edd544f23c3e14f42 Mon Sep 17 00:00:00 2001 From: picapi Date: Thu, 6 May 2021 22:27:30 +0100 Subject: [PATCH] Support local paths for modpacks / mods (#858) --- README.md | 4 ++-- start-finalSetupModpack | 41 ++++++++++++++++++++++++++--------------- 2 files changed, 28 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index 57f98170..08c5fb29 100644 --- a/README.md +++ b/README.md @@ -1123,7 +1123,7 @@ The world will only be downloaded or copied if it doesn't exist already. Set `FO ### Downloadable mod/plugin pack for Forge, Bukkit, and Spigot Servers -Like the `WORLD` option above, you can specify the URL of a "mod pack" +Like the `WORLD` option above, you can specify the URL or path of a "mod pack" to download and install into `mods` for Forge or `plugins` for Bukkit/Spigot. To use this option pass the environment variable `MODPACK`, such as @@ -1133,7 +1133,7 @@ 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. -You may also download individual mods using the `MODS` environment variable and supplying the URL +You may also download individual mods using the `MODS` environment variable and supplying the URL or path to the jar files. Multiple mods/plugins should be comma separated. docker run -d -e MODS=https://www.example.com/mods/mod1.jar,https://www.example.com/mods/mod2.jar ... diff --git a/start-finalSetupModpack b/start-finalSetupModpack index 869d8c22..c854ebb7 100644 --- a/start-finalSetupModpack +++ b/start-finalSetupModpack @@ -36,24 +36,28 @@ if [[ "$MODPACK" ]]; then log "ERROR: failed to download from $downloadUrl" exit 2 fi - - if [ "$TYPE" = "SPIGOT" ]; then - mkdir -p /data/plugins - if ! unzip -o -d /data/plugins /tmp/modpack.zip; then - log "ERROR: failed to unzip the modpack from $downloadUrl" - fi - else - mkdir -p /data/mods - if ! unzip -o -d /data/mods /tmp/modpack.zip; then - log "ERROR: failed to unzip the modpack from $downloadUrl" - fi + elif [[ "$MODPACK" =~ .*\.zip ]]; then + if ! cp $MODPACK /tmp/modpack.zip; then + log "ERROR: failed to copy from $MODPACK" + exit 2 fi - rm -f /tmp/modpack.zip - else - log "ERROR Invalid URL given for MODPACK: $MODPACK" + log "ERROR Invalid URL or Path given for MODPACK: $MODPACK" exit 1 fi + + if [ "$TYPE" = "SPIGOT" ]; then + mkdir -p /data/plugins + if ! unzip -o -d /data/plugins /tmp/modpack.zip; then + log "ERROR: failed to unzip the modpack from $downloadUrl" + fi + else + mkdir -p /data/mods + if ! unzip -o -d /data/mods /tmp/modpack.zip; then + log "ERROR: failed to unzip the modpack from $downloadUrl" + fi + fi + rm -f /tmp/modpack.zip fi # If supplied with a URL for a plugin download it. @@ -87,8 +91,15 @@ if [[ "$MODS" ]]; then exit 2 fi fi + elif [[ "$i" =~ .*\.jar ]]; then + log "Copying plugin located at $i ..." + out_file=$(basename "$i") + if ! cp "$i" "${out_dir}/$out_file"; then + log "ERROR: failed to copy from $i into $out_dir" + exit 2 + fi else - log "ERROR Invalid URL given in MODS: $i" + log "ERROR Invalid URL or Path given in MODS: $i" exit 2 fi done