mirror of
https://github.com/itzg/docker-minecraft-server.git
synced 2026-02-17 15:13:55 +00:00
Compare commits
128 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
90907f7b1e | ||
|
|
d898796672 | ||
|
|
ed32de76ca | ||
|
|
07fc31b401 | ||
|
|
a0db92cb5e | ||
|
|
f33a94a6e2 | ||
|
|
bab31f1198 | ||
|
|
a5614ec03b | ||
|
|
70f49be4fc | ||
|
|
173f612d74 | ||
|
|
ba4578f451 | ||
|
|
1c5e4b17bf | ||
|
|
f65548894f | ||
|
|
b910a7dbe5 | ||
|
|
1c24dc1def | ||
|
|
d9c2f26506 | ||
|
|
7005f00df0 | ||
|
|
6ec6655280 | ||
|
|
848cd8b994 | ||
|
|
8a26e73dab | ||
|
|
f66e1ff103 | ||
|
|
5215dd569a | ||
|
|
ab5fe2d076 | ||
|
|
92f577e788 | ||
|
|
4c0d53ee92 | ||
|
|
c8cc882a57 | ||
|
|
a95bfdb192 | ||
|
|
2a1fba1b45 | ||
|
|
a44d114176 | ||
|
|
cce473c676 | ||
|
|
5fb09f57e3 | ||
|
|
eeacdc1e20 | ||
|
|
d0577a43fd | ||
|
|
e8b25d20a3 | ||
|
|
4192bea3ab | ||
|
|
4ff14fbf61 | ||
|
|
f0102119b6 | ||
|
|
848e9e40e4 | ||
|
|
a12a258058 | ||
|
|
bfa198de4e | ||
|
|
04b4a3e8ca | ||
|
|
f7d62474e8 | ||
|
|
5bf4a3fd1d | ||
|
|
35ec677446 | ||
|
|
f4631703ca | ||
|
|
767fa4962b | ||
|
|
08ba471710 | ||
|
|
d93f6bad16 | ||
|
|
488e478374 | ||
|
|
e2bf56938b | ||
|
|
5267927c3f | ||
|
|
1f04ca946c | ||
|
|
959bdeef54 | ||
|
|
2627317e03 | ||
|
|
c288557188 | ||
|
|
7f82d3098c | ||
|
|
0a7a666904 | ||
|
|
7bbe2fd28d | ||
|
|
8857abdc05 | ||
|
|
423b45cb7b | ||
|
|
6ef6bc68c2 | ||
|
|
b8e996d3c4 | ||
|
|
345696227d | ||
|
|
66330af708 | ||
|
|
3444d88e4d | ||
|
|
95416a799e | ||
|
|
dc3c93becf | ||
|
|
ce4b4ad208 | ||
|
|
7afa00b72c | ||
|
|
230b575983 | ||
|
|
2f3e93c619 | ||
|
|
59753d8310 | ||
|
|
4fb881a583 | ||
|
|
e42e9ac489 | ||
|
|
f5f20f3563 | ||
|
|
931c27a5ec | ||
|
|
bc100163c2 | ||
|
|
3a64e32184 | ||
|
|
b9787182e6 | ||
|
|
7797bf23fb | ||
|
|
f347f30353 | ||
|
|
eb239bfdb7 | ||
|
|
7047e565fc | ||
|
|
f178c6c0a1 | ||
|
|
ee5a95baa8 | ||
|
|
0c1c6d198c | ||
|
|
a0e605814f | ||
|
|
518986d28e | ||
|
|
2357914b4c | ||
|
|
e5a4428515 | ||
|
|
6b9033318b | ||
|
|
9ee907783d | ||
|
|
463cc62b75 | ||
|
|
5afd98edd8 | ||
|
|
8b9051d72e | ||
|
|
d6392f3aa9 | ||
|
|
fe808be91b | ||
|
|
2cab10e906 | ||
|
|
7f39d1f22e | ||
|
|
a9184368c1 | ||
|
|
caf2fc2ab6 | ||
|
|
5dd8141e5e | ||
|
|
2ff28675d4 | ||
|
|
519bd986b5 | ||
|
|
e41efba176 | ||
|
|
0502813496 | ||
|
|
932a6828f9 | ||
|
|
d176ef3f6a | ||
|
|
deb98268f6 | ||
|
|
e1531c3237 | ||
|
|
47af45a430 | ||
|
|
0195b42eea | ||
|
|
f875af5cdb | ||
|
|
32a918b902 | ||
|
|
d09a56075f | ||
|
|
e261fae348 | ||
|
|
5b8668d73f | ||
|
|
123292b56b | ||
|
|
0e0828f47f | ||
|
|
532c9fa69a | ||
|
|
e509563b10 | ||
|
|
899f31917c | ||
|
|
e6ca9a1c6d | ||
|
|
24c68b9c2c | ||
|
|
2891e1ac3e | ||
|
|
da9618c08b | ||
|
|
cb6643a345 | ||
|
|
71527b87c1 |
17
.circleci/config.yml
Normal file
17
.circleci/config.yml
Normal file
@@ -0,0 +1,17 @@
|
||||
version: 2
|
||||
jobs:
|
||||
minecraft_server:
|
||||
docker:
|
||||
- image: circleci/buildpack-deps:18.04
|
||||
steps:
|
||||
- checkout
|
||||
- setup_remote_docker
|
||||
- run:
|
||||
name: Build image
|
||||
command: docker build -t mc:$CIRCLE_BUILD_NUM minecraft-server
|
||||
|
||||
workflows:
|
||||
version: 2
|
||||
build:
|
||||
jobs:
|
||||
- minecraft_server
|
||||
5
.editorconfig
Normal file
5
.editorconfig
Normal file
@@ -0,0 +1,5 @@
|
||||
root = true
|
||||
|
||||
[*]
|
||||
end_of_line = lf
|
||||
indent_style = space
|
||||
@@ -3,7 +3,7 @@ This repository contains the various Dockerfile definitions I'm maintaining.
|
||||
|
||||
[](https://gitter.im/itzg/dockerfiles?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)
|
||||
|
||||
### Discontinued
|
||||
### Images that are discontinued
|
||||
|
||||
##### Cassandra
|
||||
|
||||
|
||||
@@ -4,12 +4,18 @@ LABEL maintainer "itzg"
|
||||
|
||||
RUN apk -U add bash
|
||||
|
||||
ENV ES_VERSION=5.4.1
|
||||
ARG ES_VERSION=5.5.2
|
||||
# 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 && \
|
||||
tar xf /tmp/es.tgz && \
|
||||
rm /tmp/es.tgz
|
||||
if [ -f /tmp/elasticsearch-$ES_VERSION.tar.gz ]; then \
|
||||
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
|
||||
|
||||
@@ -17,9 +23,10 @@ HEALTHCHECK --timeout=5s CMD wget -q -O - http://$HOSTNAME:9200/_cat/health
|
||||
|
||||
ENV ES_HOME=/usr/share/elasticsearch-$ES_VERSION \
|
||||
DEFAULT_ES_USER=elasticsearch \
|
||||
DEFAULT_ES_USER_UID=$DEFAULT_ES_USER_UID \
|
||||
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"]
|
||||
|
||||
|
||||
@@ -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
|
||||
large cluster
|
||||
* `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
|
||||
* `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:
|
||||
|
||||
|
||||
35
elasticsearch/docker-compose-3x1GB.yml
Normal file
35
elasticsearch/docker-compose-3x1GB.yml
Normal 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
|
||||
@@ -28,7 +28,7 @@ services:
|
||||
TYPE: INGEST
|
||||
UNICAST_HOSTS: master
|
||||
kibana:
|
||||
image: kibana
|
||||
image: kibana:5.5.1
|
||||
ports:
|
||||
- "5601:5601"
|
||||
environment:
|
||||
|
||||
21
elasticsearch/docker-compose-min.yml
Normal file
21
elasticsearch/docker-compose-min.yml
Normal 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
|
||||
@@ -99,10 +99,18 @@ setup_personality() {
|
||||
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"
|
||||
;;
|
||||
|
||||
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"
|
||||
exit 1
|
||||
|
||||
2
minecraft-server/.editorconfig
Normal file
2
minecraft-server/.editorconfig
Normal file
@@ -0,0 +1,2 @@
|
||||
[start-*]
|
||||
indent_size = 2
|
||||
@@ -1,50 +1,61 @@
|
||||
FROM alpine
|
||||
|
||||
FROM openjdk:8u171-jre-alpine
|
||||
|
||||
LABEL maintainer "itzg"
|
||||
|
||||
RUN echo "http://dl-3.alpinelinux.org/alpine/v3.5/community/" >> /etc/apk/repositories &&\
|
||||
apk update && \
|
||||
apk add \
|
||||
openjdk8-jre-base \
|
||||
RUN apk add --no-cache -U \
|
||||
openssl \
|
||||
imagemagick \
|
||||
lsof \
|
||||
su-exec \
|
||||
shadow \
|
||||
bash \
|
||||
curl \
|
||||
curl iputils wget \
|
||||
git \
|
||||
jq \
|
||||
mysql-client \
|
||||
python python-dev && \
|
||||
rm -rf /var/cache/apk/*
|
||||
python python-dev py2-pip
|
||||
|
||||
RUN pip install mcstatus
|
||||
|
||||
HEALTHCHECK CMD mcstatus localhost:$SERVER_PORT ping
|
||||
|
||||
RUN addgroup -g 1000 minecraft \
|
||||
&& adduser -Ss /bin/false -u 1000 -G minecraft -h /home/minecraft minecraft \
|
||||
&& mkdir /data \
|
||||
&& mkdir /config \
|
||||
&& mkdir /mods \
|
||||
&& mkdir /plugins \
|
||||
&& mkdir -m 777 /data /mods /config /plugins \
|
||||
&& chown minecraft:minecraft /data /config /mods /plugins /home/minecraft
|
||||
|
||||
EXPOSE 25565 25575
|
||||
|
||||
ADD https://github.com/itzg/restify/releases/download/1.0.4/restify_linux_amd64 /usr/local/bin/restify
|
||||
ADD https://github.com/itzg/rcon-cli/releases/download/1.3/rcon-cli_linux_amd64 /usr/local/bin/rcon-cli
|
||||
COPY start.sh /start
|
||||
COPY start-minecraft.sh /start-minecraft
|
||||
ARG RESTIFY_VER=1.1.4
|
||||
ARG RCON_CLI_VER=1.4.0
|
||||
ARG MC_SERVER_RUNNER_VER=1.2.0
|
||||
ARG ARCH=amd64
|
||||
|
||||
ADD https://github.com/itzg/restify/releases/download/${RESTIFY_VER}/restify_${RESTIFY_VER}_linux_${ARCH}.tar.gz /tmp/restify.tgz
|
||||
RUN tar -x -C /usr/local/bin -f /tmp/restify.tgz restify && \
|
||||
rm /tmp/restify.tgz
|
||||
|
||||
ADD https://github.com/itzg/rcon-cli/releases/download/${RCON_CLI_VER}/rcon-cli_${RCON_CLI_VER}_linux_${ARCH}.tar.gz /tmp/rcon-cli.tgz
|
||||
RUN tar -x -C /usr/local/bin -f /tmp/rcon-cli.tgz rcon-cli && \
|
||||
rm /tmp/rcon-cli.tgz
|
||||
|
||||
ADD https://github.com/itzg/mc-server-runner/releases/download/${MC_SERVER_RUNNER_VER}/mc-server-runner_${MC_SERVER_RUNNER_VER}_linux_${ARCH}.tar.gz /tmp/mc-server-runner.tgz
|
||||
RUN tar -x -C /usr/local/bin -f /tmp/mc-server-runner.tgz mc-server-runner && \
|
||||
rm /tmp/mc-server-runner.tgz
|
||||
|
||||
COPY mcadmin.jq /usr/share
|
||||
RUN chmod +x /usr/local/bin/*
|
||||
|
||||
VOLUME ["/data","/mods","/config","/plugins","/home/minecraft"]
|
||||
VOLUME ["/data","/mods","/config","/plugins"]
|
||||
COPY server.properties /tmp/server.properties
|
||||
WORKDIR /data
|
||||
|
||||
ENTRYPOINT [ "/start" ]
|
||||
|
||||
ENV UID=1000 GID=1000 \
|
||||
MOTD="A Minecraft Server Powered by Docker" \
|
||||
JVM_XX_OPTS="-XX:+UseG1GC" MEMORY="1G" \
|
||||
TYPE=VANILLA VERSION=LATEST FORGEVERSION=RECOMMENDED LEVEL=world PVP=true DIFFICULTY=easy \
|
||||
ENABLE_RCON=true RCON_PORT=25575 RCON_PASSWORD=minecraft \
|
||||
LEVEL_TYPE=DEFAULT GENERATOR_SETTINGS= WORLD= MODPACK= ONLINE_MODE=TRUE CONSOLE=true
|
||||
TYPE=VANILLA VERSION=LATEST FORGEVERSION=RECOMMENDED SPONGEBRANCH=STABLE SPONGEVERSION= LEVEL=world \
|
||||
PVP=true DIFFICULTY=easy ENABLE_RCON=true RCON_PORT=25575 RCON_PASSWORD=minecraft \
|
||||
LEVEL_TYPE=DEFAULT GENERATOR_SETTINGS= WORLD= MODPACK= SERVER_PORT=25565 ONLINE_MODE=TRUE CONSOLE=true
|
||||
|
||||
COPY start* /
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
|
||||
[](https://hub.docker.com/r/itzg/minecraft-server/)
|
||||
[](https://hub.docker.com/r/itzg/minecraft-server/)
|
||||
[](https://github.com/itzg/dockerfiles/issues)
|
||||
|
||||
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
|
||||
@@ -90,17 +91,6 @@ to map a directory on your host machine to the container's `/data` directory, su
|
||||
When attached in this way you can stop the server, edit the configuration under your attached `/path/on/host`
|
||||
and start the server again with `docker start CONTAINERID` to pick up the new configuration.
|
||||
|
||||
**NOTE**: By default, the files in the attached directory will be owned by the host user with UID of 1000 and host group with GID of 1000.
|
||||
You can use an different UID and GID by passing the options:
|
||||
|
||||
-e UID=1000 -e GID=1000
|
||||
|
||||
replacing 1000 with a UID and GID that is present on the host.
|
||||
Here is one way to find the UID and GID:
|
||||
|
||||
id some_host_user
|
||||
getent group some_host_group
|
||||
|
||||
## Versions
|
||||
|
||||
To use a different Minecraft version, pass the `VERSION` environment variable, which can have the value
|
||||
@@ -117,6 +107,34 @@ or a specific version:
|
||||
|
||||
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
|
||||
|
||||
Enable Forge server mode by adding a `-e TYPE=FORGE` to your command-line.
|
||||
@@ -127,6 +145,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 \
|
||||
-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.
|
||||
|
||||
### Using the /data volume
|
||||
@@ -336,24 +368,30 @@ with `FTB_SERVER_MOD` specifying the updated modpack file.
|
||||
-e FTB_SERVER_MOD=FTBPresentsSkyfactory3Server_3.0.7.zip \
|
||||
-p 25565:25565 -e EULA=TRUE --name mc itzg/minecraft-server
|
||||
|
||||
### FTB server JVM options
|
||||
### Fixing "unable to launch forgemodloader"
|
||||
|
||||
An FTB server modpack contains its own startup script that launches the
|
||||
JVM and it does not use the `JVM_OPTS` environment variable. Instead
|
||||
you can use `MIN_RAM` and `MAX_RAM` variables. These are appended to
|
||||
the JVM `-Xms` and `-Xmx` options. For example, `-e MIN_RAM=2G` results
|
||||
in `-Xms2G` passed to the JVM.
|
||||
If your server's modpack fails to load with an error [like this](https://support.feed-the-beast.com/t/cant-start-crashlanding-server-unable-to-launch-forgemodloader/6028/2):
|
||||
|
||||
Additionally, `PERMGEN_SIZE` is passed on to `-XX:PermSize`. Here is an
|
||||
example:
|
||||
unable to launch forgemodloader
|
||||
|
||||
$ docker run -d -v /path/on/host:/data -e TYPE=FTB \
|
||||
-e MIN_RAM=1G -e MAX_RAM=2G -e PERMGEN_SIZE=512M \
|
||||
-e FTB_SERVER_MOD=FTBPresentsSkyfactory3Server_3.0.6.zip \
|
||||
then you apply a workaround by adding this to the run invocation:
|
||||
|
||||
-e FTB_LEGACYJAVAFIXER=true
|
||||
|
||||
## Running a SpongeVanilla server
|
||||
|
||||
Enable SpongeVanilla server mode by adding a `-e TYPE=SPONGEVANILLA` to your command-line.
|
||||
By default the container will run the latest `STABLE` version.
|
||||
If you want to run a specific version, you can add `-e SPONGEVERSION=1.11.2-6.1.0-BETA-19` to your command-line.
|
||||
|
||||
docker run -d -v /path/on/host:/data -e TYPE=SPONGEVANILLA \
|
||||
-p 25565:25565 -e EULA=TRUE --name mc itzg/minecraft-server
|
||||
|
||||
Note: The FTB server start script will also override other options,
|
||||
like `MOTD`.
|
||||
You can also choose to use the `EXPERIMENTAL` branch.
|
||||
Just change it with `SPONGEBRANCH`, such as:
|
||||
|
||||
$ docker run -d -v /path/on/host:/data ... \
|
||||
-e TYPE=SPONGEVANILLA -e SPONGEBRANCH=EXPERIMENTAL ...
|
||||
|
||||
## Using Docker Compose
|
||||
|
||||
@@ -388,6 +426,11 @@ this server instance.
|
||||
|
||||
## Server configuration
|
||||
|
||||
### Server port
|
||||
|
||||
The server port can be set like:
|
||||
docker run -d -e SERVER_PORT=25565 ...
|
||||
|
||||
### Difficulty
|
||||
|
||||
The difficulty level (default: `easy`) can be set like:
|
||||
@@ -489,6 +532,12 @@ If set to true, players will be set to spectator mode if they die.
|
||||
|
||||
docker run -d -e HARDCORE=false
|
||||
|
||||
### Snooper
|
||||
|
||||
If set to false, the server will not send data to snoop.minecraft.net server.
|
||||
|
||||
docker run -d -e SNOOPER_ENABLED=false
|
||||
|
||||
### Max Build Height
|
||||
|
||||
The maximum height in which building is allowed.
|
||||
@@ -555,8 +604,14 @@ The message of the day, shown below each server entry in the UI, can be changed
|
||||
|
||||
docker run -d -e 'MOTD=My Server' ...
|
||||
|
||||
If you leave it off, the last used or default message will be used. _The example shows how to specify a server
|
||||
message of the day that contains spaces by putting quotes around the whole thing._
|
||||
If you leave it off, a default is computed from the server type and version, such as
|
||||
|
||||
A Paper Minecraft Server powered by Docker
|
||||
|
||||
when `TYPE` is `PAPER`. That way you can easily differentiate between several servers you may have started.
|
||||
|
||||
_The example shows how to specify a server message of the day that contains spaces by putting quotes
|
||||
around the whole thing._
|
||||
|
||||
### PVP Mode
|
||||
|
||||
@@ -575,10 +630,11 @@ be configured by setting `LEVEL_TYPE` to
|
||||
* LARGEBIOMES
|
||||
* AMPLIFIED
|
||||
* CUSTOMIZED
|
||||
* BUFFET
|
||||
|
||||
Descriptions are available at the [gamepedia](http://minecraft.gamepedia.com/Server.properties).
|
||||
|
||||
When using a level type of `FLAT` and `CUSTOMIZED`, you can further configure the world generator
|
||||
When using a level type of `FLAT`, `CUSTOMIZED`, and `BUFFET`, you can further configure the world generator
|
||||
by passing [custom generator settings](http://minecraft.gamepedia.com/Superflat).
|
||||
**Since generator settings usually have ;'s in them, surround the -e value with a single quote, like below.**
|
||||
|
||||
@@ -630,14 +686,41 @@ 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
|
||||
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
|
||||
|
||||
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
|
||||
|
||||
docker run -d -e ONLINE_MODE=FALSE ...
|
||||
|
||||
### Allow flight
|
||||
|
||||
Allows users to use flight on your server while in Survival mode, if they have a mod that provides flight installed.
|
||||
|
||||
-e ALLOW_FLIGHT=TRUE|FALSE
|
||||
|
||||
## Miscellaneous Options
|
||||
|
||||
### Running as alternate user/group ID
|
||||
|
||||
By default, the container will switch to user ID 1000 and group ID 1000;
|
||||
however, you can override those values by setting `UID` and `GID`, respectively.
|
||||
The container will also skip user switching if the `--user`/`-u` argument
|
||||
is passed to `docker run`.
|
||||
|
||||
### Memory Limit
|
||||
|
||||
By default, the image declares a Java initial and maximum memory limit of 1 GB. There are several
|
||||
@@ -651,6 +734,16 @@ ways to adjust the memory settings:
|
||||
The values of all three are passed directly to the JVM and support format/units as
|
||||
`<size>[g|G|m|M|k|K]`.
|
||||
|
||||
### /data ownership
|
||||
### JVM Options
|
||||
|
||||
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`.
|
||||
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.
|
||||
|
||||
### HTTP Proxy
|
||||
|
||||
You may configure the use of an HTTP/HTTPS proxy by passing the proxy's URL via the `PROXY`
|
||||
environment variable. In [the example compose file](docker-compose-proxied.yml) it references
|
||||
a companion squid proxy by setting the equivalent of
|
||||
|
||||
-e PROXY=proxy:3128
|
||||
|
||||
16
minecraft-server/docker-compose-proxied.yml
Normal file
16
minecraft-server/docker-compose-proxied.yml
Normal file
@@ -0,0 +1,16 @@
|
||||
version: '3'
|
||||
|
||||
services:
|
||||
mc:
|
||||
# build: .
|
||||
image: itzg/minecraft-server
|
||||
ports:
|
||||
- 25565:25565
|
||||
environment:
|
||||
EULA: "TRUE"
|
||||
# TYPE: SPIGOT
|
||||
# VERSION: 1.11.2
|
||||
PROXY: proxy:3128
|
||||
proxy:
|
||||
image: sameersbn/squid
|
||||
|
||||
11
minecraft-server/examples/docker-compose-curseforge.yml
Normal file
11
minecraft-server/examples/docker-compose-curseforge.yml
Normal file
@@ -0,0 +1,11 @@
|
||||
version: '3.2'
|
||||
|
||||
services:
|
||||
mc:
|
||||
image: itzg/minecraft-server
|
||||
environment:
|
||||
EULA: "true"
|
||||
TYPE: FTB
|
||||
FTB_SERVER_MOD: https://minecraft.curseforge.com/projects/all-the-mods-expert-remastered/files/2493900/download
|
||||
ports:
|
||||
- 25565:25565
|
||||
16
minecraft-server/examples/docker-compose-ftb.yml
Normal file
16
minecraft-server/examples/docker-compose-ftb.yml
Normal file
@@ -0,0 +1,16 @@
|
||||
version: '3.2'
|
||||
|
||||
services:
|
||||
mc:
|
||||
image: itzg/minecraft-server
|
||||
environment:
|
||||
EULA: "true"
|
||||
TYPE: FTB
|
||||
FTB_SERVER_MOD: https://www.feed-the-beast.com/projects/ftb-presents-skyfactory-3/files/2481284
|
||||
ports:
|
||||
- 25565:25565
|
||||
volumes:
|
||||
- mc-ftb:/data
|
||||
|
||||
volumes:
|
||||
mc-ftb:
|
||||
41
minecraft-server/k8s-examples/vanilla-deployment.yml
Normal file
41
minecraft-server/k8s-examples/vanilla-deployment.yml
Normal file
@@ -0,0 +1,41 @@
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: mc-vanilla
|
||||
spec:
|
||||
type: NodePort
|
||||
ports:
|
||||
- port: 25565
|
||||
nodePort: 30000
|
||||
selector:
|
||||
app: mc-vanilla
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: mc-vanilla
|
||||
spec:
|
||||
selector:
|
||||
matchLabels:
|
||||
app: mc-vanilla
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: mc-vanilla
|
||||
spec:
|
||||
containers:
|
||||
- image: itzg/minecraft-server
|
||||
name: mc-vanilla
|
||||
env:
|
||||
# Use secret in real usage
|
||||
- name: EULA
|
||||
value: "true"
|
||||
ports:
|
||||
- containerPort: 25565
|
||||
name: main
|
||||
volumeMounts:
|
||||
- name: mc-data
|
||||
mountPath: /data
|
||||
volumes:
|
||||
- name: mc-data
|
||||
emptyDir: {}
|
||||
19
minecraft-server/start
Executable file
19
minecraft-server/start
Executable file
@@ -0,0 +1,19 @@
|
||||
#!/bin/bash
|
||||
|
||||
if [ $(id -u) = 0 ]; then
|
||||
if [[ -v UID && $UID != $(id -u) ]]; then
|
||||
usermod -u $UID minecraft
|
||||
fi
|
||||
if [[ -v GID ]]; then
|
||||
groupmod -g $GID minecraft
|
||||
fi
|
||||
|
||||
if [[ $(stat -c "%u" /data) != $UID ]]; then
|
||||
echo "Changing ownership of /data to $UID ..."
|
||||
chown -R minecraft:minecraft /data
|
||||
fi
|
||||
|
||||
su-exec minecraft:minecraft /start-configuration
|
||||
else
|
||||
exec /start-configuration
|
||||
fi
|
||||
98
minecraft-server/start-configuration
Executable file
98
minecraft-server/start-configuration
Executable file
@@ -0,0 +1,98 @@
|
||||
#!/bin/bash
|
||||
|
||||
shopt -s nullglob
|
||||
|
||||
#umask 002
|
||||
export HOME=/data
|
||||
|
||||
if [ ! -e /data/eula.txt ]; then
|
||||
if [ "$EULA" != "" ]; then
|
||||
echo "# Generated via Docker on $(date)" > 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
|
||||
echo ""
|
||||
echo "Please accept the Minecraft EULA at"
|
||||
echo " https://account.mojang.com/documents/minecraft_eula"
|
||||
echo "by adding the following immediately after 'docker run':"
|
||||
echo " -e EULA=TRUE"
|
||||
echo ""
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "Running as uid=$(id -u) gid=$(id -g) with /data as '$(ls -lnd /data)'"
|
||||
|
||||
if ! touch /data/.verify_access; then
|
||||
echo "ERROR: /data doesn't seem to be writable. Please make sure attached directory is writable by uid=$(id -u)"
|
||||
exit 2
|
||||
fi
|
||||
|
||||
rm /data/.verify_access || true
|
||||
|
||||
if [[ $PROXY ]]; then
|
||||
export http_proxy="$PROXY"
|
||||
export https_proxy="$PROXY"
|
||||
echo "INFO: Giving proxy time to startup..."
|
||||
sleep 5
|
||||
fi
|
||||
|
||||
export SERVER_PROPERTIES=/data/server.properties
|
||||
export VERSIONS_JSON=https://launchermeta.mojang.com/mc/game/version_manifest.json
|
||||
|
||||
echo "Checking version information."
|
||||
case "X$VERSION" in
|
||||
X|XLATEST|Xlatest)
|
||||
export VANILLA_VERSION=`curl -fsSL $VERSIONS_JSON | jq -r '.latest.release'`
|
||||
;;
|
||||
XSNAPSHOT|Xsnapshot)
|
||||
export VANILLA_VERSION=`curl -fsSL $VERSIONS_JSON | jq -r '.latest.snapshot'`
|
||||
;;
|
||||
X[1-9]*)
|
||||
export VANILLA_VERSION=$VERSION
|
||||
;;
|
||||
*)
|
||||
export VANILLA_VERSION=`curl -fsSL $VERSIONS_JSON | jq -r '.latest.release'`
|
||||
;;
|
||||
esac
|
||||
|
||||
cd /data
|
||||
|
||||
export ORIGINAL_TYPE=${TYPE^^}
|
||||
|
||||
echo "Checking type information."
|
||||
case "${TYPE^^}" in
|
||||
*BUKKIT|SPIGOT)
|
||||
exec /start-deployBukkitSpigot $@
|
||||
;;
|
||||
|
||||
PAPER)
|
||||
exec /start-deployPaper $@
|
||||
;;
|
||||
|
||||
FORGE)
|
||||
exec /start-deployForge $@
|
||||
;;
|
||||
|
||||
FTB|CURSEFORGE)
|
||||
exec /start-deployFTB $@
|
||||
;;
|
||||
|
||||
VANILLA)
|
||||
exec /start-deployVanilla $@
|
||||
;;
|
||||
|
||||
SPONGEVANILLA)
|
||||
exec /start-deploySpongeVanilla $@
|
||||
;;
|
||||
|
||||
*)
|
||||
echo "Invalid type: '$TYPE'"
|
||||
echo "Must be: VANILLA, FORGE, BUKKIT, SPIGOT, PAPER, FTB, CURSEFORGE, SPONGEVANILLA"
|
||||
exit 1
|
||||
;;
|
||||
|
||||
esac
|
||||
78
minecraft-server/start-deployBukkitSpigot
Executable file
78
minecraft-server/start-deployBukkitSpigot
Executable file
@@ -0,0 +1,78 @@
|
||||
#!/bin/bash
|
||||
|
||||
function buildSpigotFromSource {
|
||||
echo "Building Spigot $VANILLA_VERSION from source, might take a while, get some coffee"
|
||||
mkdir /data/temp
|
||||
cd /data/temp
|
||||
curl -sSL -o /data/temp/BuildTools.jar https://hub.spigotmc.org/jenkins/job/BuildTools/lastSuccessfulBuild/artifact/target/BuildTools.jar && \
|
||||
java -jar /data/temp/BuildTools.jar --rev $VANILLA_VERSION 2>&1 |tee /data/spigot_build.log| while read l; do echo -n .; done; echo "done"
|
||||
mv spigot-*.jar /data/spigot_server.jar
|
||||
mv craftbukkit-*.jar /data/craftbukkit_server.jar
|
||||
echo "Cleaning up"
|
||||
rm -rf /data/temp
|
||||
cd /data
|
||||
}
|
||||
|
||||
function downloadSpigot {
|
||||
local match
|
||||
case "$TYPE" in
|
||||
*BUKKIT|*bukkit)
|
||||
match="CraftBukkit"
|
||||
downloadUrl=${BUKKIT_DOWNLOAD_URL}
|
||||
getbukkitFlavor=craftbukkit
|
||||
;;
|
||||
*)
|
||||
match="Spigot"
|
||||
downloadUrl=${SPIGOT_DOWNLOAD_URL}
|
||||
getbukkitFlavor=spigot
|
||||
;;
|
||||
esac
|
||||
|
||||
local downloadVersion
|
||||
if [[ ${VERSION} == LATEST ]]; then
|
||||
downloadVersion=${VANILLA_VERSION}
|
||||
else
|
||||
downloadVersion=${VERSION}
|
||||
fi
|
||||
|
||||
if [[ -z $downloadUrl ]]; then
|
||||
downloadUrl="https://cdn.getbukkit.org/${getbukkitFlavor}/${getbukkitFlavor}-${downloadVersion}.jar"
|
||||
fi
|
||||
|
||||
echo "Downloading $match from $downloadUrl ..."
|
||||
curl -fsSL -o $SERVER "$downloadUrl"
|
||||
if [[ $? != 0 || $(grep -c "DOCTYPE html" $SERVER) != 0 ]]; then
|
||||
cat <<EOF
|
||||
|
||||
ERROR: failed to download from $downloadUrl
|
||||
Visit https://getbukkit.org/download/${getbukkitFlavor} to lookup the
|
||||
exact version, such as 1.4.6-R0.4-SNAPSHOT or 1.8-R0.1-SNAPSHOT-LATEST
|
||||
|
||||
EOF
|
||||
exit 3
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
case "$TYPE" in
|
||||
*BUKKIT|*bukkit)
|
||||
export SERVER=craftbukkit_server.jar
|
||||
;;
|
||||
*)
|
||||
export SERVER=spigot_server.jar
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ ! -f $SERVER ]; then
|
||||
if [[ "$BUILD_SPIGOT_FROM_SOURCE" = TRUE || "$BUILD_SPIGOT_FROM_SOURCE" = true || "$BUILD_FROM_SOURCE" = TRUE || "$BUILD_FROM_SOURCE" = true ]]; then
|
||||
buildSpigotFromSource
|
||||
else
|
||||
downloadSpigot
|
||||
fi
|
||||
fi
|
||||
|
||||
# Normalize on Spigot for operations below
|
||||
export TYPE=SPIGOT
|
||||
|
||||
# Continue to Final Setup
|
||||
exec /start-finalSetup01World $@
|
||||
99
minecraft-server/start-deployFTB
Executable file
99
minecraft-server/start-deployFTB
Executable file
@@ -0,0 +1,99 @@
|
||||
#!/bin/bash
|
||||
|
||||
. /start-utils
|
||||
|
||||
export FTB_BASE_DIR=/data/FeedTheBeast
|
||||
legacyJavaFixerUrl=http://ftb.cursecdn.com/FTB2/maven/net/minecraftforge/lex/legacyjavafixer/1.0/legacyjavafixer-1.0.jar
|
||||
export TYPE=FEED-THE-BEAST
|
||||
|
||||
echo "Looking for Feed-The-Beast server modpack."
|
||||
if [[ -z $FTB_SERVER_MOD ]]; then
|
||||
echo "Environment variable FTB_SERVER_MOD not set."
|
||||
echo "Set FTB_SERVER_MOD to the file name of the FTB server modpack."
|
||||
echo "(And place the modpack in the /data directory.)"
|
||||
exit 2
|
||||
fi
|
||||
|
||||
if [[ -d ${FTB_BASE_DIR} ]]; then
|
||||
startScriptCount=$(find ${FTB_BASE_DIR} -name ServerStart.sh |wc -l)
|
||||
if [[ $startScriptCount > 1 ]]; then
|
||||
echo "Conflicting FTB/CurseForge packages have been installed. Please cleanup ${FTB_BASE_DIR}"
|
||||
exit 2
|
||||
fi
|
||||
else
|
||||
startScriptCount=0
|
||||
fi
|
||||
|
||||
# only download and install if a mod pack isn't already installed
|
||||
# also check for the start script rather than just the folder
|
||||
# this allows saving just the world separate from the rest of the data directory
|
||||
if [[ $startScriptCount = 0 ]]; then
|
||||
srv_modpack=${FTB_SERVER_MOD}
|
||||
if isURL ${srv_modpack}; then
|
||||
case $srv_modpack in
|
||||
https://www.feed-the-beast.com/*/download)
|
||||
;;
|
||||
https://www.feed-the-beast.com/*)
|
||||
srv_modpack=${srv_modpack}/download;;
|
||||
esac
|
||||
file=$(basename $(dirname $srv_modpack))
|
||||
downloaded=/data/${file}.zip
|
||||
if [ ! -e $downloaded ]; then
|
||||
echo "Downloading FTB modpack...
|
||||
$srv_modpack -> $downloaded"
|
||||
curl -sSL -o $downloaded $srv_modpack
|
||||
fi
|
||||
srv_modpack=$downloaded
|
||||
fi
|
||||
if [[ ${srv_modpack:0:5} == "data/" ]]; then
|
||||
# Prepend with "/"
|
||||
srv_modpack=/${srv_modpack}
|
||||
fi
|
||||
if [[ ! ${srv_modpack:0:1} == "/" ]]; then
|
||||
# If not an absolute path, assume file is in "/data"
|
||||
srv_modpack=/data/${srv_modpack}
|
||||
fi
|
||||
if [[ ! -f ${srv_modpack} ]]; then
|
||||
echo "FTB server modpack ${srv_modpack} not found."
|
||||
exit 2
|
||||
fi
|
||||
if [[ ! ${srv_modpack: -4} == ".zip" ]]; then
|
||||
echo "FTB server modpack ${srv_modpack} is not a zip archive."
|
||||
echo "Please set FTB_SERVER_MOD to a file with a .zip extension."
|
||||
exit 2
|
||||
fi
|
||||
|
||||
echo "Unpacking FTB server modpack ${srv_modpack} ..."
|
||||
mkdir -p ${FTB_BASE_DIR}
|
||||
unzip -o ${srv_modpack} -d ${FTB_BASE_DIR} | awk '{printf "."} END {print ""}'
|
||||
fi
|
||||
|
||||
if [[ $(find ${FTB_BASE_DIR} -name ServerStart.sh |wc -l) = 0 ]]; then
|
||||
echo "Please make sure you are using the server version of the FTB modpack!"
|
||||
exit 2
|
||||
fi
|
||||
|
||||
export FTB_SERVER_START=./ServerStart.sh
|
||||
export FTB_DIR=$(dirname $(find ${FTB_DIR} -name ServerStart.sh))
|
||||
chmod a+x ${FTB_DIR}/${FTB_SERVER_START}
|
||||
sed -i 's/-jar/-Dfml.queryResult=confirm -jar/' ${FTB_DIR}/${FTB_SERVER_START}
|
||||
sed -i 's/.*read.*Restart now/#\0/' ${FTB_DIR}/${FTB_SERVER_START}
|
||||
legacyJavaFixerPath=${FTB_DIR}/mods/legacyjavafixer.jar
|
||||
|
||||
if isTrue ${FTB_LEGACYJAVAFIXER} && [ ! -e ${legacyJavaFixerPath} ]; then
|
||||
echo "Installing legacy java fixer to ${legacyJavaFixerPath}"
|
||||
curl -sSL -o ${legacyJavaFixerPath} ${legacyJavaFixerUrl}
|
||||
fi
|
||||
|
||||
if [ -e ${FTB_DIR}/FTBInstall.sh ]; then
|
||||
pushd ${FTB_DIR}
|
||||
sh ${FTB_DIR}/FTBInstall.sh
|
||||
popd
|
||||
elif [ -e ${FTB_DIR}/Install.sh ]; then
|
||||
pushd ${FTB_DIR}
|
||||
sh ${FTB_DIR}/Install.sh
|
||||
popd
|
||||
fi
|
||||
|
||||
# Continue to Final Setup
|
||||
exec /start-finalSetup01World $@
|
||||
120
minecraft-server/start-deployForge
Executable file
120
minecraft-server/start-deployForge
Executable file
@@ -0,0 +1,120 @@
|
||||
#!/bin/bash
|
||||
|
||||
export TYPE=FORGE
|
||||
|
||||
if [[ -z $FORGE_INSTALLER && -z $FORGE_INSTALLER_URL ]]; then
|
||||
norm=$VANILLA_VERSION
|
||||
|
||||
case $VANILLA_VERSION in
|
||||
*.*.*)
|
||||
norm=$VANILLA_VERSION ;;
|
||||
*.*)
|
||||
norm=${VANILLA_VERSION}.0 ;;
|
||||
esac
|
||||
|
||||
################### TEMPORORAY LOGIC util forge is generally available for 1.13
|
||||
|
||||
if [[ $VERSION = LATEST ]]; then
|
||||
VANILLA_VERSION=1.12.2
|
||||
fi
|
||||
|
||||
#################################################################################
|
||||
|
||||
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
|
||||
FORGE_VERSION=$(cat /tmp/forge.json | jq -r ".promos[\"$VANILLA_VERSION-latest\"]")
|
||||
if [ $FORGE_VERSION = null ]; then
|
||||
echo "ERROR: Version $VANILLA_VERSION is not supported by Forge"
|
||||
echo " Refer to http://files.minecraftforge.net/ for supported versions"
|
||||
exit 2
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
|
||||
*)
|
||||
FORGE_VERSION=$FORGEVERSION
|
||||
;;
|
||||
esac
|
||||
|
||||
normForgeVersion=$VANILLA_VERSION-$FORGE_VERSION-$norm
|
||||
shortForgeVersion=$VANILLA_VERSION-$FORGE_VERSION
|
||||
|
||||
FORGE_INSTALLER="/tmp/forge-$shortForgeVersion-installer.jar"
|
||||
elif [[ -z $FORGE_INSTALLER ]]; then
|
||||
FORGE_INSTALLER="/tmp/forge-installer.jar"
|
||||
elif [[ ! -e $FORGE_INSTALLER ]]; then
|
||||
echo "ERROR: the given Forge installer doesn't exist : $FORGE_INSTALLER"
|
||||
exit 2
|
||||
fi
|
||||
|
||||
installMarker=".forge-installed-$shortForgeVersion"
|
||||
|
||||
if [ ! -e $installMarker ]; then
|
||||
if [ ! -e $FORGE_INSTALLER ]; then
|
||||
|
||||
if [[ -z $FORGE_INSTALLER_URL ]]; then
|
||||
echo "Downloading $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
|
||||
fi
|
||||
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..."
|
||||
unset -v latest
|
||||
for file in *forge*.jar; do
|
||||
[[ $file =~ installer ]] || [[ $file -nt $latest ]] && latest=$file
|
||||
done
|
||||
if [[ -z $latest ]]; then
|
||||
echo "Unable to derive server jar for Forge"
|
||||
exit 2
|
||||
fi
|
||||
|
||||
export SERVER=$latest
|
||||
echo "Using server $SERVER"
|
||||
echo $SERVER > $installMarker
|
||||
|
||||
else
|
||||
export SERVER=$(cat $installMarker)
|
||||
fi
|
||||
|
||||
# Continue to Final Setup
|
||||
exec /start-finalSetup01World $@
|
||||
50
minecraft-server/start-deployPaper
Executable file
50
minecraft-server/start-deployPaper
Executable file
@@ -0,0 +1,50 @@
|
||||
#!/bin/bash
|
||||
|
||||
export SERVER=paper_server.jar
|
||||
if [ ! -f $SERVER ]; then
|
||||
job=PaperSpigot
|
||||
case "${VANILLA_VERSION}" in
|
||||
1.13.*)
|
||||
job=Paper-1.13
|
||||
build="lastSuccessfulBuild"
|
||||
;;
|
||||
1.12.2)
|
||||
build="lastSuccessfulBuild";;
|
||||
1.11.2)
|
||||
build="1104";;
|
||||
1.10.2)
|
||||
build="916";;
|
||||
1.9.4)
|
||||
build="773";;
|
||||
1.9.2)
|
||||
build="727";;
|
||||
1.9)
|
||||
build="612";;
|
||||
1.8.8)
|
||||
build="443";;
|
||||
*)
|
||||
build="nosupp";;
|
||||
esac
|
||||
|
||||
if [ $build != "nosupp" ]; then
|
||||
rm -f $SERVER
|
||||
downloadUrl=${PAPER_DOWNLOAD_URL:-https://ci.destroystokyo.com/job/$job/$build/artifact/paperclip.jar}
|
||||
echo "Downloading Paper $VANILLA_VERSION from $downloadUrl ..."
|
||||
curl -fsSL -o $SERVER "$downloadUrl"
|
||||
if [ ! -f $SERVER ]; then
|
||||
echo "ERROR: failed to download from $downloadUrl (status=$?)"
|
||||
exit 3
|
||||
fi
|
||||
else
|
||||
echo "ERROR: Version $VERSION is not supported for $TYPE"
|
||||
echo " Refer to https://ci.destroystokyo.com/job/PaperSpigot/"
|
||||
echo " for supported versions"
|
||||
exit 2
|
||||
fi
|
||||
fi
|
||||
|
||||
# Normalize on Spigot for operations below
|
||||
export TYPE=SPIGOT
|
||||
|
||||
# Continue to Final Setup
|
||||
exec /start-finalSetup01World $@
|
||||
37
minecraft-server/start-deploySpongeVanilla
Executable file
37
minecraft-server/start-deploySpongeVanilla
Executable file
@@ -0,0 +1,37 @@
|
||||
#!/bin/bash
|
||||
|
||||
export TYPE=spongevanilla
|
||||
|
||||
# Parse branch
|
||||
echo "Choosing branch for Sponge"
|
||||
case "$SPONGEBRANCH" in
|
||||
|
||||
EXPERIMENTAL|experimental|BLEEDING|bleeding)
|
||||
SPONGEBRANCH=bleeding
|
||||
;;
|
||||
|
||||
*)
|
||||
SPONGEBRANCH=stable
|
||||
;;
|
||||
|
||||
esac
|
||||
|
||||
# If not SPONGEVERSION selected, detect last version on selected branch
|
||||
if [ -z $SPONGEVERSION ]; then
|
||||
echo "Choosing Version for Sponge"
|
||||
if [ "$SPONGEBRANCH" == "stable" ]; then
|
||||
export SPONGEVERSION=`curl -fsSL https://dl-api.spongepowered.org/v1/org.spongepowered/$TYPE | jq -r '.buildTypes.stable.latest.version'`
|
||||
else
|
||||
export SPONGEVERSION=`curl -fsSL https://dl-api.spongepowered.org/v1/org.spongepowered/$TYPE | jq -r '.buildTypes.bleeding.latest.version'`
|
||||
fi
|
||||
fi
|
||||
|
||||
export SERVER="spongevanilla-$SPONGEVERSION.jar"
|
||||
|
||||
if [ ! -e $SERVER ]; then
|
||||
echo "Downloading $SERVER ..."
|
||||
curl -sSL -o $SERVER https://repo.spongepowered.org/maven/org/spongepowered/$TYPE/$SPONGEVERSION/$SERVER
|
||||
fi
|
||||
|
||||
# Continue to Final Setup
|
||||
exec /start-finalSetup01World $@
|
||||
11
minecraft-server/start-deployVanilla
Executable file
11
minecraft-server/start-deployVanilla
Executable file
@@ -0,0 +1,11 @@
|
||||
#!/bin/bash
|
||||
|
||||
export SERVER="minecraft_server.$VANILLA_VERSION.jar"
|
||||
|
||||
if [ ! -e $SERVER ]; then
|
||||
echo "Downloading $SERVER ..."
|
||||
curl -sSL -o $SERVER $(curl -s $(curl -s 'https://launchermeta.mojang.com/mc/game/version_manifest.json' | jq --arg VANILLA_VERSION "$VANILLA_VERSION" --raw-output '[.versions[]|select(.id == $VANILLA_VERSION)][0].url') | jq --raw-output '.downloads.server.url')
|
||||
fi
|
||||
|
||||
# Continue to Final Setup
|
||||
exec /start-finalSetup01World $@
|
||||
35
minecraft-server/start-finalSetup01World
Executable file
35
minecraft-server/start-finalSetup01World
Executable file
@@ -0,0 +1,35 @@
|
||||
#!/bin/bash
|
||||
|
||||
# If supplied with a URL for a world, download it and unpack
|
||||
if [[ "$WORLD" ]]; then
|
||||
case "X$WORLD" in
|
||||
X[Hh][Tt][Tt][Pp]*)
|
||||
echo "Downloading world from $WORLD"
|
||||
curl -sSL -o - "$WORLD" > /data/world.zip
|
||||
echo "Unzipping world"
|
||||
unzip -o -q /data/world.zip
|
||||
rm -f /data/world.zip
|
||||
if [ ! -d /data/world ]; then
|
||||
echo World directory not found
|
||||
for i in /data/*/level.dat; do
|
||||
if [ -f "$i" ]; then
|
||||
d=`dirname "$i"`
|
||||
echo Renaming world directory from $d
|
||||
mv -f "$d" /data/world
|
||||
fi
|
||||
done
|
||||
fi
|
||||
if [ "$TYPE" = "SPIGOT" ]; then
|
||||
# Reorganise if a Spigot server
|
||||
echo "Moving End and Nether maps to Spigot location"
|
||||
[ -d "/data/world/DIM1" ] && mv -f "/data/world/DIM1" "/data/world_the_end"
|
||||
[ -d "/data/world/DIM-1" ] && mv -f "/data/world/DIM-1" "/data/world_nether"
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
echo "Invalid URL given for world: Must be HTTP or HTTPS and a ZIP file"
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
exec /start-finalSetup02Modpack $@
|
||||
39
minecraft-server/start-finalSetup02Modpack
Executable file
39
minecraft-server/start-finalSetup02Modpack
Executable file
@@ -0,0 +1,39 @@
|
||||
#!/bin/bash
|
||||
|
||||
# If supplied with a URL for a modpack (simple zip of jars), download it and unpack
|
||||
if [[ "$MODPACK" ]]; then
|
||||
case "X$MODPACK" in
|
||||
X[Hh][Tt][Tt][Pp]*.zip)
|
||||
echo "Downloading mod/plugin pack via HTTP"
|
||||
echo " from $MODPACK ..."
|
||||
if ! curl -sSL -o /tmp/modpack.zip "$MODPACK"; then
|
||||
echo "ERROR: failed to download from $MODPACK"
|
||||
exit 2
|
||||
fi
|
||||
|
||||
if [ "$TYPE" = "SPIGOT" ]; then
|
||||
if [ "$REMOVE_OLD_MODS" = "TRUE" ]; then
|
||||
rm -rf /data/plugins/*
|
||||
fi
|
||||
mkdir -p /data/plugins
|
||||
if ! unzip -o -d /data/plugins /tmp/modpack.zip; then
|
||||
echo "ERROR: failed to unzip the modpack from $MODPACK"
|
||||
fi
|
||||
else
|
||||
if [ "$REMOVE_OLD_MODS" = "TRUE" ]; then
|
||||
rm -rf /data/mods/*
|
||||
fi
|
||||
mkdir -p /data/mods
|
||||
if ! unzip -o -d /data/mods /tmp/modpack.zip; then
|
||||
echo "ERROR: failed to unzip the modpack from $MODPACK"
|
||||
fi
|
||||
fi
|
||||
rm -f /tmp/modpack.zip
|
||||
;;
|
||||
*)
|
||||
echo "Invalid URL given for modpack: Must be HTTP or HTTPS and a ZIP file"
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
exec /start-finalSetup03Modconfig $@
|
||||
25
minecraft-server/start-finalSetup03Modconfig
Executable file
25
minecraft-server/start-finalSetup03Modconfig
Executable file
@@ -0,0 +1,25 @@
|
||||
#!/bin/bash
|
||||
|
||||
# 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
|
||||
|
||||
exec /start-finalSetup04ServerProperties $@
|
||||
149
minecraft-server/start-finalSetup04ServerProperties
Executable file
149
minecraft-server/start-finalSetup04ServerProperties
Executable file
@@ -0,0 +1,149 @@
|
||||
#!/bin/bash
|
||||
|
||||
# FUNCTIONS
|
||||
function setServerProp {
|
||||
local prop=$1
|
||||
local var=$2
|
||||
if [ -n "$var" ]; then
|
||||
# normalize booleans
|
||||
case ${var^^} in
|
||||
TRUE|FALSE)
|
||||
var=${var,,} ;;
|
||||
esac
|
||||
echo "Setting ${prop} to '${var}' in ${SERVER_PROPERTIES}"
|
||||
sed -i "/^${prop}\s*=/ c ${prop}=${var}" $SERVER_PROPERTIES
|
||||
else
|
||||
echo "Skip setting ${prop}"
|
||||
fi
|
||||
}
|
||||
|
||||
# Deploy server.properties file
|
||||
if [ ! -e $SERVER_PROPERTIES ]; then
|
||||
echo "Creating server.properties in ${SERVER_PROPERTIES}"
|
||||
cp /tmp/server.properties $SERVER_PROPERTIES
|
||||
|
||||
if [[ ${TYPE} == "FEED-THE-BEAST" ]]; then
|
||||
export SERVER_PROPERTIES=${FTB_DIR}/server.properties
|
||||
echo "detected FTB, changing properties path to ${SERVER_PROPERTIES}"
|
||||
cp /tmp/server.properties $SERVER_PROPERTIES
|
||||
fi
|
||||
|
||||
if [ -n "$WHITELIST" ]; then
|
||||
echo "Creating whitelist"
|
||||
setServerProp "whitelist" "true"
|
||||
setServerProp "white-list" "true"
|
||||
fi
|
||||
|
||||
# If not provided, generate a reasonable default message-of-the-day,
|
||||
# which shows up in the server listing in the client
|
||||
if [ -z $MOTD ]; then
|
||||
# snapshot is the odd case where we have to look at version to identify that label
|
||||
if [[ ${ORIGINAL_TYPE} == "VANILLA" && ${VERSION} == "SNAPSHOT" ]]; then
|
||||
label=SNAPSHOT
|
||||
else
|
||||
label=${ORIGINAL_TYPE}
|
||||
fi
|
||||
|
||||
# Convert label to title-case
|
||||
label=${label,,}
|
||||
label=${label^}
|
||||
MOTD="A ${label} Minecraft Server powered by Docker"
|
||||
fi
|
||||
|
||||
setServerProp "server-port" "$SERVER_PORT"
|
||||
setServerProp "motd" "$MOTD"
|
||||
setServerProp "allow-nether" "$ALLOW_NETHER"
|
||||
setServerProp "announce-player-achievements" "$ANNOUNCE_PLAYER_ACHIEVEMENTS"
|
||||
setServerProp "enable-command-block" "$ENABLE_COMMAND_BLOCK"
|
||||
setServerProp "spawn-animals" "$SPAWN_ANIMALS"
|
||||
setServerProp "spawn-monsters" "$SPAWN_MONSTERS"
|
||||
setServerProp "spawn-npcs" "$SPAWN_NPCS"
|
||||
setServerProp "generate-structures" "$GENERATE_STRUCTURES"
|
||||
setServerProp "view-distance" "$VIEW_DISTANCE"
|
||||
setServerProp "hardcore" "$HARDCORE"
|
||||
setServerProp "snooper-enabled" "$SNOOPER_ENABLED"
|
||||
setServerProp "max-build-height" "$MAX_BUILD_HEIGHT"
|
||||
setServerProp "force-gamemode" "$FORCE_GAMEMODE"
|
||||
setServerProp "max-tick-time" "$MAX_TICK_TIME"
|
||||
setServerProp "enable-query" "$ENABLE_QUERY"
|
||||
setServerProp "query.port" "$QUERY_PORT"
|
||||
setServerProp "enable-rcon" "$ENABLE_RCON"
|
||||
setServerProp "rcon.password" "$RCON_PASSWORD"
|
||||
setServerProp "rcon.port" "$RCON_PORT"
|
||||
setServerProp "max-players" "$MAX_PLAYERS"
|
||||
setServerProp "max-world-size" "$MAX_WORLD_SIZE"
|
||||
setServerProp "level-name" "$LEVEL"
|
||||
setServerProp "level-seed" "$SEED"
|
||||
setServerProp "pvp" "$PVP"
|
||||
setServerProp "generator-settings" "$GENERATOR_SETTINGS"
|
||||
setServerProp "online-mode" "$ONLINE_MODE"
|
||||
setServerProp "allow-flight" "$ALLOW_FLIGHT"
|
||||
|
||||
if [ -n "$LEVEL_TYPE" ]; then
|
||||
# normalize to uppercase
|
||||
LEVEL_TYPE=$( echo ${LEVEL_TYPE} | tr '[:lower:]' '[:upper:]' )
|
||||
echo "Setting level type to $LEVEL_TYPE"
|
||||
# check for valid values and only then set
|
||||
case $LEVEL_TYPE in
|
||||
DEFAULT|FLAT|LARGEBIOMES|AMPLIFIED|CUSTOMIZED|BIOMESOP|RTG|RWG|BUFFET)
|
||||
setServerProp "level-type" "$LEVEL_TYPE"
|
||||
;;
|
||||
*)
|
||||
echo "Invalid LEVEL_TYPE: $LEVEL_TYPE"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
if [ -n "$DIFFICULTY" ]; then
|
||||
case $DIFFICULTY in
|
||||
peaceful|0)
|
||||
DIFFICULTY=0
|
||||
;;
|
||||
easy|1)
|
||||
DIFFICULTY=1
|
||||
;;
|
||||
normal|2)
|
||||
DIFFICULTY=2
|
||||
;;
|
||||
hard|3)
|
||||
DIFFICULTY=3
|
||||
;;
|
||||
*)
|
||||
echo "DIFFICULTY must be peaceful, easy, normal, or hard."
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
setServerProp "difficulty" "$DIFFICULTY"
|
||||
fi
|
||||
|
||||
if [ -n "$MODE" ]; then
|
||||
echo "Setting mode"
|
||||
MODE_LC=$( echo $MODE | tr '[:upper:]' '[:lower:]' )
|
||||
case $MODE_LC in
|
||||
0|1|2|3)
|
||||
;;
|
||||
su*)
|
||||
MODE=0
|
||||
;;
|
||||
c*)
|
||||
MODE=1
|
||||
;;
|
||||
a*)
|
||||
MODE=2
|
||||
;;
|
||||
sp*)
|
||||
MODE=3
|
||||
;;
|
||||
*)
|
||||
echo "ERROR: Invalid game mode: $MODE"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
setServerProp "gamemode" "$MODE"
|
||||
fi
|
||||
else
|
||||
echo "server.properties already created, skipping"
|
||||
fi
|
||||
|
||||
exec /start-minecraftFinalSetup $@
|
||||
@@ -1,588 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
#umask 002
|
||||
export HOME=/data
|
||||
|
||||
if [ ! -e /data/eula.txt ]; then
|
||||
if [ "$EULA" != "" ]; then
|
||||
echo "# Generated via Docker on $(date)" > eula.txt
|
||||
echo "eula=$EULA" >> eula.txt
|
||||
else
|
||||
echo ""
|
||||
echo "Please accept the Minecraft EULA at"
|
||||
echo " https://account.mojang.com/documents/minecraft_eula"
|
||||
echo "by adding the following immediately after 'docker run':"
|
||||
echo " -e EULA=TRUE"
|
||||
echo ""
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
SERVER_PROPERTIES=/data/server.properties
|
||||
FTB_DIR=/data/FeedTheBeast
|
||||
VERSIONS_JSON=https://launchermeta.mojang.com/mc/game/version_manifest.json
|
||||
|
||||
echo "Checking version information."
|
||||
case "X$VERSION" in
|
||||
X|XLATEST|Xlatest)
|
||||
VANILLA_VERSION=`curl -fsSL $VERSIONS_JSON | jq -r '.latest.release'`
|
||||
;;
|
||||
XSNAPSHOT|Xsnapshot)
|
||||
VANILLA_VERSION=`curl -fsSL $VERSIONS_JSON | jq -r '.latest.snapshot'`
|
||||
;;
|
||||
X[1-9]*)
|
||||
VANILLA_VERSION=$VERSION
|
||||
;;
|
||||
*)
|
||||
VANILLA_VERSION=`curl -fsSL $VERSIONS_JSON | jq -r '.latest.release'`
|
||||
;;
|
||||
esac
|
||||
|
||||
cd /data
|
||||
|
||||
function buildSpigotFromSource {
|
||||
echo "Building Spigot $VANILLA_VERSION from source, might take a while, get some coffee"
|
||||
mkdir /data/temp
|
||||
cd /data/temp
|
||||
wget -q -P /data/temp https://hub.spigotmc.org/jenkins/job/BuildTools/lastSuccessfulBuild/artifact/target/BuildTools.jar && \
|
||||
java -jar /data/temp/BuildTools.jar --rev $VANILLA_VERSION 2>&1 |tee /data/spigot_build.log| while read l; do echo -n .; done; echo "done"
|
||||
mv spigot-*.jar /data/spigot_server.jar
|
||||
mv craftbukkit-*.jar /data/craftbukkit_server.jar
|
||||
echo "Cleaning up"
|
||||
rm -rf /data/temp
|
||||
cd /data
|
||||
}
|
||||
|
||||
function downloadSpigot {
|
||||
local match
|
||||
case "$TYPE" in
|
||||
*BUKKIT|*bukkit)
|
||||
match="Craftbukkit"
|
||||
downloadUrl=${BUKKIT_DOWNLOAD_URL}
|
||||
;;
|
||||
*)
|
||||
match="Spigot"
|
||||
downloadUrl=${SPIGOT_DOWNLOAD_URL}
|
||||
;;
|
||||
esac
|
||||
|
||||
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
|
||||
fi
|
||||
|
||||
echo "Downloading $match"
|
||||
curl -kfsSL -o $SERVER "$downloadUrl"
|
||||
status=$?
|
||||
if [ ! -f $SERVER ]; then
|
||||
echo "ERROR: failed to download from $downloadUrl (status=$status)"
|
||||
exit 3
|
||||
fi
|
||||
|
||||
}
|
||||
|
||||
function downloadPaper {
|
||||
local build
|
||||
case "$VERSION" in
|
||||
latest|LATEST|1.10)
|
||||
build="lastSuccessfulBuild";;
|
||||
1.9.4)
|
||||
build="773";;
|
||||
1.9.2)
|
||||
build="727";;
|
||||
1.9)
|
||||
build="612";;
|
||||
1.8.8)
|
||||
build="443";;
|
||||
*)
|
||||
build="nosupp";;
|
||||
esac
|
||||
|
||||
if [ $build != "nosupp" ]; then
|
||||
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
|
||||
echo "ERROR: Version $VERSION is not supported for $TYPE"
|
||||
echo " Refer to https://ci.destroystokyo.com/job/PaperSpigot/"
|
||||
echo " for supported versions"
|
||||
exit 2
|
||||
fi
|
||||
}
|
||||
|
||||
function installForge {
|
||||
TYPE=FORGE
|
||||
norm=$VANILLA_VERSION
|
||||
|
||||
case $VANILLA_VERSION in
|
||||
*.*.*)
|
||||
norm=$VANILLA_VERSION ;;
|
||||
*.*)
|
||||
norm=${VANILLA_VERSION}.0 ;;
|
||||
esac
|
||||
|
||||
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
|
||||
FORGE_VERSION=$(cat /tmp/forge.json | jq -r ".promos[\"$VANILLA_VERSION-latest\"]")
|
||||
if [ $FORGE_VERSION = null ]; then
|
||||
echo "ERROR: Version $VANILLA_VERSION is not supported by Forge"
|
||||
echo " Refer to http://files.minecraftforge.net/ for supported versions"
|
||||
exit 2
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
|
||||
*)
|
||||
FORGE_VERSION=$FORGEVERSION
|
||||
;;
|
||||
esac
|
||||
|
||||
normForgeVersion=$VANILLA_VERSION-$FORGE_VERSION-$norm
|
||||
shortForgeVersion=$VANILLA_VERSION-$FORGE_VERSION
|
||||
|
||||
forgeFileNames="
|
||||
$normForgeVersion/forge-$normForgeVersion-installer.jar
|
||||
$shortForgeVersion/forge-$shortForgeVersion-installer.jar
|
||||
END
|
||||
"
|
||||
|
||||
FORGE_INSTALLER="/tmp/forge-$shortForgeVersion-installer.jar"
|
||||
installMarker=".forge-installed-$shortForgeVersion"
|
||||
|
||||
if [ ! -e $installMarker ]; then
|
||||
if [ ! -e $FORGE_INSTALLER ]; then
|
||||
echo "Downloading $normForgeVersion"
|
||||
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
|
||||
|
||||
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
|
||||
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
|
||||
else
|
||||
SERVER=$(cat $installMarker)
|
||||
fi
|
||||
}
|
||||
|
||||
function isURL {
|
||||
local value=$1
|
||||
|
||||
if [[ ${value:0:8} == "https://" || ${value:0:7} = "http://" ]]; then
|
||||
return 0
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
function installFTB {
|
||||
TYPE=FEED-THE-BEAST
|
||||
|
||||
echo "Looking for Feed-The-Beast server modpack."
|
||||
if [[ -z $FTB_SERVER_MOD ]]; then
|
||||
echo "Environment variable FTB_SERVER_MOD not set."
|
||||
echo "Set FTB_SERVER_MOD to the file name of the FTB server modpack."
|
||||
echo "(And place the modpack in the /data directory.)"
|
||||
exit 2
|
||||
fi
|
||||
local srv_modpack=${FTB_SERVER_MOD}
|
||||
if isURL ${srv_modpack}; then
|
||||
case $srv_modpack in
|
||||
*/download)
|
||||
break;;
|
||||
*)
|
||||
srv_modpack=${srv_modpack}/download;;
|
||||
esac
|
||||
local file=$(basename $(dirname $srv_modpack))
|
||||
local downloaded=/data/${file}.zip
|
||||
echo "Downloading FTB modpack...
|
||||
$srv_modpack -> $downloaded"
|
||||
curl -sSL -o $downloaded $srv_modpack
|
||||
srv_modpack=$downloaded
|
||||
fi
|
||||
if [[ ${srv_modpack:0:5} == "data/" ]]; then
|
||||
# Prepend with "/"
|
||||
srv_modpack=/${srv_modpack}
|
||||
fi
|
||||
if [[ ! ${srv_modpack:0:1} == "/" ]]; then
|
||||
# If not an absolute path, assume file is in "/data"
|
||||
srv_modpack=/data/${srv_modpack}
|
||||
fi
|
||||
if [[ ! -f ${srv_modpack} ]]; then
|
||||
echo "FTB server modpack ${srv_modpack} not found."
|
||||
exit 2
|
||||
fi
|
||||
if [[ ! ${srv_modpack: -4} == ".zip" ]]; then
|
||||
echo "FTB server modpack ${srv_modpack} is not a zip archive."
|
||||
echo "Please set FTB_SERVER_MOD to a file with a .zip extension."
|
||||
exit 2
|
||||
fi
|
||||
|
||||
echo "Unpacking FTB server modpack ${srv_modpack} ..."
|
||||
mkdir -p ${FTB_DIR}
|
||||
unzip -o ${srv_modpack} -d ${FTB_DIR}
|
||||
cp -f /data/eula.txt ${FTB_DIR}/eula.txt
|
||||
FTB_SERVER_START=${FTB_DIR}/ServerStart.sh
|
||||
chmod a+x ${FTB_SERVER_START}
|
||||
sed -i "s/-jar/-Dfml.queryResult=confirm -jar/" ${FTB_SERVER_START}
|
||||
}
|
||||
|
||||
function installVanilla {
|
||||
SERVER="minecraft_server.$VANILLA_VERSION.jar"
|
||||
|
||||
if [ ! -e $SERVER ]; then
|
||||
echo "Downloading $SERVER ..."
|
||||
wget -q https://s3.amazonaws.com/Minecraft.Download/versions/$VANILLA_VERSION/$SERVER
|
||||
fi
|
||||
}
|
||||
|
||||
echo "Checking type information."
|
||||
case "$TYPE" in
|
||||
*BUKKIT|*bukkit|SPIGOT|spigot)
|
||||
case "$TYPE" in
|
||||
*BUKKIT|*bukkit)
|
||||
SERVER=craftbukkit_server.jar
|
||||
;;
|
||||
*)
|
||||
SERVER=spigot_server.jar
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ ! -f $SERVER ]; then
|
||||
if [[ "$BUILD_SPIGOT_FROM_SOURCE" = TRUE || "$BUILD_SPIGOT_FROM_SOURCE" = true || "$BUILD_FROM_SOURCE" = TRUE || "$BUILD_FROM_SOURCE" = true ]]; then
|
||||
buildSpigotFromSource
|
||||
else
|
||||
downloadSpigot
|
||||
fi
|
||||
fi
|
||||
# normalize on Spigot for operations below
|
||||
TYPE=SPIGOT
|
||||
;;
|
||||
|
||||
PAPER|paper)
|
||||
SERVER=paper_server.jar
|
||||
if [ ! -f $SERVER ]; then
|
||||
downloadPaper
|
||||
fi
|
||||
# normalize on Spigot for operations below
|
||||
TYPE=SPIGOT
|
||||
;;
|
||||
|
||||
FORGE|forge)
|
||||
TYPE=FORGE
|
||||
installForge
|
||||
;;
|
||||
|
||||
FTB|ftb)
|
||||
TYPE=FEED-THE-BEAST
|
||||
installFTB
|
||||
;;
|
||||
|
||||
VANILLA|vanilla)
|
||||
installVanilla
|
||||
;;
|
||||
|
||||
*)
|
||||
echo "Invalid type: '$TYPE'"
|
||||
echo "Must be: VANILLA, FORGE, SPIGOT"
|
||||
exit 1
|
||||
;;
|
||||
|
||||
esac
|
||||
|
||||
|
||||
# If supplied with a URL for a world, download it and unpack
|
||||
if [[ "$WORLD" ]]; then
|
||||
case "X$WORLD" in
|
||||
X[Hh][Tt][Tt][Pp]*)
|
||||
echo "Downloading world via HTTP"
|
||||
echo "$WORLD"
|
||||
wget -q -O - "$WORLD" > /data/world.zip
|
||||
echo "Unzipping word"
|
||||
unzip -q /data/world.zip
|
||||
rm -f /data/world.zip
|
||||
if [ ! -d /data/world ]; then
|
||||
echo World directory not found
|
||||
for i in /data/*/level.dat; do
|
||||
if [ -f "$i" ]; then
|
||||
d=`dirname "$i"`
|
||||
echo Renaming world directory from $d
|
||||
mv -f "$d" /data/world
|
||||
fi
|
||||
done
|
||||
fi
|
||||
if [ "$TYPE" = "SPIGOT" ]; then
|
||||
# Reorganise if a Spigot server
|
||||
echo "Moving End and Nether maps to Spigot location"
|
||||
[ -d "/data/world/DIM1" ] && mv -f "/data/world/DIM1" "/data/world_the_end"
|
||||
[ -d "/data/world/DIM-1" ] && mv -f "/data/world/DIM-1" "/data/world_nether"
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
echo "Invalid URL given for world: Must be HTTP or HTTPS and a ZIP file"
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
# If supplied with a URL for a modpack (simple zip of jars), download it and unpack
|
||||
if [[ "$MODPACK" ]]; then
|
||||
case "X$MODPACK" in
|
||||
X[Hh][Tt][Tt][Pp]*[Zz][iI][pP])
|
||||
echo "Downloading mod/plugin pack via HTTP"
|
||||
echo " from $MODPACK ..."
|
||||
curl -sSL -o /tmp/modpack.zip "$MODPACK"
|
||||
if [ "$TYPE" = "SPIGOT" ]; then
|
||||
mkdir -p /data/plugins
|
||||
unzip -o -d /data/plugins /tmp/modpack.zip
|
||||
else
|
||||
mkdir -p /data/mods
|
||||
unzip -o -d /data/mods /tmp/modpack.zip
|
||||
fi
|
||||
rm -f /tmp/modpack.zip
|
||||
;;
|
||||
*)
|
||||
echo "Invalid URL given for modpack: Must be HTTP or HTTPS and a ZIP file"
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
function setServerProp {
|
||||
local prop=$1
|
||||
local var=$2
|
||||
if [ -n "$var" ]; then
|
||||
echo "Setting $prop to $var"
|
||||
sed -i "/$prop\s*=/ c $prop=$var" /data/server.properties
|
||||
fi
|
||||
|
||||
}
|
||||
|
||||
if [ ! -e server.properties ]; then
|
||||
echo "Creating server.properties"
|
||||
cp /tmp/server.properties .
|
||||
|
||||
if [ -n "$WHITELIST" ]; then
|
||||
echo "Creating whitelist"
|
||||
sed -i "/whitelist\s*=/ c whitelist=true" /data/server.properties
|
||||
sed -i "/white-list\s*=/ c white-list=true" /data/server.properties
|
||||
fi
|
||||
|
||||
setServerProp "motd" "$MOTD"
|
||||
setServerProp "allow-nether" "$ALLOW_NETHER"
|
||||
setServerProp "announce-player-achievements" "$ANNOUNCE_PLAYER_ACHIEVEMENTS"
|
||||
setServerProp "enable-command-block" "$ENABLE_COMMAND_BLOCK"
|
||||
setServerProp "spawn-animals" "$SPAWN_ANIMAILS"
|
||||
setServerProp "spawn-monsters" "$SPAWN_MONSTERS"
|
||||
setServerProp "spawn-npcs" "$SPAWN_NPCS"
|
||||
setServerProp "generate-structures" "$GENERATE_STRUCTURES"
|
||||
setServerProp "spawn-npcs" "$SPAWN_NPCS"
|
||||
setServerProp "view-distance" "$VIEW_DISTANCE"
|
||||
setServerProp "hardcore" "$HARDCORE"
|
||||
setServerProp "max-build-height" "$MAX_BUILD_HEIGHT"
|
||||
setServerProp "force-gamemode" "$FORCE_GAMEMODE"
|
||||
setServerProp "hardmax-tick-timecore" "$MAX_TICK_TIME"
|
||||
setServerProp "enable-query" "$ENABLE_QUERY"
|
||||
setServerProp "query.port" "$QUERY_PORT"
|
||||
setServerProp "enable-rcon" "$ENABLE_RCON"
|
||||
setServerProp "rcon.password" "$RCON_PASSWORD"
|
||||
setServerProp "rcon.port" "$RCON_PORT"
|
||||
setServerProp "max-players" "$MAX_PLAYERS"
|
||||
setServerProp "max-world-size" "$MAX_WORLD_SIZE"
|
||||
setServerProp "level-name" "$LEVEL"
|
||||
setServerProp "level-seed" "$SEED"
|
||||
setServerProp "pvp" "$PVP"
|
||||
setServerProp "generator-settings" "$GENERATOR_SETTINGS"
|
||||
setServerProp "online-mode" "$ONLINE_MODE"
|
||||
|
||||
if [ -n "$LEVEL_TYPE" ]; then
|
||||
# normalize to uppercase
|
||||
LEVEL_TYPE=$( echo ${LEVEL_TYPE} | tr '[:lower:]' '[:upper:]' )
|
||||
echo "Setting level type to $LEVEL_TYPE"
|
||||
# check for valid values and only then set
|
||||
case $LEVEL_TYPE in
|
||||
DEFAULT|FLAT|LARGEBIOMES|AMPLIFIED|CUSTOMIZED)
|
||||
sed -i "/level-type\s*=/ c level-type=$LEVEL_TYPE" /data/server.properties
|
||||
;;
|
||||
*)
|
||||
echo "Invalid LEVEL_TYPE: $LEVEL_TYPE"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
if [ -n "$DIFFICULTY" ]; then
|
||||
case $DIFFICULTY in
|
||||
peaceful|0)
|
||||
DIFFICULTY=0
|
||||
;;
|
||||
easy|1)
|
||||
DIFFICULTY=1
|
||||
;;
|
||||
normal|2)
|
||||
DIFFICULTY=2
|
||||
;;
|
||||
hard|3)
|
||||
DIFFICULTY=3
|
||||
;;
|
||||
*)
|
||||
echo "DIFFICULTY must be peaceful, easy, normal, or hard."
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
echo "Setting difficulty to $DIFFICULTY"
|
||||
sed -i "/difficulty\s*=/ c difficulty=$DIFFICULTY" /data/server.properties
|
||||
fi
|
||||
|
||||
if [ -n "$MODE" ]; then
|
||||
echo "Setting mode"
|
||||
MODE_LC=$( echo $MODE | tr '[:upper:]' '[:lower:]' )
|
||||
case $MODE_LC in
|
||||
0|1|2|3)
|
||||
;;
|
||||
su*)
|
||||
MODE=0
|
||||
;;
|
||||
c*)
|
||||
MODE=1
|
||||
;;
|
||||
a*)
|
||||
MODE=2
|
||||
;;
|
||||
sp*)
|
||||
MODE=3
|
||||
;;
|
||||
*)
|
||||
echo "ERROR: Invalid game mode: $MODE"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
sed -i "/gamemode\s*=/ c gamemode=$MODE" $SERVER_PROPERTIES
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
if [ -n "$OPS" -a ! -e ops.txt.converted ]; then
|
||||
echo "Setting ops"
|
||||
echo $OPS | awk -v RS=, '{print}' >> ops.txt
|
||||
fi
|
||||
|
||||
if [ -n "$WHITELIST" -a ! -e white-list.txt.converted ]; then
|
||||
echo "Setting whitelist"
|
||||
echo $WHITELIST | awk -v RS=, '{print}' >> white-list.txt
|
||||
fi
|
||||
|
||||
if [ -n "$ICON" -a ! -e server-icon.png ]; then
|
||||
echo "Using server icon from $ICON..."
|
||||
# Not sure what it is yet...call it "img"
|
||||
wget -q -O /tmp/icon.img $ICON
|
||||
specs=$(identify /tmp/icon.img | awk '{print $2,$3}')
|
||||
if [ "$specs" = "PNG 64x64" ]; then
|
||||
mv /tmp/icon.img /data/server-icon.png
|
||||
else
|
||||
echo "Converting image to 64x64 PNG..."
|
||||
convert /tmp/icon.img -resize 64x64! /data/server-icon.png
|
||||
fi
|
||||
fi
|
||||
|
||||
# Make sure files exist to avoid errors
|
||||
if [ ! -e banned-players.json ]; then
|
||||
echo '' > banned-players.json
|
||||
fi
|
||||
if [ ! -e banned-ips.json ]; then
|
||||
echo '' > banned-ips.json
|
||||
fi
|
||||
|
||||
# If any modules have been provided, copy them over
|
||||
mkdir -p /data/mods
|
||||
for m in /mods/*.{jar,zip}
|
||||
do
|
||||
if [ -f "$m" -a ! -f "/data/mods/$m" ]; then
|
||||
echo Copying mod `basename "$m"`
|
||||
cp "$m" /data/mods
|
||||
fi
|
||||
done
|
||||
[ -d /data/config ] || mkdir /data/config
|
||||
for c in /config/*
|
||||
do
|
||||
if [ -f "$c" ]; then
|
||||
echo Copying configuration `basename "$c"`
|
||||
cp -rf "$c" /data/config
|
||||
fi
|
||||
done
|
||||
|
||||
if [ "$TYPE" = "SPIGOT" ]; then
|
||||
if [ -d /plugins ]; then
|
||||
echo Copying any Bukkit plugins over
|
||||
cp -r /plugins /data
|
||||
fi
|
||||
fi
|
||||
|
||||
EXTRA_ARGS=""
|
||||
# Optional disable console
|
||||
if [[ ${CONSOLE} = false || ${CONSOLE} = FALSE ]]; then
|
||||
EXTRA_ARGS+="--noconsole"
|
||||
fi
|
||||
|
||||
# Optional disable GUI for headless servers
|
||||
if [[ ${GUI} = false || ${GUI} = FALSE ]]; then
|
||||
EXTRA_ARGS="${EXTRA_ARGS} nogui"
|
||||
fi
|
||||
|
||||
# put these prior JVM_OPTS at the end to give any memory settings there higher precedence
|
||||
echo "Setting initial memory to ${INIT_MEMORY:-${MEMORY}} and max to ${MAX_MEMORY:-${MEMORY}}"
|
||||
JVM_OPTS="-Xms${INIT_MEMORY:-${MEMORY}} -Xmx${MAX_MEMORY:-${MEMORY}} ${JVM_OPTS}"
|
||||
|
||||
if [[ ${TYPE} == "FEED-THE-BEAST" ]]; then
|
||||
cp -f $SERVER_PROPERTIES ${FTB_DIR}/server.properties
|
||||
cp -f /data/{eula,ops,white-list}.txt ${FTB_DIR}/
|
||||
cd ${FTB_DIR}
|
||||
echo "Running FTB server modpack start ..."
|
||||
exec sh ${FTB_SERVER_START}
|
||||
else
|
||||
# If we have a bootstrap.txt file... feed that in to the server stdin
|
||||
if [ -f /data/bootstrap.txt ];
|
||||
then
|
||||
exec java $JVM_XX_OPTS $JVM_OPTS -jar $SERVER "$@" $EXTRA_ARGS < /data/bootstrap.txt
|
||||
else
|
||||
exec java $JVM_XX_OPTS $JVM_OPTS -jar $SERVER "$@" $EXTRA_ARGS
|
||||
fi
|
||||
fi
|
||||
105
minecraft-server/start-minecraftFinalSetup
Executable file
105
minecraft-server/start-minecraftFinalSetup
Executable file
@@ -0,0 +1,105 @@
|
||||
#!/bin/bash
|
||||
|
||||
if [ -n "$OPS" -a ! -e ops.txt.converted ]; then
|
||||
echo "Setting ops"
|
||||
echo $OPS | awk -v RS=, '{print}' >> ops.txt
|
||||
fi
|
||||
|
||||
if [ -n "$WHITELIST" -a ! -e white-list.txt.converted ]; then
|
||||
echo "Setting whitelist"
|
||||
echo $WHITELIST | awk -v RS=, '{print}' >> white-list.txt
|
||||
fi
|
||||
|
||||
if [ -n "$ICON" -a ! -e server-icon.png ]; then
|
||||
echo "Using server icon from $ICON..."
|
||||
# Not sure what it is yet...call it "img"
|
||||
curl -sSL -o /tmp/icon.img $ICON
|
||||
specs=$(identify /tmp/icon.img | awk '{print $2,$3}')
|
||||
if [ "$specs" = "PNG 64x64" ]; then
|
||||
mv /tmp/icon.img /data/server-icon.png
|
||||
else
|
||||
echo "Converting image to 64x64 PNG..."
|
||||
convert /tmp/icon.img -resize 64x64! /data/server-icon.png
|
||||
fi
|
||||
fi
|
||||
|
||||
# Make sure files exist and are valid JSON (for pre-1.12 to 1.12 upgrades)
|
||||
if [[ -z "ls *.json" ]]; then
|
||||
echo "Checking JSON files"
|
||||
for j in *.json; do
|
||||
if [[ $(python -c "print open('$j').read().strip()==''") = True ]]; then
|
||||
echo "Fixing JSON $j"
|
||||
echo '[]' > $j
|
||||
fi
|
||||
done
|
||||
else
|
||||
echo "Skipping JSON check. No files present."
|
||||
fi
|
||||
|
||||
# If any modules have been provided, copy them over
|
||||
mkdir -p /data/mods
|
||||
for m in /mods/*.{jar,zip}
|
||||
do
|
||||
if [ -f "$m" -a ! -f "/data/mods/$m" ]; then
|
||||
echo Copying mod `basename "$m"`
|
||||
cp "$m" /data/mods
|
||||
fi
|
||||
done
|
||||
[ -d /data/config ] || mkdir /data/config
|
||||
for c in /config/*
|
||||
do
|
||||
if [ -f "$c" ]; then
|
||||
echo Copying configuration `basename "$c"`
|
||||
cp -rf "$c" /data/config
|
||||
fi
|
||||
done
|
||||
|
||||
if [ "$TYPE" = "SPIGOT" ]; then
|
||||
if [ -d /plugins ]; then
|
||||
echo Copying any Bukkit plugins over
|
||||
cp -r /plugins /data
|
||||
fi
|
||||
fi
|
||||
|
||||
EXTRA_ARGS=""
|
||||
# Optional disable console
|
||||
if [[ ${CONSOLE} = false || ${CONSOLE} = FALSE ]]; then
|
||||
EXTRA_ARGS+="--noconsole"
|
||||
fi
|
||||
|
||||
# Optional disable GUI for headless servers
|
||||
if [[ ${GUI} = false || ${GUI} = FALSE ]]; then
|
||||
EXTRA_ARGS="${EXTRA_ARGS} nogui"
|
||||
fi
|
||||
|
||||
# put these prior JVM_OPTS at the end to give any memory settings there higher precedence
|
||||
echo "Setting initial memory to ${INIT_MEMORY:=${MEMORY}} and max to ${MAX_MEMORY:=${MEMORY}}"
|
||||
|
||||
if [[ ${TYPE} == "FEED-THE-BEAST" ]]; then
|
||||
if [ ! -e ${FTB_DIR}/ops.json -a -e /data/ops.txt ]; then
|
||||
cp -f /data/ops.txt ${FTB_DIR}/
|
||||
fi
|
||||
|
||||
if [ ! -e ${FTB_DIR}/whitelist.json -a -e /data/white-list.txt ]; then
|
||||
cp -f /data/white-list.txt ${FTB_DIR}/
|
||||
fi
|
||||
|
||||
cp -f /data/eula.txt ${FTB_DIR}/
|
||||
|
||||
cat > ${FTB_DIR}/settings-local.sh <<EOF
|
||||
export MIN_RAM="${INIT_MEMORY}"
|
||||
export MAX_RAM="${MAX_MEMORY}"
|
||||
EOF
|
||||
|
||||
cd ${FTB_DIR}
|
||||
echo "Running FTB ${FTB_SERVER_START} in ${FTB_DIR} ..."
|
||||
exec mc-server-runner ${FTB_SERVER_START}
|
||||
else
|
||||
# If we have a bootstrap.txt file... feed that in to the server stdin
|
||||
if [ -f /data/bootstrap.txt ]; then
|
||||
bootstrapArgs="--bootstrap /data/bootstrap.txt"
|
||||
fi
|
||||
|
||||
JVM_OPTS="-Xms${INIT_MEMORY} -Xmx${MAX_MEMORY} ${JVM_OPTS}"
|
||||
exec mc-server-runner ${bootstrapArgs} java $JVM_XX_OPTS $JVM_OPTS -jar $SERVER "$@" $EXTRA_ARGS
|
||||
fi
|
||||
28
minecraft-server/start-utils
Normal file
28
minecraft-server/start-utils
Normal file
@@ -0,0 +1,28 @@
|
||||
#!/bin/bash
|
||||
|
||||
function isURL {
|
||||
local value=$1
|
||||
|
||||
if [[ ${value:0:8} == "https://" || ${value:0:7} = "http://" ]]; then
|
||||
return 0
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
function isTrue {
|
||||
local value=${1,,}
|
||||
|
||||
result=
|
||||
|
||||
case ${value} in
|
||||
true|on)
|
||||
result=0
|
||||
;;
|
||||
*)
|
||||
result=1
|
||||
;;
|
||||
esac
|
||||
|
||||
return ${result}
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -e
|
||||
sed -i "/^minecraft/s/:1000:1000:/:${UID}:${GID}:/g" /etc/passwd
|
||||
sed -i "/^minecraft/s/:1000:/:${GID}:/g" /etc/group
|
||||
|
||||
if [ "$SKIP_OWNERSHIP_FIX" != "TRUE" ]; then
|
||||
fix_ownership() {
|
||||
dir=$1
|
||||
if ! su-exec minecraft test -w $dir; then
|
||||
echo "Correcting writability of $dir ..."
|
||||
chown -R minecraft:minecraft $dir
|
||||
chmod -R u+w $dir
|
||||
fi
|
||||
}
|
||||
|
||||
fix_ownership /data
|
||||
fix_ownership /home/minecraft
|
||||
fi
|
||||
|
||||
echo "Switching to user 'minecraft'"
|
||||
su-exec minecraft /start-minecraft $@
|
||||
Reference in New Issue
Block a user