Compare commits

...

38 Commits

Author SHA1 Message Date
Geoff Bourne
9ee907783d [mc] Added issues link 2017-09-02 12:29:50 -05:00
Geoff Bourne
463cc62b75 [mc] Check writability of /data
Document JVM_OPTS
For #176 and #177
2017-09-02 12:24:09 -05:00
Geoff Bourne
5afd98edd8 [es] Upgrade to 5.5.1 2017-08-12 13:58:39 -05:00
Geoff Bourne
8b9051d72e Merge pull request #174 from Rob5Underscores/master
Add support for a zip file of mod configs to be supplied!
2017-07-17 06:56:44 -05:00
Rob Weddell
d6392f3aa9 Add support for a zip file of mod configs to be supplied!
This was added such that Sponge servers are supported.
(For Sponge: TYPE=FORGE, MODPACK=[zip including sponge plugins and jar], MODCONFIG=[sponge configuration])
2017-07-17 11:48:23 +01:00
Geoff Bourne
fe808be91b Merge pull request #173 from opHASnoNAME/master
Set UID for ES_DEFAULT_USER to 1100, avoid conflicts with debian host…
2017-07-16 14:16:24 -05:00
Arne Riemann
2cab10e906 Forgot -u for UID 2017-07-16 16:09:28 +02:00
Geoff Bourne
7f39d1f22e [mc] Properly check empty json files to fix
For #162
2017-07-15 20:02:40 -05:00
Arne Riemann
a9184368c1 Set UID for ES_DEFAULT_USER to 1100, avoid conflicts with debian host systems 2017-07-15 06:38:36 +02:00
Geoff Bourne
caf2fc2ab6 [es] Correcting old-ADD tar file path 2017-07-13 09:09:10 -05:00
Geoff Bourne
5dd8141e5e Merge pull request #169 from manojsb/patch-1
Upgrade to ES 5.5.0
2017-07-13 08:53:42 -05:00
Geoff Bourne
2ff28675d4 [es] Adapt to new Dockerfile ADD behavior 2017-07-13 08:52:02 -05:00
Manoj Kumar
519bd986b5 Update Dockerfile
Updated to v5.5.0
2017-07-12 11:41:13 +05:30
Geoff Bourne
e41efba176 [es] Using NON_DATA in 3x1GB stack
For #165
2017-07-04 18:08:10 -05:00
Geoff Bourne
0502813496 [es] Add NON_DATA type
For #165
2017-07-04 18:06:08 -05:00
Geoff Bourne
932a6828f9 [mc] Auto fix pre 1.12 empty json
For #162
2017-07-03 14:20:12 -05:00
Geoff Bourne
d176ef3f6a Merge pull request #167 from lukascernydis/master
Added option REMOVE_OLD_MODS
2017-07-01 20:09:12 -05:00
Lukáš Černý
deb98268f6 Added option REMOVE_OLD_MODS 2017-07-02 01:32:24 +02:00
Geoff Bourne
e1531c3237 [mc] Switch to openjdk alpine base image 2017-06-29 19:45:51 -05:00
Geoff Bourne
47af45a430 Merge pull request #166 from macman31/patch-1
Fix typos in config file generation
2017-06-29 19:19:11 -05:00
ATMD
0195b42eea Fix regex to change gamemode value
The sed command `sed -i "/gamemode\s*=/ c gamemode=$MODE" $SERVER_PROPERTIES` matches all lines containing `gamemode=`.
This includes the line `force-gamemode` that is set it with `setServerProp "force-gamemode" "$FORCE_GAMEMODE"`
So basically the `force-gamemode` line is erased and the `gamemode=value` line is duplicated, and then the server cleans it up at start and deduplicates the `gamemode` line and create a new `force-gamemode` line with a default value.
This fix ensures that only the `gamemode=` line is modified when changing the gamemode value.
2017-06-29 21:53:26 +02:00
ATMD
f875af5cdb Delete repetition of spawn-npcs 2017-06-29 20:25:24 +02:00
ATMD
32a918b902 Fix typo SPAWN_ANIMIALS 2017-06-29 19:56:14 +02:00
Geoff Bourne
d09a56075f [es] Add an example minimal composition 2017-06-28 23:17:39 -05:00
Geoff Bourne
e261fae348 [es] Upgrade to 5.4.2 2017-06-21 19:06:13 -05:00
Geoff Bourne
5b8668d73f [mc] Add dinnerbone's mcstatus and use it for HEALTHCHECK
Part of #159
2017-06-11 11:03:00 -05:00
Geoff Bourne
123292b56b Merge pull request #156 from dirkcjelli/mc_fixes
minecraft-server: Fixed FORGEVERSION case, add support for BIOMESOP
Fixes #139
2017-06-07 21:00:39 -05:00
Sascha Askani
0e0828f47f Revert "Fix FORGEVERSION -> FORGE_VERSION, remove unneeded statement in default"
This reverts commit cb6643a345.
2017-06-07 20:55:39 -05:00
Geoff Bourne
532c9fa69a Merge branch 'master' into mc_fixes 2017-06-07 20:54:35 -05:00
Geoff Bourne
e509563b10 [mc] Correctly pre-populate json config files
For #158
2017-06-07 20:43:35 -05:00
Geoff Bourne
899f31917c [mc] Add some FORGE_INSTALLER lookup messages 2017-06-07 08:07:44 -05:00
Geoff Bourne
e6ca9a1c6d [mc] glob for forge jar, but exclude installer 2017-06-06 23:09:45 -05:00
Geoff Bourne
24c68b9c2c [mc] Avoid trying to run forge installer as server 2017-06-06 22:36:39 -05:00
Geoff Bourne
2891e1ac3e [mc] Check for valid $FORGE_INSTALLER 2017-06-05 21:34:15 -05:00
Sascha Askani
da9618c08b add support for BIOMESOP level type 2017-06-05 16:09:26 +02:00
Sascha Askani
cb6643a345 Fix FORGEVERSION -> FORGE_VERSION, remove unneeded statement in default
case
2017-06-05 16:08:26 +02:00
Geoff Bourne
71527b87c1 [mc] Add support for custom Forge installer sources
For #154
2017-06-03 20:51:54 -05:00
Geoff Bourne
df25a22634 [es] Upgrade to 5.4.1 2017-06-02 12:02:11 -05:00
9 changed files with 293 additions and 97 deletions

