From eb0c30d1341dcbc42eed31c9fb8196474c29fca3 Mon Sep 17 00:00:00 2001 From: Geoff Bourne Date: Sun, 30 Jan 2022 19:49:54 -0600 Subject: [PATCH] feat: added prefix/suffix support for GENERIC_PACKS (#1321) For #1315 --- README.md | 16 +++++++++++++--- scripts/start-setupModpack | 7 +++++-- .../generic-packs-prefix/docker-compose.yml | 14 ++++++++++++++ .../generic-packs-prefix/packs/testing.zip | Bin 0 -> 212 bytes .../generic-packs-prefix/verify.sh | 1 + .../generic-packs/docker-compose.yml | 8 +++++++- tests/setuponlytests/generic-packs/verify.sh | 3 ++- .../generic-packs/web/configs.zip | Bin 0 -> 126 bytes 8 files changed, 42 insertions(+), 7 deletions(-) create mode 100644 tests/setuponlytests/generic-packs-prefix/docker-compose.yml create mode 100644 tests/setuponlytests/generic-packs-prefix/packs/testing.zip create mode 100644 tests/setuponlytests/generic-packs-prefix/verify.sh create mode 100644 tests/setuponlytests/generic-packs/web/configs.zip diff --git a/README.md b/README.md index aafa9bab..04d4ec4f 100644 --- a/README.md +++ b/README.md @@ -798,11 +798,21 @@ Example of expected ForgeAPI file format. ] ``` -### Generic pack file +### Generic pack files -To install all of the server content (jars, mods, plugins, configs, etc) from a zip file, such as a CurseForge modpack that is missing a server start script, then set `GENERIC_PACK` to the container path of the zip file. That, combined with `TYPE`, allows for custom content along with container managed server download and install. +To install all of the server content (jars, mods, plugins, configs, etc) from a zip or tgz file, such as a CurseForge modpack that is missing a server start script, then set `GENERIC_PACK` to the container path or URL of the archive file. -If multiple generic packs need to be applied together, set `GENERIC_PACKS` instead, with a comma separated list of zip file paths and/or URLs to zip files. +If multiple generic packs need to be applied together, set `GENERIC_PACKS` instead, with a comma separated list of archive file paths and/or URLs to files. + +To avoid repetition, each entry will be prefixed by the value of `GENERIC_PACKS_PREFIX` and suffixed by the value of `GENERIC_PACKS_SUFFIX`, both of which are optional. For example, the following variables + +``` +GENERIC_PACKS=configs-v9.0.1,mods-v4.3.6 +GENERIC_PACKS_PREFIX=https://cdn.example.org/ +GENERIC_PACKS_SUFFIX=.zip +``` + +would expand to `https://cdn.example.org/configs-v9.0.1.zip,https://cdn.example.org/mods-v4.3.6.zip`. ### Mod/Plugin URL Listing File diff --git a/scripts/start-setupModpack b/scripts/start-setupModpack index 5dc66e38..88281d4a 100755 --- a/scripts/start-setupModpack +++ b/scripts/start-setupModpack @@ -188,13 +188,16 @@ esac fi : "${GENERIC_PACKS:=${GENERIC_PACK}}" +: "${GENERIC_PACKS_PREFIX:=}" +: "${GENERIC_PACKS_SUFFIX:=}" if [[ "${GENERIC_PACKS}" ]]; then IFS=',' read -ra packs <<< "${GENERIC_PACKS}" packFiles=() - for pack in "${packs[@]}"; do - if isURL "$pack"; then + for packEntry in "${packs[@]}"; do + pack="${GENERIC_PACKS_PREFIX}${packEntry}${GENERIC_PACKS_SUFFIX}" + if isURL "${pack}"; then mkdir -p /data/packs if ! outfile=$(get -o /data/packs --output-filename --skip-existing "$pack"); then log "ERROR: failed to download $pack" diff --git a/tests/setuponlytests/generic-packs-prefix/docker-compose.yml b/tests/setuponlytests/generic-packs-prefix/docker-compose.yml new file mode 100644 index 00000000..4d84fa67 --- /dev/null +++ b/tests/setuponlytests/generic-packs-prefix/docker-compose.yml @@ -0,0 +1,14 @@ +version: "3" + +services: + mc: + image: ${IMAGE_TO_TEST:-itzg/minecraft-server} + environment: + EULA: "true" + SETUP_ONLY: "TRUE" + GENERIC_PACKS: testing + GENERIC_PACKS_PREFIX: /packs/ + GENERIC_PACKS_SUFFIX: .zip + volumes: + - ./packs:/packs + - ./data:/data diff --git a/tests/setuponlytests/generic-packs-prefix/packs/testing.zip b/tests/setuponlytests/generic-packs-prefix/packs/testing.zip new file mode 100644 index 0000000000000000000000000000000000000000..3bab4151dc3e39c20c43ed93c720158acbb46935 GIT binary patch literal 212 zcmWIWW@Zs#00Hs&5y4;vlwb$a`FW{&B^4zBa7Bt}igO=z k2r*j$LLrPtXu@UzLX#?xiE14y8%UN32=jroKZwHs0QdwMxBvhE literal 0 HcmV?d00001 diff --git a/tests/setuponlytests/generic-packs-prefix/verify.sh b/tests/setuponlytests/generic-packs-prefix/verify.sh new file mode 100644 index 00000000..cb4652ec --- /dev/null +++ b/tests/setuponlytests/generic-packs-prefix/verify.sh @@ -0,0 +1 @@ +mc-image-helper assert fileExists one.txt mods/two.txt diff --git a/tests/setuponlytests/generic-packs/docker-compose.yml b/tests/setuponlytests/generic-packs/docker-compose.yml index 071c430d..b5450605 100644 --- a/tests/setuponlytests/generic-packs/docker-compose.yml +++ b/tests/setuponlytests/generic-packs/docker-compose.yml @@ -1,12 +1,18 @@ version: "3" services: + web: + image: nginx + volumes: + - ./web:/usr/share/nginx/html mc: + depends_on: + - web image: ${IMAGE_TO_TEST:-itzg/minecraft-server} environment: EULA: "true" SETUP_ONLY: "TRUE" - GENERIC_PACKS: https://github.com/itzg/mc-image-helper/releases/download/v1.9.5/mc-image-helper-1.9.5.zip,/packs/testing.zip + GENERIC_PACKS: http://web/configs.zip,/packs/testing.zip volumes: - ./packs:/packs - ./data:/data diff --git a/tests/setuponlytests/generic-packs/verify.sh b/tests/setuponlytests/generic-packs/verify.sh index 15166fe9..0b66ce48 100644 --- a/tests/setuponlytests/generic-packs/verify.sh +++ b/tests/setuponlytests/generic-packs/verify.sh @@ -1 +1,2 @@ -mc-image-helper assert fileExists one.txt mods/two.txt \ No newline at end of file +mc-image-helper assert fileExists one.txt mods/two.txt +mc-image-helper assert fileExists one.txt config/opt.yml \ No newline at end of file diff --git a/tests/setuponlytests/generic-packs/web/configs.zip b/tests/setuponlytests/generic-packs/web/configs.zip new file mode 100644 index 0000000000000000000000000000000000000000..3848a7f671b0d37c0f97182a0eef497752f50c22 GIT binary patch literal 126 zcmWIWW@Zs#0D+udyAUt~O7H>co OBp89v21x6GRRI89B@oX5 literal 0 HcmV?d00001