From bc318fa18585a99a0c4abf4eae0dfa810252cc5d Mon Sep 17 00:00:00 2001 From: Geoff Bourne Date: Fri, 19 Jun 2020 11:31:56 -0500 Subject: [PATCH] Added support for Mohist servers --- README.md | 9 +++++++++ start-configuration | 4 ++++ start-mohist | 40 ++++++++++++++++++++++++++++++++++++++++ start-utils | 9 ++++++++- 4 files changed, 61 insertions(+), 1 deletion(-) create mode 100644 start-mohist diff --git a/README.md b/README.md index 07247960..da9fdbeb 100644 --- a/README.md +++ b/README.md @@ -525,6 +525,15 @@ A [Magma](https://magmafoundation.org/) server, which is a combination of Forge > **NOTE** there are limited base versions supported, so you will also need to set `VERSION`, such as "1.12.2" + +## Running a Mohist server + +A [Mohist](https://github.com/Mohist-Community/Mohist) server can be used with + + -e TYPE=MOHIST + +> **NOTE** there are limited base versions supported, so you will also need to set `VERSION`, such as "1.12.2" + ## Running a server with a Feed the Beast modpack > **NOTE** requires `itzg/minecraft-server:multiarch` image diff --git a/start-configuration b/start-configuration index 737c960a..a41cae58 100644 --- a/start-configuration +++ b/start-configuration @@ -118,6 +118,10 @@ case "${TYPE^^}" in exec ${SCRIPTS:-/}start-magma "$@" ;; + MOHIST) + exec ${SCRIPTS:-/}start-mohist "$@" + ;; + *) log "Invalid type: '$TYPE'" log "Must be: VANILLA, FORGE, BUKKIT, SPIGOT, PAPER, FTB, CURSEFORGE, SPONGEVANILLA" diff --git a/start-mohist b/start-mohist new file mode 100644 index 00000000..c9fcecd2 --- /dev/null +++ b/start-mohist @@ -0,0 +1,40 @@ +#!/bin/bash + +. ${SCRIPTS:-/}start-utils +requireVar VANILLA_VERSION +set -o pipefail +set -e +isDebugging && set -x + +mohistJobs=https://ci.codemc.io/job/Mohist-Community/job/ +mohistJob=${mohistJobs}Mohist-${VANILLA_VERSION}/ + +if ! curl -X HEAD -o /dev/null -fsSL "${mohistJob}"; then + log "ERROR: mohist builds do not exist for ${VANILLA_VERSION}" + log " check https://ci.codemc.io/job/Mohist-Community/ for available versions" + exit 1 +fi + +latestBuildRelPath=$( + curl -fsSL "${mohistJob}lastSuccessfulBuild/api/json" | + jq -r '.artifacts[0].relativePath' +) + +baseName=$(basename "${latestBuildRelPath}") +if [[ ${baseName} != *-server.jar* ]]; then + log "ERROR: mohist build for ${VANILLA_VERSION} is not a valid server jar, found ${baseName}" + log " check https://ci.codemc.io/job/Mohist-Community/ for available versions" + exit 1 +fi + +export SERVER="/data/${baseName}" + +if [ ! -f ${SERVER} ]; then + log "Downloading ${SERVER}" + curl -o "${SERVER}" -fsSL "${mohistJob}lastSuccessfulBuild/artifact/${latestBuildRelPath}" +fi + +export SKIP_LOG4J_CONFIG=true + +# Continue to Final Setup +exec ${SCRIPTS:-/}start-finalSetup01World $@ diff --git a/start-utils b/start-utils index e054396a..aa8d933a 100644 --- a/start-utils +++ b/start-utils @@ -99,4 +99,11 @@ function versionLessThan { return 1 fi fi -} \ No newline at end of file +} + +requireVar() { + if [ ! -v $1 ]; then + log "ERROR: $1 is required to be set" + exit 1 + fi +}