Skip to content

Commit 75f5647

Browse files
authored
Fallback to existing server file when getbukkit retrieval fails (#2721)
1 parent d7512c4 commit 75f5647

File tree

3 files changed

+40
-20
lines changed

3 files changed

+40
-20
lines changed

examples/docker-compose.yml

+2-8
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
version: '3'
2-
# Other docker-compose examples in /examples
3-
41
services:
52
minecraft:
63
image: itzg/minecraft-server
@@ -9,10 +6,7 @@ services:
96
ports:
107
- "25565:25565"
118
volumes:
12-
- "mc:/data"
9+
- ./data:/data
1310
environment:
1411
EULA: "TRUE"
15-
restart: always
16-
17-
volumes:
18-
mc: {}
12+
restart: unless-stopped

examples/spigot/docker-compose.yml

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
services:
2+
mc:
3+
image: itzg/minecraft-server
4+
environment:
5+
EULA: true
6+
TYPE: SPIGOT
7+
VERSION: 1.20.4
8+
ports:
9+
- "25565:25565"
10+
volumes:
11+
- data:/data
12+
volumes:
13+
data: {}

scripts/start-deployBukkitSpigot

+25-12
Original file line numberDiff line numberDiff line change
@@ -76,35 +76,48 @@ function downloadSpigot {
7676
fi
7777

7878
setServerVar
79+
curlArgs=()
7980
if [ -f "$SERVER" ] && ! isTrue "$FORCE_REDOWNLOAD"; then
8081
# tell curl to only download when newer
81-
curlArgs="-z $SERVER"
82+
curlArgs+=(-z "$SERVER")
8283
fi
8384
if isDebugging; then
84-
curlArgs="$curlArgs -v"
85+
curlArgs+=(-v)
8586
fi
8687
log "Downloading $match from $downloadUrl ..."
87-
curl -fsSL -o "$SERVER" $curlArgs "$downloadUrl"
88-
if [[ $? != 0 || $(grep -c "DOCTYPE html" "$SERVER") != 0 ]]; then
88+
89+
tempFile="$SERVER.$$"
90+
91+
# HTTP error or download site responded with an HTML error page
92+
if ! curl -fsSL -o "$tempFile" "${curlArgs[@]}" "$downloadUrl" || grep -iq "doctype html" "$tempFile"; then
93+
8994
cat <<EOF
9095
9196
ERROR: failed to download from $downloadUrl
9297
Visit https://getbukkit.org/download/${getbukkitFlavor} to lookup the
93-
exact version, such as 1.4.6-R0.4-SNAPSHOT or 1.8-R0.1-SNAPSHOT-latest.
94-
Click into the version entry to find the **exact** version, because something
95-
like "1.8" is not sufficient according to their download naming.
98+
exact version or see if download site is unavailable.
99+
Click into the version entry to find the **exact** version.
96100
97101
EOF
98102

99-
if isDebugging && [[ $(grep -c "DOCTYPE html" "$SERVER") != 0 ]]; then
100-
cat "$SERVER"
103+
if isDebugging && grep -iq "doctype html" "$tempFile"; then
104+
cat "$tempFile"
105+
fi
106+
107+
if [ -f "$SERVER" ]; then
108+
log "Continuing with existing $SERVER file"
109+
else
110+
# remove invalid download
111+
rm "$tempFile"
112+
exit 3
101113
fi
102114

103-
# remove invalid download
104-
rm "$SERVER"
105-
exit 3
115+
else
116+
mv "$tempFile" "$SERVER"
117+
106118
fi
107119

120+
108121
JVM_OPTS="${JVM_OPTS} -DIReallyKnowWhatIAmDoingISwear"
109122
export JVM_OPTS
110123
}

0 commit comments

Comments
 (0)