View File

@@ -4,12 +4,18 @@ LABEL maintainer "itzg"
RUN apk -U add bash RUN apk -U add bash
ENV ES_VERSION=5.4.0 ARG ES_VERSION=5.5.1
# avoid conflicts with debian host systems when mounting to host volume
ARG DEFAULT_ES_USER_UID=1100
ADD https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-$ES_VERSION.tar.gz /tmp/es.tgz ADD https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-$ES_VERSION.tar.gz /tmp
# need to adapt to both Docker's new remote-unpack-ADD behavior and the old behavior
RUN cd /usr/share && \ RUN cd /usr/share && \
tar xf /tmp/es.tgz && \ if [ -f /tmp/elasticsearch-$ES_VERSION.tar.gz ]; then \
rm /tmp/es.tgz tar xf /tmp/elasticsearch-$ES_VERSION.tar.gz; \
else mv /tmp/elasticsearch-${ES_VERSION} /usr/share; \
fi && \
rm -f /tmp/elasticsearch-$ES_VERSION.tar.gz
EXPOSE 9200 9300 EXPOSE 9200 9300
@@ -17,9 +23,10 @@ HEALTHCHECK --timeout=5s CMD wget -q -O - http://$HOSTNAME:9200/_cat/health
ENV ES_HOME=/usr/share/elasticsearch-$ES_VERSION \ ENV ES_HOME=/usr/share/elasticsearch-$ES_VERSION \
DEFAULT_ES_USER=elasticsearch \ DEFAULT_ES_USER=elasticsearch \
DEFAULT_ES_USER_UID=$DEFAULT_ES_USER_UID \
ES_JAVA_OPTS="-Xms1g -Xmx1g" ES_JAVA_OPTS="-Xms1g -Xmx1g"
RUN adduser -S -s /bin/sh $DEFAULT_ES_USER RUN adduser -S -s /bin/sh -u $DEFAULT_ES_USER_UID $DEFAULT_ES_USER
VOLUME ["/data","/conf"] VOLUME ["/data","/conf"]

