[mc] Use restify to lookup Spigot/Bukkit URLs at startup

For #87
This commit is contained in:
Geoff Bourne 2016-07-01 22:17:10 -05:00
parent 413de37568
commit 379905c6ff
4 changed files with 20 additions and 31 deletions

View file

@ -21,28 +21,22 @@ RUN useradd -M -s /bin/false --uid 1000 minecraft \
&& mkdir /plugins \
&& chown minecraft:minecraft /data /config /mods /plugins
EXPOSE 25565
EXPOSE 25575
EXPOSE 25565 25575
COPY get-mcadmin-versions.sh /get-mcadmin-versions
RUN /get-mcadmin-versions https://mcadmin.net/
ADD https://github.com/itzg/restify/releases/download/1.0.3/restify_linux_amd64 /usr/local/bin/restify
COPY start.sh /start
COPY start-minecraft.sh /start-minecraft
COPY mcadmin.jq /usr/share
RUN chmod +x /usr/local/bin/*
VOLUME ["/data"]
VOLUME ["/mods"]
VOLUME ["/config"]
VOLUME ["/plugins"]
VOLUME ["/data","/mods","/config","/plugins"]
COPY server.properties /tmp/server.properties
WORKDIR /data
ENTRYPOINT [ "/start" ]
# Special marker ENV used by MCCY management tool
ENV MC_IMAGE=YES
ENV UID=1000 GID=1000
ENV MOTD A Minecraft Server Powered by Docker
ENV JVM_OPTS -Xmx1024M -Xms1024M
ENV TYPE=VANILLA VERSION=LATEST FORGEVERSION=RECOMMENDED LEVEL=world PVP=true DIFFICULTY=easy \
ENV UID=1000 GID=1000 \
MOTD="A Minecraft Server Powered by Docker" \
JVM_OPTS="-Xmx1024M -Xms1024M" \
TYPE=VANILLA VERSION=LATEST FORGEVERSION=RECOMMENDED LEVEL=world PVP=true DIFFICULTY=easy \
LEVEL_TYPE=DEFAULT GENERATOR_SETTINGS= WORLD= MODPACK=

View file

@ -1,13 +0,0 @@
#!/bin/bash
if [ $# -lt 1 ]; then
echo Missing arg: URL
exit 1
fi
cd /tmp
wget -qO 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 -q 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

@ -0,0 +1,7 @@
.[] |
select(.elements | length > 1) |
select(.elements[].elements[] | select(.class == "version" and .text == $version)) |
.elements[].elements[] |
select(.class|contains("server-jar")) |
.elements[] | select(.name="a") |
.href

View file

@ -63,7 +63,8 @@ function downloadSpigot {
;;
esac
downloadUrl=$(awk -F:: "\$1 == \"${match}\" && \$2 == \"${VANILLA_VERSION}\" {print \$3}" /tmp/mcadmin-versions.db)
downloadUrl=$(restify --class=jar-div https://mcadmin.net/ | \
jq --arg version "$match $VANILLA_VERSION" -r -f /usr/share/mcadmin.jq)
if [[ -n $downloadUrl ]]; then
echo "Downloading $match"
wget -q -O $SERVER "$downloadUrl"
@ -74,7 +75,7 @@ function downloadSpigot {
fi
else
echo "ERROR: Version $VANILLA_VERSION is not supported for $TYPE"
echo " Refer to http://getspigot.org for supported versions"
echo " Refer to https://mcadmin.net/ for supported versions"
exit 2
fi
}