Fallback to existing server file when getbukkit retrieval fails (#2721)

This commit is contained in:
Geoff Bourne 2024-03-16 14:01:21 -05:00 committed by GitHub
parent d7512c44a9
commit 75f5647c93
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 40 additions and 20 deletions

View File

@ -1,6 +1,3 @@
version: '3'
# Other docker-compose examples in /examples
services:
minecraft:
image: itzg/minecraft-server
@ -9,10 +6,7 @@ services:
ports:
- "25565:25565"
volumes:
- "mc:/data"
- ./data:/data
environment:
EULA: "TRUE"
restart: always
volumes:
mc: {}
restart: unless-stopped

View File

@ -0,0 +1,13 @@
services:
mc:
image: itzg/minecraft-server
environment:
EULA: true
TYPE: SPIGOT
VERSION: 1.20.4
ports:
- "25565:25565"
volumes:
- data:/data
volumes:
data: {}

View File

@ -76,35 +76,48 @@ function downloadSpigot {
fi
setServerVar
curlArgs=()
if [ -f "$SERVER" ] && ! isTrue "$FORCE_REDOWNLOAD"; then
# tell curl to only download when newer
curlArgs="-z $SERVER"
curlArgs+=(-z "$SERVER")
fi
if isDebugging; then
curlArgs="$curlArgs -v"
curlArgs+=(-v)
fi
log "Downloading $match from $downloadUrl ..."
curl -fsSL -o "$SERVER" $curlArgs "$downloadUrl"
if [[ $? != 0 || $(grep -c "DOCTYPE html" "$SERVER") != 0 ]]; then
tempFile="$SERVER.$$"
# HTTP error or download site responded with an HTML error page
if ! curl -fsSL -o "$tempFile" "${curlArgs[@]}" "$downloadUrl" || grep -iq "doctype html" "$tempFile"; then
cat <<EOF
ERROR: failed to download from $downloadUrl
Visit https://getbukkit.org/download/${getbukkitFlavor} to lookup the
exact version, such as 1.4.6-R0.4-SNAPSHOT or 1.8-R0.1-SNAPSHOT-latest.
Click into the version entry to find the **exact** version, because something
like "1.8" is not sufficient according to their download naming.
exact version or see if download site is unavailable.
Click into the version entry to find the **exact** version.
EOF
if isDebugging && [[ $(grep -c "DOCTYPE html" "$SERVER") != 0 ]]; then
cat "$SERVER"
if isDebugging && grep -iq "doctype html" "$tempFile"; then
cat "$tempFile"
fi
# remove invalid download
rm "$SERVER"
exit 3
if [ -f "$SERVER" ]; then
log "Continuing with existing $SERVER file"
else
# remove invalid download
rm "$tempFile"
exit 3
fi
else
mv "$tempFile" "$SERVER"
fi
JVM_OPTS="${JVM_OPTS} -DIReallyKnowWhatIAmDoingISwear"
export JVM_OPTS
}