Pre-compute the Bukkit/Spigot download URLs

For #77
This commit is contained in:
Geoff Bourne 2016-05-09 19:28:25 -05:00
parent b5e459ab0a
commit 5617936f10
3 changed files with 20 additions and 9 deletions

View File

@ -24,6 +24,8 @@ RUN useradd -M -s /bin/false --uid 1000 minecraft \
EXPOSE 25565
EXPOSE 25575
COPY get-mcadmin-versions.sh /get-mcadmin-versions
RUN /get-mcadmin-versions https://mcadmin.net/
COPY start.sh /start
COPY start-minecraft.sh /start-minecraft

View File

@ -0,0 +1,13 @@
#!/bin/bash
if [ $# -lt 1 ]; then
echo Missing arg: URL
exit 1
fi
cd /tmp
wget -O mcadmin-versions.jar https://bintray.com/itzgeoff/artifacts/download_file?file_path=me%2Fitzg%2Fmcadmin-versions%2F1.1.0%2Fmcadmin-versions-1.1.0.jar
wget http://central.maven.org/maven2/org/jsoup/jsoup/1.9.1/jsoup-1.9.1.jar
java -jar mcadmin-versions.jar $1 > /tmp/mcadmin-versions.db
rm *.jar

View File

@ -50,22 +50,18 @@ function buildSpigotFromSource {
}
function downloadSpigot {
local match
case "$TYPE" in
*BUKKIT|*bukkit)
match="Craftbukkit $VANILLA_VERSION"
match="Craftbukkit"
;;
*)
match="Spigot $VANILLA_VERSION"
match="Spigot"
;;
esac
curl -o /tmp/versions -sSL https://getspigot.org/api/getversions
status=$?
if [ $status != 0 ]; then
echo "ERROR: failed to access Spigot versions (curl error code was $status)"
exit 3
fi
downloadUrl=$(cat /tmp/versions | jq -r ".[] | select(.version == \"$match\") | .downloadUrl")
downloadUrl=$(awk -F:: "\$1 == \"${match}\" && \$2 == \"${VANILLA_VERSION}\" {print \$3}" /tmp/mcadmin-versions.db)
if [[ -n $downloadUrl ]]; then
echo "Downloading $match"
wget -q -O $SERVER "$downloadUrl"