From 32ed58692cb0ef9633565cc62d5183c66724214f Mon Sep 17 00:00:00 2001 From: Geoff Bourne Date: Fri, 15 Oct 2021 18:42:44 -0500 Subject: [PATCH] Added MODS_FILE option #1072 --- DEVELOPMENT.md | 23 ++++++++ Dockerfile | 5 +- README.md | 30 ++++++++-- examples/docker-compose-mods-file.yml | 19 +++++++ examples/mods.txt | 80 +++++++++++++++++++++++++++ start-setupModpack | 45 +++++++++++++-- 6 files changed, 192 insertions(+), 10 deletions(-) create mode 100644 examples/docker-compose-mods-file.yml create mode 100644 examples/mods.txt diff --git a/DEVELOPMENT.md b/DEVELOPMENT.md index fadc6141..86df0d84 100644 --- a/DEVELOPMENT.md +++ b/DEVELOPMENT.md @@ -40,6 +40,29 @@ VANILLA_VERSION=1.12.2 /scripts/start-magma > NOTE: You may want to temporarily add an `exit` statement near the end of your script to isolate execution to just the script you're developing. +## Using development copy of mc-image-helper + +In the cloned copy of [`mc-image-helper`](https://github.com/itzg/mc-image-helper), create an up-to-date snapshot build of the tgz distribution using: + +```shell +./gradlew distTar +``` + +Assuming [http-server](https://www.npmjs.com/package/http-server) is installed globally, start a static web server using: + +```shell +http-server ./build/distributions -p 0 +``` + +Note the port that was selected by http-server and pass the build arguments, such as: + +```shell +--build-arg MC_HELPER_VERSION=1.8.1-SNAPSHOT \ +--build-arg MC_HELPER_BASE_URL=http://host.docker.internal:8080 +``` + +Now the image can be built like normal and it will install mc-image-helper from the locally built copy. + ## Multi-base-image variants Several base-image variants are maintained in order to offer choices in JDK provider and version. The variants are maintained in their respective branches: diff --git a/Dockerfile b/Dockerfile index e1fee7b6..cf40df61 100644 --- a/Dockerfile +++ b/Dockerfile @@ -60,8 +60,9 @@ RUN easy-add --var os=${TARGETOS} --var arch=${TARGETARCH}${TARGETVARIANT} \ --var version=0.1.1 --var app=maven-metadata-release --file {{.app}} \ --from https://github.com/itzg/{{.app}}/releases/download/{{.version}}/{{.app}}_{{.version}}_{{.os}}_{{.arch}}.tar.gz -ARG MC_HELPER_VERSION=1.6.1 -RUN curl -fsSL https://github.com/itzg/mc-image-helper/releases/download/v${MC_HELPER_VERSION}/mc-image-helper-${MC_HELPER_VERSION}.tgz \ +ARG MC_HELPER_VERSION=1.8.1 +ARG MC_HELPER_BASE_URL=https://github.com/itzg/mc-image-helper/releases/download/v${MC_HELPER_VERSION} +RUN curl -fsSL ${MC_HELPER_BASE_URL}/mc-image-helper-${MC_HELPER_VERSION}.tgz \ | tar -C /usr/share -zxf - \ && ln -s /usr/share/mc-image-helper-${MC_HELPER_VERSION}/bin/mc-image-helper /usr/bin diff --git a/README.md b/README.md index cfb04ba8..d6b9cf79 100644 --- a/README.md +++ b/README.md @@ -408,7 +408,7 @@ If you are hosting your own copy of Bukkit/Spigot you can override the download You can build spigot from source by adding `-e BUILD_FROM_SOURCE=true` -Plugins can either be managed within the `plugins` subdirectory of the [data directory](#data-directory) or you can also [attach a `/plugins` volume](#deploying-plugins-from-attached-volume). If you add plugins while the container is running, you'll need to restart it to pick those up. +Plugins can either be managed within the `plugins` subdirectory of the [data directory](#data-directory) or you can also [attach a `/plugins` volume](#optional-plugins-mods-and-config-attach-points). If you add plugins while the container is running, you'll need to restart it to pick those up. [You can also auto-download plugins using `SPIGET_RESOURCES`.](#auto-downloading-spigotmcbukkitpapermc-plugins) @@ -432,7 +432,7 @@ If you are hosting your own copy of Paper you can override the download URL with An example compose file is provided at [examples/docker-compose-paper.yml](examples/docker-compose-paper.yml). -If you have attached a host directory to the `/data` volume, then you can install plugins via the `plugins` subdirectory. You can also [attach a `/plugins` volume](#deploying-plugins-from-attached-volume). If you add plugins while the container is running, you'll need to restart it to pick those up. +If you have attached a host directory to the `/data` volume, then you can install plugins via the `plugins` subdirectory. You can also [attach a `/plugins` volume](#optional-plugins-mods-and-config-attach-points). If you add plugins while the container is running, you'll need to restart it to pick those up. [You can also auto-download plugins using `SPIGET_RESOURCES`.](#auto-downloading-spigotmcbukkitpapermc-plugins) @@ -694,14 +694,36 @@ You may also download or copy over individual mods using the `MODS` environment docker run -d -e MODS=https://www.example.com/mods/mod1.jar,/plugins/common,/plugins/special/mod2.jar ... +### Mod/Plugin URL Listing File + +As an alternative to `MODS`, the variable `MODS_FILE` can be set with the path to a text file listing a mod/plugin URL on each line. For example, the following + + -e MODS_FILE=/extras/mods.txt + +would load from a file mounted into the container at `/extras/mods.txt`. That file might look like: + +```text +https://edge.forgecdn.net/files/2965/233/Bookshelf-1.15.2-5.6.40.jar +https://edge.forgecdn.net/files/2926/27/ProgressiveBosses-2.1.5-mc1.15.2.jar +# This and next line are ignored +#https://edge.forgecdn.net/files/3248/905/goblintraders-1.3.1-1.15.2.jar +https://edge.forgecdn.net/files/3272/32/jei-1.15.2-6.0.3.16.jar +https://edge.forgecdn.net/files/2871/647/ToastControl-1.15.2-3.0.1.jar +``` +> Blank lines and lines that start with a `#` will be ignored + +> [This compose file](examples/docker-compose-mods-file.yml) shows another example of using this feature. + +> It is recommended to combine this option with `REMOVE_OLD_MODS=TRUE` to ensure the mods/plugins remain consistent with the file's listing. + ### 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 +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 ... + docker run -d -e REMOVE_OLD_MODS=TRUE -e MODPACK=http://www.example.com/mods/modpack.zip ... **WARNING:** All content of the `mods` or `plugins` directory will be deleted before unpacking new content from the MODPACK or MODS. diff --git a/examples/docker-compose-mods-file.yml b/examples/docker-compose-mods-file.yml new file mode 100644 index 00000000..100e8984 --- /dev/null +++ b/examples/docker-compose-mods-file.yml @@ -0,0 +1,19 @@ +version: '3.8' + +services: + mc: + image: itzg/minecraft-server + environment: + EULA: "true" + TYPE: FORGE + VERSION: 1.15.2 + MODS_FILE: /extras/mods.txt + REMOVE_OLD_MODS: "true" + ports: + - 25565:25565 + volumes: + - data:/data + - ./mods.txt:/extras/mods.txt:ro + +volumes: + data: diff --git a/examples/mods.txt b/examples/mods.txt new file mode 100644 index 00000000..ae6f5efb --- /dev/null +++ b/examples/mods.txt @@ -0,0 +1,80 @@ +https://edge.forgecdn.net/files/2965/233/Bookshelf-1.15.2-5.6.40.jar +https://edge.forgecdn.net/files/2926/27/ProgressiveBosses-2.1.5-mc1.15.2.jar +https://edge.forgecdn.net/files/3248/905/goblintraders-1.3.1-1.15.2.jar +https://edge.forgecdn.net/files/3272/32/jei-1.15.2-6.0.3.16.jar +https://edge.forgecdn.net/files/2871/647/ToastControl-1.15.2-3.0.1.jar +https://edge.forgecdn.net/files/3101/903/Druidcraft-1.15-0.4.45.jar +https://edge.forgecdn.net/files/2880/426/DefaultOptions_1.15.2-11.0.1.jar +https://edge.forgecdn.net/files/2996/535/MekanismAdditions-1.15.2-9.10.9.422.jar +https://edge.forgecdn.net/files/3147/275/blockcarpentry-1.15-0.8.2.jar +https://edge.forgecdn.net/files/3005/715/refinedstorageaddons-0.6.3.jar +https://edge.forgecdn.net/files/3140/146/rftoolsbase-1.15-1.1.10.jar +https://edge.forgecdn.net/files/3236/649/cc-tweaked-1.15.2-1.95.3.jar +https://edge.forgecdn.net/files/3048/970/light-overlay-4.7.2.jar +https://edge.forgecdn.net/files/3015/904/randompatches-1.15.2-1.22.1.1.jar +https://edge.forgecdn.net/files/3131/439/engineersdecor-1.15.2-1.1.4.jar +https://edge.forgecdn.net/files/3051/255/carryon-1.15.2-1.13.0.5.jar +https://edge.forgecdn.net/files/3175/752/EnderStorage-1.15.2-2.5.2.164-universal.jar +https://edge.forgecdn.net/files/2997/84/Savage-and-Ravage-1.15.2-1.1.4.jar +https://edge.forgecdn.net/files/3053/840/PackMenu-1.15.2-1.2.8.jar +https://edge.forgecdn.net/files/3003/397/JEITweaker-1.15.2-1.0.1.3.jar +https://edge.forgecdn.net/files/3069/489/absentbydesign-1.15.2-1.1.1.jar +https://edge.forgecdn.net/files/2997/601/Upgrade-Aquatic-1.15.2-1.7.1.jar +https://edge.forgecdn.net/files/2950/766/ReAuth-1.14-1.15-3.8.1.jar +https://edge.forgecdn.net/files/3024/179/Powah-1.15.2-1.1.15.jar +https://edge.forgecdn.net/files/3092/975/StorageDrawers-1.15.2-7.0.3.jar +https://edge.forgecdn.net/files/2853/267/furniture-7.0.0-pre16-1.15.1.jar +https://edge.forgecdn.net/files/2987/251/AppleSkin-mc1.15.2-forge-1.0.14.jar +https://edge.forgecdn.net/files/2980/323/industrial-foregoing-1.15.2-2.3.3-e356e61.jar +https://edge.forgecdn.net/files/3024/178/Lollipop-1.15.2-1.0.16.jar +https://edge.forgecdn.net/files/3210/106/tablechair-1.4.jar +https://edge.forgecdn.net/files/3047/358/xercapaint-1.15.2-3.3.jar +https://edge.forgecdn.net/files/2873/657/BonsaiTrees-2.1.2.6.jar +https://edge.forgecdn.net/files/2938/583/config-2-3.0.jar +https://edge.forgecdn.net/files/2991/235/Waystones_1.15.2-6.0.2.jar +https://edge.forgecdn.net/files/2957/23/OpenLoader-1.15.2-4.0.5.jar +https://edge.forgecdn.net/files/3275/718/XaerosWorldMap_1.13.2_Forge_1.15.2.jar +https://edge.forgecdn.net/files/2876/104/AI-Improvements-1.15.2-0.3.0.jar +https://edge.forgecdn.net/files/3005/515/mysticallib-1.15.2-2.0.1.jar +https://edge.forgecdn.net/files/3008/867/WAWLA-1.15.2-3.0.4.jar +https://edge.forgecdn.net/files/2964/474/WailaHarvestability-mc1.15.2-1.1.12.jar +https://edge.forgecdn.net/files/3103/508/Kiwi-1.15.2-2.8.5.jar +https://edge.forgecdn.net/files/3128/662/Atum-1.15.2-2.1.12.jar +https://edge.forgecdn.net/files/2988/910/Buzzier-Bees-1.15.2-1.5.2.jar +https://edge.forgecdn.net/files/3030/627/u_team_core-1.15.2-3.0.2.169.jar +https://edge.forgecdn.net/files/3003/984/SilentLib-1.15.2-4.6.6+59.jar +https://edge.forgecdn.net/files/2968/353/refinedpipes-0.4.2.jar +https://edge.forgecdn.net/files/3140/149/rftoolsbuilder-1.15-2.1.16.jar +https://edge.forgecdn.net/files/3067/203/mightyarchitect-mc1.15.2_v0.5.jar +https://edge.forgecdn.net/files/2980/153/EquipmentTooltips-1.15.2-1.4.3+14.jar +https://edge.forgecdn.net/files/3103/510/FruitTrees-1.15.2-1.7.0.jar +https://edge.forgecdn.net/files/2989/38/Atmospheric-1.15.2-1.4.1.jar +https://edge.forgecdn.net/files/3096/836/rftoolscontrol-1.15-3.0.9.jar +https://edge.forgecdn.net/files/2989/662/Enhanced-Mushrooms-1.15.2-v1.2.2.jar +https://edge.forgecdn.net/files/3227/891/SimpleStorageNetwork-1.15.2-1.0.2.jar +https://edge.forgecdn.net/files/3217/290/minecolonies-0.13.645-RELEASE-universal.jar +https://edge.forgecdn.net/files/2935/384/SnowRealMagic-1.15.2-1.7.5.jar +https://edge.forgecdn.net/files/2988/584/aiotbotania-1.15.2-1.2.3.jar +https://edge.forgecdn.net/files/3255/408/mowziesmobs-1.5.15.jar +https://edge.forgecdn.net/files/3062/510/HealthOverlay-1.15.2-1.0.2.jar +https://edge.forgecdn.net/files/3023/121/neoncraft-1.1.jar +https://edge.forgecdn.net/files/2997/617/Swamp-Expansion-1.15.2-1.7.3.jar +https://edge.forgecdn.net/files/2980/252/titanium-1.15.2-2.4.2.jar +https://edge.forgecdn.net/files/3152/946/rftoolsutility-1.15-2.1.20.jar +https://edge.forgecdn.net/files/3083/277/swingthroughgrass-1.15.2-1.4.1.jar +https://edge.forgecdn.net/files/3138/530/SilentGear-1.15.2-1.11.4+187.jar +https://edge.forgecdn.net/files/3105/429/DarkUtilities-1.15.2-3.1.9.jar +https://edge.forgecdn.net/files/3099/23/ImmersiveEngineering-1.15.2-4.1.1-125.jar +https://edge.forgecdn.net/files/2856/529/FastFurnace-1.15.1-3.0.0.jar +https://edge.forgecdn.net/files/2988/999/BiomesOPlenty-1.15.2-10.0.0.366-universal.jar +https://edge.forgecdn.net/files/2989/95/The-Endergetic-Expansion-1.15.2-v1.3.2.jar +https://edge.forgecdn.net/files/2993/960/FluxNetworks-1.15.2-5.0.3-4.jar +https://edge.forgecdn.net/files/3028/611/ServerTabInfo-1.15.2-1.2.8.jar +https://edge.forgecdn.net/files/3134/277/fairylights-3.0.15-1.15.2.jar +https://edge.forgecdn.net/files/3048/54/useful_backpacks-1.15.2-1.10.3.77.jar +https://edge.forgecdn.net/files/3273/515/mcw-trapdoors-1.0.2-mc1.15.2.jar +https://edge.forgecdn.net/files/2986/639/CraftingTweaks_1.15.2-11.0.1.jar +https://edge.forgecdn.net/files/3261/454/create-mc1.15.2_v0.3.1a.jar +https://edge.forgecdn.net/files/3211/10/supermartijn642configlib-1.0.5-mc1.15.jar +https://edge.forgecdn.net/files/2995/786/TerraForged-1.15.2-0.0.15.jar +https://edge.forgecdn.net/files/2892/562/leavesdecayonotherleaves-1.1.jar \ No newline at end of file diff --git a/start-setupModpack b/start-setupModpack index 56bea8ed..572454b8 100755 --- a/start-setupModpack +++ b/start-setupModpack @@ -2,8 +2,13 @@ set -e -o pipefail +: "${REMOVE_OLD_MODS:=false}" +: "${MODS_FILE:=}" +: "${REMOVE_OLD_MODS_DEPTH:=1} " +: "${REMOVE_OLD_MODS_INCLUDE:=*.jar}" + # shellcheck source=start-utils -. ${SCRIPTS:-/}start-utils +. "${SCRIPTS:-$(dirname "$0")}/start-utils" if isDebugging; then set -x fi @@ -12,7 +17,7 @@ fi CURSE_URL_BASE=${CURSE_URL_BASE:-https://minecraft.curseforge.com/projects} # Remove old mods/plugins -if isTrue ${REMOVE_OLD_MODS:-false}; then +if isTrue "${REMOVE_OLD_MODS}" && [ -z "${MODS_FILE}" ]; then removeOldMods /data/mods removeOldMods /data/plugins fi @@ -95,6 +100,38 @@ if [[ "$MODS" ]]; then done fi +if [[ "$MODS_FILE" ]]; then + if [ ! -f "$MODS_FILE" ]; then + log "ERROR: given MODS_FILE file does not exist" + exit 2 + fi + + if [ "$TYPE" = "SPIGOT" ]; then + out_dir=/data/plugins + else + out_dir=/data/mods + fi + mkdir -p "$out_dir" + + args=( + -o "${out_dir}" + --log-progress-each + --skip-existing + --uris-file "${MODS_FILE}" + ) + if isTrue "${REMOVE_OLD_MODS}"; then + args+=( + --prune-others "${REMOVE_OLD_MODS_INCLUDE}" + --prune-depth "${REMOVE_OLD_MODS_DEPTH}" + ) + fi + + if ! get "${args[@]}" ; then + log "ERROR: failed to retrieve one or more mods" + exit 1 + fi +fi + if [[ "$MANIFEST" ]]; then if [[ -e "$MANIFEST" ]]; then EFFECTIVE_MANIFEST_FILE=$MANIFEST @@ -129,7 +166,7 @@ case "X$EFFECTIVE_MANIFEST_FILE" in fi done else - log "Could not find manifest file, unsufficient privs, or malformed path." + log "Could not find manifest file, insufficient privileges, or malformed path." fi ;; *) @@ -175,4 +212,4 @@ if [[ "${GENERIC_PACK}" ]]; then fi fi -exec ${SCRIPTS:-/}start-setupModconfig $@ +exec "${SCRIPTS:-$(dirname "$0")}/start-setupModconfig" "$@"