diff --git a/Dockerfile b/Dockerfile index 25a34014..899a723e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -46,8 +46,10 @@ 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.27.9 +ARG MC_HELPER_VERSION=1.28.2 ARG MC_HELPER_BASE_URL=https://github.com/itzg/mc-image-helper/releases/download/${MC_HELPER_VERSION} +# used for cache busting local copy of mc-image-helper +ARG MC_HELPER_REV=1 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 5ef55813..167de3b3 100644 --- a/README.md +++ b/README.md @@ -593,6 +593,28 @@ Configuration options with defaults: Crucible is only available for 1.7.10, so be sure to set `VERSION=1.7.10`. +## Running a server with a Modrinth modpack + +[Modrinth Modpacks](https://modrinth.com/modpacks) can automatically be installed along with the required mod loader (Forge or Fabric) by setting `TYPE` to "MODRINTH". Upgrading (and downgrading) takes care of cleaning up old files and upgrading (and downgrading) the mod loader. + +The desired modpack project is specified with the `MODRINTH_PROJECT` environment variable and must be one of: + +- The project "slug", which is located in the URL shown here: + + ![](docs/modrinth-project-slug.drawio.png) +- The project ID, which is located in the bottom of the left panel, shown here + + ![](docs/modrinth-project-id.drawio.png) +- The project page URL, such as . As described below, this can further be the page URL of a modpack's version page. + +By default, the latest available version of the Modrinth modpack is selected based upon the value of `MODRINTH_DEFAULT_VERSION_TYPE`, which defaults to "release". Other valid values are "beta" and "alpha". + +The selected version can also be narrowed by a few means: If wanting to use a particular mod loader, set `MODRINTH_LOADER` to either "forge" or "fabric" (Quilt support is coming soon). Since the overall `VERSION` gets dictated by the modpack, a specific modpack Minecraft version can be specified by setting `MODRINTH_MC_VERSION` to a valid version, such as "1.19.2". + +A specific version of modpack file can be specified by passing the version's page URL to `MODRINTH_PROJECT`, such as or by setting `MODRINTH_VERSION_ID` to the version ID located in the Metadata section, as shown here + +![](docs/modrinth-version-id.drawio.png) + ## Running a server with a Feed the Beast modpack > **NOTE** requires one of the Ubuntu with Hotspot images listed in [the Java versions section](#running-minecraft-server-on-different-java-version). diff --git a/docs/modrinth-project-id.drawio.png b/docs/modrinth-project-id.drawio.png new file mode 100644 index 00000000..d299f0c0 Binary files /dev/null and b/docs/modrinth-project-id.drawio.png differ diff --git a/docs/modrinth-project-slug.drawio.png b/docs/modrinth-project-slug.drawio.png new file mode 100644 index 00000000..f8dd5154 Binary files /dev/null and b/docs/modrinth-project-slug.drawio.png differ diff --git a/docs/modrinth-version-id.drawio.png b/docs/modrinth-version-id.drawio.png new file mode 100644 index 00000000..7ff96c9f Binary files /dev/null and b/docs/modrinth-version-id.drawio.png differ diff --git a/examples/docker-compose-modrinth-modpack.yml b/examples/docker-compose-modrinth-modpack.yml new file mode 100644 index 00000000..f6e213cb --- /dev/null +++ b/examples/docker-compose-modrinth-modpack.yml @@ -0,0 +1,20 @@ +version: "3.8" + +services: + mc: + image: itzg/minecraft-server + tty: true + stdin_open: true + ports: + - "25565:25565" + environment: + EULA: "TRUE" + TYPE: MODRINTH + MODRINTH_PROJECT: https://modrinth.com/modpack/cobblemon-fabric/version/1.3.2 + # or could be https://modrinth.com/modpack/cobblemon-fabric for auto-upgrading to latest + # or just cobblemon-fabric or 5FFgwNNP + # and could replace version URL with + # MODRINTH_VERSION_ID: nvrqJg44 + volumes: + # attach the relative directory 'data' to the container's /data path + - ./data:/data diff --git a/scripts/start-configuration b/scripts/start-configuration index aff3eb54..455542a0 100755 --- a/scripts/start-configuration +++ b/scripts/start-configuration @@ -208,6 +208,10 @@ case "${TYPE^^}" in exec "${SCRIPTS:-/}start-deployAutoCF" "$@" ;; + MODRINTH) + exec "${SCRIPTS:-/}start-deployModrinth" "$@" + ;; + VANILLA) exec "${SCRIPTS:-/}start-deployVanilla" "$@" ;; diff --git a/scripts/start-deployModrinth b/scripts/start-deployModrinth new file mode 100644 index 00000000..ae01fa26 --- /dev/null +++ b/scripts/start-deployModrinth @@ -0,0 +1,50 @@ +#!/bin/bash +set -eu + +# shellcheck source=start-utils +. "${SCRIPTS:-/}start-utils" + +resultsFile=/data/.install-modrinth.env + +requireVar MODRINTH_PROJECT +: "${MODRINTH_MC_VERSION:=}" +: "${MODRINTH_LOADER:=}" +: "${MODRINTH_VERSION_ID:=}" +: "${MODRINTH_DEFAULT_VERSION_TYPE:=release}" + +isDebugging && set -x + +args=( + --results-file="$resultsFile" + --project="${MODRINTH_PROJECT}" + --output-directory=/data +) + +setArg() { + arg="${1?}" + var="${2?}" + + if [[ ${!var} ]]; then + args+=("${arg}=${!var}") + fi +} +setArg --game-version MODRINTH_MC_VERSION +setArg --loader MODRINTH_LOADER +setArg --version-id MODRINTH_VERSION_ID +setArg --default-version-type MODRINTH_DEFAULT_VERSION_TYPE + +if ! mc-image-helper install-modrinth-modpack "${args[@]}"; then + log "ERROR failed to install Modrinth modpack" + exit 1 +fi + +# grab SERVER, FAMILY and export it +set -a +# shellcheck disable=SC1090 +source "${resultsFile}" +set +a +# grab the version resolved from modpack +VANILLA_VERSION="$VERSION" +export VANILLA_VERSION + +exec "${SCRIPTS:-/}start-setupWorld" "$@"