Support automatically downloading and upgrading CurseForge modpacks (#1889)
This commit is contained in:
parent
dd6cda1ae5
commit
48367b7c1f
|
@ -46,7 +46,7 @@ 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.23.1
|
||||
ARG MC_HELPER_VERSION=1.24.1
|
||||
ARG MC_HELPER_BASE_URL=https://github.com/itzg/mc-image-helper/releases/download/${MC_HELPER_VERSION}
|
||||
RUN curl -fsSL ${MC_HELPER_BASE_URL}/mc-image-helper-${MC_HELPER_VERSION}.tgz \
|
||||
| tar -C /usr/share -zxf - \
|
||||
|
|
41
README.md
41
README.md
|
@ -610,6 +610,47 @@ docker run -d --name mc-ftb -e EULA=TRUE \
|
|||
|
||||
## Running a server with a CurseForge modpack
|
||||
|
||||
### New approach
|
||||
|
||||
> **NOTE** This approach is in early access. Please include as many details as possible when reporting issues for this.
|
||||
|
||||
To manage a CurseForge modpack automatically with upgrade support, set `TYPE` to "AUTO_CURSEFORGE". The appropriate mod loader (Forge / Fabric) will also be automatically installed with the version declared by the modpack.
|
||||
|
||||
Use one of the following to specify the modpack to install:
|
||||
|
||||
Pass a page URL to the modpack or a specific file with `CF_PAGE_URL` such as the modpack page "https://www.curseforge.com/minecraft/modpacks/all-the-mods-8" or a specific file "https://www.curseforge.com/minecraft/modpacks/all-the-mods-8/files/4248390". For example:
|
||||
|
||||
```
|
||||
-e TYPE=AUTO_CURSEFORGE -e CF_PAGE_URL=https://www.curseforge.com/minecraft/modpacks/all-the-mods-8
|
||||
```
|
||||
|
||||
Instead of a URL, the modpack slug can be provided as `CF_SLUG`. The slug is the short identifier visible in the URL after "/modpacks/", such as
|
||||
|
||||
![img.png](docs/cf-slug.png)
|
||||
|
||||
For example:
|
||||
```
|
||||
-e TYPE=AUTO_CURSEFORGE -e CF_SLUG=all-the-mods-8
|
||||
```
|
||||
|
||||
With either the modpack page or slug approach, the latest file will be located and used. If a specific version is desired, set either `CF_FILE_ID` to the numerical file ID or use a matching substring with `CF_FILENAME_MATCHER`.
|
||||
|
||||
The file ID can be located in the URL like
|
||||
|
||||
![img.png](docs/cf-file-id.png)
|
||||
|
||||
The following two examples both refer to version 1.0.7 of ATM8:
|
||||
|
||||
```
|
||||
-e TYPE=AUTO_CURSEFORGE -e CF_SLUG=all-the-mods-8 -e CF_FILE_ID=4248390
|
||||
```
|
||||
|
||||
```
|
||||
-e TYPE=AUTO_CURSEFORGE -e CF_SLUG=all-the-mods-8 -e CF_FILENAME_MATCHER=1.0.7
|
||||
```
|
||||
|
||||
### Old approach
|
||||
|
||||
Enable this server mode by adding `-e TYPE=CURSEFORGE` to your command-line,
|
||||
but note the following additional steps needed...
|
||||
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
/.*.bkp
|
Binary file not shown.
After Width: | Height: | Size: 5.4 KiB |
Binary file not shown.
After Width: | Height: | Size: 3.2 KiB |
|
@ -0,0 +1,43 @@
|
|||
#!/bin/bash
|
||||
set -eu
|
||||
|
||||
# shellcheck source=start-utils
|
||||
. "${SCRIPTS:-/}start-utils"
|
||||
|
||||
: "${CF_PAGE_URL:=}"
|
||||
: "${CF_SLUG:=}"
|
||||
: "${CF_FILE_ID:=}"
|
||||
: "${CF_FILENAME_MATCHER:=}"
|
||||
|
||||
resultsFile=/data/.install-curseforge.env
|
||||
|
||||
isDebugging && set -x
|
||||
|
||||
args=(
|
||||
--results-file="$resultsFile"
|
||||
)
|
||||
if [[ $CF_PAGE_URL ]]; then
|
||||
args+=(--modpack-page-url="$CF_PAGE_URL")
|
||||
fi
|
||||
if [[ $CF_FILE_ID ]]; then
|
||||
args+=(--file-id="$CF_FILE_ID")
|
||||
fi
|
||||
if [[ $CF_SLUG ]]; then
|
||||
args+=(--slug="$CF_SLUG")
|
||||
fi
|
||||
if [[ $CF_FILENAME_MATCHER ]]; then
|
||||
args+=(--filename-matcher="$CF_FILENAME_MATCHER")
|
||||
fi
|
||||
|
||||
if ! mc-image-helper install-curseforge "${args[@]}"; then
|
||||
log "ERROR failed to auto-install CurseForge modpack"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# grab SERVER, FAMILY and export it
|
||||
set -a
|
||||
# shellcheck disable=SC1090
|
||||
source "${resultsFile}"
|
||||
set +a
|
||||
|
||||
exec "${SCRIPTS:-/}start-setupWorld" "$@"
|
|
@ -136,11 +136,11 @@ cd /data || exit 1
|
|||
export ORIGINAL_TYPE=${TYPE^^}
|
||||
|
||||
if isTrue "${ENABLE_AUTOPAUSE}"; then
|
||||
${SCRIPTS:-/}start-autopause
|
||||
"${SCRIPTS:-/}start-autopause"
|
||||
fi
|
||||
|
||||
if isTrue "${ENABLE_AUTOSTOP}"; then
|
||||
${SCRIPTS:-/}start-autostop
|
||||
"${SCRIPTS:-/}start-autostop"
|
||||
fi
|
||||
|
||||
if
|
||||
|
@ -152,7 +152,7 @@ if
|
|||
then
|
||||
log "Starting RCON commands"
|
||||
# shellcheck source=start-rconcmds
|
||||
${SCRIPTS:-/}start-rconcmds
|
||||
"${SCRIPTS:-/}start-rconcmds"
|
||||
fi
|
||||
|
||||
if versionLessThan 1.7; then
|
||||
|
@ -196,6 +196,10 @@ case "${TYPE^^}" in
|
|||
exec "${SCRIPTS:-/}start-deployCF" "$@"
|
||||
;;
|
||||
|
||||
AUTO_CURSEFORGE)
|
||||
exec "${SCRIPTS:-/}start-autoDeployCF" "$@"
|
||||
;;
|
||||
|
||||
VANILLA)
|
||||
exec "${SCRIPTS:-/}start-deployVanilla" "$@"
|
||||
;;
|
||||
|
|
|
@ -4,47 +4,49 @@ set -eu
|
|||
# shellcheck source=start-utils
|
||||
. "${SCRIPTS:-/}start-utils"
|
||||
|
||||
requireVar VANILLA_VERSION
|
||||
export TYPE=FABRIC
|
||||
: "${FABRIC_LAUNCHER_VERSION:=${FABRIC_INSTALLER_VERSION:-LATEST}}"
|
||||
: "${FABRIC_LAUNCHER:=}"
|
||||
: "${FABRIC_LAUNCHER_URL:=}"
|
||||
: "${FABRIC_LOADER_VERSION:=LATEST}"
|
||||
|
||||
resultsFile=/data/.install-fabric.env
|
||||
|
||||
isDebugging && set -x
|
||||
|
||||
# Custom fabric jar
|
||||
if [[ $FABRIC_LAUNCHER ]]; then
|
||||
export SERVER=${FABRIC_LAUNCHER}
|
||||
if ! mc-image-helper install-fabric-loader \
|
||||
--results-file=${resultsFile} \
|
||||
--from-local-file="$FABRIC_LAUNCHER"; then
|
||||
log "ERROR failed to install Fabric launcher from $FABRIC_LAUNCHER"
|
||||
exit 1
|
||||
fi
|
||||
# Custom fabric jar url
|
||||
elif [[ $FABRIC_LAUNCHER_URL ]]; then
|
||||
export SERVER=fabric-server-$(echo -n "$FABRIC_LAUNCHER_URL" | mc-image-helper hash)
|
||||
if ! mc-image-helper install-fabric-loader \
|
||||
--results-file=${resultsFile} \
|
||||
--from-url="$FABRIC_LAUNCHER_URL"; then
|
||||
log "ERROR failed to install Fabric launcher from $FABRIC_LAUNCHER_URL"
|
||||
exit 1
|
||||
fi
|
||||
# Official fabric launcher
|
||||
else
|
||||
if [[ ${FABRIC_LAUNCHER_VERSION^^} = LATEST ]]; then
|
||||
log "Checking Fabric Launcher version information."
|
||||
FABRIC_LAUNCHER_VERSION=$(maven-metadata-release https://maven.fabricmc.net/net/fabricmc/fabric-installer/maven-metadata.xml)
|
||||
fi
|
||||
if [[ ${FABRIC_LOADER_VERSION^^} = LATEST ]]; then
|
||||
log "Checking Fabric Loader version information."
|
||||
FABRIC_LOADER_VERSION=$(maven-metadata-release https://maven.fabricmc.net/net/fabricmc/fabric-loader/maven-metadata.xml)
|
||||
fi
|
||||
export SERVER=fabric-server-mc.${VANILLA_VERSION}-loader.${FABRIC_LOADER_VERSION}-launcher.${FABRIC_LAUNCHER_VERSION}.jar
|
||||
export FABRIC_LAUNCHER_URL="https://meta.fabricmc.net/v2/versions/loader/${VANILLA_VERSION}/${FABRIC_LOADER_VERSION}/${FABRIC_LAUNCHER_VERSION}/server/jar"
|
||||
fi
|
||||
|
||||
if [[ ! -e ${SERVER} && ! -z ${FABRIC_LAUNCHER_URL} ]]; then
|
||||
log "Downloading $FABRIC_LAUNCHER_URL ..."
|
||||
if ! get -o "$SERVER" "$FABRIC_LAUNCHER_URL"; then
|
||||
log "Failed to download from given location $FABRIC_LAUNCHER_URL"
|
||||
exit 2
|
||||
if ! mc-image-helper install-fabric-loader \
|
||||
--results-file=${resultsFile} \
|
||||
--minecraft-version="${VANILLA_VERSION}" \
|
||||
--installer-version="${FABRIC_LAUNCHER_VERSION}" \
|
||||
--loader-version="${FABRIC_LOADER_VERSION}"; then
|
||||
log "ERROR failed to install Fabric launcher from $VANILLA_VERSION, $FABRIC_LAUNCHER_VERSION, $FABRIC_LOADER_VERSION"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ ! -e ${SERVER} ]]; then
|
||||
log "$SERVER does not exist, cannot launch server!"
|
||||
exit 1
|
||||
fi
|
||||
# grab SERVER and export it
|
||||
set -a
|
||||
# shellcheck disable=SC1090
|
||||
source "${resultsFile}"
|
||||
set +a
|
||||
|
||||
export FAMILY=FABRIC
|
||||
exec "${SCRIPTS:-/}start-setupWorld" "$@"
|
||||
|
|
Loading…
Reference in New Issue