Skip to content

Commit

Permalink
Fallback to existing server file when getbukkit retrieval fails (#2721)
Browse files Browse the repository at this point in the history
  • Loading branch information
itzg authored Mar 16, 2024
1 parent d7512c4 commit 75f5647
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 20 deletions.
10 changes: 2 additions & 8 deletions examples/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
version: '3'
# Other docker-compose examples in /examples

services:
minecraft:
image: itzg/minecraft-server
Expand All @@ -9,10 +6,7 @@ services:
ports:
- "25565:25565"
volumes:
- "mc:/data"
- ./data:/data
environment:
EULA: "TRUE"
restart: always

volumes:
mc: {}
restart: unless-stopped
13 changes: 13 additions & 0 deletions examples/spigot/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -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: {}
37 changes: 25 additions & 12 deletions scripts/start-deployBukkitSpigot
Original file line number Diff line number Diff line change
Expand Up @@ -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

if [ -f "$SERVER" ]; then
log "Continuing with existing $SERVER file"
else
# remove invalid download
rm "$tempFile"
exit 3
fi

# remove invalid download
rm "$SERVER"
exit 3
else
mv "$tempFile" "$SERVER"

fi


JVM_OPTS="${JVM_OPTS} -DIReallyKnowWhatIAmDoingISwear"
export JVM_OPTS
}
Expand Down

0 comments on commit 75f5647

Please sign in to comment.