From c8ffbec928b54909e601e43b1ecccef54d3b14e0 Mon Sep 17 00:00:00 2001 From: Geoff Bourne Date: Sun, 11 Jun 2023 11:00:39 -0500 Subject: [PATCH] For backward compatibility, allow MODS to list plugins for those server types (#2200) --- docs/mods-and-plugins/index.md | 14 ++-- kustomize/base/kustomization.yml | 2 + scripts/start-setupModpack | 111 ++++++++++++++++--------------- scripts/start-setupMounts | 33 +++++---- 4 files changed, 86 insertions(+), 74 deletions(-) diff --git a/docs/mods-and-plugins/index.md b/docs/mods-and-plugins/index.md index 37891d64..7bb54ab0 100644 --- a/docs/mods-and-plugins/index.md +++ b/docs/mods-and-plugins/index.md @@ -14,18 +14,22 @@ The following are some supported mod platforms: On the left, there are sections describing some download automation options. +## Mods vs Plugins + +The terms "mods" and "plugins" can be quite confusing. Generally, the rule of thumb is that "mods" are used by the types that run client side to modify rendering, add new blocks, and add behaviors server, such as [Forge](../types-and-platforms/server-types/forge.md) and [Fabric](../types-and-platforms/server-types/fabric.md). "Plugins" are used by the types that **only run on servers** to add behaviors, commands, etc such as [Paper](../types-and-platforms/server-types/paper.md) (which derives from [Bukkit/Spigot](../types-and-platforms/server-types/bukkit-spigot.md)). There are also some types that are [hybrids](../types-and-platforms/server-types/hybrids.md), such as Magma, that use both "mods" and "plugins" + ## Optional plugins, mods, and config attach points There are optional volume paths that can be attached to supply content to be copied into the data area: `/plugins` -: contents are synchronized into `/data/plugins` for Bukkit related server types. The source can be changed by setting `COPY_PLUGINS_SRC`. The destination can be changed by setting `COPY_PLUGINS_DEST`. Set `SYNC_SKIP_NEWER_IN_DESTINATION=false` if you want files from `/plugins` to take precedence over newer files in `/data/plugins`. +: content in this directory is synchronized into `/data/plugins` for server types that use plugins, [as described above](#mods-vs-plugins). For special cases, the source can be changed by setting `COPY_PLUGINS_SRC` and destination by setting `COPY_PLUGINS_DEST`. `/mods` -: contents are synchronized into `/data/mods` for Fabric and Forge related server types. The source can be changed by setting `COPY_MODS_SRC`. The destination can be changed by setting `COPY_MODS_DEST`. +: content in this directory is synchronized into `/data/mods` for server types that use mods, [as described above](#mods-vs-plugins). For special cases, the source can be changed by setting `COPY_MODS_SRC` and destination by setting `COPY_MODS_DEST`. `/config` -: contents are synchronized into `/data/config` by default, but can be changed with `COPY_CONFIG_DEST`. The source can be changed by setting `COPY_CONFIG_SRC`. For example, `-v ./config:/config -e COPY_CONFIG_DEST=/data` will allow you to copy over files like `bukkit.yml` and so on directly into the server directory. Set `SYNC_SKIP_NEWER_IN_DESTINATION=false` if you want files from `/config` to take precedence over newer files in `/data/config`. +: contents are synchronized into `/data/config` by default, but can be changed with `COPY_CONFIG_DEST`. For example, `-v ./config:/config -e COPY_CONFIG_DEST=/data` will allow you to copy over files like `bukkit.yml` and so on directly into the server directory. The source can be changed by setting `COPY_CONFIG_SRC`. Set `SYNC_SKIP_NEWER_IN_DESTINATION=false` if you want files from `/config` to take precedence over newer files in `/data/config`. By default, the [environment variable processing](../configuration/interpolating.md) is performed on synchronized files that match the expected suffixes in `REPLACE_ENV_SUFFIXES` (by default "yml,yaml,txt,cfg,conf,properties,hjson,json,tml,toml") and are not excluded by `REPLACE_ENV_VARIABLES_EXCLUDES` and `REPLACE_ENV_VARIABLES_EXCLUDE_PATHS`. This processing can be disabled by setting `REPLACE_ENV_DURING_SYNC` to `false`. @@ -37,7 +41,9 @@ For example: `-e REMOVE_OLD_MODS=TRUE -e REMOVE_OLD_MODS_INCLUDE="*.jar" -e REMO These paths work well if you want to have a common set of modules in a separate location, but still have multiple worlds with different server requirements in either persistent volumes or a downloadable archive. -> For more flexibility with mods/plugins preparation, you can declare directories to use in [the `MODS` variable](#modsplugins-list) +!!! information "" + For more flexibility with mods/plugins preparation, you can declare other directories, files, and URLs to use in [the `MODS` / `PLUGINS` variables](#modsplugins-list). + ## Zip file modpack diff --git a/kustomize/base/kustomization.yml b/kustomize/base/kustomization.yml index 7e36e256..dbcc8326 100644 --- a/kustomize/base/kustomization.yml +++ b/kustomize/base/kustomization.yml @@ -1,3 +1,5 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization resources: - statefulset.yml - service.yml \ No newline at end of file diff --git a/scripts/start-setupModpack b/scripts/start-setupModpack index 7956a58f..aac36a8b 100755 --- a/scripts/start-setupModpack +++ b/scripts/start-setupModpack @@ -22,8 +22,8 @@ CURSE_URL_BASE=${CURSE_URL_BASE:-https://minecraft.curseforge.com/projects} # Remove old mods/plugins if isTrue "${REMOVE_OLD_MODS}" && [ -z "${MODS_FILE}" ]; then - removeOldMods /data/mods - removeOldMods /data/plugins + removeOldMods "$MODS_OUT_DIR" + removeOldMods "$PLUGINS_OUT_DIR" rm -f "$sum_file" fi @@ -66,13 +66,13 @@ if [[ "$MODPACK" ]]; then fi if [ "$FAMILY" = "SPIGOT" ]; then - mkdir -p /data/plugins - if ! unzip -o -d /data/plugins /tmp/modpack.zip; then + mkdir -p "$PLUGINS_OUT_DIR" + if ! unzip -o -d "$PLUGINS_OUT_DIR" /tmp/modpack.zip; then log "ERROR: failed to unzip the modpack from ${MODPACK}" fi else - mkdir -p /data/mods - if ! unzip -o -d /data/mods /tmp/modpack.zip; then + mkdir -p "$MODS_OUT_DIR" + if ! unzip -o -d "$MODS_OUT_DIR" /tmp/modpack.zip; then log "ERROR: failed to unzip the modpack from ${MODPACK}" fi fi @@ -81,58 +81,65 @@ fi } function handleListings() { - if [[ "$MODS" ]]; then - if usesMods; then - mkdir -p "$MODS_OUT_DIR" - mc-image-helper mcopy \ - --glob=*.jar \ - --scope=var-list \ - --to="$MODS_OUT_DIR" \ - "$MODS" - else - log "ERROR: TYPE=$TYPE does not support mods" - exit 1 - fi - fi - if [[ "$PLUGINS" ]]; then - if usesPlugins; then - mkdir -p "$PLUGINS_OUT_DIR" - mc-image-helper mcopy \ - --glob=*.jar \ - --scope=var-list \ - --to="$PLUGINS_OUT_DIR" \ - "$PLUGINS" - else - log "ERROR: TYPE=$TYPE does not support plugins" - exit 1 - fi - fi + if usesMods && usesPlugins; then + if [[ "$MODS" ]]; then + mkdir -p "$MODS_OUT_DIR" + mc-image-helper mcopy \ + --glob=*.jar \ + --scope=var-list \ + --to="$MODS_OUT_DIR" \ + "$MODS" + fi + if [[ "$PLUGINS" ]]; then + mkdir -p "$PLUGINS_OUT_DIR" + mc-image-helper mcopy \ + --glob=*.jar \ + --scope=var-list \ + --to="$PLUGINS_OUT_DIR" \ + "$PLUGINS" + fi - if [[ "$MODS_FILE" ]]; then - if usesMods; then - mkdir -p "$MODS_OUT_DIR" - mc-image-helper mcopy \ - --file-is-listing \ - --scope=file-list \ - --to="$MODS_OUT_DIR" \ - "$MODS_FILE" - else - log "ERROR: TYPE=$TYPE does not support mods" - exit 1 - fi - fi - if [[ "$PLUGINS_FILE" ]]; then + if [[ "$MODS_FILE" ]]; then + mkdir -p "$MODS_OUT_DIR" + mc-image-helper mcopy \ + --file-is-listing \ + --scope=file-list \ + --to="$MODS_OUT_DIR" \ + "$MODS_FILE" + fi + if [[ "$PLUGINS_FILE" ]]; then + mkdir -p "$PLUGINS_OUT_DIR" + mc-image-helper mcopy \ + --file-is-listing \ + --scope=file-list \ + --to="$PLUGINS_OUT_DIR" \ + "$PLUGINS_FILE" + fi + + elif usesPlugins || usesMods; then + outDir="$MODS_OUT_DIR" if usesPlugins; then - mkdir -p "$PLUGINS_OUT_DIR" + outDir="$PLUGINS_OUT_DIR" + fi + + if [[ "$MODS" || "$PLUGINS" ]]; then + mkdir -p "$outDir" + mc-image-helper mcopy \ + --glob=*.jar \ + --scope=var-list \ + --to="$outDir" \ + "$MODS" "$PLUGINS" + fi + + if [[ "$MODS_FILE" || "$PLUGINS_FILE" ]]; then + mkdir -p "$outDir" mc-image-helper mcopy \ --file-is-listing \ --scope=file-list \ - --to="$PLUGINS_OUT_DIR" \ - "$PLUGINS_FILE" - else - log "ERROR: TYPE=$TYPE does not support plugins" - exit 1 + --to="$outDir" \ + "$MODS_FILE" "$PLUGINS_FILE" fi + fi } diff --git a/scripts/start-setupMounts b/scripts/start-setupMounts index fb1da99a..d1b83c43 100755 --- a/scripts/start-setupMounts +++ b/scripts/start-setupMounts @@ -10,6 +10,8 @@ : "${REPLACE_ENV_VARIABLES_EXCLUDES:=}" : "${REPLACE_ENV_VARIABLES_EXCLUDE_PATHS:=}" : "${DEBUG:=false}" +: "${MODS_OUT_DIR:=/data/mods}" +: "${PLUGINS_OUT_DIR:=/data/plugins}" set -e isDebugging && set -x @@ -25,29 +27,24 @@ else fi : "${COPY_PLUGINS_SRC:="/plugins"}" -: "${COPY_PLUGINS_DEST:="/data/plugins"}" +: "${COPY_PLUGINS_DEST:=${PLUGINS_OUT_DIR}}" -if [ -d "${COPY_PLUGINS_SRC}" ]; then - case ${FAMILY} in - SPIGOT|HYBRID) - mkdir -p "${COPY_PLUGINS_DEST}" - log "Copying any plugins from ${COPY_PLUGINS_SRC} to ${COPY_PLUGINS_DEST}" - mc-image-helper \ - ${subcommand} $updateArg \ - --replace-env-file-suffixes="${REPLACE_ENV_SUFFIXES}" \ - --replace-env-excludes="${REPLACE_ENV_VARIABLES_EXCLUDES}" \ - --replace-env-exclude-paths="${REPLACE_ENV_VARIABLES_EXCLUDE_PATHS}" \ - --replace-env-prefix="${REPLACE_ENV_VARIABLE_PREFIX}" \ - "${COPY_PLUGINS_SRC}" "${COPY_PLUGINS_DEST}" - ;; - esac +if usesPlugins && [ -d "${COPY_PLUGINS_SRC}" ]; then + mkdir -p "${COPY_PLUGINS_DEST}" + log "Copying any plugins from ${COPY_PLUGINS_SRC} to ${COPY_PLUGINS_DEST}" + mc-image-helper \ + ${subcommand} $updateArg \ + --replace-env-file-suffixes="${REPLACE_ENV_SUFFIXES}" \ + --replace-env-excludes="${REPLACE_ENV_VARIABLES_EXCLUDES}" \ + --replace-env-exclude-paths="${REPLACE_ENV_VARIABLES_EXCLUDE_PATHS}" \ + --replace-env-prefix="${REPLACE_ENV_VARIABLE_PREFIX}" \ + "${COPY_PLUGINS_SRC}" "${COPY_PLUGINS_DEST}" fi -# If any modules have been provided, copy them over : "${COPY_MODS_SRC:="/mods"}" -: "${COPY_MODS_DEST:="/data/mods"}" +: "${COPY_MODS_DEST:=${MODS_OUT_DIR}}" -if [ -d "${COPY_MODS_SRC}" ]; then +if usesMods && [ -d "${COPY_MODS_SRC}" ]; then log "Copying any mods from ${COPY_MODS_SRC} to ${COPY_MODS_DEST}" mc-image-helper \ ${subcommand} $updateArg \