mirror of
https://github.com/itzg/docker-minecraft-server.git
synced 2024-06-07 19:40:43 +00:00
Perform clean Forge version changes (#1669)
Switched to mc-image-helper
This commit is contained in:
parent
380ea202dc
commit
7a85cb5f39
@ -46,8 +46,9 @@ 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.20.3
|
||||
ARG MC_HELPER_BASE_URL=https://github.com/itzg/mc-image-helper/releases/download/v${MC_HELPER_VERSION}
|
||||
ARG MC_HELPER_VERSION=1.21.0
|
||||
ARG MC_HELPER_RELEASE=v${MC_HELPER_VERSION}
|
||||
ARG MC_HELPER_BASE_URL=https://github.com/itzg/mc-image-helper/releases/download/${MC_HELPER_RELEASE}
|
||||
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
|
||||
|
@ -6,155 +6,21 @@
|
||||
. "${SCRIPTS:-$(dirname "$0")}/start-utils"
|
||||
isDebugging && set -x
|
||||
|
||||
get_installer() {
|
||||
if [[ -z $FORGE_INSTALLER_URL ]]; then
|
||||
log "Downloading Forge Installer $normForgeVersion"
|
||||
|
||||
forgeFileNames="
|
||||
$shortForgeVersion/forge-$shortForgeVersion-installer.jar
|
||||
$normForgeVersion/forge-$normForgeVersion-installer.jar
|
||||
"
|
||||
|
||||
for fn in $forgeFileNames; do
|
||||
downloadUrl=https://maven.minecraftforge.net/net/minecraftforge/forge/$fn
|
||||
log "...trying $downloadUrl"
|
||||
if get -o "$FORGE_INSTALLER" "$downloadUrl"; then
|
||||
return
|
||||
fi
|
||||
done
|
||||
log "Unable to locate usable URL for $normForgeVersion"
|
||||
exit 2
|
||||
else
|
||||
log "Downloading Forge Installer from $FORGE_INSTALLER_URL ..."
|
||||
if ! get -o "$FORGE_INSTALLER" "$FORGE_INSTALLER_URL"; then
|
||||
log "Failed to download from given location $FORGE_INSTALLER_URL"
|
||||
exit 2
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
install() {
|
||||
if [ ! -e "$FORGE_INSTALLER" ]; then
|
||||
get_installer "$normForgeVersion" "$shortForgeVersion"
|
||||
fi
|
||||
|
||||
# reference issue #1459
|
||||
rm -f run.sh
|
||||
|
||||
log "Installing Forge $shortForgeVersion. This might take a minute or two..."
|
||||
mkdir -p mods
|
||||
tries=3
|
||||
while true; do
|
||||
if ! java -jar "$FORGE_INSTALLER" --installServer &> forge-installer.log; then
|
||||
if ((--tries <= 0)); then
|
||||
cat forge-installer.log
|
||||
log "
|
||||
ERROR Forge failed to install after several tries.
|
||||
"
|
||||
exit 1
|
||||
fi
|
||||
log "Install failed. Trying again..."
|
||||
else
|
||||
break # out of this loop
|
||||
fi
|
||||
done
|
||||
# NOTE $shortForgeVersion will be empty if installer location was given to us
|
||||
log "Finding installed server jar..."
|
||||
unset -v latest
|
||||
# 1.17+ ?
|
||||
if [ -f /data/run.sh ]; then
|
||||
latest=/data/run.sh
|
||||
# else pre 1.17
|
||||
else
|
||||
for file in *forge*.jar; do
|
||||
if ! [[ $file =~ installer ]]; then
|
||||
if [[ -z $latest ]] || [[ $file -nt $latest ]]; then
|
||||
latest=$file
|
||||
fi
|
||||
fi
|
||||
done
|
||||
fi
|
||||
if [[ -z $latest ]]; then
|
||||
log "Unable to derive server jar for Forge"
|
||||
exit 2
|
||||
fi
|
||||
|
||||
export SERVER=$latest
|
||||
log "Using server $SERVER"
|
||||
debug "Writing install marker at $installMarker"
|
||||
echo "$SERVER" > "$installMarker"
|
||||
}
|
||||
|
||||
resolve_versions() {
|
||||
if [[ -z $FORGE_INSTALLER && -z $FORGE_INSTALLER_URL ]]; then
|
||||
norm=$VANILLA_VERSION
|
||||
|
||||
case $VANILLA_VERSION in
|
||||
*.*.*)
|
||||
norm=$VANILLA_VERSION ;;
|
||||
*.*)
|
||||
norm=${VANILLA_VERSION}.0 ;;
|
||||
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']" --json-value-when-missing "" "$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)
|
||||
if ! FORGE_VERSION=$(get --json-path ".promos['$VANILLA_VERSION-recommended']" --json-value-when-missing "" "$promosUrl"); then
|
||||
if ! FORGE_VERSION=$(get --json-path ".promos['$VANILLA_VERSION-latest']" --json-value-when-missing "" "$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
|
||||
fi
|
||||
;;
|
||||
|
||||
*)
|
||||
FORGE_VERSION=$FORGEVERSION
|
||||
;;
|
||||
esac
|
||||
|
||||
normForgeVersion=$VANILLA_VERSION-$FORGE_VERSION-$norm
|
||||
shortForgeVersion=$VANILLA_VERSION-$FORGE_VERSION
|
||||
|
||||
FORGE_INSTALLER="/tmp/forge-$shortForgeVersion-installer.jar"
|
||||
elif [[ -z $FORGE_INSTALLER ]]; then
|
||||
FORGE_INSTALLER="/tmp/forge-installer.jar"
|
||||
elif [[ ! -e $FORGE_INSTALLER ]]; then
|
||||
log "ERROR: the given Forge installer doesn't exist : $FORGE_INSTALLER"
|
||||
exit 2
|
||||
else
|
||||
shortForgeVersion=$VANILLA_VERSION-${FORGE_INSTALLER_CUSTOM_VERSION:-custom}
|
||||
fi
|
||||
}
|
||||
|
||||
### main
|
||||
|
||||
resolve_versions
|
||||
|
||||
installMarker="/data/.forge-installed-$shortForgeVersion"
|
||||
|
||||
if [ ! -e "$installMarker" ] || isTrue "${FORCE_REINSTALL:-false}"; then
|
||||
install
|
||||
else
|
||||
SERVER=$(cat "$installMarker")
|
||||
export SERVER
|
||||
if [ ! -e "$SERVER" ]; then
|
||||
rm "$installMarker"
|
||||
install
|
||||
fi
|
||||
if ! mc-image-helper install-forge \
|
||||
--output-directory=/data \
|
||||
--results-file=/data/.run-forge.env \
|
||||
--minecraft-version="${VANILLA_VERSION}" \
|
||||
--forge-version="${FORGEVERSION}" \
|
||||
--force-reinstall="${FORCE_REINSTALL:-false}"; then
|
||||
log "ERROR failed to install forge"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# grab SERVER and export it
|
||||
set -a
|
||||
source /data/.run-forge.env
|
||||
set +a
|
||||
|
||||
export FAMILY=FORGE
|
||||
|
||||
exec "${SCRIPTS:-/}start-setupWorld" "$@"
|
||||
|
Loading…
Reference in New Issue
Block a user