[mc] Add support for DOWNLOAD_*_URL overrides

Also switched from wget to curl
This commit is contained in:
Geoff Bourne 2017-04-08 07:20:04 -05:00
parent 80c18004c1
commit 72d055ac19
4 changed files with 47 additions and 28 deletions

View File

@ -12,6 +12,7 @@ RUN echo "http://dl-3.alpinelinux.org/alpine/v3.5/community/" >> /etc/apk/reposi
lsof \
su-exec \
bash \
curl \
git \
jq &&\
rm -rf /var/cache/apk/*

View File

@ -39,11 +39,16 @@ With that you can easily view the logs, stop, or re-start the container:
access the Minecraft server console:
```
docker exec -it mc rcon-cli
docker exec -i mc rcon-cli
```
Replacing `mc` with your container's name or ID. The `-it` is important needed for interactive
access to the console.
or
```
echo stop | docker exec -it mc rcon-cli
```
Note: The `-i` is needed to attach to the standard *input* of the rcon-cli.
In order to attach and interact with the Minecraft server, add `-it` when starting the container, such as
@ -169,6 +174,10 @@ Enable Bukkit/Spigot server mode by adding a `-e TYPE=BUKKIT -e VERSION=1.8` or
-e TYPE=SPIGOT -e VERSION=1.8 \
-p 25565:25565 -e EULA=TRUE --name mc itzg/minecraft-server
If you are hosting your own copy of Bukkit/Spigot you can override the download URLs with:
* -e BUKKIT_DOWNLOAD_URL=<url>
* -e SPIGOT_DOWNLOAD_URL=<url>
You can build spigot from source by adding `-e BUILD_FROM_SOURCE=true`
__NOTE: to avoid pegging the CPU when running Spigot,__ you will need to
@ -234,6 +243,9 @@ pass `--noconsole` at the very end of the command line and not use `-it`. For ex
-e TYPE=PAPER -e VERSION=1.9.4 \
-p 25565:25565 -e EULA=TRUE --name mc itzg/minecraft-server --noconsole
If you are hosting your own copy of PaperSpigot you can override the download URL with:
* -e PAPER_DOWNLOAD_URL=<url>
You can install Bukkit plugins in two ways...
### Using the /data volume

View File

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

View File

@ -23,16 +23,16 @@ VERSIONS_JSON=https://launchermeta.mojang.com/mc/game/version_manifest.json
echo "Checking version information."
case "X$VERSION" in
X|XLATEST|Xlatest)
VANILLA_VERSION=`wget -O - -q $VERSIONS_JSON | jq -r '.latest.release'`
VANILLA_VERSION=`curl -fsSL $VERSIONS_JSON | jq -r '.latest.release'`
;;
XSNAPSHOT|Xsnapshot)
VANILLA_VERSION=`wget -O - -q $VERSIONS_JSON | jq -r '.latest.snapshot'`
VANILLA_VERSION=`curl -fsSL $VERSIONS_JSON | jq -r '.latest.snapshot'`
;;
X[1-9]*)
VANILLA_VERSION=$VERSION
;;
*)
VANILLA_VERSION=`wget -O - -q $VERSIONS_JSON | jq -r '.latest.release'`
VANILLA_VERSION=`curl -fsSL $VERSIONS_JSON | jq -r '.latest.release'`
;;
esac
@ -56,28 +56,32 @@ function downloadSpigot {
case "$TYPE" in
*BUKKIT|*bukkit)
match="Craftbukkit"
downloadUrl=${BUKKIT_DOWNLOAD_URL}
;;
*)
match="Spigot"
downloadUrl=${SPIGOT_DOWNLOAD_URL}
;;
esac
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"
status=$?
if [ $status != 0 ]; then
echo "ERROR: failed to download from $downloadUrl due to (error code was $status)"
exit 3
if [[ -z $downloadUrl ]]; then
downloadUrl=$(restify --class=jar-div https://mcadmin.net/ | \
jq --arg version "$match $VANILLA_VERSION" -r -f /usr/share/mcadmin.jq)
if [[ -z $downloadUrl ]]; then
echo "ERROR: Version $VANILLA_VERSION is not supported for $TYPE"
echo " Refer to https://mcadmin.net/ for supported versions"
exit 2
fi
else
echo "ERROR: Version $VANILLA_VERSION is not supported for $TYPE"
echo " Refer to https://mcadmin.net/ for supported versions"
exit 2
fi
echo "Downloading $match"
curl -fsSL -o $SERVER "$downloadUrl"
status=$?
if [ ! -f $SERVER ]; then
echo "ERROR: failed to download from $downloadUrl (status=$status)"
exit 3
fi
}
function downloadPaper {
@ -98,11 +102,11 @@ function downloadPaper {
esac
if [ $build != "nosupp" ]; then
downloadUrl="https://ci.destroystokyo.com/job/PaperSpigot/$build/artifact/paperclip.jar"
wget -q -O $SERVER "$downloadUrl"
status=$?
if [ $status != 0 ]; then
echo "ERROR: failed to download from $downloadUrl due to (error code was $status)"
rm $SERVER
downloadUrl=${PAPER_DOWNLOAD_URL:-https://ci.destroystokyo.com/job/PaperSpigot/$build/artifact/paperclip.jar}
curl -fsSL -o $SERVER "$downloadUrl"
if [ ! -f $SERVER ]; then
echo "ERROR: failed to download from $downloadUrl (status=$?)"
exit 3
fi
else
@ -120,7 +124,7 @@ function installForge {
echo "Checking Forge version information."
case $FORGEVERSION in
RECOMMENDED)
wget -q -O /tmp/forge.json http://files.minecraftforge.net/maven/net/minecraftforge/forge/promotions_slim.json
curl -fsSL -o /tmp/forge.json http://files.minecraftforge.net/maven/net/minecraftforge/forge/promotions_slim.json
FORGE_VERSION=$(cat /tmp/forge.json | jq -r ".promos[\"$norm-recommended\"]")
if [ $FORGE_VERSION = null ]; then
FORGE_VERSION=$(cat /tmp/forge.json | jq -r ".promos[\"$norm-latest\"]")
@ -149,9 +153,11 @@ function installForge {
FORGE_INSTALLER="forge-$normForgeVersion-installer.jar"
SERVER="forge-$normForgeVersion-universal.jar"
downloadUrl="http://files.minecraftforge.net/maven/net/minecraftforge/forge/$normForgeVersion/$FORGE_INSTALLER"
if [ ! -e "$SERVER" ]; then
echo "Downloading $FORGE_INSTALLER ..."
wget -q http://files.minecraftforge.net/maven/net/minecraftforge/forge/$normForgeVersion/$FORGE_INSTALLER
wget -q $downloadUrl
echo "Installing $SERVER"
java -jar $FORGE_INSTALLER --installServer
fi