Converted TYPE=FORGE to use image helper

This commit is contained in:
Geoff Bourne 2021-10-16 22:32:34 -05:00
parent 043d9778b8
commit 6008660a81
4 changed files with 31 additions and 21 deletions

View file

@ -60,7 +60,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.9.0
ARG MC_HELPER_VERSION=1.9.2
ARG MC_HELPER_BASE_URL=https://github.com/itzg/mc-image-helper/releases/download/v${MC_HELPER_VERSION}
RUN curl -fsSL ${MC_HELPER_BASE_URL}/mc-image-helper-${MC_HELPER_VERSION}.tgz \
| tar -C /usr/share -zxf - \

1
examples/.gitignore vendored Normal file
View file

@ -0,0 +1 @@
/data/

View file

@ -2,15 +2,16 @@ version: "3.8"
services:
mc:
image: itzg/minecraft-server:java8
image: itzg/minecraft-server
ports:
# expose the Minecraft server port outside of container
- 25565:25565
- "25565:25565"
environment:
# REQUIRED for all types
EULA: "TRUE"
# Set server type (vs the default of vanilla)
TYPE: FORGE
DEBUG: "true"
volumes:
# use a named, managed volume for data volume
- mc_forge:/data

View file

@ -1,7 +1,9 @@
#!/bin/bash
. ${SCRIPTS:-/}start-utils
: ${FORGEVERSION:=RECOMMENDED}
: "${FORGEVERSION:=RECOMMENDED}"
# shellcheck source=start-utils
. "${SCRIPTS:-$(dirname "$0")}/start-utils"
isDebugging && set -x
get_installer() {
@ -16,7 +18,7 @@ get_installer() {
for fn in $forgeFileNames; do
downloadUrl=https://maven.minecraftforge.net/net/minecraftforge/forge/$fn
log "...trying $downloadUrl"
if curl -o $FORGE_INSTALLER -fsSL $downloadUrl; then
if get -o "$FORGE_INSTALLER" "$downloadUrl"; then
return
fi
done
@ -24,7 +26,7 @@ get_installer() {
exit 2
else
log "Downloading $FORGE_INSTALLER_URL ..."
if ! curl -o $FORGE_INSTALLER -fsSL $FORGE_INSTALLER_URL; then
if ! get -o "$FORGE_INSTALLER" "$FORGE_INSTALLER_URL"; then
log "Failed to download from given location $FORGE_INSTALLER_URL"
exit 2
fi
@ -32,20 +34,19 @@ get_installer() {
}
install() {
if [ ! -e $FORGE_INSTALLER ]; then
get_installer $normForgeVersion $shortForgeVersion
if [ ! -e "$FORGE_INSTALLER" ]; then
get_installer "$normForgeVersion" "$shortForgeVersion"
fi
log "Installing Forge $shortForgeVersion using $FORGE_INSTALLER"
mkdir -p mods
tries=3
while ((--tries >= 0)); do
java -jar $FORGE_INSTALLER --installServer
if [ $? == 0 ]; then
if java -jar "$FORGE_INSTALLER" --installServer; then
break
fi
done
if (($tries < 0)); then
if ((tries < 0)); then
log "Forge failed to install after several tries." >&2
exit 10
fi
@ -66,7 +67,7 @@ install() {
export SERVER=$latest
log "Using server $SERVER"
echo $SERVER > $installMarker
echo "$SERVER" > "$installMarker"
}
resolve_versions() {
@ -81,15 +82,21 @@ resolve_versions() {
esac
#################################################################################
promosUrl=http://files.minecraftforge.net/maven/net/minecraftforge/forge/promotions_slim.json
log "Checking Forge version information."
case $FORGEVERSION in
LATEST)
if ! FORGE_VERSION=$(get --json-path ".promos['$VANILLA_VERSION-latest']" "$promosUrl"); then
log "ERROR: Version $VANILLA_VERSION is not supported by Forge"
log " Refer to http://files.minecraftforge.net/ for supported versions"
exit 2
fi
;;
RECOMMENDED)
curl -fsSL -o /tmp/forge.json http://files.minecraftforge.net/maven/net/minecraftforge/forge/promotions_slim.json
FORGE_VERSION=$(cat /tmp/forge.json | jq -r ".promos[\"$VANILLA_VERSION-recommended\"]")
if [ $FORGE_VERSION = null ]; then
FORGE_VERSION=$(cat /tmp/forge.json | jq -r ".promos[\"$VANILLA_VERSION-latest\"]")
if [ $FORGE_VERSION = null ]; then
if ! FORGE_VERSION=$(get --json-path ".promos['$VANILLA_VERSION-recommended']" "$promosUrl"); then
if ! FORGE_VERSION=$(get --json-path ".promos['$VANILLA_VERSION-latest']" "$promosUrl"); then
log "ERROR: Version $VANILLA_VERSION is not supported by Forge"
log " Refer to http://files.minecraftforge.net/ for supported versions"
exit 2
@ -122,14 +129,15 @@ resolve_versions
installMarker="/data/.forge-installed-$shortForgeVersion"
if [ ! -e $installMarker ]; then
if [ ! -e "$installMarker" ]; then
install
else
export SERVER=$(cat $installMarker)
SERVER=$(cat "$installMarker")
export SERVER
if [ ! -e "$SERVER" ] && versionLessThan 1.17; then
rm "$installMarker"
install
fi
fi
exec ${SCRIPTS:-/}start-setupWorld $@
exec "${SCRIPTS:-$(dirname "$0")}/start-setupWorld" "$@"