From 1087e206af0f1b2152ec0efd5f8bb3808408009d Mon Sep 17 00:00:00 2001 From: Ryan Hullah Date: Tue, 7 Feb 2023 19:44:00 +0000 Subject: [PATCH 1/2] Add source dir override for /mods and /config --- README.md | 4 ++-- scripts/start-setupMounts | 14 ++++++++------ .../mounts-custom/custom/config/test.json | 1 + .../mounts-custom/custom/mods/mod.jar | 0 .../mounts-custom/docker-compose.yml | 19 +++++++++++++++++++ tests/setuponlytests/mounts-custom/fake.jar | 0 tests/setuponlytests/mounts-custom/verify.sh | 2 ++ 7 files changed, 32 insertions(+), 8 deletions(-) create mode 100644 tests/setuponlytests/mounts-custom/custom/config/test.json create mode 100644 tests/setuponlytests/mounts-custom/custom/mods/mod.jar create mode 100644 tests/setuponlytests/mounts-custom/docker-compose.yml create mode 100644 tests/setuponlytests/mounts-custom/fake.jar create mode 100644 tests/setuponlytests/mounts-custom/verify.sh diff --git a/README.md b/README.md index 939f36e5ca3..00409695110 100644 --- a/README.md +++ b/README.md @@ -750,10 +750,10 @@ There are optional volume paths that can be attached to supply content to be cop : contents are synchronized into `/data/plugins` for Bukkit related server types. Set `SYNC_SKIP_NEWER_IN_DESTINATION=false` if you want files from `/plugins` to take precedence over newer files in `/data/plugins`. `/mods` -: contents are synchronized into `/data/mods` for Fabric and Forge related server types. The destination can be changed by setting `COPY_MODS_DEST`. +: 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`. `/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. 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`. 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`. By default, the [environment variable processing](#replacing-variables-inside-configs) 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`. diff --git a/scripts/start-setupMounts b/scripts/start-setupMounts index c11f5f0425e..894a9e08d3e 100755 --- a/scripts/start-setupMounts +++ b/scripts/start-setupMounts @@ -41,30 +41,32 @@ if [ -d /plugins ]; then fi # If any modules have been provided, copy them over +: "${COPY_MODS_SRC:="/mods"}" : "${COPY_MODS_DEST:="/data/mods"}" -if [ -d /mods ]; then - log "Copying any mods over..." +if [ -d "${COPY_MODS_SRC}" ]; then + log "Copying any mods from ${COPY_MODS_SRC} to ${COPY_MODS_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}" \ - /mods "${COPY_MODS_DEST}" + "${COPY_MODS_SRC}" "${COPY_MODS_DEST}" fi +: "${COPY_CONFIG_SRC:="/config"}" : "${COPY_CONFIG_DEST:="/data/config"}" -if [ -d /config ]; then - log "Copying any configs from /config to ${COPY_CONFIG_DEST}" +if [ -d "${COPY_CONFIG_SRC}" ]; then + log "Copying any configs from ${COPY_CONFIG_SRC} to ${COPY_CONFIG_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}" \ - /config "${COPY_CONFIG_DEST}" + "${COPY_CONFIG_SRC}" "${COPY_CONFIG_DEST}" fi exec "${SCRIPTS:-/}start-setupServerProperties" "$@" diff --git a/tests/setuponlytests/mounts-custom/custom/config/test.json b/tests/setuponlytests/mounts-custom/custom/config/test.json new file mode 100644 index 00000000000..9e26dfeeb6e --- /dev/null +++ b/tests/setuponlytests/mounts-custom/custom/config/test.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/tests/setuponlytests/mounts-custom/custom/mods/mod.jar b/tests/setuponlytests/mounts-custom/custom/mods/mod.jar new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/setuponlytests/mounts-custom/docker-compose.yml b/tests/setuponlytests/mounts-custom/docker-compose.yml new file mode 100644 index 00000000000..1d84641edc2 --- /dev/null +++ b/tests/setuponlytests/mounts-custom/docker-compose.yml @@ -0,0 +1,19 @@ +version: "3" + +services: + mc: + image: ${IMAGE_TO_TEST:-itzg/minecraft-server} + environment: + EULA: "true" + SETUP_ONLY: "true" + TYPE: CUSTOM + CUSTOM_SERVER: /servers/fake.jar + VERSION: 1.18.1 + COPY_MODS_SRC: /custom/mods + COPY_MODS_DEST: /data/custom-mods + COPY_CONFIG_SRC: /custom/config + COPY_CONFIG_DEST: /data/custom-config + volumes: + - ./data:/data + - ./custom:/custom + - ./fake.jar:/servers/fake.jar diff --git a/tests/setuponlytests/mounts-custom/fake.jar b/tests/setuponlytests/mounts-custom/fake.jar new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/setuponlytests/mounts-custom/verify.sh b/tests/setuponlytests/mounts-custom/verify.sh new file mode 100644 index 00000000000..120eb209c38 --- /dev/null +++ b/tests/setuponlytests/mounts-custom/verify.sh @@ -0,0 +1,2 @@ +mc-image-helper assert fileExists custom-mods/mod.jar +mc-image-helper assert fileExists custom-config/test.json From 9e67641406bc00f01ceb58928ec9859d21e51421 Mon Sep 17 00:00:00 2001 From: Ryan Hullah Date: Wed, 8 Feb 2023 13:53:41 +0000 Subject: [PATCH 2/2] Added `COPY_PLUGINS_SRC` and `COPY_PLUGINS_DEST` --- README.md | 2 +- scripts/start-setupMounts | 11 +++++++---- .../mounts-custom/custom/plugins/plugin.jar | 0 tests/setuponlytests/mounts-custom/docker-compose.yml | 2 ++ tests/setuponlytests/mounts-custom/verify.sh | 1 + 5 files changed, 11 insertions(+), 5 deletions(-) create mode 100644 tests/setuponlytests/mounts-custom/custom/plugins/plugin.jar diff --git a/README.md b/README.md index 00409695110..21d62b11e99 100644 --- a/README.md +++ b/README.md @@ -747,7 +747,7 @@ packwiz modpack defitions are processed before other mod definitions (`MODPACK`, 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. Set `SYNC_SKIP_NEWER_IN_DESTINATION=false` if you want files from `/plugins` to take precedence over newer files in `/data/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`. `/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`. diff --git a/scripts/start-setupMounts b/scripts/start-setupMounts index 894a9e08d3e..fb1da99a89f 100755 --- a/scripts/start-setupMounts +++ b/scripts/start-setupMounts @@ -24,18 +24,21 @@ else subcommand=sync fi -if [ -d /plugins ]; then +: "${COPY_PLUGINS_SRC:="/plugins"}" +: "${COPY_PLUGINS_DEST:="/data/plugins"}" + +if [ -d "${COPY_PLUGINS_SRC}" ]; then case ${FAMILY} in SPIGOT|HYBRID) - mkdir -p /data/plugins - log "Copying plugins over..." + 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}" \ - /plugins /data/plugins + "${COPY_PLUGINS_SRC}" "${COPY_PLUGINS_DEST}" ;; esac fi diff --git a/tests/setuponlytests/mounts-custom/custom/plugins/plugin.jar b/tests/setuponlytests/mounts-custom/custom/plugins/plugin.jar new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/setuponlytests/mounts-custom/docker-compose.yml b/tests/setuponlytests/mounts-custom/docker-compose.yml index 1d84641edc2..0f6a59fa23d 100644 --- a/tests/setuponlytests/mounts-custom/docker-compose.yml +++ b/tests/setuponlytests/mounts-custom/docker-compose.yml @@ -9,6 +9,8 @@ services: TYPE: CUSTOM CUSTOM_SERVER: /servers/fake.jar VERSION: 1.18.1 + COPY_PLUGINS_SRC: /custom/plugins + COPY_PLUGINS_DEST: /data/custom-plugins COPY_MODS_SRC: /custom/mods COPY_MODS_DEST: /data/custom-mods COPY_CONFIG_SRC: /custom/config diff --git a/tests/setuponlytests/mounts-custom/verify.sh b/tests/setuponlytests/mounts-custom/verify.sh index 120eb209c38..b409ffb3412 100644 --- a/tests/setuponlytests/mounts-custom/verify.sh +++ b/tests/setuponlytests/mounts-custom/verify.sh @@ -1,2 +1,3 @@ +mc-image-helper assert fileExists custom-plugins/plugin.jar mc-image-helper assert fileExists custom-mods/mod.jar mc-image-helper assert fileExists custom-config/test.json