View File

@@ -181,8 +181,9 @@ To simplify all that, this image provides a `TYPE` variable to let you amongst t
* `MASTER` : master-eligible, but holds no data. It is good to have three or more of these in a * `MASTER` : master-eligible, but holds no data. It is good to have three or more of these in a
large cluster large cluster
* `DATA` (or `NON_MASTER`) : holds data and serves search/index requests. Scale these out for elastic-y goodness. * `DATA` (or `NON_MASTER`) : holds data and serves search/index requests. Scale these out for elastic-y goodness.
* `NON_DATA` : performs all duties except holding data
* `GATEWAY` (or `COORDINATING`) : only operates as a client node or a "smart router". These are the ones whose HTTP port 9200 will need to be exposed * `GATEWAY` (or `COORDINATING`) : only operates as a client node or a "smart router". These are the ones whose HTTP port 9200 will need to be exposed
* `INGEST` : operates only as an ingest node and is not master or data eligble * `INGEST` : operates only as an ingest node and is not master or data eligible
A [Docker Compose](https://docs.docker.com/compose/overview/) file will serve as a good example of these three node types: A [Docker Compose](https://docs.docker.com/compose/overview/) file will serve as a good example of these three node types:

View File

@@ -0,0 +1,35 @@
# This composition is known to work on a Swarm cluster consisting of
# 3 VM nodes with 1GB allocated to each.
version: '3'
services:
master:
image: itzg/elasticsearch
environment:
UNICAST_HOSTS: master
MIN_MASTERS: 1
ES_JAVA_OPTS: -Xms756m -Xmx756m
TYPE: NON_DATA
ports:
- "9200:9200"
- "9300:9300"
deploy:
replicas: 1
update_config:
parallelism: 1
data:
image: itzg/elasticsearch
deploy:
mode: global
update_config:
parallelism: 1
environment:
TYPE: DATA
UNICAST_HOSTS: master
ES_JAVA_OPTS: -Xms512m -Xmx512m
kibana:
image: kibana
ports:
- "5601:5601"
environment:
ELASTICSEARCH_URL: http://master:9200

View File

@@ -7,20 +7,11 @@ services:
TYPE: MASTER TYPE: MASTER
UNICAST_HOSTS: master UNICAST_HOSTS: master
MIN_MASTERS: 1 MIN_MASTERS: 1
deploy:
replicas: 1
update_config:
parallelism: 1
data: data:
build: . build: .
environment: environment:
TYPE: DATA TYPE: DATA
UNICAST_HOSTS: master UNICAST_HOSTS: master
deploy:
replicas: 2
update_config:
parallelism: 1
delay: 60s
gateway: gateway:
build: . build: .
ports: ports:
@@ -37,7 +28,7 @@ services:
TYPE: INGEST TYPE: INGEST
UNICAST_HOSTS: master UNICAST_HOSTS: master
kibana: kibana:
image: kibana image: kibana:5.5.1
ports: ports:
- "5601:5601" - "5601:5601"
environment: environment:

View File

@@ -0,0 +1,21 @@
version: '3'
services:
master:
image: itzg/elasticsearch
environment:
UNICAST_HOSTS: master
MIN_MASTERS: 1
ports:
- "9200:9200"
- "9300:9300"
deploy:
replicas: 1
update_config:
parallelism: 1
kibana:
image: kibana
ports:
- "5601:5601"
environment:
ELASTICSEARCH_URL: http://master:9200

View File

@@ -99,10 +99,18 @@ setup_personality() {
OPTS="$OPTS -E node.master=false -E node.data=false -E node.ingest=true" OPTS="$OPTS -E node.master=false -E node.data=false -E node.ingest=true"
;; ;;
DATA|NON_MASTER) DATA)
OPTS="$OPTS -E node.master=false -E node.data=true -E node.ingest=false" OPTS="$OPTS -E node.master=false -E node.data=true -E node.ingest=false"
;; ;;
NON_MASTER)
OPTS="$OPTS -E node.master=false -E node.data=true -E node.ingest=true"
;;
NON_DATA)
OPTS="$OPTS -E node.master=true -E node.data=false -E node.ingest=true"
;;
*) *)
echo "Unknown node type. Please use MASTER|GATEWAY|DATA|NON_MASTER" echo "Unknown node type. Please use MASTER|GATEWAY|DATA|NON_MASTER"
exit 1 exit 1

