Skip to content

Commit 5cec413

Browse files
authored
Download and use Magma server jar rather than installer (#1618)
1 parent eb22d4c commit 5cec413

File tree

2 files changed

+8
-49
lines changed

2 files changed

+8
-49
lines changed

examples/docker-compose-magma.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@ version: "3.8"
22

33
services:
44
mc:
5-
image: itzg/minecraft-server
5+
image: itzg/minecraft-server:java8
66
tty: true
77
stdin_open: true
88
ports:
99
- "25565:25565"
1010
environment:
1111
EULA: "TRUE"
1212
TYPE: MAGMA
13-
VERSION: 1.18.2
13+
VERSION: 1.16.5
1414
volumes:
1515
- data:/data
1616
volumes:

scripts/start-deployMagma

Lines changed: 6 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -6,58 +6,17 @@ isDebugging && set -x
66

77
: "${VANILLA_VERSION?}"
88

9-
magmaHandleInstaller() {
10-
url=${1?}
11-
tagName=${2?}
12-
markerFile=${3?}
13-
14-
installerFile="magma-installer-${VANILLA_VERSION}-${tagName}.jar"
15-
log "Downloading Magma installer file for ${VANILLA_VERSION} @ ${tagName}"
16-
if ! curl -o "$installerFile" -fsSL "$url"; then
17-
log "ERROR failed to download Magma installer from $url (status=$?)"
18-
exit 1
19-
fi
20-
21-
echo "forge" > "$markerFile"
22-
23-
export FORGE_INSTALLER="$installerFile"
24-
export FORGE_INSTALLER_CUSTOM_VERSION="$tagName"
25-
26-
# now hand off the rest to forge
27-
exec ${SCRIPTS:-/}start-deployForge "$@"
28-
}
29-
30-
latestMeta=$(curl -fsSL https://api.magmafoundation.org/api/v2/${VANILLA_VERSION}/latest || exit $?)
31-
if [ $? != 0 ]; then
32-
log "ERROR failed to locate latest Magma info for ${VANILLA_VERSION} (error=$?)"
9+
if ! downloadUrl=$(get --json-path '$.link' "https://api.magmafoundation.org/api/v2/${VANILLA_VERSION}/latest"); then
10+
log "ERROR failed to locate latest Magma download for ${VANILLA_VERSION}. Is that version supported?"
3311
exit 1
3412
fi
3513

36-
tagName=$(echo "${latestMeta}" | jq -r '.tag_name')
37-
markerFile=".magma-installed-${VANILLA_VERSION}-${tagName}"
38-
if [ -f "${markerFile}" ]; then
39-
installedTagName=$(cat "${markerFile}")
40-
fi
41-
42-
if [ ! -f "${markerFile}" ]; then
43-
assetUrl=$(echo "${latestMeta}" | jq -r ".installer_link")
44-
if [ $? != 0 ] || [ -z "$assetUrl" ]; then
45-
log "ERROR failed to extract installer for ${VANILLA_VERSION} tag ${tagName}"
46-
exit 1
47-
fi
48-
49-
magmaHandleInstaller "$assetUrl" "$tagName" "$markerFile"
50-
else
51-
export SERVER=$(cat "${markerFile}")
52-
53-
if [[ $SERVER == "forge" ]]; then
54-
export FORGE_INSTALLER="magma-installer-${VANILLA_VERSION}-${tagName}.jar"
55-
export FORGE_INSTALLER_CUSTOM_VERSION="$tagName"
56-
# now hand off the rest to forge
57-
exec ${SCRIPTS:-/}start-deployForge "$@"
58-
fi
14+
if ! SERVER=$(get --output-filename --skip-up-to-date --output /data "$downloadUrl"); then
15+
log "ERROR: failed to download Magma server jar from $downloadUrl"
16+
exit 1
5917
fi
6018

19+
export SERVER
6120
export FAMILY=HYBRID
6221

6322
exec "${SCRIPTS:-/}start-setupWorld" "$@"

0 commit comments

Comments
 (0)