Skip to content

Commit 2eb6604

Browse files
authored
Fix Spigot/Bukkit downloads (#3500)
1 parent 446db80 commit 2eb6604

File tree

1 file changed

+8
-45
lines changed

1 file changed

+8
-45
lines changed

scripts/start-deployBukkitSpigot

Lines changed: 8 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -70,38 +70,19 @@ function downloadSpigot {
7070
esac
7171

7272
if [[ ${VERSION^^} = LATEST ]]; then
73-
if ! VERSION=$(restify ${getBukkitSpigotUrl} --attribute='property=og:title' | jq -r '.[0] | .attributes | select(.property == "og:title") | .content | split(" ") | .[-1]'); then
73+
if ! downloadUrl=$(restify "${getBukkitBaseUrl}/${getbukkitFlavor}" --id='downloadr' | jq -r '.[0] | .href '); then
7474
logError "Failed to retrieve latest version from ${getBukkitSpigotUrl} -- site might be down"
7575
exit 1
7676
fi
7777
fi
7878

7979
if [[ -z $downloadUrl ]]; then
80-
downloadBaseUrl="https://"
81-
downloadSuffixUrl=".getbukkit.org/${getbukkitFlavor}/${getbukkitFlavor}-${VERSION}.jar"
82-
if versionLessThan 1.16.5 || { [[ ${getbukkitFlavor} = "craftbukkit" ]] && [[ ${VERSION} = "1.16.5" ]] ; }; then
83-
downloadBaseUrl+="cdn"
84-
else
85-
downloadBaseUrl+="download"
86-
fi
87-
downloadUrl="${downloadBaseUrl}${downloadSuffixUrl}"
88-
fi
89-
90-
setServerVar
91-
curlArgs=()
92-
if [ -f "$SERVER" ] && ! isTrue "$FORCE_REDOWNLOAD"; then
93-
# tell curl to only download when newer
94-
curlArgs+=(-z "$SERVER")
80+
downloadUrl="https://cdn.getbukkit.org/${getbukkitFlavor}/${getbukkitFlavor}-${VERSION}.jar"
9581
fi
96-
if isDebugging; then
97-
curlArgs+=(-v)
98-
fi
99-
log "Downloading $match from $downloadUrl ..."
10082

101-
tempFile="$SERVER.$$"
83+
log "Downloading $match from $downloadUrl if missing ..."
10284

103-
# HTTP error or download site responded with an HTML error page
104-
if ! curl -fsSL -o "$tempFile" "${curlArgs[@]}" "$downloadUrl" || ( [ -f "$tempFile" ] && grep -iq "doctype html" "$tempFile" ); then
85+
if ! SERVER=$(get -o /data --skip-existing --output-filename "$downloadUrl"); then
10586

10687
cat <<EOF
10788
@@ -111,29 +92,9 @@ ERROR: failed to download from $downloadUrl
11192
Click into the version entry to find the **exact** version.
11293
11394
EOF
114-
115-
if isDebugging && grep -iq "doctype html" "$tempFile"; then
116-
cat "$tempFile"
117-
fi
118-
119-
if [ -f "$SERVER" ]; then
120-
log "Continuing with existing $SERVER file"
121-
else
122-
# remove invalid download
123-
rm "$tempFile"
124-
exit 3
125-
fi
126-
127-
else
128-
if [ -f "$tempFile" ]; then
129-
mv "$tempFile" "$SERVER"
95+
exit 1
13096
fi
131-
132-
fi
133-
134-
135-
JVM_OPTS="${JVM_OPTS} -DIReallyKnowWhatIAmDoingISwear"
136-
export JVM_OPTS
97+
export SERVER
13798
}
13899

139100
function setServerVar {
@@ -157,6 +118,8 @@ else
157118
downloadSpigot
158119
fi
159120

121+
JVM_OPTS="${JVM_OPTS} -DIReallyKnowWhatIAmDoingISwear"
122+
export JVM_OPTS
160123
# Normalize on Spigot for operations below
161124
export FAMILY=SPIGOT
162125

0 commit comments

Comments
 (0)