diff --git a/Dockerfile b/Dockerfile index 6fa657f..0a14e9f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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.31.0 +ARG MC_HELPER_VERSION=1.32.0 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 diff --git a/docs/misc/contributing/development.md b/docs/misc/contributing/development.md index 43ec9e6..525d3ea 100644 --- a/docs/misc/contributing/development.md +++ b/docs/misc/contributing/development.md @@ -55,14 +55,14 @@ docker run -it --rm -v ${PWD}:/scripts -e SCRIPTS=/scripts/ --entrypoint bash mc From within the container you can run individual scripts via the attached `/scripts/` path; however, be sure to set any environment variables expected by the scripts by either `export`ing them manually: ```shell script -export VANILLA_VERSION=1.12.2 +export VERSION=1.12.2 /scripts/start-magma ``` ...or pre-pending script execution: ```shell script -VANILLA_VERSION=1.12.2 /scripts/start-magma +VERSION=1.12.2 /scripts/start-magma ``` > NOTE: You may want to temporarily add an `exit` statement near the end of your script to isolate execution to just the script you're developing. diff --git a/examples/atm8/docker-compose.yml b/examples/atm8/docker-compose.yml index c04a9d3..eea889f 100644 --- a/examples/atm8/docker-compose.yml +++ b/examples/atm8/docker-compose.yml @@ -7,7 +7,7 @@ services: - "25565:25565" environment: EULA: "true" - TYPE: AUTO_CURSEFORGE + MOD_PLATFORM: AUTO_CURSEFORGE # allocate from https://console.curseforge.com/ and set in .env file CF_API_KEY: ${CF_API_KEY} CF_PAGE_URL: https://www.curseforge.com/minecraft/modpacks/all-the-mods-8 diff --git a/examples/docker-compose-modrinth-modpack.yml b/examples/modrinth-modpack/docker-compose.yml similarity index 93% rename from examples/docker-compose-modrinth-modpack.yml rename to examples/modrinth-modpack/docker-compose.yml index f5befad..69d3084 100644 --- a/examples/docker-compose-modrinth-modpack.yml +++ b/examples/modrinth-modpack/docker-compose.yml @@ -9,7 +9,7 @@ services: - "25565:25565" environment: EULA: "TRUE" - TYPE: MODRINTH + MOD_PLATFORM: MODRINTH MODRINTH_PROJECT: https://modrinth.com/modpack/cobblemon-fabric/version/1.3.2 # or for auto-upgrading to latest # MODRINTH_PROJECT: https://modrinth.com/modpack/cobblemon-fabric @@ -18,7 +18,6 @@ services: # MODRINTH_VERSION: nvrqJg44 # MODRINTH_VERSION: 1.3.2 # MODRINTH_VERSION: "Cobblemon [Fabric] 1.3.2" - SETUP_ONLY: "true" volumes: # attach the relative directory 'data' to the container's /data path - ./data:/data diff --git a/examples/modrinth-paper/docker-compose.yml b/examples/modrinth-paper/docker-compose.yml index 84d4e96..73647b2 100644 --- a/examples/modrinth-paper/docker-compose.yml +++ b/examples/modrinth-paper/docker-compose.yml @@ -2,7 +2,7 @@ version: "3" services: mc: - image: ${IMAGE_TO_TEST:-itzg/minecraft-server} + image: itzg/minecraft-server environment: EULA: "true" TYPE: PAPER diff --git a/examples/one-block-modded/docker-compose.yml b/examples/one-block-modded/docker-compose.yml index 2148f9e..6dacabe 100644 --- a/examples/one-block-modded/docker-compose.yml +++ b/examples/one-block-modded/docker-compose.yml @@ -7,7 +7,7 @@ services: - "25565:25565" environment: EULA: "true" - TYPE: AUTO_CURSEFORGE + MOD_PLATFORM: AUTO_CURSEFORGE # CF_API_KEY=... must be set in .env file or as environment variable CF_API_KEY: ${CF_API_KEY} CF_SLUG: one-block-modded diff --git a/examples/pixelmon/docker-compose.yml b/examples/pixelmon/docker-compose.yml index 6a990b2..1d79408 100644 --- a/examples/pixelmon/docker-compose.yml +++ b/examples/pixelmon/docker-compose.yml @@ -7,7 +7,7 @@ services: - "25565:25565" environment: EULA: "true" - TYPE: AUTO_CURSEFORGE + MOD_PLATFORM: AUTO_CURSEFORGE CF_API_KEY: # allocate from https://console.curseforge.com/ CF_SLUG: the-pixelmon-modpack CF_FILENAME_MATCHER: "9.1.2" diff --git a/examples/valhesia5/docker-compose.yml b/examples/valhesia5/docker-compose.yml index 7c47ddb..f89c3db 100644 --- a/examples/valhesia5/docker-compose.yml +++ b/examples/valhesia5/docker-compose.yml @@ -7,7 +7,7 @@ services: - "25565:25565" environment: EULA: "true" - TYPE: AUTO_CURSEFORGE + MOD_PLATFORM: AUTO_CURSEFORGE CF_API_KEY: # allocate from https://console.curseforge.com/ CF_FORCE_SYNCHRONIZE: "true" CF_PAGE_URL: https://www.curseforge.com/minecraft/modpacks/valhelsia-5/files/4429560 diff --git a/examples/vault-hunters-1-18-2/docker-compose.yml b/examples/vault-hunters-1-18-2/docker-compose.yml index 12bbd7d..2248fcc 100644 --- a/examples/vault-hunters-1-18-2/docker-compose.yml +++ b/examples/vault-hunters-1-18-2/docker-compose.yml @@ -7,7 +7,7 @@ services: - "25565:25565" environment: EULA: "true" - TYPE: AUTO_CURSEFORGE + MOD_PLATFORM: AUTO_CURSEFORGE CF_API_KEY: # allocate from https://console.curseforge.com/ CF_SLUG: vault-hunters-1-18-2 CF_FILENAME_MATCHER: "Update-10.0.0" diff --git a/notes/Going from docker run to compose.drawio.png b/notes/Going from docker run to compose.drawio.png index e69de29..d12219b 100644 Binary files a/notes/Going from docker run to compose.drawio.png and b/notes/Going from docker run to compose.drawio.png differ diff --git a/notes/start-script-flow.drawio.png b/notes/start-script-flow.drawio.png index e69de29..7db6894 100644 Binary files a/notes/start-script-flow.drawio.png and b/notes/start-script-flow.drawio.png differ diff --git a/scripts/start-configuration b/scripts/start-configuration index 1fc0a75..6ac08f9 100755 --- a/scripts/start-configuration +++ b/scripts/start-configuration @@ -105,31 +105,6 @@ function fixJavaPath() { fi } -function resolveVersion() { - VERSIONS_JSON=https://launchermeta.mojang.com/mc/game/version_manifest.json - - case "X$VERSION" in - X|XLATEST|Xlatest) - if ! VANILLA_VERSION=$(get --json-path '$.latest.release' "$VERSIONS_JSON"); then - log "ERROR: version lookup failed: $VANILLA_VERSION" - exit 1 - fi - ;; - XSNAPSHOT|Xsnapshot) - if ! VANILLA_VERSION=$(get --json-path '$.latest.snapshot' "$VERSIONS_JSON"); then - log "ERROR: version lookup failed: $VANILLA_VERSION" - exit 1 - fi - ;; - *) - VANILLA_VERSION=$VERSION - ;; - esac - export VANILLA_VERSION - MAJOR_VANILLA_VERSION=$(get_major_version "$VANILLA_VERSION") - export MAJOR_VANILLA_VERSION - log "Resolved version given ${VERSION} into ${VANILLA_VERSION} and major version ${MAJOR_VANILLA_VERSION}" -} if ! fixJavaPath; then log "ERROR: could not locate path that contains java" @@ -187,8 +162,6 @@ if [[ $MOD_PLATFORM ]]; then esac fi -resolveVersion - log "Resolving type given ${TYPE}" case "${TYPE^^}" in *BUKKIT|SPIGOT) @@ -204,7 +177,6 @@ case "${TYPE^^}" in ;; FORGE) - evaluateJavaCompatibilityForForge exec "${SCRIPTS:-/}start-deployForge" "$@" ;; @@ -261,12 +233,6 @@ case "${TYPE^^}" in ;; CRUCIBLE) - log "**********************************************************************" - log "WARNING: The image tag itzg/minecraft-server:java8 is recommended" - log " since some mods require Java 8" - log " Exception traces reporting ClassCastException: class jdk.internal.loader.ClassLoaders\$AppClassLoader" - log " can be fixed with java8" - log "**********************************************************************" exec "${SCRIPTS:-/}start-deployCrucible" "$@" ;; diff --git a/scripts/start-deployAutoCF b/scripts/start-deployAutoCF index 00af156..fa7cea9 100644 --- a/scripts/start-deployAutoCF +++ b/scripts/start-deployAutoCF @@ -66,13 +66,11 @@ if ! mc-image-helper install-curseforge "${args[@]}"; then exit 1 fi -# grab SERVER, FAMILY and export it +# grab SERVER, TYPE, VERSION and export it set -a # shellcheck disable=SC1090 source "${resultsFile}" set +a -# grab the version resolved from modpack -VANILLA_VERSION="$VERSION" -export VANILLA_VERSION +resolveFamily exec "${SCRIPTS:-/}start-setupWorld" "$@" diff --git a/scripts/start-deployBukkitSpigot b/scripts/start-deployBukkitSpigot index 80ebe82..cfc1396 100755 --- a/scripts/start-deployBukkitSpigot +++ b/scripts/start-deployBukkitSpigot @@ -1,6 +1,7 @@ #!/bin/bash -. ${SCRIPTS:-/}start-utils +# shellcheck source=start-utils +. "${SCRIPTS:-/}start-utils" isDebugging && set -x set -e @@ -60,14 +61,14 @@ function downloadSpigot { esac if [[ ${VERSION^^} = LATEST ]]; then - VANILLA_VERSION=$(restify https://getbukkit.org/download/spigot --attribute='property=og:title' | jq -r '.[0] | .attributes | select(.property == "og:title") | .content | split(" ") | .[-1]') + VERSION=$(restify https://getbukkit.org/download/spigot --attribute='property=og:title' | jq -r '.[0] | .attributes | select(.property == "og:title") | .content | split(" ") | .[-1]') fi if [[ -z $downloadUrl ]]; then - if versionLessThan 1.16.5 || ([[ ${getbukkitFlavor} = "craftbukkit" ]] && [[ ${VANILLA_VERSION} = "1.16.5" ]]); then - downloadUrl="https://cdn.getbukkit.org/${getbukkitFlavor}/${getbukkitFlavor}-${VANILLA_VERSION}.jar" + if versionLessThan 1.16.5 || ([[ ${getbukkitFlavor} = "craftbukkit" ]] && [[ ${VERSION} = "1.16.5" ]]); then + downloadUrl="https://cdn.getbukkit.org/${getbukkitFlavor}/${getbukkitFlavor}-${VERSION}.jar" else - downloadUrl="https://download.getbukkit.org/${getbukkitFlavor}/${getbukkitFlavor}-${VANILLA_VERSION}.jar" + downloadUrl="https://download.getbukkit.org/${getbukkitFlavor}/${getbukkitFlavor}-${VERSION}.jar" fi fi @@ -108,15 +109,16 @@ EOF function setServerVar { case "$TYPE" in *BUKKIT|*bukkit) - export SERVER=craftbukkit_server-${VANILLA_VERSION}.jar + export SERVER=craftbukkit_server-${VERSION}.jar ;; *) - export SERVER=spigot_server-${VANILLA_VERSION}.jar + export SERVER=spigot_server-${VERSION}.jar ;; esac } if isTrue "$BUILD_SPIGOT_FROM_SOURCE" || isTrue "$BUILD_FROM_SOURCE"; then + resolveVersion setServerVar if [ ! -f "$SERVER" ] || isTrue "$FORCE_REDOWNLOAD"; then buildSpigotFromSource diff --git a/scripts/start-deployCrucible b/scripts/start-deployCrucible index c5daf77..a1aecb3 100755 --- a/scripts/start-deployCrucible +++ b/scripts/start-deployCrucible @@ -6,7 +6,7 @@ set -o pipefail set -e isDebugging && set -x -requireVar VANILLA_VERSION +resolveVersion : "${CRUCIBLE_RELEASE:=latest}" crucibleReleasesUrl=https://api.github.com/repos/CrucibleMC/Crucible/releases @@ -16,14 +16,14 @@ else crucibleReleaseUrl=${crucibleReleasesUrl}/tags/${CRUCIBLE_RELEASE} fi -if ! downloadUrl=$(get --json-path "$.assets[?(@.name =~ /Crucible-${VANILLA_VERSION}-.*\.jar/)].browser_download_url" \ +if ! downloadUrl=$(get --json-path "$.assets[?(@.name =~ /Crucible-${VERSION}-.*\.jar/)].browser_download_url" \ --accept "application/vnd.github.v3+json" "$crucibleReleaseUrl"); then log "ERROR: failed to access ${CRUCIBLE_RELEASE} release of Crucible" exit 1 fi if [[ $downloadUrl = null ]]; then - log "ERROR: failed to locate Crucible jar for $VANILLA_VERSION from ${CRUCIBLE_RELEASE}" + log "ERROR: failed to locate Crucible jar for $VERSION from ${CRUCIBLE_RELEASE}" exit 1 fi diff --git a/scripts/start-deployFabric b/scripts/start-deployFabric index 1a94283..9d80724 100755 --- a/scripts/start-deployFabric +++ b/scripts/start-deployFabric @@ -19,9 +19,10 @@ if [[ $FABRIC_LAUNCHER ]]; then 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" + log "ERROR failed to use provided Fabric launcher" exit 1 fi + # Custom fabric jar url elif [[ $FABRIC_LAUNCHER_URL ]]; then if ! mc-image-helper install-fabric-loader \ @@ -30,19 +31,21 @@ elif [[ $FABRIC_LAUNCHER_URL ]]; then log "ERROR failed to install Fabric launcher from $FABRIC_LAUNCHER_URL" exit 1 fi + # Official fabric launcher else if ! mc-image-helper install-fabric-loader \ --results-file=${resultsFile} \ - --minecraft-version="${VANILLA_VERSION}" \ + --minecraft-version="${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" + log "ERROR failed to install Fabric launcher given $VERSION, $FABRIC_LAUNCHER_VERSION, $FABRIC_LOADER_VERSION" exit 1 fi + fi -# grab SERVER and export it +# grab SERVER, etc and export it set -a # shellcheck disable=SC1090 source "${resultsFile}" diff --git a/scripts/start-deployForge b/scripts/start-deployForge index e19f2e2..b6ccb20 100755 --- a/scripts/start-deployForge +++ b/scripts/start-deployForge @@ -7,8 +7,6 @@ . "${SCRIPTS:-$(dirname "$0")}/start-utils" isDebugging && set -x -# NOTE: VERSION rather than VANILLA_VERSION is specified to allow for latest supported -# Forge version to be selected. if [[ ${FORGE_INSTALLER} ]]; then if ! mc-image-helper install-forge \ --output-directory=/data \ diff --git a/scripts/start-deployMagma b/scripts/start-deployMagma index f748e92..9a6f92e 100755 --- a/scripts/start-deployMagma +++ b/scripts/start-deployMagma @@ -4,10 +4,15 @@ . "${SCRIPTS:-/}start-utils" isDebugging && set -x -: "${VANILLA_VERSION?}" +resolveVersion -if ! downloadUrl=$(get --json-path '$.link' "https://api.magmafoundation.org/api/v2/${VANILLA_VERSION}/latest"); then - log "ERROR failed to locate latest Magma download for ${VANILLA_VERSION}. Is that version supported?" +if ! downloadUrl=$(get --json-path '$.link' "https://api.magmafoundation.org/api/v2/${VERSION}/latest"); then + log "ERROR failed to locate latest Magma download for ${VERSION}. Is that version supported?" + exit 1 +fi + +if [[ $downloadUrl == null ]]; then + log "ERROR Magma does not seem to be available for $VERSION" exit 1 fi diff --git a/scripts/start-deployModrinth b/scripts/start-deployModrinth index 1f1bf0a..176ccf7 100644 --- a/scripts/start-deployModrinth +++ b/scripts/start-deployModrinth @@ -48,13 +48,11 @@ if ! mc-image-helper install-modrinth-modpack "${args[@]}"; then exit 1 fi -# grab SERVER, FAMILY and export it +# grab SERVER, TYPE, VERSION and export it set -a # shellcheck disable=SC1090 source "${resultsFile}" set +a -# grab the version resolved from modpack -VANILLA_VERSION="$VERSION" -export VANILLA_VERSION +resolveFamily exec "${SCRIPTS:-/}start-setupWorld" "$@" diff --git a/scripts/start-deployMohist b/scripts/start-deployMohist index 35dc97c..de9f608 100755 --- a/scripts/start-deployMohist +++ b/scripts/start-deployMohist @@ -6,14 +6,14 @@ set -o pipefail set -e isDebugging && set -x -requireVar VANILLA_VERSION +resolveVersion : "${MOHIST_BUILD:=lastSuccessfulBuild}" mohistJobs=https://ci.codemc.io/job/MohistMC/job/ -mohistJob=${mohistJobs}Mohist-${VANILLA_VERSION}/ +mohistJob=${mohistJobs}Mohist-${VERSION}/ if ! get --exists "${mohistJob}"; then - log "ERROR: mohist builds do not exist for ${VANILLA_VERSION}" + log "ERROR: mohist builds do not exist for ${VERSION}" log " check https://ci.codemc.io/job/MohistMC/ for available versions" log " and set VERSION accordingly" exit 1 @@ -25,7 +25,7 @@ buildRelPath=$( baseName=$(basename "${buildRelPath}") if [[ ${baseName} != *-server.jar* ]]; then - log "ERROR: mohist build for ${VANILLA_VERSION} is not a valid server jar, found ${baseName}" + log "ERROR: mohist build for ${VERSION} is not a valid server jar, found ${baseName}" log " check https://ci.codemc.io/job/MohistMC/ for available versions" log " and set VERSION accordingly" exit 1 diff --git a/scripts/start-deployPufferfish b/scripts/start-deployPufferfish index 96f6255..b1e9861 100755 --- a/scripts/start-deployPufferfish +++ b/scripts/start-deployPufferfish @@ -15,7 +15,8 @@ fi : "${PUFFERFISH_BUILD:=lastSuccessfulBuild}" -PUFFERFISH_BUILD_JSON=$(curl -X GET -s "https://ci.pufferfish.host/job/Pufferfish-${MAJOR_VANILLA_VERSION}/${PUFFERFISH_BUILD}/api/json") +majorVersion=$(get_major_version "$VERSION") +PUFFERFISH_BUILD_JSON=$(curl -X GET -s "https://ci.pufferfish.host/job/Pufferfish-${majorVersion}/${PUFFERFISH_BUILD}/api/json") # Example: "url": "https://ci.pufferfish.host/job/Pufferfish-1.18/50/", PUFFERFISH_BUILD_URL=$(jq -n "$PUFFERFISH_BUILD_JSON" | jq -jc '.url // empty' ) # Example: "fileName": "pufferfish-paperclip-1.18.2-R0.1-SNAPSHOT-reobf.jar", diff --git a/scripts/start-deployQuilt b/scripts/start-deployQuilt index ad46d24..2a442ec 100755 --- a/scripts/start-deployQuilt +++ b/scripts/start-deployQuilt @@ -4,8 +4,6 @@ set -eu # shellcheck source=start-utils . "${SCRIPTS:-/}start-utils" -requireVar VANILLA_VERSION -export TYPE=QUILT : "${QUILT_LAUNCHER:=}" : "${QUILT_LAUNCHER_URL:=}" : "${QUILT_INSTALLER_URL:=}" @@ -14,47 +12,50 @@ export TYPE=QUILT isDebugging && set -x -# Custom quilt jar +resultsFile=/data/.quilt.env + if [[ $QUILT_LAUNCHER ]]; then - export SERVER=${QUILT_LAUNCHER} -# Custom quilt jar url + log "WARNING: use of QUILT_LAUNCHER is a deprecated feature." + SERVER="$QUILT_LAUNCHER" + export SERVER + resolveVersion + + export FAMILY=FABRIC + exec "${SCRIPTS:-/}start-setupWorld" "$@" + elif [[ $QUILT_LAUNCHER_URL ]]; then - export SERVER=quilt-server-$(echo -n "$QUILT_LAUNCHER_URL" | mc-image-helper hash) -# Official quilt installer + log "ERROR: QUILT_LAUNCHER_URL is not longer supported. Pre-download and use QUILT_LAUNCHER." + exit 2 + +elif [[ $QUILT_INSTALLER_URL ]]; then + if ! mc-image-helper install-quilt \ + --loader-version="$QUILT_LOADER_VERSION" \ + --minecraft-version="$VERSION" \ + --output-directory=/data \ + --results-file="$resultsFile" \ + --installer-url="$QUILT_INSTALLER_URL"; then + log "ERROR: failed to install Quilt given custom installer URL $QUILT_INSTALLER_URL" + exit 2 + fi + else - if [[ ${QUILT_INSTALLER_VERSION^^} = LATEST ]]; then - log "Checking Quilt Installer version information." - QUILT_INSTALLER_VERSION=$(maven-metadata-release https://maven.quiltmc.org/repository/release/org/quiltmc/quilt-installer/maven-metadata.xml) + if ! mc-image-helper install-quilt \ + --loader-version="$QUILT_LOADER_VERSION" \ + --minecraft-version="$VERSION" \ + --output-directory=/data \ + --results-file="$resultsFile" \ + --installer-version="$QUILT_INSTALLER_VERSION"; then + log "ERROR: failed to install Quilt given installer version $QUILT_INSTALLER_VERSION" + exit 2 fi - if [[ ${QUILT_LOADER_VERSION^^} = LATEST ]]; then - log "Checking Quilt Loader version information." - QUILT_LOADER_VERSION=$(maven-metadata-release https://maven.quiltmc.org/repository/release/org/quiltmc/quilt-loader/maven-metadata.xml) - fi - export INSTALLER=quilt-installer-${QUILT_INSTALLER_VERSION}.jar - export SERVER=quilt-server-${VANILLA_VERSION}-${QUILT_LOADER_VERSION}-launch.jar - export QUILT_INSTALLER_URL="https://maven.quiltmc.org/repository/release/org/quiltmc/quilt-installer/${QUILT_INSTALLER_VERSION}/quilt-installer-${QUILT_INSTALLER_VERSION}.jar" + fi -if [[ ! -e ${SERVER} && ! -z ${QUILT_INSTALLER_URL} ]]; then - log "Downloading and installing $QUILT_INSTALLER_URL ..." - if ! get -o "$INSTALLER" "$QUILT_INSTALLER_URL"; then - log "Failed to download from given location $QUILT_INSTALLER_URL" - exit 2 - fi - if ! java -jar ${INSTALLER} install server ${VANILLA_VERSION} ${QUILT_LOADER_VERSION} --install-dir=./ --download-server; then - log "Failed to install $INSTALLER" - exit 2 - fi - if ! mv quilt-server-launch.jar ${SERVER}; then - log "Failed to rename $SERVER" - exit 2 - fi -fi - -if [[ ! -e ${SERVER} ]]; then - log "$SERVER does not exist, cannot launch server!" - exit 1 -fi +# grab SERVER, VERSION and export it +set -a +# shellcheck disable=SC1090 +source "${resultsFile}" +set +a export FAMILY=FABRIC exec "${SCRIPTS:-/}start-setupWorld" "$@" diff --git a/scripts/start-deploySpongeVanilla b/scripts/start-deploySpongeVanilla index 07e8818..9aeafcd 100755 --- a/scripts/start-deploySpongeVanilla +++ b/scripts/start-deploySpongeVanilla @@ -1,5 +1,6 @@ #!/bin/bash +# shellcheck source=start-utils . ${SCRIPTS:-/}start-utils export TYPE=spongevanilla @@ -24,20 +25,20 @@ esac if [ -z $SPONGEVERSION ]; then log "Choosing Version for Sponge" if [ "$SPONGEBRANCH" == "stable" ]; then - SPONGEVERSION=`curl -fsSL https://dl-api.spongepowered.org/v1/org.spongepowered/$TYPE | jq -r '.buildTypes.stable.latest.version'` + SPONGEVERSION=$(curl -fsSL https://dl-api.spongepowered.org/v1/org.spongepowered/$TYPE | jq -r '.buildTypes.stable.latest.version') else - SPONGEVERSION=`curl -fsSL https://dl-api.spongepowered.org/v1/org.spongepowered/$TYPE | jq -r '.buildTypes.bleeding.latest.version'` + SPONGEVERSION=$(curl -fsSL https://dl-api.spongepowered.org/v1/org.spongepowered/$TYPE | jq -r '.buildTypes.bleeding.latest.version') fi fi -VANILLA_VERSION="$SPONGEVERSION" -export VANILLA_VERSION +VERSION="$SPONGEVERSION" +export VERSION export SERVER="spongevanilla-$SPONGEVERSION.jar" -if [ ! -e $SERVER ] || [ -n "$FORCE_REDOWNLOAD" ]; then +if [ ! -e "$SERVER" ] || [ -n "$FORCE_REDOWNLOAD" ]; then log "Downloading $SERVER ..." - curl -sSL -o $SERVER https://repo.spongepowered.org/maven/org/spongepowered/$TYPE/$SPONGEVERSION/$SERVER + curl -sSL -o "$SERVER" "https://repo.spongepowered.org/maven/org/spongepowered/$TYPE/$SPONGEVERSION/$SERVER" fi export FAMILY=SPONGE -exec ${SCRIPTS:-/}start-setupWorld "$@" +exec "${SCRIPTS:-/}start-setupWorld" "$@" diff --git a/scripts/start-deployVanilla b/scripts/start-deployVanilla index 870cc61..c4c51f0 100755 --- a/scripts/start-deployVanilla +++ b/scripts/start-deployVanilla @@ -5,18 +5,19 @@ isDebugging && set -x set -o pipefail -export SERVER="minecraft_server.${VANILLA_VERSION// /_}.jar" +resolveVersion +export SERVER="minecraft_server.${VERSION// /_}.jar" if [ ! -e "$SERVER" ] || [ -n "$FORCE_REDOWNLOAD" ]; then - debug "Finding version manifest for $VANILLA_VERSION" - versionManifestUrl=$(get 'https://launchermeta.mojang.com/mc/game/version_manifest.json' | jq --arg VANILLA_VERSION "$VANILLA_VERSION" --raw-output '[.versions[]|select(.id == $VANILLA_VERSION)][0].url') + debug "Finding version manifest for $VERSION" + versionManifestUrl=$(get 'https://launchermeta.mojang.com/mc/game/version_manifest.json' | jq --arg VERSION "$VERSION" --raw-output '[.versions[]|select(.id == $VERSION)][0].url') result=$? if [ $result != 0 ]; then log "ERROR: failed to obtain version manifest URL ($result)" exit 1 fi if [ "$versionManifestUrl" = "null" ]; then - log "ERROR: couldn't find a matching manifest entry for $VANILLA_VERSION" + log "ERROR: couldn't find a matching manifest entry for $VERSION" exit 1 fi debug "Found version manifest at $versionManifestUrl" @@ -25,11 +26,11 @@ if [ ! -e "$SERVER" ] || [ -n "$FORCE_REDOWNLOAD" ]; then log "ERROR: failed to obtain version manifest from $versionManifestUrl ($result)" exit 1 elif [ "$serverDownloadUrl" = "null" ]; then - log "ERROR: there is not a server download for version $VANILLA_VERSION" + log "ERROR: there is not a server download for version $VERSION" exit 1 fi - log "Downloading $VANILLA_VERSION server..." + log "Downloading $VERSION server..." debug "Downloading server from $serverDownloadUrl" get -o "$SERVER" "$serverDownloadUrl" result=$? diff --git a/scripts/start-setupForgeApiMods b/scripts/start-setupForgeApiMods index bc0d566..9986dd2 100644 --- a/scripts/start-setupForgeApiMods +++ b/scripts/start-setupForgeApiMods @@ -57,7 +57,7 @@ updateReleaseNumber(){ } retrieveVersionTypeNumber(){ - VERSION_NAME="Minecraft ${MAJOR_VANILLA_VERSION}" + VERSION_NAME=$(get_major_version "$VERSION") minecraft_types=$(curl -X GET -s \ "${FORGEAPI_BASE_URL}/games/${MINECRAFT_GAME_ID}/version-types" \ -H 'Accept: application/json' -H 'x-api-key: '${MODS_FORGEAPI_KEY}'') diff --git a/scripts/start-setupModpack b/scripts/start-setupModpack index aac36a8..ef0b662 100755 --- a/scripts/start-setupModpack +++ b/scripts/start-setupModpack @@ -289,7 +289,7 @@ function handleModrinthProjects() { mc-image-helper modrinth \ --output-directory=/data \ --projects="${MODRINTH_PROJECTS}" \ - --game-version="${VANILLA_VERSION}" \ + --game-version="${VERSION}" \ --loader="$loader" \ --download-optional-dependencies="$MODRINTH_DOWNLOAD_OPTIONAL_DEPENDENCIES" \ --allowed-version-type="$MODRINTH_ALLOWED_VERSION_TYPE" diff --git a/scripts/start-utils b/scripts/start-utils index b568ee6..7c4ff97 100755 --- a/scripts/start-utils +++ b/scripts/start-utils @@ -163,7 +163,7 @@ function normalizeMemSize() { function versionLessThan() { # Use if-else since strict mode might be enabled - if mc-image-helper compare-versions "${VANILLA_VERSION}" lt "${1?}"; then + if mc-image-helper compare-versions "${VERSION}" lt "${1?}"; then return 0 else return 1 @@ -320,4 +320,28 @@ function usesPlugins() { return 0 esac return 1 +} + +function resolveVersion() { + givenVersion="$VERSION" + # shellcheck disable=SC2153 + if ! VERSION=$(mc-image-helper resolve-minecraft-version "$VERSION"); then + exit 2 + fi + log "Resolved version given ${givenVersion} into ${VERSION}" +} + +function resolveFamily() { + case "$TYPE" in + PAPER|SPIGOT|BUKKIT|CANYON|PUFFERFISH|PURPUR) + FAMILY=SIGOT + ;; + FORGE) + FAMILY=FORGE + ;; + FABRIC|QUILT) + FAMILY=FABRIC + ;; + esac + export FAMILY } \ No newline at end of file diff --git a/tests/setuponlytests/auto_curseforge/docker-compose.yml b/tests/setuponlytests/auto_curseforge/docker-compose.yml index 69d7b49..ddf2030 100644 --- a/tests/setuponlytests/auto_curseforge/docker-compose.yml +++ b/tests/setuponlytests/auto_curseforge/docker-compose.yml @@ -6,7 +6,7 @@ services: environment: EULA: "true" SETUP_ONLY: "TRUE" - TYPE: AUTO_CURSEFORGE + MOD_PLATFORM: AUTO_CURSEFORGE CF_API_KEY: ${CF_API_KEY} CF_SLUG: the-pixelmon-modpack CF_FILENAME_MATCHER: "9.1.2" diff --git a/tests/setuponlytests/modrinth/docker-compose.yml b/tests/setuponlytests/modrinth/docker-compose.yml index 25bc377..d2e8fbb 100644 --- a/tests/setuponlytests/modrinth/docker-compose.yml +++ b/tests/setuponlytests/modrinth/docker-compose.yml @@ -7,10 +7,7 @@ services: EULA: "true" SETUP_ONLY: "true" TYPE: FABRIC - FABRIC_LAUNCHER: /servers/fake.jar - CUSTOM_SERVER: /servers/fake.jar VERSION: 1.19.1 MODRINTH_PROJECTS: fabric-api,cloth-config volumes: - ./data:/data - - ./fake.jar:/servers/fake.jar diff --git a/tests/setuponlytests/modrinth/fake.jar b/tests/setuponlytests/modrinth/fake.jar deleted file mode 100644 index e69de29..0000000