View File

@@ -1,12 +1,8 @@
FROM alpine FROM openjdk:8u131-jre-alpine
LABEL maintainer "itzg" LABEL maintainer "itzg"
RUN echo "http://dl-3.alpinelinux.org/alpine/v3.5/community/" >> /etc/apk/repositories &&\ RUN apk add -U \
apk update && \
apk add \
openjdk8-jre-base \
openssl \ openssl \
imagemagick \ imagemagick \
lsof \ lsof \
@@ -16,9 +12,13 @@ RUN echo "http://dl-3.alpinelinux.org/alpine/v3.5/community/" >> /etc/apk/reposi
git \ git \
jq \ jq \
mysql-client \ mysql-client \
python python-dev && \ python python-dev py2-pip && \
rm -rf /var/cache/apk/* rm -rf /var/cache/apk/*
RUN pip install mcstatus
HEALTHCHECK CMD mcstatus localhost ping
RUN addgroup -g 1000 minecraft \ RUN addgroup -g 1000 minecraft \
&& adduser -Ss /bin/false -u 1000 -G minecraft -h /home/minecraft minecraft \ && adduser -Ss /bin/false -u 1000 -G minecraft -h /home/minecraft minecraft \
&& mkdir /data \ && mkdir /data \

View File

@@ -1,6 +1,7 @@
[![Docker Pulls](https://img.shields.io/docker/pulls/itzg/minecraft-server.svg)](https://hub.docker.com/r/itzg/minecraft-server/) [![Docker Pulls](https://img.shields.io/docker/pulls/itzg/minecraft-server.svg)](https://hub.docker.com/r/itzg/minecraft-server/)
[![Docker Stars](https://img.shields.io/docker/stars/itzg/minecraft-server.svg?maxAge=2592000)](https://hub.docker.com/r/itzg/minecraft-server/) [![Docker Stars](https://img.shields.io/docker/stars/itzg/minecraft-server.svg?maxAge=2592000)](https://hub.docker.com/r/itzg/minecraft-server/)
[![GitHub Issues](https://img.shields.io/github/issues-raw/itzg/dockerfiles.svg)](https://github.com/itzg/dockerfiles/issues)
This docker image provides a Minecraft Server that will automatically download the latest stable This docker image provides a Minecraft Server that will automatically download the latest stable
version at startup. You can also run/upgrade to any specific version or the version at startup. You can also run/upgrade to any specific version or the
@@ -117,6 +118,34 @@ or a specific version:
docker run -d -e VERSION=1.7.9 ... docker run -d -e VERSION=1.7.9 ...
## Healthcheck
This image contains [Dinnerbone's mcstatus](https://github.com/Dinnerbone/mcstatus) and uses
its `ping` command to continually check on the container's. That can be observed
from the `STATUS` column of `docker ps`
```
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
b418af073764 mc "/start" 43 seconds ago Up 41 seconds (healthy) 0.0.0.0:25565->25565/tcp, 25575/tcp mc
```
You can also query the container's health in a script friendly way:
```
> docker container inspect -f "{{.State.Health.Status}}" mc
healthy
```
Finally, since `mcstatus` is on the `PATH` you can exec into the container
and use mcstatus directly and invoke any of its other commands:
```
> docker exec mc mcstatus localhost status
version: v1.12 (protocol 335)
description: "{u'text': u'A Minecraft Server Powered by Docker'}"
players: 0/20 No players online
```
## Running a Forge Server ## Running a Forge Server
Enable Forge server mode by adding a `-e TYPE=FORGE` to your command-line. Enable Forge server mode by adding a `-e TYPE=FORGE` to your command-line.
@@ -127,6 +156,20 @@ but you can also choose to run a specific version with `-e FORGEVERSION=10.13.4.
-e TYPE=FORGE -e FORGEVERSION=10.13.4.1448 \ -e TYPE=FORGE -e FORGEVERSION=10.13.4.1448 \
-p 25565:25565 -e EULA=TRUE --name mc itzg/minecraft-server -p 25565:25565 -e EULA=TRUE --name mc itzg/minecraft-server
To use a pre-downloaded Forge installer, place it in the attached `/data` directory and
specify the name of the installer file with `FORGE_INSTALLER`, such as:
$ docker run -d -v /path/on/host:/data ... \
-e FORGE_INSTALLER=forge-1.11.2-13.20.0.2228-installer.jar ...
To download a Forge installer from a custom location, such as your own file repository, specify
the URL with `FORGE_INSTALLER_URL`, such as:
$ docker run -d -v /path/on/host:/data ... \
-e FORGE_INSTALLER_URL=http://HOST/forge-1.11.2-13.20.0.2228-installer.jar ...
In both of the cases above, there is no need for the `VERSION` or `FORGEVERSION` variables.
In order to add mods, you have two options. In order to add mods, you have two options.
### Using the /data volume ### Using the /data volume
@@ -630,6 +673,20 @@ To use this option pass the environment variable `MODPACK`, such as
top level of the zip archive. Make sure the jars are compatible with the top level of the zip archive. Make sure the jars are compatible with the
particular `TYPE` of server you are running. particular `TYPE` of server you are running.
### Remove old mods/plugins
When the option above is specified (`MODPACK`) you can also instruct script to
delete old mods/plugins prior to installing new ones. This behaviour is desirable
in case you want to upgrade mods/plugins from downloaded zip file.
To use this option pass the environment variable `REMOVE_OLD_MODS="TRUE"`, such as
docker run -d -e REMOVE_OLD_MODS="TRUE" -e MODPACK=http://www.example.com/mods/modpack.zip ...
**NOTE:** This option will be taken into account only when option `MODPACK` is also used.
**WARNING:** All content of the `mods` or `plugins` directory will be deleted
before unpacking new content from the zip file.
### Online mode ### Online mode
By default, server checks connecting players against Minecraft's account database. If you want to create an offline server or your server is not connected to the internet, you can disable the server to try connecting to minecraft.net to authenticate players with environment variable `ONLINE_MODE`, like this By default, server checks connecting players against Minecraft's account database. If you want to create an offline server or your server is not connected to the internet, you can disable the server to try connecting to minecraft.net to authenticate players with environment variable `ONLINE_MODE`, like this
@@ -654,3 +711,9 @@ The values of all three are passed directly to the JVM and support format/units
### /data ownership ### /data ownership
In order to adapt to differences in `UID` and `GID` settings the entry script will attempt to correct ownership and writability of the `/data` directory. This logic can be disabled by setting `-e SKIP_OWNERSHIP_FIX=TRUE`. In order to adapt to differences in `UID` and `GID` settings the entry script will attempt to correct ownership and writability of the `/data` directory. This logic can be disabled by setting `-e SKIP_OWNERSHIP_FIX=TRUE`.
### JVM Options
General JVM options can be passed to the Minecraft Server invocation by passing a `JVM_OPTS`
environment variable. Options like `-X` that need to proceed general JVM options can be passed
via a `JVM_XX_OPTS` environment variable.

View File

@@ -1,5 +1,7 @@
#!/bin/bash #!/bin/bash
shopt -s nullglob
#umask 002 #umask 002
export HOME=/data export HOME=/data
@@ -7,6 +9,10 @@ if [ ! -e /data/eula.txt ]; then
if [ "$EULA" != "" ]; then if [ "$EULA" != "" ]; then
echo "# Generated via Docker on $(date)" > eula.txt echo "# Generated via Docker on $(date)" > eula.txt
echo "eula=$EULA" >> eula.txt echo "eula=$EULA" >> eula.txt
if [ $? != 0 ]; then
echo "ERROR: unable to write eula to /data. Please make sure attached directory is writable by uid=${UID}"
exit 2
fi
else else
echo "" echo ""
echo "Please accept the Minecraft EULA at" echo "Please accept the Minecraft EULA at"
@@ -18,6 +24,11 @@ if [ ! -e /data/eula.txt ]; then
fi fi
fi fi
if ! touch /data/.verify_access; then
echo "ERROR: /data doesn't seem to be writable. Please make sure attached directory is writable by uid=${UID} "
exit 2
fi
SERVER_PROPERTIES=/data/server.properties SERVER_PROPERTIES=/data/server.properties
FTB_DIR=/data/FeedTheBeast FTB_DIR=/data/FeedTheBeast
VERSIONS_JSON=https://launchermeta.mojang.com/mc/game/version_manifest.json VERSIONS_JSON=https://launchermeta.mojang.com/mc/game/version_manifest.json
@@ -121,84 +132,116 @@ function downloadPaper {
function installForge { function installForge {
TYPE=FORGE TYPE=FORGE
norm=$VANILLA_VERSION
case $VANILLA_VERSION in if [[ -z $FORGE_INSTALLER && -z $FORGE_INSTALLER_URL ]]; then
*.*.*) norm=$VANILLA_VERSION
norm=$VANILLA_VERSION ;;
*.*)
norm=${VANILLA_VERSION}.0 ;;
esac
echo "Checking Forge version information." case $VANILLA_VERSION in
case $FORGEVERSION in *.*.*)
RECOMMENDED) norm=$VANILLA_VERSION ;;
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[\"$VANILLA_VERSION-recommended\"]") norm=${VANILLA_VERSION}.0 ;;
if [ $FORGE_VERSION = null ]; then esac
FORGE_VERSION=$(cat /tmp/forge.json | jq -r ".promos[\"$VANILLA_VERSION-latest\"]")
echo "Checking Forge version information."
case $FORGEVERSION in
RECOMMENDED)
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[\"$VANILLA_VERSION-recommended\"]")
if [ $FORGE_VERSION = null ]; then if [ $FORGE_VERSION = null ]; then
echo "ERROR: Version $VANILLA_VERSION is not supported by Forge" FORGE_VERSION=$(cat /tmp/forge.json | jq -r ".promos[\"$VANILLA_VERSION-latest\"]")
echo " Refer to http://files.minecraftforge.net/ for supported versions" if [ $FORGE_VERSION = null ]; then
exit 2 echo "ERROR: Version $VANILLA_VERSION is not supported by Forge"
echo " Refer to http://files.minecraftforge.net/ for supported versions"
exit 2
fi
fi fi
fi ;;
;;
*) *)
FORGE_VERSION=$FORGEVERSION FORGE_VERSION=$FORGEVERSION
;; ;;
esac esac
normForgeVersion=$VANILLA_VERSION-$FORGE_VERSION-$norm normForgeVersion=$VANILLA_VERSION-$FORGE_VERSION-$norm
shortForgeVersion=$VANILLA_VERSION-$FORGE_VERSION shortForgeVersion=$VANILLA_VERSION-$FORGE_VERSION
forgeFileNames=" FORGE_INSTALLER="/tmp/forge-$shortForgeVersion-installer.jar"
$normForgeVersion/forge-$normForgeVersion-installer.jar elif [[ -z $FORGE_INSTALLER ]]; then
$shortForgeVersion/forge-$shortForgeVersion-installer.jar FORGE_INSTALLER="/tmp/forge-installer.jar"
END elif [[ ! -e $FORGE_INSTALLER ]]; then
" echo "ERROR: the given Forge installer doesn't exist : $FORGE_INSTALLER"
exit 2
fi
FORGE_INSTALLER="/tmp/forge-$shortForgeVersion-installer.jar"
installMarker=".forge-installed-$shortForgeVersion" installMarker=".forge-installed-$shortForgeVersion"
if [ ! -e $installMarker ]; then if [ ! -e $installMarker ]; then
if [ ! -e $FORGE_INSTALLER ]; then if [ ! -e $FORGE_INSTALLER ]; then
echo "Downloading $normForgeVersion"
for fn in $forgeFileNames; do if [[ -z $FORGE_INSTALLER_URL ]]; then
if [ $fn == END ]; then echo "Downloading $normForgeVersion"
echo "Unable to compute URL for $normForgeVersion"
forgeFileNames="
$normForgeVersion/forge-$normForgeVersion-installer.jar
$shortForgeVersion/forge-$shortForgeVersion-installer.jar
END
"
for fn in $forgeFileNames; do
if [ $fn == END ]; then
echo "Unable to compute URL for $normForgeVersion"
exit 2
fi
downloadUrl=http://files.minecraftforge.net/maven/net/minecraftforge/forge/$fn
echo "...trying $downloadUrl"
if curl -o $FORGE_INSTALLER -fsSL $downloadUrl; then
break
fi
done
else
echo "Downloading $FORGE_INSTALLER_URL ..."
if ! curl -o $FORGE_INSTALLER -fsSL $FORGE_INSTALLER_URL; then
echo "Failed to download from given location $FORGE_INSTALLER_URL"
exit 2 exit 2
fi fi
downloadUrl=http://files.minecraftforge.net/maven/net/minecraftforge/forge/$fn
echo "...trying $downloadUrl"
if curl -o $FORGE_INSTALLER -fsSL $downloadUrl; then
break
fi
done
echo "Installing Forge $shortForgeVersion"
mkdir -p mods
tries=3
while ((--tries >= 0)); do
java -jar $FORGE_INSTALLER --installServer
if [ $? == 0 ]; then
break
fi
done
if (($tries < 0)); then
echo "Forge failed to install after several tries." >&2
exit 10
fi fi
SERVER=$(ls *forge*$shortForgeVersion*.jar)
if [ -z $SERVER ]; then
echo "Unable to derive server jar for Forge $shortForgeVersion"
exit 2
fi
echo "Using server $SERVER"
echo $SERVER > $installMarker
fi fi
echo "Installing Forge $shortForgeVersion using $FORGE_INSTALLER"
mkdir -p mods
tries=3
while ((--tries >= 0)); do
java -jar $FORGE_INSTALLER --installServer
if [ $? == 0 ]; then
break
fi
done
if (($tries < 0)); then
echo "Forge failed to install after several tries." >&2
exit 10
fi
# NOTE $shortForgeVersion will be empty if installer location was given to us
echo "Finding installed server jar..."
for j in *forge*.jar; do
echo "...$j"
case $j in
*installer*)
;;
*)
SERVER=$j
break
;;
esac
done
if [[ -z $SERVER ]]; then
echo "Unable to derive server jar for Forge"
exit 2
fi
echo "Using server $SERVER"
echo $SERVER > $installMarker
else else
SERVER=$(cat $installMarker) SERVER=$(cat $installMarker)
fi fi
@@ -371,9 +414,15 @@ case "X$MODPACK" in
echo " from $MODPACK ..." echo " from $MODPACK ..."
curl -sSL -o /tmp/modpack.zip "$MODPACK" curl -sSL -o /tmp/modpack.zip "$MODPACK"
if [ "$TYPE" = "SPIGOT" ]; then if [ "$TYPE" = "SPIGOT" ]; then
if [ "$REMOVE_OLD_MODS" = "TRUE" ]; then
rm -rf /data/plugins/*
fi
mkdir -p /data/plugins mkdir -p /data/plugins
unzip -o -d /data/plugins /tmp/modpack.zip unzip -o -d /data/plugins /tmp/modpack.zip
else else
if [ "$REMOVE_OLD_MODS" = "TRUE" ]; then
rm -rf /data/mods/*
fi
mkdir -p /data/mods mkdir -p /data/mods
unzip -o -d /data/mods /tmp/modpack.zip unzip -o -d /data/mods /tmp/modpack.zip
fi fi
@@ -385,6 +434,28 @@ case "X$MODPACK" in
esac esac
fi fi
# If supplied with a URL for a config (simple zip of configurations), download it and unpack
if [[ "$MODCONFIG" ]]; then
case "X$MODCONFIG" in
X[Hh][Tt][Tt][Pp]*[Zz][iI][pP])
echo "Downloading mod/plugin configs via HTTP"
echo " from $MODCONFIG ..."
curl -sSL -o /tmp/modconfig.zip "$MODCONFIG"
if [ "$TYPE" = "SPIGOT" ]; then
mkdir -p /data/plugins
unzip -o -d /data/plugins /tmp/modconfig.zip
else
mkdir -p /data/config
unzip -o -d /data/config /tmp/modconfig.zip
fi
rm -f /tmp/modconfig.zip
;;
*)
echo "Invalid URL given for modconfig: Must be HTTP or HTTPS and a ZIP file"
;;
esac
fi
function setServerProp { function setServerProp {
local prop=$1 local prop=$1
local var=$2 local var=$2
@@ -409,11 +480,10 @@ if [ ! -e server.properties ]; then
setServerProp "allow-nether" "$ALLOW_NETHER" setServerProp "allow-nether" "$ALLOW_NETHER"
setServerProp "announce-player-achievements" "$ANNOUNCE_PLAYER_ACHIEVEMENTS" setServerProp "announce-player-achievements" "$ANNOUNCE_PLAYER_ACHIEVEMENTS"
setServerProp "enable-command-block" "$ENABLE_COMMAND_BLOCK" setServerProp "enable-command-block" "$ENABLE_COMMAND_BLOCK"
setServerProp "spawn-animals" "$SPAWN_ANIMAILS" setServerProp "spawn-animals" "$SPAWN_ANIMALS"
setServerProp "spawn-monsters" "$SPAWN_MONSTERS" setServerProp "spawn-monsters" "$SPAWN_MONSTERS"
setServerProp "spawn-npcs" "$SPAWN_NPCS" setServerProp "spawn-npcs" "$SPAWN_NPCS"
setServerProp "generate-structures" "$GENERATE_STRUCTURES" setServerProp "generate-structures" "$GENERATE_STRUCTURES"
setServerProp "spawn-npcs" "$SPAWN_NPCS"
setServerProp "view-distance" "$VIEW_DISTANCE" setServerProp "view-distance" "$VIEW_DISTANCE"
setServerProp "hardcore" "$HARDCORE" setServerProp "hardcore" "$HARDCORE"
setServerProp "max-build-height" "$MAX_BUILD_HEIGHT" setServerProp "max-build-height" "$MAX_BUILD_HEIGHT"
@@ -438,7 +508,7 @@ if [ ! -e server.properties ]; then
echo "Setting level type to $LEVEL_TYPE" echo "Setting level type to $LEVEL_TYPE"
# check for valid values and only then set # check for valid values and only then set
case $LEVEL_TYPE in case $LEVEL_TYPE in
DEFAULT|FLAT|LARGEBIOMES|AMPLIFIED|CUSTOMIZED) DEFAULT|FLAT|LARGEBIOMES|AMPLIFIED|CUSTOMIZED|BIOMESOP)
sed -i "/level-type\s*=/ c level-type=$LEVEL_TYPE" /data/server.properties sed -i "/level-type\s*=/ c level-type=$LEVEL_TYPE" /data/server.properties
;; ;;
*) *)
@@ -495,7 +565,7 @@ if [ ! -e server.properties ]; then
;; ;;
esac esac
sed -i "/gamemode\s*=/ c gamemode=$MODE" $SERVER_PROPERTIES sed -i "/^gamemode\s*=/ c gamemode=$MODE" $SERVER_PROPERTIES
fi fi
fi fi
@@ -523,13 +593,13 @@ if [ -n "$ICON" -a ! -e server-icon.png ]; then
fi fi
fi fi
# Make sure files exist to avoid errors # Make sure files exist and are valid JSON (for pre-1.12 to 1.12 upgrades)
if [ ! -e banned-players.json ]; then for j in *.json; do
echo '' > banned-players.json if [[ $(python -c "print open('$j').read().strip()==''") = True ]]; then
fi echo "Fixing JSON $j"
if [ ! -e banned-ips.json ]; then echo '[]' > $j
echo '' > banned-ips.json fi
fi done
# If any modules have been provided, copy them over # If any modules have been provided, copy them over
mkdir -p /data/mods mkdir -p /data/mods