mirror of
https://github.com/itzg/docker-minecraft-server.git
synced 2026-02-17 07:03:57 +00:00
Compare commits
308 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
52cbf1fb64 | ||
|
|
190e401452 | ||
|
|
b881a27c8d | ||
|
|
7aa47e2a60 | ||
|
|
327538a98f | ||
|
|
f6c71e27d8 | ||
|
|
4628da7ea2 | ||
|
|
02ba96c421 | ||
|
|
87f6fe6b20 | ||
|
|
8049bd5b80 | ||
|
|
5225ba06c8 | ||
|
|
d695fc3fbc | ||
|
|
a2132292ac | ||
|
|
c31b191b96 | ||
|
|
c4b573f608 | ||
|
|
28810fcba3 | ||
|
|
8d1989a595 | ||
|
|
d022956e24 | ||
|
|
2bdaa4dc4e | ||
|
|
46bfbaada1 | ||
|
|
e659343821 | ||
|
|
44138564b0 | ||
|
|
3c77abbbab | ||
|
|
209c6e6dab | ||
|
|
6fa827e9a1 | ||
|
|
cd3ea7fd2e | ||
|
|
d3bd697cb2 | ||
|
|
6c6bf030c5 | ||
|
|
6e2b3ae0c7 | ||
|
|
9915929340 | ||
|
|
5c1f176848 | ||
|
|
861aec6bd6 | ||
|
|
53f5fbb77f | ||
|
|
9299f00d20 | ||
|
|
e5e97a3560 | ||
|
|
32bc0382d6 | ||
|
|
fa53abdfb7 | ||
|
|
0cbfb81b4c | ||
|
|
d47c801b18 | ||
|
|
c056b9d2dd | ||
|
|
92a15ea85d | ||
|
|
6fe022ccc8 | ||
|
|
b71eb666a7 | ||
|
|
c48f6c31ce | ||
|
|
b2d23edf6d | ||
|
|
31f25cfd1b | ||
|
|
7d4e4c167e | ||
|
|
eb12030975 | ||
|
|
e46af9d54c | ||
|
|
861faaa285 | ||
|
|
8312233a93 | ||
|
|
959bf73485 | ||
|
|
beeaf1a996 | ||
|
|
96aa1054dc | ||
|
|
e7937206af | ||
|
|
081b2c11e4 | ||
|
|
f342f4aa98 | ||
|
|
4e73e69342 | ||
|
|
c6ff80b71c | ||
|
|
37cad3f255 | ||
|
|
5700f36a6f | ||
|
|
34f800d815 | ||
|
|
ffec50141a | ||
|
|
54027049d3 | ||
|
|
4c2829e3d2 | ||
|
|
69e308d420 | ||
|
|
ad46f10b55 | ||
|
|
cd0fdfc95b | ||
|
|
d95abfce82 | ||
|
|
942a125e04 | ||
|
|
a3677d5aa8 | ||
|
|
f927933c46 | ||
|
|
5ab83bcb21 | ||
|
|
fdf5fb46bc | ||
|
|
8c6ca5e999 | ||
|
|
bb2b9eeea9 | ||
|
|
d1cbce3f89 | ||
|
|
55b5f6821f | ||
|
|
2fb01b4adf | ||
|
|
02bce8c3a8 | ||
|
|
468671a3fa | ||
|
|
8ee650f38d | ||
|
|
3de2bf88df | ||
|
|
1fcbd8410f | ||
|
|
d40bbdc3a5 | ||
|
|
61c291ae4e | ||
|
|
f613228619 | ||
|
|
ca9f883352 | ||
|
|
9d68fa3b88 | ||
|
|
d3a5885d95 | ||
|
|
c1db13c1f6 | ||
|
|
31b0f711b8 | ||
|
|
59ca1ce3a6 | ||
|
|
0f7bd5f4fd | ||
|
|
a368f4cf57 | ||
|
|
08a4bde6c1 | ||
|
|
f68e979229 | ||
|
|
544b1f243d | ||
|
|
391e807c78 | ||
|
|
4099cde737 | ||
|
|
e56a74dc81 | ||
|
|
31b8535854 | ||
|
|
ed1bb73c22 | ||
|
|
b7ac28e902 | ||
|
|
3cb72797b6 | ||
|
|
6f1f8d7806 | ||
|
|
b06f1115d4 | ||
|
|
777ad31de0 | ||
|
|
8b977f8786 | ||
|
|
7c3139226c | ||
|
|
0ddabf3089 | ||
|
|
6cfc7e45ef | ||
|
|
9ea675bc89 | ||
|
|
42f90c8806 | ||
|
|
c8b6eac8fe | ||
|
|
d78272c1fa | ||
|
|
48ccdf128f | ||
|
|
2322dffd49 | ||
|
|
8a5e5bf01e | ||
|
|
99ed83022e | ||
|
|
07185534fb | ||
|
|
4fe55b5a28 | ||
|
|
bd503f224d | ||
|
|
b5c91647ca | ||
|
|
c359a0f2ac | ||
|
|
49d9f4a89d | ||
|
|
aebe35c9d4 | ||
|
|
a26361c79f | ||
|
|
a486458a08 | ||
|
|
82b8401414 | ||
|
|
8b6ee91ec1 | ||
|
|
06cffd9e15 | ||
|
|
beaccbcf3b | ||
|
|
21ee5e2401 | ||
|
|
747c188824 | ||
|
|
692087dd25 | ||
|
|
6fe13e8654 | ||
|
|
3b2b98b9fe | ||
|
|
796f2fe14a | ||
|
|
4fef391b64 | ||
|
|
83f6cebd0b | ||
|
|
90183ae823 | ||
|
|
3c9df03584 | ||
|
|
367c6cfd92 | ||
|
|
5e75410e7c | ||
|
|
38028f7d0c | ||
|
|
a07ae685e2 | ||
|
|
092b530537 | ||
|
|
cf691499a1 | ||
|
|
0bb9cccdc6 | ||
|
|
4cb12f6cae | ||
|
|
ecbdeb2096 | ||
|
|
9a7a532f7b | ||
|
|
825833c859 | ||
|
|
c4c3613874 | ||
|
|
3a03156cb3 | ||
|
|
b3780186f8 | ||
|
|
c4654e44d8 | ||
|
|
9c6047e3fc | ||
|
|
260cc7d180 | ||
|
|
bbe930e552 | ||
|
|
a655fe860e | ||
|
|
ddf36aa879 | ||
|
|
34c31c561d | ||
|
|
3cc7d00d71 | ||
|
|
ed214b1382 | ||
|
|
f8405e298c | ||
|
|
539159ba50 | ||
|
|
f2c9d2f905 | ||
|
|
1b11331881 | ||
|
|
b71afff29f | ||
|
|
b4c6950f95 | ||
|
|
ec0329efb1 | ||
|
|
477caa12c3 | ||
|
|
8f82ff9b1d | ||
|
|
7d97fdcbec | ||
|
|
5ee0150154 | ||
|
|
1bcacfc474 | ||
|
|
34603184a4 | ||
|
|
2ee5a25c91 | ||
|
|
60ef1b8867 | ||
|
|
3eaf756aa2 | ||
|
|
bc318fa185 | ||
|
|
f93c42a23f | ||
|
|
f5dde77efe | ||
|
|
2b7f923865 | ||
|
|
80099ad63d | ||
|
|
b273bf2947 | ||
|
|
2241ba8819 | ||
|
|
3cf58e3caf | ||
|
|
450442a916 | ||
|
|
8c866bd17d | ||
|
|
8deaf1850b | ||
|
|
6da2aca975 | ||
|
|
11989d17e3 | ||
|
|
5aa6e5c2a9 | ||
|
|
825398f4d4 | ||
|
|
ccac249c01 | ||
|
|
f2806d9335 | ||
|
|
b11806e341 | ||
|
|
71a7afab17 | ||
|
|
ede58d9159 | ||
|
|
b271b529ea | ||
|
|
d24690ab8c | ||
|
|
89fa3ff8fe | ||
|
|
5c0a3a64ab | ||
|
|
b66629b951 | ||
|
|
de866a322f | ||
|
|
79ac19937f | ||
|
|
08e8fcdc7c | ||
|
|
6941e63a2c | ||
|
|
c68997936a | ||
|
|
40547439b2 | ||
|
|
691fe638e4 | ||
|
|
fbdee6a7a7 | ||
|
|
664f3d7eaa | ||
|
|
c2846fc586 | ||
|
|
e9b1332119 | ||
|
|
757a5146a1 | ||
|
|
f9defda106 | ||
|
|
e6a3ca0a1f | ||
|
|
1cf478f5b3 | ||
|
|
9ff94f9bd5 | ||
|
|
9842a52820 | ||
|
|
dbca9c30b0 | ||
|
|
220f2fbd79 | ||
|
|
8dbbdd8cd2 | ||
|
|
1c2a0c506c | ||
|
|
90a6707280 | ||
|
|
e7cc54092a | ||
|
|
cd70cbcbea | ||
|
|
7910005086 | ||
|
|
b8ace17b7c | ||
|
|
f70814d6b6 | ||
|
|
8440e57118 | ||
|
|
29eda3530c | ||
|
|
558544f1e4 | ||
|
|
56c2f0b466 | ||
|
|
4bbc7d142f | ||
|
|
26cc3943ce | ||
|
|
6521f45f0b | ||
|
|
d62c2ffb42 | ||
|
|
d131941b62 | ||
|
|
98f0b36cfc | ||
|
|
6465bca640 | ||
|
|
4ad447ba6c | ||
|
|
736979c20b | ||
|
|
0c34a61332 | ||
|
|
67d58678a3 | ||
|
|
fb92a74084 | ||
|
|
8b5430ca44 | ||
|
|
f24827f558 | ||
|
|
f49b967d5a | ||
|
|
111ca85c4f | ||
|
|
c73bedc63c | ||
|
|
6f67f76eef | ||
|
|
002ed4bc77 | ||
|
|
9d48e79c64 | ||
|
|
ba7db26157 | ||
|
|
fc6129261b | ||
|
|
7702d98766 | ||
|
|
04ed016175 | ||
|
|
1aaaf95950 | ||
|
|
1e334ca7d5 | ||
|
|
74df4b6a9c | ||
|
|
f63463e654 | ||
|
|
a24b633ccb | ||
|
|
5b8cd8cdcc | ||
|
|
c35c85e9b5 | ||
|
|
2ffc1641a0 | ||
|
|
9d67dceff3 | ||
|
|
c449a31b37 | ||
|
|
efd3427fc0 | ||
|
|
88ed017ca7 | ||
|
|
30ba3a4b78 | ||
|
|
c8380daee5 | ||
|
|
8afb1651fd | ||
|
|
9560903c80 | ||
|
|
e94f6608d2 | ||
|
|
949faf1620 | ||
|
|
5b3259b1ef | ||
|
|
485d7b0612 | ||
|
|
94b037428e | ||
|
|
b401873298 | ||
|
|
1c9bbee3b3 | ||
|
|
5fa33c7813 | ||
|
|
581d5fde1d | ||
|
|
382336d39d | ||
|
|
5bd3a818a3 | ||
|
|
97874f3481 | ||
|
|
135bafefeb | ||
|
|
15b8c5a7e7 | ||
|
|
15990071d4 | ||
|
|
d00f9d3609 | ||
|
|
5ad745de75 | ||
|
|
b67580af2c | ||
|
|
2900062df5 | ||
|
|
67fe8931dd | ||
|
|
e6f593e8c4 | ||
|
|
8924740cfe | ||
|
|
34d4ae0b59 | ||
|
|
62a4541df5 | ||
|
|
401958c0d6 | ||
|
|
8859d223bf | ||
|
|
621962ad9c | ||
|
|
5c238af3df | ||
|
|
8e148095f0 | ||
|
|
3c55a05b1c |
@@ -1,17 +0,0 @@
|
||||
version: 2
|
||||
jobs:
|
||||
minecraft_server:
|
||||
docker:
|
||||
- image: circleci/buildpack-deps:19.10
|
||||
steps:
|
||||
- checkout
|
||||
- setup_remote_docker
|
||||
- run:
|
||||
name: Build image
|
||||
command: docker build -t mc:$CIRCLE_BUILD_NUM .
|
||||
|
||||
workflows:
|
||||
version: 2
|
||||
build:
|
||||
jobs:
|
||||
- minecraft_server
|
||||
@@ -1,4 +1,6 @@
|
||||
data
|
||||
testdata
|
||||
examples
|
||||
k8s-examples
|
||||
.idea
|
||||
.idea
|
||||
.git
|
||||
|
||||
@@ -1,2 +1,4 @@
|
||||
[start-*]
|
||||
indent_size = 2
|
||||
indent_size = 2
|
||||
indent_style = space
|
||||
end_of_line = lf
|
||||
|
||||
83
.github/workflows/build-multiarch.yml
vendored
Normal file
83
.github/workflows/build-multiarch.yml
vendored
Normal file
@@ -0,0 +1,83 @@
|
||||
name: Build and publish multiarch
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- multiarch
|
||||
- java8-multiarch
|
||||
- multiarch-latest
|
||||
- java15
|
||||
- java15-openj9
|
||||
- test/multiarch/*
|
||||
tags:
|
||||
- "[0-9]+.[0-9]+.[0-9]+-multiarch"
|
||||
- "[0-9]+.[0-9]+.[0-9]+-multiarch-latest"
|
||||
- "[0-9]+.[0-9]+.[0-9]+-java15"
|
||||
|
||||
jobs:
|
||||
docker-buildx:
|
||||
runs-on: ubuntu-20.04
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2.2.0
|
||||
|
||||
- name: Prepare
|
||||
id: prep
|
||||
run: |
|
||||
DOCKER_IMAGE=itzg/minecraft-server
|
||||
VERSION=edge
|
||||
if [[ $GITHUB_REF == refs/tags/* ]]; then
|
||||
VERSION=${GITHUB_REF#refs/tags/}
|
||||
fi
|
||||
if [[ $GITHUB_REF == refs/heads/* ]]; then
|
||||
VERSION=${GITHUB_REF#refs/heads/}
|
||||
if [[ $VERSION == master ]]; then
|
||||
VERSION=latest
|
||||
fi
|
||||
fi
|
||||
TAGS="${DOCKER_IMAGE}:${VERSION//\//-}"
|
||||
echo ::set-output name=tags::${TAGS}
|
||||
echo ::set-output name=cache_from::${TAGS}
|
||||
echo ::set-output name=version::${VERSION//\//-}
|
||||
echo ::set-output name=cache_version::${VERSION//\//-}
|
||||
|
||||
- name: Setup Docker Buildx
|
||||
uses: docker/setup-buildx-action@v1
|
||||
|
||||
- name: Cache Docker layers
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
path: /tmp/.buildx-cache
|
||||
key: ${{ runner.os }}-buildx-${{ steps.prep.outputs.cache_version }}-${{ github.sha }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-buildx-${{ steps.prep.outputs.cache_version }}-
|
||||
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v1
|
||||
|
||||
- name: Login to DockerHub
|
||||
uses: docker/login-action@v1
|
||||
with:
|
||||
username: ${{ secrets.DOCKER_USER }}
|
||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||
|
||||
- name: Build and push
|
||||
id: docker_build
|
||||
uses: docker/build-push-action@v2
|
||||
with:
|
||||
context: .
|
||||
file: ./Dockerfile
|
||||
platforms: linux/amd64,linux/arm/v7,linux/arm64
|
||||
push: ${{ github.event_name != 'pull_request' }}
|
||||
tags: ${{ steps.prep.outputs.tags }}
|
||||
# ensure latest base image is used
|
||||
pull: true
|
||||
cache-from: type=local,src=/tmp/.buildx-cache
|
||||
cache-to: type=local,dest=/tmp/.buildx-cache
|
||||
labels: |
|
||||
org.opencontainers.image.documentation=https://github.com/itzg/docker-minecraft-server
|
||||
org.opencontainers.image.source=https://github.com/itzg/docker-minecraft-server
|
||||
org.opencontainers.image.version=${{ steps.prep.outputs.version }}
|
||||
org.opencontainers.image.revision=${{ github.sha }}
|
||||
|
||||
- name: Image digest
|
||||
run: echo ${{ steps.docker_build.outputs.digest }}
|
||||
97
.github/workflows/main.yml
vendored
Normal file
97
.github/workflows/main.yml
vendored
Normal file
@@ -0,0 +1,97 @@
|
||||
name: Build and Publish
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
- java8
|
||||
- openj9
|
||||
- openj9-11
|
||||
- adopt11
|
||||
- test/*
|
||||
tags:
|
||||
- "[0-9]+.[0-9]+.[0-9]+"
|
||||
- "[0-9]+.[0-9]+.[0-9]+-java8"
|
||||
- "[0-9]+.[0-9]+.[0-9]+-openj9"
|
||||
- "[0-9]+.[0-9]+.[0-9]+-openj9-11"
|
||||
- "[0-9]+.[0-9]+.[0-9]+-openj9-nightly"
|
||||
- "[0-9]+.[0-9]+.[0-9]+-adopt11"
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: ubuntu-20.04
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- name: Run tests
|
||||
run: |
|
||||
tests/test.sh
|
||||
build:
|
||||
needs:
|
||||
- test
|
||||
runs-on: ubuntu-20.04
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- name: Prepare
|
||||
id: prep
|
||||
run: |
|
||||
DOCKER_IMAGE=itzg/minecraft-server
|
||||
VERSION=edge
|
||||
if [[ $GITHUB_REF == refs/tags/* ]]; then
|
||||
VERSION=${GITHUB_REF#refs/tags/}
|
||||
fi
|
||||
if [[ $GITHUB_REF == refs/heads/* ]]; then
|
||||
VERSION=${GITHUB_REF#refs/heads/}
|
||||
if [[ $VERSION == master ]]; then
|
||||
VERSION=latest
|
||||
fi
|
||||
fi
|
||||
TAGS="${DOCKER_IMAGE}:${VERSION//\//-}"
|
||||
echo ::set-output name=tags::${TAGS}
|
||||
echo ::set-output name=cache_from::${TAGS}
|
||||
echo ::set-output name=version::${VERSION//\//-}
|
||||
echo ::set-output name=cache_version::${VERSION//\//-}
|
||||
|
||||
- name: Setup Docker Buildx
|
||||
uses: docker/setup-buildx-action@v1
|
||||
|
||||
- name: Cache Docker layers
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
path: /tmp/.buildx-cache
|
||||
key: ${{ runner.os }}-buildx-${{ steps.prep.outputs.cache_version }}-${{ github.sha }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-buildx-${{ steps.prep.outputs.cache_version }}-
|
||||
${{ runner.os }}-buildx-
|
||||
|
||||
- name: Login to DockerHub
|
||||
uses: docker/login-action@v1
|
||||
with:
|
||||
username: ${{ secrets.DOCKER_USER }}
|
||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||
|
||||
- name: Build and push
|
||||
id: docker_build
|
||||
uses: docker/build-push-action@v2
|
||||
with:
|
||||
context: .
|
||||
file: ./Dockerfile
|
||||
# ensure latest base image is used
|
||||
pull: true
|
||||
# publish
|
||||
push: true
|
||||
# tags determined by prep step
|
||||
tags: ${{ steps.prep.outputs.tags }}
|
||||
cache-from: type=local,src=/tmp/.buildx-cache
|
||||
cache-to: type=local,dest=/tmp/.buildx-cache
|
||||
labels: |
|
||||
org.opencontainers.image.documentation=https://github.com/itzg/docker-minecraft-server
|
||||
org.opencontainers.image.version=${{ steps.prep.outputs.version }}
|
||||
org.opencontainers.image.source=https://github.com/itzg/docker-minecraft-server
|
||||
org.opencontainers.image.revision=${{ github.sha }}
|
||||
|
||||
- name: Image digest
|
||||
run: echo ${{ steps.docker_build.outputs.digest }}
|
||||
16
.github/workflows/pr.yml
vendored
Normal file
16
.github/workflows/pr.yml
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
name: Validate PR
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
branches: [ master ]
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- name: Run tests
|
||||
run: |
|
||||
tests/test.sh
|
||||
74
DEVELOPMENT.md
Normal file
74
DEVELOPMENT.md
Normal file
@@ -0,0 +1,74 @@
|
||||
## Adding a server type
|
||||
|
||||
Adding a new server `TYPE` can vary due to the complexity of obtaining and configuring each type; however, the addition of any server type includes at least the following steps:
|
||||
|
||||
1. Copy an existing "start-deploy*" script, such as [start-deployMohist](start-deployMohist) and rename it accordingly making sure to retain the "start-deploy" prefix
|
||||
2. Modify the type-specific behavior between the "start-utils" preamble and the hand-off to `start-finalSetupWorld` at the end of the script
|
||||
3. Develop and test the changes using the [iterative process described below](#iterative-script-development)
|
||||
4. Add a case-entry to the `case "${TYPE^^}"` in [start-configuration](start-configuration)
|
||||
5. Add a section to the [README](README.md). It is recommended to copy-modify an existing section to retain a similar wording and level of detail
|
||||
6. [Submit a pull request](https://github.com/itzg/docker-minecraft-server/pulls)
|
||||
|
||||
## Iterative script development
|
||||
|
||||
Individual scripts can be iteratively developed, debugged, and tested using the following procedure.
|
||||
|
||||
First, build a baseline of the image to include the packages needed by existing or new scripts:
|
||||
|
||||
```shell script
|
||||
docker build -t mc-dev .
|
||||
```
|
||||
|
||||
Using the baseline image, an interactive container can be started to iteratively run the scripts to be developed. By attaching the current workspace directory, you can use the local editor of your choice to iteratively modify scripts while using the container to run them.
|
||||
|
||||
```shell script
|
||||
docker run -it --rm -v ${PWD}:/scripts -e SCRIPTS=/scripts/ --entrypoint bash mc-dev
|
||||
```
|
||||
|
||||
From within the container you can run individual scripts via the attached `/scripts/` path; however, be sure to set any environment variables expected by the scripts by either `export`ing them manually:
|
||||
|
||||
```shell script
|
||||
export VANILLA_VERSION=1.12.2
|
||||
/scripts/start-magma
|
||||
```
|
||||
|
||||
...or pre-pending script execution:
|
||||
|
||||
```shell script
|
||||
VANILLA_VERSION=1.12.2 /scripts/start-magma
|
||||
```
|
||||
|
||||
> NOTE: You may want to temporarily add an `exit` statement near the end of your script to isolate execution to just the script you're developing.
|
||||
|
||||
## Multi-base-image variants
|
||||
|
||||
Several base-image variants are maintained in order to offer choices in JDK provider and version. The variants are maintained in their respective branches:
|
||||
- openj9
|
||||
- openj9-nightly
|
||||
- adopt11
|
||||
- adopt13
|
||||
- multiarch
|
||||
|
||||
The [docker-versions-create.sh](docker-versions-create.sh) script is configured with the branches to maintain and is used to merge changes from the master branch into the mulit-base variant branches. The script also manages git tagging the master branch along with the merged branches. So a typical use of the script would be like:
|
||||
|
||||
```shell script
|
||||
./docker-versions-create.sh -s -t 1.2.0
|
||||
```
|
||||
|
||||
> Most often the major version will be bumped unless a bug or hotfix needs to be published in which case the patch version should be incremented.
|
||||
|
||||
> The build and publishing of those branches and their tags is currently performed within Docker Hub.
|
||||
|
||||
## multiarch support
|
||||
|
||||
The [multiarch branch](https://github.com/itzg/docker-minecraft-server/tree/multiarch) supports running the image on amd64, arm64, and armv7 (aka RaspberryPi). Unlike the mainline branches, it is based on Ubuntu 18.04 since the openjdk package provided by Ubuntu includes full JIT support on all of the processor types.
|
||||
|
||||
The multiarch images are built and published by [a Github action](https://github.com/itzg/docker-minecraft-server/actions?query=workflow%3A%22Build+and+publish+multiarch%22), which [is configured in that branch](https://github.com/itzg/docker-minecraft-server/blob/multiarch/.github/workflows/build-multiarch.yml).
|
||||
|
||||
## Generating release notes
|
||||
|
||||
The following git command can be used to provide the bulk of release notes content:
|
||||
|
||||
```shell script
|
||||
git log --invert-grep --grep "^ci:" --grep "^misc:" --grep "^docs:" --pretty="- %s" 1.1.0..1.2.0
|
||||
```
|
||||
82
Dockerfile
82
Dockerfile
@@ -1,6 +1,6 @@
|
||||
FROM openjdk:8u212-jre-alpine
|
||||
FROM adoptopenjdk/openjdk11:alpine-jre
|
||||
|
||||
LABEL maintainer "itzg"
|
||||
LABEL org.opencontainers.image.authors="Geoff Bourne <itzgeoff@gmail.com>"
|
||||
|
||||
RUN apk add --no-cache -U \
|
||||
openssl \
|
||||
@@ -16,53 +16,73 @@ RUN apk add --no-cache -U \
|
||||
tzdata \
|
||||
rsync \
|
||||
nano \
|
||||
python python-dev py2-pip
|
||||
|
||||
RUN pip install mcstatus yq
|
||||
|
||||
HEALTHCHECK CMD mcstatus localhost:$SERVER_PORT ping
|
||||
sudo \
|
||||
knock \
|
||||
ttf-dejavu
|
||||
|
||||
RUN addgroup -g 1000 minecraft \
|
||||
&& adduser -Ss /bin/false -u 1000 -G minecraft -h /home/minecraft minecraft \
|
||||
&& mkdir -m 777 /data /mods /config /plugins \
|
||||
&& chown minecraft:minecraft /data /config /mods /plugins /home/minecraft
|
||||
&& mkdir -m 777 /data \
|
||||
&& chown minecraft:minecraft /data /home/minecraft
|
||||
|
||||
COPY files/sudoers* /etc/sudoers.d
|
||||
|
||||
EXPOSE 25565 25575
|
||||
|
||||
RUN echo 'hosts: files dns' > /etc/nsswitch.conf
|
||||
# hook into docker BuildKit --platform support
|
||||
# see https://docs.docker.com/engine/reference/builder/#automatic-platform-args-in-the-global-scope
|
||||
ARG TARGETOS=linux
|
||||
ARG TARGETARCH=amd64
|
||||
ARG TARGETVARIANT=""
|
||||
|
||||
ARG RESTIFY_VER=1.1.6
|
||||
ARG RCON_CLI_VER=1.4.6
|
||||
ARG MC_SERVER_RUNNER_VER=1.3.2
|
||||
ARG ARCH=amd64
|
||||
ARG EASY_ADD_VER=0.7.1
|
||||
ADD https://github.com/itzg/easy-add/releases/download/${EASY_ADD_VER}/easy-add_${TARGETOS}_${TARGETARCH}${TARGETVARIANT} /usr/bin/easy-add
|
||||
RUN chmod +x /usr/bin/easy-add
|
||||
|
||||
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
|
||||
RUN easy-add --var os=${TARGETOS} --var arch=${TARGETARCH}${TARGETVARIANT} \
|
||||
--var version=1.2.0 --var app=restify --file {{.app}} \
|
||||
--from https://github.com/itzg/{{.app}}/releases/download/{{.version}}/{{.app}}_{{.version}}_{{.os}}_{{.arch}}.tar.gz
|
||||
|
||||
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
|
||||
RUN easy-add --var os=${TARGETOS} --var arch=${TARGETARCH}${TARGETVARIANT} \
|
||||
--var version=1.4.7 --var app=rcon-cli --file {{.app}} \
|
||||
--from https://github.com/itzg/{{.app}}/releases/download/{{.version}}/{{.app}}_{{.version}}_{{.os}}_{{.arch}}.tar.gz
|
||||
|
||||
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
|
||||
RUN easy-add --var os=${TARGETOS} --var arch=${TARGETARCH}${TARGETVARIANT} \
|
||||
--var version=0.7.1 --var app=mc-monitor --file {{.app}} \
|
||||
--from https://github.com/itzg/{{.app}}/releases/download/{{.version}}/{{.app}}_{{.version}}_{{.os}}_{{.arch}}.tar.gz
|
||||
|
||||
COPY mcadmin.jq /usr/share
|
||||
RUN chmod +x /usr/local/bin/*
|
||||
RUN easy-add --var os=${TARGETOS} --var arch=${TARGETARCH}${TARGETVARIANT} \
|
||||
--var version=1.5.0 --var app=mc-server-runner --file {{.app}} \
|
||||
--from https://github.com/itzg/{{.app}}/releases/download/{{.version}}/{{.app}}_{{.version}}_{{.os}}_{{.arch}}.tar.gz
|
||||
|
||||
VOLUME ["/data","/mods","/config"]
|
||||
RUN easy-add --var os=${TARGETOS} --var arch=${TARGETARCH}${TARGETVARIANT} \
|
||||
--var version=0.1.1 --var app=maven-metadata-release --file {{.app}} \
|
||||
--from https://github.com/itzg/{{.app}}/releases/download/{{.version}}/{{.app}}_{{.version}}_{{.os}}_{{.arch}}.tar.gz
|
||||
|
||||
COPY mcstatus /usr/local/bin
|
||||
|
||||
VOLUME ["/data"]
|
||||
COPY server.properties /tmp/server.properties
|
||||
COPY log4j2.xml /tmp/log4j2.xml
|
||||
WORKDIR /data
|
||||
|
||||
ENTRYPOINT [ "/start" ]
|
||||
STOPSIGNAL SIGTERM
|
||||
|
||||
ENV UID=1000 GID=1000 \
|
||||
JVM_XX_OPTS="-XX:+UseG1GC" MEMORY="1G" \
|
||||
TYPE=VANILLA VERSION=LATEST FORGEVERSION=RECOMMENDED SPONGEBRANCH=STABLE SPONGEVERSION= FABRICVERSION=LATEST LEVEL=world \
|
||||
PVP=true DIFFICULTY=easy ENABLE_RCON=true RCON_PORT=25575 RCON_PASSWORD=minecraft \
|
||||
LEVEL_TYPE=DEFAULT GENERATOR_SETTINGS= WORLD= MODPACK= MODS= SERVER_PORT=25565 ONLINE_MODE=TRUE CONSOLE=true SERVER_NAME="Dedicated Server" \
|
||||
REPLACE_ENV_VARIABLES="FALSE" ENV_VARIABLE_PREFIX="CFG_"
|
||||
TYPE=VANILLA VERSION=LATEST \
|
||||
ENABLE_RCON=true RCON_PORT=25575 RCON_PASSWORD=minecraft \
|
||||
SERVER_PORT=25565 ONLINE_MODE=TRUE SERVER_NAME="Dedicated Server" \
|
||||
ENABLE_AUTOPAUSE=false AUTOPAUSE_TIMEOUT_EST=3600 AUTOPAUSE_TIMEOUT_KN=120 AUTOPAUSE_TIMEOUT_INIT=600 \
|
||||
AUTOPAUSE_PERIOD=10 AUTOPAUSE_KNOCK_INTERFACE=eth0
|
||||
|
||||
COPY start* /
|
||||
COPY health.sh /
|
||||
ADD files/autopause /autopause
|
||||
|
||||
RUN dos2unix /start* && chmod +x /start*
|
||||
RUN dos2unix /health.sh && chmod +x /health.sh
|
||||
RUN dos2unix /autopause/* && chmod +x /autopause/*.sh
|
||||
|
||||
ENTRYPOINT [ "/start" ]
|
||||
HEALTHCHECK --start-period=1m CMD /health.sh
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
manifest="itzg/minecraft-server:multiarch"
|
||||
|
||||
for t in latest rpi3 aarch64; do
|
||||
docker pull itzg/minecraft-server:$t
|
||||
done
|
||||
|
||||
docker manifest create --amend ${manifest} \
|
||||
itzg/minecraft-server:aarch64 \
|
||||
itzg/minecraft-server:latest \
|
||||
itzg/minecraft-server:rpi3
|
||||
|
||||
docker manifest annotate --os linux --arch amd64 ${manifest} itzg/minecraft-server:latest
|
||||
docker manifest annotate --os linux --arch arm64 ${manifest} itzg/minecraft-server:aarch64
|
||||
docker manifest annotate --os linux --arch arm --variant v7 ${manifest} itzg/minecraft-server:rpi3
|
||||
|
||||
docker manifest push ${manifest}
|
||||
@@ -10,19 +10,7 @@ services:
|
||||
- "mc:/data"
|
||||
environment:
|
||||
EULA: "TRUE"
|
||||
CONSOLE: "false"
|
||||
ENABLE_RCON: "true"
|
||||
RCON_PASSWORD: "testing"
|
||||
RCON_PORT: 28016
|
||||
restart: always
|
||||
rcon:
|
||||
image: itzg/rcon
|
||||
ports:
|
||||
- "4326:4326"
|
||||
- "4327:4327"
|
||||
volumes:
|
||||
- "rcon:/opt/rcon-web-admin/db"
|
||||
|
||||
volumes:
|
||||
mc:
|
||||
rcon:
|
||||
mc: {}
|
||||
134
docker-versions-create.sh
Executable file
134
docker-versions-create.sh
Executable file
@@ -0,0 +1,134 @@
|
||||
#!/bin/bash
|
||||
#set -x
|
||||
# Use this variable to indicate a list of branches that docker hub is watching
|
||||
branches_list=(
|
||||
'java8'
|
||||
'java8-multiarch'
|
||||
'openj9'
|
||||
'openj9-11'
|
||||
'adopt11'
|
||||
'java15'
|
||||
'java15-openj9'
|
||||
'multiarch'
|
||||
'multiarch-latest'
|
||||
)
|
||||
|
||||
function TrapExit {
|
||||
echo "Checking out back in master"
|
||||
git checkout master
|
||||
}
|
||||
|
||||
batchMode=false
|
||||
|
||||
while getopts "hbt:s" arg
|
||||
do
|
||||
case $arg in
|
||||
b)
|
||||
batchMode=true
|
||||
;;
|
||||
t)
|
||||
tag=${OPTARG}
|
||||
;;
|
||||
s)
|
||||
tagArgs="-s -m 'Signed during docker-versions-create"
|
||||
;;
|
||||
h)
|
||||
echo "
|
||||
Usage $0 [options]
|
||||
|
||||
Options:
|
||||
-b enable batch mode, which avoids interactive prompts and causes script to fail immediately
|
||||
when any merge fails
|
||||
-t TAG tag and push the current revision on master with the given tag
|
||||
and apply respective tags to each branch
|
||||
-s enable signed tags
|
||||
-h display this help and exit
|
||||
"
|
||||
exit
|
||||
;;
|
||||
*)
|
||||
echo "Unsupported arg $arg"
|
||||
exit 2
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
${batchMode} && echo "Using batch mode"
|
||||
|
||||
trap TrapExit EXIT SIGTERM
|
||||
|
||||
test -d ./.git || { echo ".git folder was not found. Please start this script from root directory of the project!";
|
||||
exit 1; }
|
||||
|
||||
# Making sure we are in master
|
||||
git checkout master
|
||||
git pull --all || { echo "Can't pull the repo!"; \
|
||||
exit 1; }
|
||||
if [[ $tag ]]; then
|
||||
git tag $tag
|
||||
git push origin $tag
|
||||
fi
|
||||
|
||||
git_branches=$(git branch -a)
|
||||
|
||||
for branch in "${branches_list[@]}"; do
|
||||
if [[ "$git_branches" != *"$branch"* ]]; then
|
||||
echo "Can't update $branch because I can't find it in the list of branches."
|
||||
exit 1
|
||||
else
|
||||
echo "Branch $branch found. Working with it."
|
||||
git checkout "$branch" || { echo "Can't checkout into the branch. Don't know the cause."; \
|
||||
exit 1; }
|
||||
proceed='False'
|
||||
while [[ "$proceed" == "False" ]]; do
|
||||
# Ensure local branch is aligned with remote since docker-versions-create may have been run elsewhere
|
||||
git pull
|
||||
|
||||
if git merge -m 'Auto-merging via docker-versions-create' master; then
|
||||
proceed="True"
|
||||
echo "Branch $branch updated to current master successfully"
|
||||
# pushing changes to remote for this branch
|
||||
git commit -m "Auto merge branch with master" -a
|
||||
# push may fail if remote doesn't have this branch yet. In this case - sending branch
|
||||
git push || git push -u origin "$branch" || { echo "Can't push changes to the origin."; exit 1; }
|
||||
if [[ $tag ]]; then
|
||||
git tag "$tag-$branch"
|
||||
git push origin "$tag-$branch"
|
||||
fi
|
||||
elif ${batchMode}; then
|
||||
status=$?
|
||||
echo "Git merge failed in batch mode"
|
||||
exit ${status}
|
||||
# and trap exit gets us back to master
|
||||
else
|
||||
cat<<EOL
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
Master merge in the branch $branch encountered an error!
|
||||
You may try to fix the error and merge again. (Commit changes)
|
||||
Or skip this branch merge completely.
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
EOL
|
||||
printf "Should we try again? (y):"
|
||||
read -r answer
|
||||
if [[ "$answer" == '' ]] || [[ "$answer" == 'y' ]] || [[ "$answer" == 'Y' ]]; then
|
||||
# If you use non-local editor or files are changed in repo
|
||||
cat <<EOL
|
||||
|
||||
The following commands may encounter an error!
|
||||
This is completely fine if the changes were made locally and remote branch doesn't know about them.
|
||||
|
||||
EOL
|
||||
# Updating branch from remote before trying again
|
||||
git checkout master
|
||||
git fetch --all
|
||||
git pull -a
|
||||
git checkout "$branch"
|
||||
continue
|
||||
else
|
||||
break
|
||||
fi
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
done
|
||||
BIN
docs/level-vs-world.drawio.png
Normal file
BIN
docs/level-vs-world.drawio.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 32 KiB |
BIN
docs/start-script-flow.drawio.png
Normal file
BIN
docs/start-script-flow.drawio.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 34 KiB |
3
examples/README.md
Normal file
3
examples/README.md
Normal file
@@ -0,0 +1,3 @@
|
||||
# Deployment Examples
|
||||
|
||||
This directory contains various deployment examples of the [itzg/minecraft-server](https://hub.docker.com/r/itzg/minecraft-server/) Docker image.
|
||||
@@ -1,3 +0,0 @@
|
||||
FROM itzg/minecraft-server
|
||||
|
||||
ENV TYPE=SPIGOT
|
||||
@@ -1,13 +0,0 @@
|
||||
plugins:
|
||||
worldedit:
|
||||
file: WorldEdit.jar
|
||||
url: https://dev.bukkit.org/projects/worldedit/files/latest
|
||||
FastAsyncWorldEdit:
|
||||
file: FastAsyncWorldEdit.jar
|
||||
url: https://empcraft.com/fawe/latest.php?bukkit
|
||||
worldguard:
|
||||
file: WorldGuard.jar
|
||||
url: https://dev.bukkit.org/projects/worldguard/files/latest
|
||||
citizens:
|
||||
file: Citizens.jar
|
||||
url: https://dev.bukkit.org/projects/citizens/files/latest
|
||||
18
examples/docker-compose-autopause.yml
Normal file
18
examples/docker-compose-autopause.yml
Normal file
@@ -0,0 +1,18 @@
|
||||
version: '3.8'
|
||||
|
||||
services:
|
||||
minecraft:
|
||||
image: itzg/minecraft-server
|
||||
ports:
|
||||
- "25565:25565"
|
||||
volumes:
|
||||
- "mc:/data"
|
||||
environment:
|
||||
EULA: "TRUE"
|
||||
ENABLE_AUTOPAUSE: "TRUE"
|
||||
OVERRIDE_SERVER_PROPERTIES: "TRUE"
|
||||
MAX_TICK_TIME: "-1"
|
||||
restart: always
|
||||
|
||||
volumes:
|
||||
mc: {}
|
||||
@@ -2,10 +2,12 @@ version: '3.2'
|
||||
|
||||
services:
|
||||
mc:
|
||||
image: itzg/minecraft-server
|
||||
image: itzg/minecraft-server:java8
|
||||
volumes:
|
||||
- ./modpacks:/modpacks:ro
|
||||
environment:
|
||||
EULA: "true"
|
||||
TYPE: FTB
|
||||
FTB_SERVER_MOD: https://minecraft.curseforge.com/projects/all-the-mods-expert-remastered/files/2493900/download
|
||||
TYPE: CURSEFORGE
|
||||
CF_SERVER_MOD: /modpacks/SkyFactory_4_Server_4.1.0.zip
|
||||
ports:
|
||||
- 25565:25565
|
||||
|
||||
23
examples/docker-compose-forge.yml
Normal file
23
examples/docker-compose-forge.yml
Normal file
@@ -0,0 +1,23 @@
|
||||
version: "3.7"
|
||||
|
||||
services:
|
||||
mc:
|
||||
image: itzg/minecraft-server:java8
|
||||
ports:
|
||||
# expose the Minecraft server port outside of container
|
||||
- 25565:25565
|
||||
environment:
|
||||
# REQUIRED for all types
|
||||
EULA: "TRUE"
|
||||
# Set server type (vs the default of vanilla)
|
||||
TYPE: FORGE
|
||||
volumes:
|
||||
# use a named, managed volume for data volume
|
||||
- mc_forge:/data
|
||||
# attach local host directory "mods" in same directory as this compose file
|
||||
# all mods in this directory get copied into /data/mods at startup
|
||||
- ./mods:/mods:ro
|
||||
|
||||
volumes:
|
||||
# declared the named volume, but use default/local storage engine
|
||||
mc_forge: {}
|
||||
@@ -1,16 +0,0 @@
|
||||
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:
|
||||
23
examples/docker-compose-ftba.yml
Normal file
23
examples/docker-compose-ftba.yml
Normal file
@@ -0,0 +1,23 @@
|
||||
version: "3.7"
|
||||
|
||||
services:
|
||||
mc:
|
||||
# FTBA support is only available in non-Alpine images
|
||||
image: itzg/minecraft-server:java8-multiarch
|
||||
ports:
|
||||
# expose the Minecraft server port outside of container
|
||||
- 25565:25565
|
||||
environment:
|
||||
# REQUIRED for all types
|
||||
EULA: "TRUE"
|
||||
# Set server type (vs the default of vanilla)
|
||||
TYPE: FTBA
|
||||
# Use Pack ID from https://ftb.neptunepowered.org/pack/ftb-presents-direwolf20-1-12/
|
||||
FTB_MODPACK_ID: "31"
|
||||
volumes:
|
||||
# use a named, managed volume for data volume
|
||||
- mc_ftb:/data
|
||||
|
||||
volumes:
|
||||
# declared the named volume, but use default/local storage engine
|
||||
mc_ftb: {}
|
||||
@@ -7,11 +7,12 @@ services:
|
||||
EULA: "true"
|
||||
TYPE: PAPER
|
||||
VERSION: 1.9.4
|
||||
command: --noconsole
|
||||
# needed for Paper versions before 1.14
|
||||
CONSOLE: "false"
|
||||
ports:
|
||||
- 25565:25565
|
||||
volumes:
|
||||
- mc-paper:/data
|
||||
|
||||
volumes:
|
||||
mc-paper:
|
||||
mc-paper:
|
||||
|
||||
12
examples/docker-compose-simple.yml
Normal file
12
examples/docker-compose-simple.yml
Normal file
@@ -0,0 +1,12 @@
|
||||
version: "3"
|
||||
|
||||
services:
|
||||
mc:
|
||||
image: itzg/minecraft-server
|
||||
ports:
|
||||
- 25565:25565
|
||||
environment:
|
||||
EULA: "TRUE"
|
||||
volumes:
|
||||
# attach the relative directory 'data' to the container's /data path
|
||||
- ./data:/data
|
||||
@@ -5,7 +5,7 @@ version: '3'
|
||||
|
||||
services:
|
||||
minecraft:
|
||||
image: itzg/minecraft-server
|
||||
image: itzg/minecraft-server:java8
|
||||
ports:
|
||||
- "25565:25565"
|
||||
volumes:
|
||||
|
||||
11
examples/docker-compose-world-download.yml
Normal file
11
examples/docker-compose-world-download.yml
Normal file
@@ -0,0 +1,11 @@
|
||||
version: "3.7"
|
||||
|
||||
services:
|
||||
mc:
|
||||
image: itzg/minecraft-server
|
||||
ports:
|
||||
- 25565:25565
|
||||
environment:
|
||||
EULA: "TRUE"
|
||||
VERSION: 1.7.2
|
||||
WORLD: https://www.minecraftmaps.com/survival-maps/cube-survival/download
|
||||
50
examples/k8s/using-statefulset.yml
Normal file
50
examples/k8s/using-statefulset.yml
Normal file
@@ -0,0 +1,50 @@
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: StatefulSet
|
||||
metadata:
|
||||
labels:
|
||||
app: example
|
||||
name: example
|
||||
spec:
|
||||
replicas: 1
|
||||
serviceName: example
|
||||
selector:
|
||||
matchLabels:
|
||||
app: example
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: example
|
||||
spec:
|
||||
containers:
|
||||
- name: mc
|
||||
image: itzg/minecraft-server
|
||||
env:
|
||||
- name: EULA
|
||||
value: "TRUE"
|
||||
volumeMounts:
|
||||
- mountPath: /data
|
||||
name: data
|
||||
volumeClaimTemplates:
|
||||
- metadata:
|
||||
name: data
|
||||
spec:
|
||||
accessModes:
|
||||
- ReadWriteOnce
|
||||
resources:
|
||||
requests:
|
||||
storage: 1Gi
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
labels:
|
||||
service: example
|
||||
name: example
|
||||
spec:
|
||||
ports:
|
||||
- port: 25565
|
||||
targetPort: 25565
|
||||
selector:
|
||||
app: example
|
||||
type: LoadBalancer
|
||||
1
examples/modpacks/.gitignore
vendored
Normal file
1
examples/modpacks/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
*.zip
|
||||
3
examples/modpacks/README.md
Normal file
3
examples/modpacks/README.md
Normal file
@@ -0,0 +1,3 @@
|
||||
Place server [modpacks downloaded from CurseForge](https://www.curseforge.com/minecraft/modpacks) in this directory.
|
||||
|
||||
The example [`docker-compose-curseforge.yml`](../docker-compose-curseforge.yml) references a modpack downloaded from <https://www.curseforge.com/minecraft/modpacks/skyfactory-4/files/2787018>.
|
||||
5
examples/paper-build-plugins/Dockerfile
Normal file
5
examples/paper-build-plugins/Dockerfile
Normal file
@@ -0,0 +1,5 @@
|
||||
FROM itzg/minecraft-server
|
||||
|
||||
ENV TYPE=PAPER
|
||||
|
||||
COPY plugins/*.jar /plugins/
|
||||
11
examples/paper-build-plugins/docker-compose.yml
Normal file
11
examples/paper-build-plugins/docker-compose.yml
Normal file
@@ -0,0 +1,11 @@
|
||||
version: '3.7'
|
||||
|
||||
services:
|
||||
mc:
|
||||
build: .
|
||||
environment:
|
||||
EULA: "TRUE"
|
||||
ports:
|
||||
- 25565:25565
|
||||
stdin_open: true
|
||||
tty: true
|
||||
1
examples/paper-build-plugins/plugins/.gitignore
vendored
Normal file
1
examples/paper-build-plugins/plugins/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
*.jar
|
||||
1
examples/paper-build-plugins/plugins/README.md
Normal file
1
examples/paper-build-plugins/plugins/README.md
Normal file
@@ -0,0 +1 @@
|
||||
Download Bukkit/Spigot plugin jars, such as [WorldEdit](https://dev.bukkit.org/projects/worldedit/files) and place them here. At image build time the `COPY` step will place those jars in `/plugins`. At container startup, the contents of `/plugins` are sync'ed into `/data/plugins` for use with Bukkit/Spigot/Paper server types.
|
||||
122
files/autopause/autopause-daemon.sh
Normal file
122
files/autopause/autopause-daemon.sh
Normal file
@@ -0,0 +1,122 @@
|
||||
#!/bin/bash
|
||||
|
||||
. /autopause/autopause-fcns.sh
|
||||
|
||||
. ${SCRIPTS:-/}start-utils
|
||||
|
||||
|
||||
autopause_error_loop() {
|
||||
logAutopause "Available interfaces within the docker container:"
|
||||
INTERFACES=$(echo /sys/class/net/*)
|
||||
INTERFACES=${INTERFACES//\/sys\/class\/net\//}
|
||||
logAutopause " $INTERFACES"
|
||||
logAutopause "Please set the environment variable AUTOPAUSE_KNOCK_INTERFACE to the interface that handles incoming connections."
|
||||
logAutopause "If unsure which interface to choose, run the ifconfig command in the container."
|
||||
logAutopause "Autopause failed to initialize. This log entry will be printed every 30 minutes."
|
||||
while :
|
||||
do
|
||||
sleep 1800
|
||||
logAutopause "Autopause failed to initialize."
|
||||
done
|
||||
}
|
||||
|
||||
# wait for java process to be started
|
||||
while :
|
||||
do
|
||||
if java_process_exists ; then
|
||||
break
|
||||
fi
|
||||
sleep 0.1
|
||||
done
|
||||
|
||||
# check for interface existence
|
||||
if [[ -z "$AUTOPAUSE_KNOCK_INTERFACE" ]] ; then
|
||||
logAutopause "AUTOPAUSE_KNOCK_INTERFACE variable must not be empty!"
|
||||
autopause_error_loop
|
||||
fi
|
||||
if ! [[ -d "/sys/class/net/$AUTOPAUSE_KNOCK_INTERFACE" ]] ; then
|
||||
logAutopause "Selected interface \"$AUTOPAUSE_KNOCK_INTERFACE\" does not exist!"
|
||||
autopause_error_loop
|
||||
fi
|
||||
|
||||
sudo /usr/sbin/knockd -c /tmp/knockd-config.cfg -d -i "$AUTOPAUSE_KNOCK_INTERFACE"
|
||||
if [ $? -ne 0 ] ; then
|
||||
logAutopause "Failed to start knockd daemon."
|
||||
logAutopause "Probable cause: Unable to attach to interface \"$AUTOPAUSE_KNOCK_INTERFACE\"."
|
||||
autopause_error_loop
|
||||
fi
|
||||
|
||||
STATE=INIT
|
||||
|
||||
while :
|
||||
do
|
||||
case X$STATE in
|
||||
XINIT)
|
||||
# Server startup
|
||||
if mc_server_listening ; then
|
||||
TIME_THRESH=$(($(current_uptime)+$AUTOPAUSE_TIMEOUT_INIT))
|
||||
logAutopause "MC Server listening for connections - stopping in $AUTOPAUSE_TIMEOUT_INIT seconds"
|
||||
STATE=K
|
||||
fi
|
||||
;;
|
||||
XK)
|
||||
# Knocked
|
||||
if java_clients_connected ; then
|
||||
logAutopause "Client connected - waiting for disconnect"
|
||||
STATE=E
|
||||
else
|
||||
if [[ $(current_uptime) -ge $TIME_THRESH ]] ; then
|
||||
logAutopause "No client connected since startup / knocked - stopping"
|
||||
/autopause/pause.sh
|
||||
STATE=S
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
XE)
|
||||
# Established
|
||||
if ! java_clients_connected ; then
|
||||
TIME_THRESH=$(($(current_uptime)+$AUTOPAUSE_TIMEOUT_EST))
|
||||
logAutopause "All clients disconnected - stopping in $AUTOPAUSE_TIMEOUT_EST seconds"
|
||||
STATE=I
|
||||
fi
|
||||
;;
|
||||
XI)
|
||||
# Idle
|
||||
if java_clients_connected ; then
|
||||
logAutopause "Client reconnected - waiting for disconnect"
|
||||
STATE=E
|
||||
else
|
||||
if [[ $(current_uptime) -ge $TIME_THRESH ]] ; then
|
||||
logAutopause "No client reconnected - stopping"
|
||||
/autopause/pause.sh
|
||||
STATE=S
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
XS)
|
||||
# Stopped
|
||||
if rcon_client_exists ; then
|
||||
/autopause/resume.sh
|
||||
fi
|
||||
if java_running ; then
|
||||
if java_clients_connected ; then
|
||||
logAutopause "Client connected - waiting for disconnect"
|
||||
STATE=E
|
||||
else
|
||||
TIME_THRESH=$(($(current_uptime)+$AUTOPAUSE_TIMEOUT_KN))
|
||||
logAutopause "Server was knocked - waiting for clients or timeout"
|
||||
STATE=K
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
logAutopause "Error: invalid state: $STATE"
|
||||
;;
|
||||
esac
|
||||
if [[ "$STATE" == "S" ]] ; then
|
||||
# before rcon times out
|
||||
sleep 2
|
||||
else
|
||||
sleep $AUTOPAUSE_PERIOD
|
||||
fi
|
||||
done
|
||||
42
files/autopause/autopause-fcns.sh
Normal file
42
files/autopause/autopause-fcns.sh
Normal file
@@ -0,0 +1,42 @@
|
||||
#!/bin/bash
|
||||
|
||||
current_uptime() {
|
||||
echo $(awk '{print $1}' /proc/uptime | cut -d . -f 1)
|
||||
}
|
||||
|
||||
java_running() {
|
||||
[[ $( ps -a -o stat,comm | grep 'java' | awk '{ print $1 }') =~ ^S.*$ ]]
|
||||
}
|
||||
|
||||
java_process_exists() {
|
||||
[[ -n "$(ps -a -o comm | grep 'java')" ]]
|
||||
}
|
||||
|
||||
rcon_client_exists() {
|
||||
[[ -n "$(ps -a -o comm | grep 'rcon-cli')" ]]
|
||||
}
|
||||
|
||||
mc_server_listening() {
|
||||
[[ -n $(netstat -tln | grep -e "0.0.0.0:$SERVER_PORT" -e ":::$SERVER_PORT" | grep LISTEN) ]]
|
||||
}
|
||||
|
||||
java_clients_connected() {
|
||||
local connections
|
||||
connections=$(netstat -tn | grep ":$SERVER_PORT" | grep ESTABLISHED)
|
||||
if [[ -z "$connections" ]] ; then
|
||||
return 1
|
||||
fi
|
||||
IFS=$'\n'
|
||||
connections=($connections)
|
||||
unset IFS
|
||||
# check that at least one external address is not localhost
|
||||
# remember, that the host network mode does not work with autopause because of the knockd utility
|
||||
for (( i=0; i<${#connections[@]}; i++ ))
|
||||
do
|
||||
if [[ ! $(echo "${connections[$i]}" | awk '{print $5}') =~ ^localhost$|^127(?:\.[0-9]+){0,2}\.[0-9]+$|^(?:0*\:)*?:?0*1$ ]] ; then
|
||||
# not localhost
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
return 1
|
||||
}
|
||||
12
files/autopause/knockd-config.cfg
Normal file
12
files/autopause/knockd-config.cfg
Normal file
@@ -0,0 +1,12 @@
|
||||
[options]
|
||||
logfile = /dev/null
|
||||
[unpauseMCServer-server]
|
||||
sequence = 25565
|
||||
seq_timeout = 1
|
||||
command = /sbin/su-exec minecraft:minecraft /autopause/resume.sh
|
||||
tcpflags = syn
|
||||
[unpauseMCServer-rcon]
|
||||
sequence = 25575
|
||||
seq_timeout = 1
|
||||
command = /sbin/su-exec minecraft:minecraft /autopause/resume.sh
|
||||
tcpflags = syn
|
||||
21
files/autopause/pause.sh
Executable file
21
files/autopause/pause.sh
Executable file
@@ -0,0 +1,21 @@
|
||||
#!/bin/bash
|
||||
|
||||
. /start-utils
|
||||
|
||||
if [[ $( ps -a -o stat,comm | grep 'java' | awk '{ print $1 }') =~ ^S.*$ ]] ; then
|
||||
# save world
|
||||
rcon-cli save-all >/dev/null
|
||||
|
||||
# wait until mc-monitor is no longer connected to the server
|
||||
while :
|
||||
do
|
||||
if [[ -z "$(netstat -nt | grep "127.0.0.1:$SERVER_PORT" | grep 'ESTABLISHED')" ]]; then
|
||||
break
|
||||
fi
|
||||
sleep 0.1
|
||||
done
|
||||
|
||||
# finally pause the process
|
||||
logAutopauseAction "Pausing Java process"
|
||||
pkill -STOP java
|
||||
fi
|
||||
8
files/autopause/resume.sh
Executable file
8
files/autopause/resume.sh
Executable file
@@ -0,0 +1,8 @@
|
||||
#!/bin/bash
|
||||
|
||||
. /start-utils
|
||||
|
||||
if [[ $( ps -a -o stat,comm | grep 'java' | awk '{ print $1 }') =~ ^T.*$ ]] ; then
|
||||
logAutopauseAction "Knocked, resuming Java process"
|
||||
pkill -CONT java
|
||||
fi
|
||||
2
files/sudoers-mc
Normal file
2
files/sudoers-mc
Normal file
@@ -0,0 +1,2 @@
|
||||
%minecraft ALL=(ALL) NOPASSWD:/usr/bin/pkill
|
||||
%minecraft ALL=(ALL) NOPASSWD:/usr/sbin/knockd
|
||||
14
health.sh
Normal file
14
health.sh
Normal file
@@ -0,0 +1,14 @@
|
||||
#!/bin/bash
|
||||
|
||||
. ${SCRIPTS:-/}start-utils
|
||||
|
||||
if isTrue "${DISABLE_HEALTHCHECK}"; then
|
||||
echo "Healthcheck disabled"
|
||||
exit 0
|
||||
elif isTrue "${ENABLE_AUTOPAUSE}" && [[ "$( ps -a -o stat,comm | grep 'java' | awk '{ print $1 }')" =~ ^T.*$ ]]; then
|
||||
echo "Java process suspended by Autopause function"
|
||||
exit 0
|
||||
else
|
||||
mc-monitor status --host localhost --port $SERVER_PORT
|
||||
exit $?
|
||||
fi
|
||||
34
log4j2.xml
Normal file
34
log4j2.xml
Normal file
@@ -0,0 +1,34 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Configuration status="WARN" packages="com.mojang.util">
|
||||
<Appenders>
|
||||
<Console name="SysOut" target="SYSTEM_OUT">
|
||||
<PatternLayout pattern="[%d{HH:mm:ss}] [%t/%level]: %msg%n" />
|
||||
</Console>
|
||||
<Queue name="ServerGuiConsole">
|
||||
<PatternLayout pattern="[%d{HH:mm:ss} %level]: %msg%n" />
|
||||
</Queue>
|
||||
<RollingRandomAccessFile name="File" fileName="logs/latest.log" filePattern="logs/%d{yyyy-MM-dd}-%i.log.gz">
|
||||
<PatternLayout pattern="[%d{HH:mm:ss}] [%t/%level]: %msg%n" />
|
||||
<Policies>
|
||||
<TimeBasedTriggeringPolicy />
|
||||
<OnStartupTriggeringPolicy />
|
||||
</Policies>
|
||||
<DefaultRolloverStrategy>
|
||||
<Delete basePath="logs">
|
||||
<IfFileName glob="*.log.gz" />
|
||||
<IfLastModified age="7d" />
|
||||
</Delete>
|
||||
</DefaultRolloverStrategy>
|
||||
</RollingRandomAccessFile>
|
||||
</Appenders>
|
||||
<Loggers>
|
||||
<Root level="info">
|
||||
<filters>
|
||||
<MarkerFilter marker="NETWORK_PACKETS" onMatch="DENY" onMismatch="NEUTRAL" />
|
||||
</filters>
|
||||
<AppenderRef ref="SysOut"/>
|
||||
<AppenderRef ref="File"/>
|
||||
<AppenderRef ref="ServerGuiConsole"/>
|
||||
</Root>
|
||||
</Loggers>
|
||||
</Configuration>
|
||||
@@ -1,7 +0,0 @@
|
||||
.[] |
|
||||
select(.elements | length > 1) |
|
||||
select(.elements[].elements[] | select(.class == "version" and .text == $version)) |
|
||||
.elements[].elements[] |
|
||||
select(.class|contains("server-jar")) |
|
||||
.elements[] | select(.name="a") |
|
||||
.href
|
||||
18
mcstatus
Executable file
18
mcstatus
Executable file
@@ -0,0 +1,18 @@
|
||||
#!/bin/bash
|
||||
|
||||
echo "WARNING: mcstatus is deprecated; calling mc-monitor instead"
|
||||
|
||||
##### mcstatus shim for mc-monitor
|
||||
# handles translating calls to
|
||||
# mcstatus (host:port) (command)
|
||||
# where the actual command is ignore, but is typically ping or status
|
||||
|
||||
addr="$1"
|
||||
|
||||
IFS=':'
|
||||
read -a parts <<< "${addr}"
|
||||
if [[ ${#parts[*]} -gt 1 ]]; then
|
||||
exec mc-monitor status --host ${parts[0]} --port ${parts[1]}
|
||||
else
|
||||
exec mc-monitor status --host ${parts[0]}
|
||||
fi
|
||||
@@ -22,6 +22,7 @@ snooper-enabled=true
|
||||
texture-pack=
|
||||
online-mode=true
|
||||
resource-pack=
|
||||
resource-pack-sha1=
|
||||
pvp=true
|
||||
difficulty=1
|
||||
enable-command-block=true
|
||||
@@ -36,3 +37,15 @@ motd=A Minecraft Server powered by Docker
|
||||
generator-settings=
|
||||
rcon.password=
|
||||
max-world-size=29999984
|
||||
broadcast-console-to-ops=true
|
||||
broadcast-rcon-to-ops=true
|
||||
enable-jmx-monitoring=false
|
||||
sync-chunk-writes=true
|
||||
enable-status=true
|
||||
entity-broadcast-range-percentage=100
|
||||
function-permission-level=2
|
||||
network-compression-threshold=256
|
||||
op-permission-level=4
|
||||
prevent-proxy-connections=false
|
||||
use-native-transport=true
|
||||
enforce-whitelist=false
|
||||
|
||||
40
start
40
start
@@ -1,22 +1,46 @@
|
||||
#!/bin/bash
|
||||
|
||||
. ${SCRIPTS:-/}start-utils
|
||||
|
||||
umask 0002
|
||||
chmod g+w /data
|
||||
|
||||
if [ $(id -u) = 0 ]; then
|
||||
if [[ -v UID && $UID != $(id -u) ]]; then
|
||||
usermod -u $UID minecraft
|
||||
if ! isTrue "${SKIP_SUDO:-false}" && [ $(id -u) = 0 ]; then
|
||||
runAsUser=minecraft
|
||||
runAsGroup=minecraft
|
||||
|
||||
if [[ -v UID ]]; then
|
||||
if [[ $UID != 0 ]]; then
|
||||
if [[ $UID != $(id -u minecraft) ]]; then
|
||||
log "Changing uid of minecraft to $UID"
|
||||
usermod -u $UID minecraft
|
||||
fi
|
||||
else
|
||||
runAsUser=root
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ -v GID ]]; then
|
||||
groupmod -o -g $GID minecraft
|
||||
if [[ $GID != 0 ]]; then
|
||||
if [[ $GID != $(id -g minecraft) ]]; then
|
||||
log "Changing gid of minecraft to $GID"
|
||||
groupmod -o -g $GID minecraft
|
||||
fi
|
||||
else
|
||||
runAsGroup=root
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ $(stat -c "%u" /data) != $UID ]]; then
|
||||
echo "Changing ownership of /data to $UID ..."
|
||||
chown -R minecraft:minecraft /data
|
||||
log "Changing ownership of /data to $UID ..."
|
||||
chown -R ${runAsUser}:${runAsGroup} /data
|
||||
fi
|
||||
|
||||
exec su-exec minecraft:minecraft /start-configuration $@
|
||||
if [[ ${SKIP_NSSWITCH_CONF^^} != TRUE ]]; then
|
||||
echo 'hosts: files dns' > /etc/nsswitch.conf
|
||||
fi
|
||||
|
||||
exec su-exec ${runAsUser}:${runAsGroup} ${SCRIPTS:-/}start-configuration $@
|
||||
else
|
||||
exec /start-configuration $@
|
||||
exec ${SCRIPTS:-/}start-configuration $@
|
||||
fi
|
||||
|
||||
67
start-autopause
Executable file
67
start-autopause
Executable file
@@ -0,0 +1,67 @@
|
||||
#!/bin/bash
|
||||
|
||||
. ${SCRIPTS:-/}start-utils
|
||||
|
||||
log "Autopause functionality enabled"
|
||||
|
||||
cp /autopause/knockd-config.cfg /tmp/knockd-config.cfg
|
||||
|
||||
# update server port to listen to
|
||||
regseq="^\s*sequence\s*=\s*$SERVER_PORT\s*$"
|
||||
linenum=$(grep -nm1 sequence /tmp/knockd-config.cfg | cut -d : -f 1 | tail -n1)
|
||||
if ! [[ $(awk "NR==$linenum" /tmp/knockd-config.cfg) =~ $regseq ]]; then
|
||||
sed -i "${linenum}s/sequence.*/sequence = $SERVER_PORT/" /tmp/knockd-config.cfg
|
||||
log "Updated server port in knockd config"
|
||||
fi
|
||||
# update rcon port to listen to
|
||||
regseq="^\s*sequence\s*=\s*$RCON_PORT\s*$"
|
||||
linenum=$(grep -nm2 sequence /tmp/knockd-config.cfg | cut -d : -f 1 | tail -n1)
|
||||
if ! [[ $(awk "NR==$linenum" /tmp/knockd-config.cfg) =~ $regseq ]]; then
|
||||
sed -i "${linenum}s/sequence.*/sequence = $RCON_PORT/" /tmp/knockd-config.cfg
|
||||
log "Updated rcon port in knockd config"
|
||||
fi
|
||||
|
||||
if ! [[ $AUTOPAUSE_PERIOD =~ ^[0-9]+$ ]]; then
|
||||
AUTOPAUSE_PERIOD=10
|
||||
export AUTOPAUSE_PERIOD
|
||||
log "Warning: AUTOPAUSE_PERIOD is not numeric, set to 10 (seconds)"
|
||||
fi
|
||||
if [ "$AUTOPAUSE_PERIOD" -eq "0" ] ; then
|
||||
AUTOPAUSE_PERIOD=10
|
||||
export AUTOPAUSE_PERIOD
|
||||
log "Warning: AUTOPAUSE_PERIOD must not be 0, set to 10 (seconds)"
|
||||
fi
|
||||
if ! [[ $AUTOPAUSE_TIMEOUT_KN =~ ^[0-9]+$ ]] ; then
|
||||
AUTOPAUSE_TIMEOUT_KN=120
|
||||
export AUTOPAUSE_TIMEOUT_KN
|
||||
log "Warning: AUTOPAUSE_TIMEOUT_KN is not numeric, set to 120 (seconds)"
|
||||
fi
|
||||
if ! [[ $AUTOPAUSE_TIMEOUT_EST =~ ^[0-9]+$ ]] ; then
|
||||
AUTOPAUSE_TIMEOUT_EST=3600
|
||||
export AUTOPAUSE_TIMEOUT_EST
|
||||
log "Warning: AUTOPAUSE_TIMEOUT_EST is not numeric, set to 3600 (seconds)"
|
||||
fi
|
||||
if ! [[ $AUTOPAUSE_TIMEOUT_INIT =~ ^[0-9]+$ ]] ; then
|
||||
AUTOPAUSE_TIMEOUT_INIT=600
|
||||
export AUTOPAUSE_TIMEOUT_INIT
|
||||
log "Warning: AUTOPAUSE_TIMEOUT_INIT is not numeric, set to 600 (seconds)"
|
||||
fi
|
||||
if [[ "$AUTOPAUSE_KNOCK_INTERFACE" == "lo" ]] ; then
|
||||
log "Warning: AUTOPAUSE_KNOCK_INTERFACE is set to the local loopback interface."
|
||||
log " This is not advisable, as incoming connections are likely not picked up there."
|
||||
log " Continuing with this setting."
|
||||
fi
|
||||
|
||||
if [[ -n "$MAX_TICK_TIME" && "$MAX_TICK_TIME" != "-1" ]] ; then
|
||||
log "Warning: MAX_TICK_TIME is non-default, for autopause to work properly, this check should be disabled (-1 for versions >= 1.8.1)"
|
||||
elif [[ -z "$MAX_TICK_TIME" ]] ; then
|
||||
if versionLessThan 1.8.1; then
|
||||
# 10 years
|
||||
MAX_TICK_TIME=315360000000
|
||||
else
|
||||
MAX_TICK_TIME=-1
|
||||
fi
|
||||
export MAX_TICK_TIME
|
||||
fi
|
||||
|
||||
/autopause/autopause-daemon.sh &
|
||||
@@ -1,4 +1,12 @@
|
||||
#!/bin/bash
|
||||
set -euo pipefail
|
||||
IFS=$'\n\t'
|
||||
|
||||
. ${SCRIPTS:-/}start-utils
|
||||
|
||||
: ${EULA:=}
|
||||
: ${PROXY:=}
|
||||
: ${RCON_PASSWORD_FILE:=}
|
||||
|
||||
shopt -s nullglob
|
||||
|
||||
@@ -6,28 +14,24 @@ shopt -s nullglob
|
||||
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 ""
|
||||
if ! isTrue "$EULA"; then
|
||||
log ""
|
||||
log "Please accept the Minecraft EULA at"
|
||||
log " https://account.mojang.com/documents/minecraft_eula"
|
||||
log "by adding the following immediately after 'docker run':"
|
||||
log " -e EULA=TRUE"
|
||||
log ""
|
||||
exit 1
|
||||
fi
|
||||
|
||||
writeEula
|
||||
fi
|
||||
|
||||
echo "Running as uid=$(id -u) gid=$(id -g) with /data as '$(ls -lnd /data)'"
|
||||
|
||||
log "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)"
|
||||
log "ERROR: /data doesn't seem to be writable. Please make sure attached directory is writable by uid=$(id -u)"
|
||||
exit 2
|
||||
fi
|
||||
|
||||
@@ -36,70 +40,139 @@ rm /data/.verify_access || true
|
||||
if [[ $PROXY ]]; then
|
||||
export http_proxy="$PROXY"
|
||||
export https_proxy="$PROXY"
|
||||
echo "INFO: Giving proxy time to startup..."
|
||||
export JAVA_TOOL_OPTIONS+="-Djava.net.useSystemProxies=true"
|
||||
log "INFO: Giving proxy time to startup..."
|
||||
sleep 5
|
||||
fi
|
||||
|
||||
export SERVER_PROPERTIES=/data/server.properties
|
||||
if [[ $RCON_PASSWORD_FILE ]]; then
|
||||
log ""
|
||||
if [ ! -e ${RCON_PASSWORD_FILE} ]; then
|
||||
log "Initial RCON password file ${RCON_PASSWORD_FILE} does not seems to exist."
|
||||
log "Please ensure your configuration."
|
||||
log "If you are using Docker Secrets feature, please check this for further information: "
|
||||
log " https://docs.docker.com/engine/swarm/secrets"
|
||||
log ""
|
||||
exit 1
|
||||
else
|
||||
RCON_PASSWORD=$(cat ${RCON_PASSWORD_FILE})
|
||||
export RCON_PASSWORD
|
||||
fi
|
||||
log ""
|
||||
fi
|
||||
|
||||
if ! which java > /dev/null; then
|
||||
log "Fixing PATH to include java"
|
||||
PATH="${PATH}:/opt/java/openjdk/bin"
|
||||
fi
|
||||
|
||||
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'`
|
||||
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
|
||||
VANILLA_VERSION=$(curl -fsSL $VERSIONS_JSON | jq -r '.latest.snapshot')
|
||||
;;
|
||||
*)
|
||||
export VANILLA_VERSION=`curl -fsSL $VERSIONS_JSON | jq -r '.latest.release'`
|
||||
VANILLA_VERSION=$VERSION
|
||||
;;
|
||||
esac
|
||||
export VANILLA_VERSION
|
||||
log "Resolved version given ${VERSION} into ${VANILLA_VERSION}"
|
||||
|
||||
cd /data
|
||||
cd /data || exit 1
|
||||
|
||||
export ORIGINAL_TYPE=${TYPE^^}
|
||||
|
||||
echo "Checking type information."
|
||||
if isTrue "${ENABLE_AUTOPAUSE}"; then
|
||||
${SCRIPTS:-/}start-autopause
|
||||
fi
|
||||
|
||||
log "Resolving type given ${TYPE}"
|
||||
case "${TYPE^^}" in
|
||||
*BUKKIT|SPIGOT)
|
||||
exec /start-deployBukkitSpigot $@
|
||||
exec ${SCRIPTS:-/}start-deployBukkitSpigot "$@"
|
||||
;;
|
||||
|
||||
PAPER)
|
||||
exec /start-deployPaper $@
|
||||
exec ${SCRIPTS:-/}start-deployPaper "$@"
|
||||
;;
|
||||
|
||||
TUINITY)
|
||||
exec ${SCRIPTS:-/}start-deployTuinity "$@"
|
||||
;;
|
||||
|
||||
FORGE)
|
||||
exec /start-deployForge $@
|
||||
log "**********************************************************************"
|
||||
log "WARNING: The image tag itzg/minecraft-server:java8 is recommended"
|
||||
log " since some mods require Java 8"
|
||||
log " Exception traces reporting ClassCastException: class jdk.internal.loader.ClassLoaders\$AppClassLoader"
|
||||
log " can be fixed with java8"
|
||||
log "**********************************************************************"
|
||||
exec ${SCRIPTS:-/}start-deployForge "$@"
|
||||
;;
|
||||
|
||||
FABRIC)
|
||||
exec /start-deployFabric $@
|
||||
exec ${SCRIPTS:-/}start-deployFabric "$@"
|
||||
;;
|
||||
|
||||
FTB|CURSEFORGE)
|
||||
exec /start-deployFTB $@
|
||||
log "**********************************************************************"
|
||||
log "WARNING: The image tag itzg/minecraft-server:java8 is recommended"
|
||||
log " since some mods require Java 8"
|
||||
log " Exception traces reporting ClassCastException: class jdk.internal.loader.ClassLoaders\$AppClassLoader"
|
||||
log " can be fixed with java8"
|
||||
log "**********************************************************************"
|
||||
exec ${SCRIPTS:-/}start-deployCF "$@"
|
||||
;;
|
||||
|
||||
VANILLA)
|
||||
exec /start-deployVanilla $@
|
||||
exec ${SCRIPTS:-/}start-deployVanilla "$@"
|
||||
;;
|
||||
|
||||
SPONGEVANILLA)
|
||||
exec /start-deploySpongeVanilla $@
|
||||
exec ${SCRIPTS:-/}start-deploySpongeVanilla "$@"
|
||||
;;
|
||||
|
||||
CUSTOM)
|
||||
exec /start-deployCustom $@
|
||||
exec ${SCRIPTS:-/}start-deployCustom "$@"
|
||||
;;
|
||||
|
||||
CURSE_INSTANCE)
|
||||
exec ${SCRIPTS:-/}start-validateCurseInstance "$@"
|
||||
;;
|
||||
|
||||
MAGMA)
|
||||
exec ${SCRIPTS:-/}start-deployMagma "$@"
|
||||
;;
|
||||
|
||||
MOHIST)
|
||||
exec ${SCRIPTS:-/}start-deployMohist "$@"
|
||||
;;
|
||||
|
||||
CATSERVER)
|
||||
exec ${SCRIPTS:-/}start-deployCatserver "$@"
|
||||
;;
|
||||
|
||||
PURPUR)
|
||||
exec ${SCRIPTS:-/}start-deployPurpur "$@"
|
||||
;;
|
||||
|
||||
YATOPIA)
|
||||
exec ${SCRIPTS:-/}start-deployYatopia "$@"
|
||||
;;
|
||||
|
||||
AIRPLANE)
|
||||
exec ${SCRIPTS:-/}start-deployAirplane "$@"
|
||||
;;
|
||||
|
||||
*)
|
||||
echo "Invalid type: '$TYPE'"
|
||||
echo "Must be: VANILLA, FORGE, BUKKIT, SPIGOT, PAPER, FTB, CURSEFORGE, SPONGEVANILLA"
|
||||
log "Invalid type: '$TYPE'"
|
||||
log "Must be: VANILLA, FORGE, BUKKIT, SPIGOT, PAPER, FTBA (multiarch-only),"
|
||||
log " CURSE_INSTANCE, CURSEFORGE, SPONGEVANILLA, TUINITY, PURPUR"
|
||||
log " CUSTOM, MAGMA, MOHIST, CATSERVER, YATOPIA, AIRPLANE"
|
||||
exit 1
|
||||
;;
|
||||
|
||||
|
||||
37
start-deployAirplane
Normal file
37
start-deployAirplane
Normal file
@@ -0,0 +1,37 @@
|
||||
#!/bin/bash
|
||||
set -euo pipefail
|
||||
IFS=$'\n\t'
|
||||
|
||||
. ${SCRIPTS:-/}start-utils
|
||||
isDebugging && set -x
|
||||
|
||||
JAVA_VER=$(java -version 2>&1 | head -1 | cut -d'"' -f2 | sed '/^1\./s///' | cut -d'.' -f1)
|
||||
|
||||
if [ "${JAVA_VER}" != "8" ] && [ "${JAVA_VER}" != "11" ]; then
|
||||
log "ERROR: Airplane server type only supports Java versions 8 and 11"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ "${VERSION}" != "LATEST" ]; then
|
||||
log "ERROR: Airplane server type only supports VERSION=LATEST"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
export SERVER=airplane-${VANILLA_VERSION}-jdk${JAVA_VER}.jar
|
||||
|
||||
if [ ! -f "$SERVER" ] || [ -n "$FORCE_REDOWNLOAD" ]; then
|
||||
downloadUrl="https://dl.airplane.gg/latest/Airplane-JDK${JAVA_VER}/launcher-airplane.jar"
|
||||
log "Downloading Airplane from $downloadUrl ..."
|
||||
curl -fsSL -o "$SERVER" "$downloadUrl"
|
||||
if [ ! -f "$SERVER" ]; then
|
||||
log "ERROR: failed to download from $downloadUrl (status=$?)"
|
||||
exit 3
|
||||
fi
|
||||
fi
|
||||
|
||||
# Normalize on Spigot for later operations
|
||||
export TYPE=SPIGOT
|
||||
export SKIP_LOG4J_CONFIG=true
|
||||
|
||||
# Continue to Final Setup
|
||||
exec ${SCRIPTS:-/}start-finalSetupWorld $@
|
||||
@@ -1,24 +1,45 @@
|
||||
#!/bin/bash
|
||||
|
||||
. ${SCRIPTS:-/}start-utils
|
||||
isDebugging && set -x
|
||||
|
||||
set -e
|
||||
|
||||
function buildSpigotFromSource {
|
||||
echo "Building Spigot $VANILLA_VERSION from source, might take a while, get some coffee"
|
||||
if [[ ${TYPE^^} = *BUKKIT ]] && ! versionLessThan "1.14"; then
|
||||
log "ERR craftbukkit build is only supported for versions less than 1.14"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
log "Building Spigot $VANILLA_VERSION from source, might take a while, get some coffee"
|
||||
rm -rf /data/temp
|
||||
mkdir /data/temp
|
||||
cd /data/temp
|
||||
|
||||
jvmOpts="-Xms${INIT_MEMORY:-$MEMORY} -Xmx${MAX_MEMORY:-$MEMORY}"
|
||||
|
||||
logn ''
|
||||
curl -sSL -o /data/temp/BuildTools.jar https://hub.spigotmc.org/jenkins/job/BuildTools/lastSuccessfulBuild/artifact/target/BuildTools.jar && \
|
||||
java $jvmOpts -jar /data/temp/BuildTools.jar --rev $VANILLA_VERSION 2>&1 |tee /data/spigot_build.log| while read l; do echo -n .; done; echo "done"
|
||||
if ! mv spigot-*.jar /data/spigot_server.jar; then
|
||||
echo "ERR failed to build Spigot"
|
||||
cat /data/spigot_build.log
|
||||
exit 1
|
||||
fi
|
||||
mv craftbukkit-*.jar /data/craftbukkit_server.jar
|
||||
echo "Cleaning up"
|
||||
java $jvmOpts -jar /data/temp/BuildTools.jar --rev $VANILLA_VERSION 2>&1 |tee /data/spigot_build.log| while read l; do echo -n .; done; log "done"
|
||||
|
||||
case ${TYPE^^} in
|
||||
SPIGOT)
|
||||
if ! mv spigot-*.jar /data/${SERVER}; then
|
||||
log "ERR failed to build Spigot"
|
||||
cat /data/spigot_build.log
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
*BUKKIT)
|
||||
if ! mv craftbukkit-*.jar /data/${SERVER}; then
|
||||
log "ERR failed to build Spigot"
|
||||
cat /data/spigot_build.log
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
||||
log "Cleaning up"
|
||||
rm -rf /data/temp
|
||||
cd /data
|
||||
}
|
||||
@@ -38,51 +59,70 @@ function downloadSpigot {
|
||||
;;
|
||||
esac
|
||||
|
||||
local downloadVersion
|
||||
if [[ ${VERSION} == LATEST ]]; then
|
||||
downloadVersion=${VANILLA_VERSION}
|
||||
else
|
||||
downloadVersion=${VERSION}
|
||||
if [[ ${VERSION^^} = LATEST ]]; then
|
||||
VANILLA_VERSION=$(restify https://getbukkit.org/download/spigot --attribute='property=og:title' | jq -r '.[0] | .attributes | select(.property == "og:title") | .content | split(" ") | .[-1]')
|
||||
fi
|
||||
|
||||
if [[ -z $downloadUrl ]]; then
|
||||
downloadUrl="https://cdn.getbukkit.org/${getbukkitFlavor}/${getbukkitFlavor}-${downloadVersion}.jar"
|
||||
downloadUrl="https://cdn.getbukkit.org/${getbukkitFlavor}/${getbukkitFlavor}-${VANILLA_VERSION}.jar"
|
||||
fi
|
||||
|
||||
echo "Downloading $match from $downloadUrl ..."
|
||||
curl -fsSL -o $SERVER "$downloadUrl"
|
||||
setServerVar
|
||||
if [ -f $SERVER ]; then
|
||||
# tell curl to only download when newer
|
||||
curlArgs="-z $SERVER"
|
||||
fi
|
||||
if isDebugging; then
|
||||
curlArgs="$curlArgs -v"
|
||||
fi
|
||||
log "Downloading $match from $downloadUrl ..."
|
||||
curl -fsSL -o $SERVER $curlArgs "$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
|
||||
exact version, such as 1.4.6-R0.4-SNAPSHOT or 1.8-R0.1-SNAPSHOT-latest.
|
||||
Click into the version entry to find the **exact** version, because something
|
||||
like "1.8" is not sufficient according to their download naming.
|
||||
|
||||
EOF
|
||||
|
||||
if isDebugging && [[ $(grep -c "DOCTYPE html" $SERVER) != 0 ]]; then
|
||||
cat $SERVER
|
||||
fi
|
||||
|
||||
# remove invalid download
|
||||
rm $SERVER
|
||||
exit 3
|
||||
fi
|
||||
|
||||
JVM_OPTS="${JVM_OPTS} -DIReallyKnowWhatIAmDoingISwear"
|
||||
export JVM_OPTS
|
||||
}
|
||||
|
||||
function setServerVar {
|
||||
case "$TYPE" in
|
||||
*BUKKIT|*bukkit)
|
||||
export SERVER=craftbukkit_server-${VANILLA_VERSION}.jar
|
||||
;;
|
||||
*)
|
||||
export SERVER=spigot_server-${VANILLA_VERSION}.jar
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
case "$TYPE" in
|
||||
*BUKKIT|*bukkit)
|
||||
export SERVER=craftbukkit_server.jar
|
||||
;;
|
||||
*)
|
||||
export SERVER=spigot_server.jar
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ ! -f $SERVER ] || [ -n "$FORCE_REDOWNLOAD" ]; 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
|
||||
if isTrue "$BUILD_SPIGOT_FROM_SOURCE" || isTrue "$BUILD_FROM_SOURCE"; then
|
||||
setServerVar
|
||||
if [ ! -f $SERVER ] || [ -n "$FORCE_REDOWNLOAD" ]; then
|
||||
buildSpigotFromSource
|
||||
fi
|
||||
else
|
||||
downloadSpigot
|
||||
fi
|
||||
|
||||
# Normalize on Spigot for operations below
|
||||
export TYPE=SPIGOT
|
||||
export SKIP_LOG4J_CONFIG=true
|
||||
|
||||
# Continue to Final Setup
|
||||
exec /start-finalSetup01World $@
|
||||
exec ${SCRIPTS:-/}start-spiget "$@"
|
||||
|
||||
228
start-deployCF
Normal file
228
start-deployCF
Normal file
@@ -0,0 +1,228 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
. ${SCRIPTS:-/}start-utils
|
||||
|
||||
loadForgeVars() {
|
||||
cfgFile=${1?}
|
||||
pat='^([^#;][^=]+)=[:space:]*([^;]*)'
|
||||
while read -r line || [[ -n "$line" ]] ; do
|
||||
if [[ $line =~ $pat ]]; then
|
||||
#echo "MATCHED $line"
|
||||
k=${BASH_REMATCH[1]}
|
||||
v=${BASH_REMATCH[2]}
|
||||
case $k in
|
||||
FORGEURL)
|
||||
forgeInstallerUrl="$v"
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
done < "$cfgFile"
|
||||
}
|
||||
|
||||
isDebugging && set -x
|
||||
|
||||
: ${FTB_BASE_DIR:=${CF_BASE_DIR:-/data/FeedTheBeast}}
|
||||
export FTB_BASE_DIR
|
||||
|
||||
legacyJavaFixerUrl=https://ftb.forgecdn.net/FTB2/maven/net/minecraftforge/lex/legacyjavafixer/1.0/legacyjavafixer-1.0.jar
|
||||
export TYPE=FEED-THE-BEAST
|
||||
|
||||
FTB_SERVER_MOD=${FTB_SERVER_MOD:-$CF_SERVER_MOD}
|
||||
|
||||
log "Looking for Feed-The-Beast / CurseForge server modpack."
|
||||
requireVar FTB_SERVER_MOD
|
||||
|
||||
if ! isTrue ${USE_MODPACK_START_SCRIPT:-true}; then
|
||||
if ! [ -f "${FTB_SERVER_MOD}" ]; then
|
||||
log "ERROR unable to find requested modpack file ${FTB_SERVER_MOD}"
|
||||
exit 2
|
||||
fi
|
||||
|
||||
needsInstall=true
|
||||
installMarker=/data/.curseforge-installed
|
||||
if [ -f $installMarker ]; then
|
||||
if [ "$(cat $installMarker)" != "${FTB_SERVER_MOD}" ]; then
|
||||
log "Upgrading modpack"
|
||||
|
||||
serverJar=$(find ${FTB_BASE_DIR} -not -name "forge*installer.jar" -name "forge*.jar")
|
||||
if [[ "${serverJar}" ]]; then
|
||||
rm -rf $(dirname "${serverJar}")/{mods,*.jar,libraries,resources,scripts,config}
|
||||
fi
|
||||
else
|
||||
needsInstall=false
|
||||
fi
|
||||
fi
|
||||
|
||||
if $needsInstall; then
|
||||
log "Unpacking FTB server modpack ${FTB_SERVER_MOD} ..."
|
||||
mkdir -p ${FTB_BASE_DIR}
|
||||
unzip -o "${FTB_SERVER_MOD}" -d ${FTB_BASE_DIR} | awk '{printf "."} END {print ""}'
|
||||
|
||||
serverJar=$(find ${FTB_BASE_DIR} -path "*/libraries/*" -prune -type f -o -not -name "forge*installer.jar" -name "forge*.jar")
|
||||
if [[ -z "$serverJar" ]]; then
|
||||
|
||||
if [ -f "${FTB_BASE_DIR}/settings.cfg" ]; then
|
||||
loadForgeVars "${FTB_BASE_DIR}/settings.cfg"
|
||||
|
||||
if [[ $forgeInstallerUrl ]]; then
|
||||
forgeInstallerJar="${FTB_BASE_DIR}/forge-installer.jar"
|
||||
if ! curl -fsSL -o "$forgeInstallerJar" "$forgeInstallerUrl" ; then
|
||||
log "ERROR failed to download Forge installer from $forgeInstallerUrl"
|
||||
exit 2
|
||||
fi
|
||||
fi
|
||||
else
|
||||
forgeInstallerJar=$(find "${FTB_BASE_DIR}" -name "forge*installer.jar")
|
||||
fi
|
||||
|
||||
if [[ -z "${forgeInstallerJar}" ]]; then
|
||||
log "ERROR Unable to find forge installer in modpack"
|
||||
log " or download using modpack config."
|
||||
log " Make sure you downloaded the server files."
|
||||
exit 2
|
||||
fi
|
||||
|
||||
log "Installing forge server"
|
||||
(cd $(dirname "${forgeInstallerJar}"); java -jar $(basename "${forgeInstallerJar}") --installServer)
|
||||
fi
|
||||
|
||||
echo "${FTB_SERVER_MOD}" > $installMarker
|
||||
fi
|
||||
|
||||
export SERVER=$(find ${FTB_BASE_DIR} -path "*/libraries/*" -prune -type f -o -not -name "forge*installer.jar" -name "forge*.jar")
|
||||
if [[ -z "${SERVER}" || ! -f "${SERVER}" ]]; then
|
||||
log "ERROR unable to locate installed forge server jar"
|
||||
isDebugging && find ${FTB_BASE_DIR} -name "forge*.jar"
|
||||
exit 2
|
||||
fi
|
||||
|
||||
export FTB_DIR=$(dirname "${SERVER}")
|
||||
|
||||
exec ${SCRIPTS:-/}start-finalSetupWorld $@
|
||||
fi
|
||||
|
||||
entryScriptExpr="
|
||||
-name ServerStart.sh
|
||||
-o -name serverstart.sh
|
||||
-o -name ServerStartLinux.sh
|
||||
-o -name LaunchServer.sh
|
||||
-o -name server-start.sh
|
||||
-o -name startserver.sh
|
||||
-o -name StartServer.sh
|
||||
"
|
||||
|
||||
if [[ -d ${FTB_BASE_DIR} ]]; then
|
||||
startScriptCount=$(find ${FTB_BASE_DIR} $entryScriptExpr |wc -l)
|
||||
if [[ $startScriptCount > 1 ]]; then
|
||||
log "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.curseforge.com/minecraft/modpacks/*/download/*/file)
|
||||
;;
|
||||
https://www.curseforge.com/minecraft/modpacks/*/download/*)
|
||||
srv_modpack=${srv_modpack}/file;;
|
||||
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
|
||||
log "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
|
||||
log "FTB server modpack ${srv_modpack} not found."
|
||||
exit 2
|
||||
fi
|
||||
if [[ ! "${srv_modpack: -4}" == ".zip" ]]; then
|
||||
log "FTB server modpack ${srv_modpack} is not a zip archive."
|
||||
log "Please set FTB_SERVER_MOD to a file with a .zip extension."
|
||||
exit 2
|
||||
fi
|
||||
|
||||
log "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} $entryScriptExpr | wc -l) = 0 ]]; then
|
||||
|
||||
# Allow up to 2 levels since some modpacks have a top-level directory named
|
||||
# for the modpack
|
||||
forgeJar=$(find ${FTB_BASE_DIR} -maxdepth 2 -name 'forge*.jar' -a -not -name 'forge*installer')
|
||||
if [[ "$forgeJar" ]]; then
|
||||
export FTB_BASE_DIR=$(dirname "${forgeJar}")
|
||||
log "No entry script found, so building one for ${forgeJar}"
|
||||
cat > "${FTB_BASE_DIR}/ServerStart.sh" <<EOF
|
||||
#!/bin/sh
|
||||
. ./settings-local.sh
|
||||
java \${JAVA_PARAMETERS} -Xmx\${MAX_RAM} -jar $(basename "${forgeJar}") nogui
|
||||
EOF
|
||||
chmod +x "${FTB_BASE_DIR}/ServerStart.sh"
|
||||
else
|
||||
log "Please make sure you are using the server version of the FTB modpack!"
|
||||
exit 2
|
||||
fi
|
||||
fi
|
||||
|
||||
scriptCount=$(find "${FTB_BASE_DIR}" $entryScriptExpr | wc -l)
|
||||
if [[ $scriptCount = 0 ]]; then
|
||||
log "Please make sure you are using the server version of the FTB modpack!"
|
||||
exit 2
|
||||
elif [[ $scriptCount > 1 ]]; then
|
||||
log "Ambigous startup scripts in FTB modpack!"
|
||||
log "found:"
|
||||
find ${FTB_BASE_DIR} $entryScriptExpr
|
||||
exit 2
|
||||
fi
|
||||
|
||||
export FTB_SERVER_START=$(find "${FTB_BASE_DIR}" $entryScriptExpr)
|
||||
|
||||
export FTB_DIR=$(dirname "${FTB_SERVER_START}")
|
||||
chmod a+x "${FTB_SERVER_START}"
|
||||
grep fml.queryResult=confirm "${FTB_SERVER_START}" > /dev/null || \
|
||||
sed -i 's/-jar/-Dfml.queryResult=confirm -jar/' "${FTB_SERVER_START}"
|
||||
sed -i 's/.*read.*Restart now/#\0/' "${FTB_SERVER_START}"
|
||||
legacyJavaFixerPath="${FTB_DIR}/mods/legacyjavafixer.jar"
|
||||
|
||||
if isTrue ${FTB_LEGACYJAVAFIXER} && [ ! -e "${legacyJavaFixerPath}" ]; then
|
||||
log "Installing legacy java fixer to ${legacyJavaFixerPath}"
|
||||
curl -sSL -o "${legacyJavaFixerPath}" ${legacyJavaFixerUrl}
|
||||
fi
|
||||
|
||||
if [ -e "${FTB_DIR}/FTBInstall.sh" ]; then
|
||||
pushd "${FTB_DIR}"
|
||||
sh FTBInstall.sh
|
||||
popd
|
||||
elif [ -e "${FTB_DIR}/Install.sh" ]; then
|
||||
pushd "${FTB_DIR}"
|
||||
sh Install.sh
|
||||
popd
|
||||
fi
|
||||
|
||||
# Continue to Final Setup
|
||||
exec ${SCRIPTS:-/}start-finalSetupWorld $@
|
||||
32
start-deployCatserver
Normal file
32
start-deployCatserver
Normal file
@@ -0,0 +1,32 @@
|
||||
#!/bin/bash
|
||||
|
||||
. ${SCRIPTS:-/}start-utils
|
||||
set -o pipefail
|
||||
set -e
|
||||
|
||||
latestAsset=$(
|
||||
curl -fsSL https://api.github.com/repos/Luohuayu/CatServer/releases/latest | \
|
||||
jq '.assets[] | select(.name | match(".*-universal.jar"))'
|
||||
)
|
||||
|
||||
if [[ -z "${latestAsset}" ]]; then
|
||||
log "ERROR: latest release of Catserver is missing universal.jar asset"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
isDebugging && log "Latest asset ${latestAsset}"
|
||||
latestJarName=$(echo ${latestAsset} | jq --raw-output '.name')
|
||||
latestJarId=$(echo ${latestAsset} | jq --raw-output '.id')
|
||||
|
||||
|
||||
export SERVER="/data/${latestJarName}"
|
||||
|
||||
if [ ! -f ${SERVER} ]; then
|
||||
log "Downloading ${latestJarName}"
|
||||
curl -H "Accept:application/octet-stream" -o "$SERVER" -fsSL https://api.github.com/repos/Luohuayu/CatServer/releases/assets/${latestJarId}
|
||||
fi
|
||||
|
||||
export SKIP_LOG4J_CONFIG=true
|
||||
|
||||
# Continue to Final Setup
|
||||
exec ${SCRIPTS:-/}start-finalSetupWorld "$@"
|
||||
@@ -1,29 +1,36 @@
|
||||
#!/bin/bash
|
||||
|
||||
. /start-utils
|
||||
. ${SCRIPTS:-/}start-utils
|
||||
isDebugging && set -x
|
||||
|
||||
if isURL ${CUSTOM_SERVER}; then
|
||||
filename=$(basename ${CUSTOM_SERVER})
|
||||
export SERVER=/data/${filename}
|
||||
|
||||
if [[ -f ${SERVER} ]] || [ -n "$FORCE_REDOWNLOAD" ]; then
|
||||
echo "Using previously downloaded jar at ${SERVER}"
|
||||
log "Using previously downloaded jar at ${SERVER}"
|
||||
else
|
||||
echo "Downloading custom server jar from ${CUSTOM_SERVER} ..."
|
||||
log "Downloading custom server jar from ${CUSTOM_SERVER} ..."
|
||||
if ! curl -sSL -o ${SERVER} ${CUSTOM_SERVER}; then
|
||||
echo "Failed to download from ${CUSTOM_SERVER}"
|
||||
log "Failed to download from ${CUSTOM_SERVER}"
|
||||
exit 2
|
||||
fi
|
||||
fi
|
||||
|
||||
elif [[ -f ${CUSTOM_SERVER} ]]; then
|
||||
echo "Using custom server jar at ${CUSTOM_SERVER} ..."
|
||||
export SERVER=${CUSTOM_SERVER}
|
||||
|
||||
elif [[ ${GENERIC_PACK} ]]; then
|
||||
log "Using custom server jar from generic pack at ${CUSTOM_SERVER} ..."
|
||||
export SERVER=${CUSTOM_SERVER}
|
||||
|
||||
else
|
||||
echo "CUSTOM_SERVER is not properly set to a URL or existing jar file"
|
||||
log "CUSTOM_SERVER is not properly set to a URL or existing jar file"
|
||||
exit 2
|
||||
|
||||
fi
|
||||
|
||||
export SKIP_LOG4J_CONFIG=true
|
||||
|
||||
# Continue to Final Setup
|
||||
exec /start-finalSetup01World $@
|
||||
exec ${SCRIPTS:-/}start-finalSetupWorld $@
|
||||
|
||||
130
start-deployFTB
130
start-deployFTB
@@ -1,130 +0,0 @@
|
||||
#!/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
|
||||
|
||||
FTB_SERVER_MOD=${FTB_SERVER_MOD:-$CF_SERVER_MOD}
|
||||
|
||||
echo "Looking for Feed-The-Beast / CurseForge 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
|
||||
|
||||
entryScriptExpr="-name ServerStart.sh -o -name ServerStartLinux.sh -o -name LaunchServer.sh"
|
||||
|
||||
if [[ -d ${FTB_BASE_DIR} ]]; then
|
||||
startScriptCount=$(find ${FTB_BASE_DIR} $entryScriptExpr |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.curseforge.com/minecraft/modpacks/*/download/*/file)
|
||||
;;
|
||||
https://www.curseforge.com/minecraft/modpacks/*/download/*)
|
||||
srv_modpack=${srv_modpack}/file;;
|
||||
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} $entryScriptExpr | wc -l) = 0 ]]; then
|
||||
|
||||
forgeJar=$(find ${FTB_BASE_DIR} -name 'forge*.jar' -a -not -name 'forge*installer')
|
||||
if [[ "$forgeJar" ]]; then
|
||||
export FTB_BASE_DIR=$(dirname "${forgeJar}")
|
||||
echo "No entry script found, so building one for ${forgeJar}"
|
||||
cat > "${FTB_BASE_DIR}/ServerStart.sh" <<EOF
|
||||
#!/bin/sh
|
||||
. ./settings-local.sh
|
||||
java \${JAVA_PARAMETERS} -Xmx\${MAX_RAM} -jar $(basename "${forgeJar}") nogui
|
||||
EOF
|
||||
chmod +x "${FTB_BASE_DIR}/ServerStart.sh"
|
||||
else
|
||||
echo "Please make sure you are using the server version of the FTB modpack!"
|
||||
exit 2
|
||||
fi
|
||||
fi
|
||||
|
||||
scriptCount=$(find "${FTB_BASE_DIR}" $entryScriptExpr | wc -l)
|
||||
if [[ $scriptCount = 0 ]]; then
|
||||
echo "Please make sure you are using the server version of the FTB modpack!"
|
||||
exit 2
|
||||
elif [[ $scriptCount > 1 ]]; then
|
||||
echo "Ambigous startup scripts in FTB modpack!"
|
||||
echo "found:"
|
||||
find ${FTB_BASE_DIR} $entryScriptExpr
|
||||
exit 2
|
||||
fi
|
||||
|
||||
export FTB_SERVER_START=$(find "${FTB_BASE_DIR}" $entryScriptExpr)
|
||||
|
||||
export FTB_DIR=$(dirname "${FTB_SERVER_START}")
|
||||
chmod a+x "${FTB_SERVER_START}"
|
||||
sed -i 's/-jar/-Dfml.queryResult=confirm -jar/' "${FTB_SERVER_START}"
|
||||
sed -i 's/.*read.*Restart now/#\0/' "${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 FTBInstall.sh
|
||||
popd
|
||||
elif [ -e "${FTB_DIR}/Install.sh" ]; then
|
||||
pushd "${FTB_DIR}"
|
||||
sh Install.sh
|
||||
popd
|
||||
fi
|
||||
|
||||
# Continue to Final Setup
|
||||
exec /start-finalSetup01World $@
|
||||
@@ -1,67 +1,74 @@
|
||||
#!/bin/bash
|
||||
set -u
|
||||
set -eu
|
||||
|
||||
. ${SCRIPTS:-/}start-utils
|
||||
|
||||
export TYPE=FABRIC
|
||||
|
||||
FABRIC_INSTALLER=${FABRIC_INSTALLER:-}
|
||||
FABRIC_INSTALLER_URL=${FABRIC_INSTALLER_URL:-}
|
||||
FABRICVERSION=${FABRICVERSION:-LATEST}
|
||||
FABRIC_INSTALLER_VERSION=${FABRIC_INSTALLER_VERSION:-${FABRICVERSION:-LATEST}}
|
||||
if [[ -z $FABRIC_INSTALLER && -z $FABRIC_INSTALLER_URL ]]; then
|
||||
echo "Checking Fabric version information."
|
||||
case $FABRICVERSION in
|
||||
log "Checking Fabric version information."
|
||||
case $FABRIC_INSTALLER_VERSION in
|
||||
LATEST)
|
||||
curl -fsSL https://maven.fabricmc.net/net/fabricmc/fabric-installer/maven-metadata.xml | xq -c . > /tmp/fabric.json
|
||||
FABRIC_VERSION=$(< /tmp/fabric.json jq -r ".metadata.versioning.release")
|
||||
;;
|
||||
|
||||
*)
|
||||
FABRIC_VERSION=$FABRICVERSION
|
||||
FABRIC_INSTALLER_VERSION=$(maven-metadata-release https://maven.fabricmc.net/net/fabricmc/fabric-installer/maven-metadata.xml)
|
||||
;;
|
||||
esac
|
||||
|
||||
FABRIC_INSTALLER="/tmp/fabric-installer-$FABRIC_VERSION.jar"
|
||||
FABRIC_INSTALLER="/tmp/fabric-installer-${FABRIC_INSTALLER_VERSION}.jar"
|
||||
markerVersion=$FABRIC_INSTALLER_VERSION
|
||||
|
||||
elif [[ -z $FABRIC_INSTALLER ]]; then
|
||||
FABRIC_INSTALLER="/tmp/fabric-installer.jar"
|
||||
markerVersion=custom
|
||||
elif [[ ! -e $FABRIC_INSTALLER ]]; then
|
||||
echo "ERROR: the given Fabric installer doesn't exist : $FABRIC_INSTALLER"
|
||||
log "ERROR: the given Fabric installer doesn't exist : $FABRIC_INSTALLER"
|
||||
exit 2
|
||||
fi
|
||||
|
||||
installMarker=".fabric-installed-${FABRIC_VERSION:-manual}"
|
||||
installMarker="/data/.fabric-installed-${VANILLA_VERSION}-${markerVersion}"
|
||||
|
||||
debug Checking for installMarker ${installMarker}
|
||||
if [[ ! -e $installMarker ]]; then
|
||||
if [[ ! -e $FABRIC_INSTALLER ]]; then
|
||||
if [[ -z $FABRIC_INSTALLER_URL ]]; then
|
||||
echo "Downloading $FABRIC_VERSION"
|
||||
downloadUrl="https://maven.fabricmc.net/net/fabricmc/fabric-installer/$FABRIC_VERSION/fabric-installer-$FABRIC_VERSION.jar"
|
||||
echo "...trying $downloadUrl"
|
||||
log "Downloading installer version $FABRIC_INSTALLER_VERSION"
|
||||
downloadUrl="https://maven.fabricmc.net/net/fabricmc/fabric-installer/${FABRIC_INSTALLER_VERSION}/fabric-installer-${FABRIC_INSTALLER_VERSION}.jar"
|
||||
log "...trying $downloadUrl"
|
||||
curl -o $FABRIC_INSTALLER -fsSL $downloadUrl
|
||||
else
|
||||
echo "Downloading $FABRIC_INSTALLER_URL ..."
|
||||
log "Downloading $FABRIC_INSTALLER_URL ..."
|
||||
if ! curl -o $FABRIC_INSTALLER -fsSL $FABRIC_INSTALLER_URL; then
|
||||
echo "Failed to download from given location $FABRIC_INSTALLER_URL"
|
||||
log "Failed to download from given location $FABRIC_INSTALLER_URL"
|
||||
exit 2
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "Installing Fabric $FABRIC_VERSION using $FABRIC_INSTALLER"
|
||||
if isDebugging; then
|
||||
debug "Installing Fabric ${VANILLA_VERSION} using $FABRIC_INSTALLER"
|
||||
else
|
||||
log "Installing Fabric using $FABRIC_INSTALLER"
|
||||
fi
|
||||
tries=3
|
||||
set +e
|
||||
while ((--tries >= 0)); do
|
||||
java -jar $FABRIC_INSTALLER server -mcversion $VANILLA_VERSION -downloadMinecraft
|
||||
java -jar $FABRIC_INSTALLER server \
|
||||
-mcversion $VANILLA_VERSION \
|
||||
-downloadMinecraft \
|
||||
-dir /data
|
||||
if [[ $? == 0 ]]; then
|
||||
break
|
||||
fi
|
||||
done
|
||||
set -e
|
||||
if (($tries < 0)); then
|
||||
echo "Fabric failed to install after several tries." >&2
|
||||
log "Fabric failed to install after several tries." >&2
|
||||
exit 10
|
||||
fi
|
||||
export SERVER=fabric-server-launch.jar
|
||||
echo "Using server $SERVER"
|
||||
log "Using server $SERVER"
|
||||
echo $SERVER > $installMarker
|
||||
|
||||
else
|
||||
@@ -69,4 +76,4 @@ else
|
||||
fi
|
||||
|
||||
# Contineut to Final Setup
|
||||
exec /start-finalSetup01World $@
|
||||
exec ${SCRIPTS:-/}start-finalSetupWorld $@
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
#!/bin/bash
|
||||
|
||||
. ${SCRIPTS:-/}start-utils
|
||||
export TYPE=FORGE
|
||||
: ${FORGEVERSION:=RECOMMENDED}
|
||||
isDebugging && set -x
|
||||
|
||||
if [[ -z $FORGE_INSTALLER && -z $FORGE_INSTALLER_URL ]]; then
|
||||
norm=$VANILLA_VERSION
|
||||
@@ -14,7 +17,7 @@ if [[ -z $FORGE_INSTALLER && -z $FORGE_INSTALLER_URL ]]; then
|
||||
|
||||
#################################################################################
|
||||
|
||||
echo "Checking Forge version information."
|
||||
log "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
|
||||
@@ -22,8 +25,8 @@ if [[ -z $FORGE_INSTALLER && -z $FORGE_INSTALLER_URL ]]; then
|
||||
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"
|
||||
log "ERROR: Version $VANILLA_VERSION is not supported by Forge"
|
||||
log " Refer to http://files.minecraftforge.net/ for supported versions"
|
||||
exit 2
|
||||
fi
|
||||
fi
|
||||
@@ -41,17 +44,19 @@ if [[ -z $FORGE_INSTALLER && -z $FORGE_INSTALLER_URL ]]; then
|
||||
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"
|
||||
log "ERROR: the given Forge installer doesn't exist : $FORGE_INSTALLER"
|
||||
exit 2
|
||||
else
|
||||
shortForgeVersion=$VANILLA_VERSION-custom
|
||||
fi
|
||||
|
||||
installMarker=".forge-installed-$shortForgeVersion"
|
||||
installMarker="/data/.forge-installed-$shortForgeVersion"
|
||||
|
||||
if [ ! -e $installMarker ]; then
|
||||
if [ ! -e $FORGE_INSTALLER ]; then
|
||||
|
||||
if [[ -z $FORGE_INSTALLER_URL ]]; then
|
||||
echo "Downloading $normForgeVersion"
|
||||
log "Downloading $normForgeVersion"
|
||||
|
||||
forgeFileNames="
|
||||
$normForgeVersion/forge-$normForgeVersion-installer.jar
|
||||
@@ -60,25 +65,25 @@ if [ ! -e $installMarker ]; then
|
||||
"
|
||||
for fn in $forgeFileNames; do
|
||||
if [ $fn == END ]; then
|
||||
echo "Unable to compute URL for $normForgeVersion"
|
||||
log "Unable to compute URL for $normForgeVersion"
|
||||
exit 2
|
||||
fi
|
||||
downloadUrl=http://files.minecraftforge.net/maven/net/minecraftforge/forge/$fn
|
||||
echo "...trying $downloadUrl"
|
||||
log "...trying $downloadUrl"
|
||||
if curl -o $FORGE_INSTALLER -fsSL $downloadUrl; then
|
||||
break
|
||||
fi
|
||||
done
|
||||
else
|
||||
echo "Downloading $FORGE_INSTALLER_URL ..."
|
||||
log "Downloading $FORGE_INSTALLER_URL ..."
|
||||
if ! curl -o $FORGE_INSTALLER -fsSL $FORGE_INSTALLER_URL; then
|
||||
echo "Failed to download from given location $FORGE_INSTALLER_URL"
|
||||
log "Failed to download from given location $FORGE_INSTALLER_URL"
|
||||
exit 2
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "Installing Forge $shortForgeVersion using $FORGE_INSTALLER"
|
||||
log "Installing Forge $shortForgeVersion using $FORGE_INSTALLER"
|
||||
mkdir -p mods
|
||||
tries=3
|
||||
while ((--tries >= 0)); do
|
||||
@@ -88,22 +93,26 @@ if [ ! -e $installMarker ]; then
|
||||
fi
|
||||
done
|
||||
if (($tries < 0)); then
|
||||
echo "Forge failed to install after several tries." >&2
|
||||
log "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..."
|
||||
log "Finding installed server jar..."
|
||||
unset -v latest
|
||||
for file in *forge*.jar; do
|
||||
[[ $file =~ installer ]] || [[ $file -nt $latest ]] && latest=$file
|
||||
if ! [[ $file =~ installer ]]; then
|
||||
if [[ -z $latest ]] || [[ $file -nt $latest ]]; then
|
||||
latest=$file
|
||||
fi
|
||||
fi
|
||||
done
|
||||
if [[ -z $latest ]]; then
|
||||
echo "Unable to derive server jar for Forge"
|
||||
log "Unable to derive server jar for Forge"
|
||||
exit 2
|
||||
fi
|
||||
|
||||
export SERVER=$latest
|
||||
echo "Using server $SERVER"
|
||||
log "Using server $SERVER"
|
||||
echo $SERVER > $installMarker
|
||||
|
||||
else
|
||||
@@ -111,4 +120,4 @@ else
|
||||
fi
|
||||
|
||||
# Continue to Final Setup
|
||||
exec /start-finalSetup01World $@
|
||||
exec ${SCRIPTS:-/}start-finalSetupWorld $@
|
||||
|
||||
18
start-deployMagma
Normal file
18
start-deployMagma
Normal file
@@ -0,0 +1,18 @@
|
||||
#!/bin/bash
|
||||
|
||||
. ${SCRIPTS:-/}start-utils
|
||||
|
||||
export SERVER="/data/magma-server-${VANILLA_VERSION}.jar"
|
||||
|
||||
# Always download since new updates of each base version are published frequently
|
||||
if ! curl -o /data/magma-server-${VANILLA_VERSION}.jar -fsSL \
|
||||
https://api.magmafoundation.org/api/resources/Magma/${VANILLA_VERSION}/stable/latest/download; then
|
||||
log "ERROR unable to download version ${VANILLA_VERSION} of Magma"
|
||||
log " Check https://magmafoundation.org/ for available versions"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
export SKIP_LOG4J_CONFIG=true
|
||||
|
||||
# Continue to Final Setup
|
||||
exec ${SCRIPTS:-/}start-finalSetupWorld $@
|
||||
44
start-deployMohist
Normal file
44
start-deployMohist
Normal file
@@ -0,0 +1,44 @@
|
||||
#!/bin/bash
|
||||
|
||||
. ${SCRIPTS:-/}start-utils
|
||||
set -o pipefail
|
||||
set -e
|
||||
isDebugging && set -x
|
||||
|
||||
requireVar VANILLA_VERSION
|
||||
: ${MOHIST_BUILD:=lastSuccessfulBuild}
|
||||
|
||||
mohistJobs=https://ci.codemc.io/job/Mohist-Community/job/
|
||||
mohistJob=${mohistJobs}Mohist-${VANILLA_VERSION}/
|
||||
|
||||
if ! curl -X HEAD -o /dev/null -fsSL "${mohistJob}"; then
|
||||
log "ERROR: mohist builds do not exist for ${VANILLA_VERSION}"
|
||||
log " check https://ci.codemc.io/job/Mohist-Community/ for available versions"
|
||||
log " and set VERSION accordingly"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
buildRelPath=$(
|
||||
curl -fsSL "${mohistJob}${MOHIST_BUILD}/api/json" |
|
||||
jq -r '.artifacts[0].relativePath'
|
||||
)
|
||||
|
||||
baseName=$(basename "${buildRelPath}")
|
||||
if [[ ${baseName} != *-server.jar* ]]; then
|
||||
log "ERROR: mohist build for ${VANILLA_VERSION} is not a valid server jar, found ${baseName}"
|
||||
log " check https://ci.codemc.io/job/Mohist-Community/ for available versions"
|
||||
log " and set VERSION accordingly"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
export SERVER="/data/${baseName}"
|
||||
|
||||
if [ ! -f ${SERVER} ]; then
|
||||
log "Downloading ${baseName}"
|
||||
curl -o "${SERVER}" -fsSL "${mohistJob}${MOHIST_BUILD}/artifact/${buildRelPath}"
|
||||
fi
|
||||
|
||||
export SKIP_LOG4J_CONFIG=true
|
||||
|
||||
# Continue to Final Setup
|
||||
exec ${SCRIPTS:-/}start-finalSetupWorld "$@"
|
||||
@@ -1,18 +1,79 @@
|
||||
#!/bin/bash
|
||||
|
||||
export SERVER=paper_server.jar
|
||||
if [ ! -f $SERVER ] || [ -n "$FORCE_REDOWNLOAD" ]; then
|
||||
downloadUrl=${PAPER_DOWNLOAD_URL:-https://papermc.io/api/v1/paper/${VANILLA_VERSION}/latest/download}
|
||||
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
|
||||
. ${SCRIPTS:-/}start-utils
|
||||
set -o pipefail
|
||||
isDebugging && set -x
|
||||
|
||||
if [[ $PAPER_DOWNLOAD_URL ]]; then
|
||||
export SERVER=$(getFilenameFromUrl "${PAPER_DOWNLOAD_URL}")
|
||||
|
||||
if [ -f "$SERVER" ]; then
|
||||
zarg=(-z "$SERVER")
|
||||
fi
|
||||
|
||||
echo "Preparing custom PaperMC jar from $PAPER_DOWNLOAD_URL"
|
||||
|
||||
curl -fsSL -o "$SERVER" "${zarg[@]}" "${PAPER_DOWNLOAD_URL}"
|
||||
else
|
||||
# PaperMC API v2 docs : https://papermc.io/api/docs/swagger-ui/index.html?configUrl=/api/openapi/swagger-config
|
||||
|
||||
build=${PAPERBUILD:=$(curl -fsSL "https://papermc.io/api/v2/projects/paper/versions/${VANILLA_VERSION}" -H "accept: application/json" \
|
||||
| jq '.builds[-1]')}
|
||||
case $? in
|
||||
0)
|
||||
;;
|
||||
22)
|
||||
versions=$(curl -fsSL "https://papermc.io/api/v2/projects/paper" -H "accept: application/json")
|
||||
if [[ $VERSION = LATEST ]]; then
|
||||
VANILLA_VERSION=$(echo "$versions" | jq -r '.versions[-1]')
|
||||
log "WARN: using ${VANILLA_VERSION} since that's the latest provided by PaperMC"
|
||||
# re-execute the current script with the newly computed version
|
||||
exec "$0" "$@"
|
||||
fi
|
||||
log "ERROR: ${VANILLA_VERSION} is not published by PaperMC"
|
||||
log " Set VERSION to one of the following: "
|
||||
log " $(echo "$versions" | jq -r '.versions | join(", ")')"
|
||||
exit 1
|
||||
;;
|
||||
*)
|
||||
echo "ERROR: unknown error while looking up PaperMC version=${VANILLA_VERSION}"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
if [ $? != 0 ]; then
|
||||
echo "ERROR: failed to lookup PaperMC build from version ${VANILLA_VERSION}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
export SERVER=$(curl -fsSL "https://papermc.io/api/v2/projects/paper/versions/${VANILLA_VERSION}/builds/${build}" -H "accept: application/json" \
|
||||
| jq -r '.downloads.application.name')
|
||||
if [ $? != 0 ]; then
|
||||
echo "ERROR: failed to lookup PaperMC download file from version=${VANILLA_VERSION} build=${build}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -f "$SERVER" ]; then
|
||||
zarg=(-z "$SERVER")
|
||||
fi
|
||||
|
||||
log "Removing old PaperMC versions ..."
|
||||
shopt -s nullglob
|
||||
for f in paper-*.jar; do
|
||||
[[ $f != $SERVER ]] && rm $f
|
||||
done
|
||||
|
||||
log "Downloading PaperMC $VANILLA_VERSION (build $build) ..."
|
||||
curl -fsSL -o "$SERVER" "${zarg[@]}" \
|
||||
"https://papermc.io/api/v2/projects/paper/versions/${VANILLA_VERSION}/builds/${build}/downloads/${SERVER}" \
|
||||
-H "accept: application/java-archive"
|
||||
if [ $? != 0 ]; then
|
||||
echo "ERROR: failed to download PaperMC from version=${VANILLA_VERSION} build=${build} download=${SERVER}"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
# Normalize on Spigot for operations below
|
||||
# Normalize on Spigot for downstream operations
|
||||
export TYPE=SPIGOT
|
||||
export SKIP_LOG4J_CONFIG=true
|
||||
|
||||
# Continue to Final Setup
|
||||
exec /start-finalSetup01World $@
|
||||
exec ${SCRIPTS:-/}start-spiget "$@"
|
||||
|
||||
38
start-deployPurpur
Executable file
38
start-deployPurpur
Executable file
@@ -0,0 +1,38 @@
|
||||
#!/bin/bash
|
||||
set -euo pipefail
|
||||
IFS=$'\n\t'
|
||||
|
||||
. ${SCRIPTS:-/}start-utils
|
||||
isDebugging && set -x
|
||||
|
||||
: ${VANILLA_VERSION:?}
|
||||
: ${PURPUR_BUILD:=LATEST}
|
||||
: ${FORCE_REDOWNLOAD:=false}
|
||||
|
||||
if [[ ${PURPUR_BUILD} == LATEST ]]; then
|
||||
PURPUR_BUILD=$(curl -fsSL "https://purpur.pl3x.net/api/v1/purpur/${VANILLA_VERSION}" |
|
||||
jq -r '.builds.latest' || echo "")
|
||||
if [[ -z ${PURPUR_BUILD} ]]; then
|
||||
log "ERROR: Failed to locate a Purpur build for ${VANILLA_VERSION}."
|
||||
log " Please check if a download is available at https://purpur.pl3x.net/downloads/"
|
||||
exit 3
|
||||
fi
|
||||
fi
|
||||
|
||||
export SERVER="purpur-${VANILLA_VERSION}-${PURPUR_BUILD}.jar"
|
||||
|
||||
if [ ! -f "$SERVER" ] || isTrue "$FORCE_REDOWNLOAD"; then
|
||||
downloadUrl="https://purpur.pl3x.net/api/v1/purpur/${VANILLA_VERSION}/${PURPUR_BUILD}/download"
|
||||
log "Downloading Purpur from $downloadUrl ..."
|
||||
if ! curl -fsSL -o "$SERVER" "$downloadUrl"; then
|
||||
log "ERROR: failed to download from $downloadUrl (status=$?)"
|
||||
exit 3
|
||||
fi
|
||||
fi
|
||||
|
||||
# Normalize on Spigot for later operations
|
||||
export TYPE=SPIGOT
|
||||
export SKIP_LOG4J_CONFIG=true
|
||||
|
||||
# Continue to Final Setup
|
||||
exec ${SCRIPTS:-/}start-finalSetupWorld $@
|
||||
@@ -1,9 +1,13 @@
|
||||
#!/bin/bash
|
||||
|
||||
. ${SCRIPTS:-/}start-utils
|
||||
|
||||
export TYPE=spongevanilla
|
||||
: ${SPONGEBRANCH:=STABLE}
|
||||
: ${SPONGEVERSION:=}
|
||||
|
||||
# Parse branch
|
||||
echo "Choosing branch for Sponge"
|
||||
log "Choosing branch for Sponge"
|
||||
case "$SPONGEBRANCH" in
|
||||
|
||||
EXPERIMENTAL|experimental|BLEEDING|bleeding)
|
||||
@@ -18,7 +22,7 @@ esac
|
||||
|
||||
# If not SPONGEVERSION selected, detect last version on selected branch
|
||||
if [ -z $SPONGEVERSION ]; then
|
||||
echo "Choosing Version for Sponge"
|
||||
log "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
|
||||
@@ -29,9 +33,9 @@ fi
|
||||
export SERVER="spongevanilla-$SPONGEVERSION.jar"
|
||||
|
||||
if [ ! -e $SERVER ] || [ -n "$FORCE_REDOWNLOAD" ]; then
|
||||
echo "Downloading $SERVER ..."
|
||||
log "Downloading $SERVER ..."
|
||||
curl -sSL -o $SERVER https://repo.spongepowered.org/maven/org/spongepowered/$TYPE/$SPONGEVERSION/$SERVER
|
||||
fi
|
||||
|
||||
# Continue to Final Setup
|
||||
exec /start-finalSetup01World $@
|
||||
exec ${SCRIPTS:-/}start-finalSetupWorld $@
|
||||
|
||||
27
start-deployTuinity
Normal file
27
start-deployTuinity
Normal file
@@ -0,0 +1,27 @@
|
||||
#!/bin/bash
|
||||
|
||||
. ${SCRIPTS:-/}start-utils
|
||||
|
||||
if [ "${VERSION}" != "LATEST" ]; then
|
||||
log "ERROR: Tunity server type only supports VERSION=LATEST"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
: ${TUNITY_BUILD:=lastSuccessfulBuild}
|
||||
export SERVER=tunity-${VANILLA_VERSION}-${TUNITY_BUILD}.jar
|
||||
|
||||
if [ ! -f "$SERVER" ] || [ -n "$FORCE_REDOWNLOAD" ]; then
|
||||
downloadUrl="https://ci.codemc.io/job/Spottedleaf/job/Tuinity/${TUNITY_BUILD}/artifact/tuinity-paperclip.jar"
|
||||
log "Downloading Tunity (build $TUNITY_BUILD) from $downloadUrl ..."
|
||||
curl -fsSL -o "$SERVER" "$downloadUrl"
|
||||
if [ ! -f "$SERVER" ]; then
|
||||
log "ERROR: failed to download from $downloadUrl (status=$?)"
|
||||
exit 3
|
||||
fi
|
||||
fi
|
||||
|
||||
# Normalize on Spigot for later operations
|
||||
export TYPE=SPIGOT
|
||||
|
||||
# Continue to Final Setup
|
||||
exec ${SCRIPTS:-/}start-finalSetupWorld $@
|
||||
@@ -1,21 +1,22 @@
|
||||
#!/bin/bash
|
||||
|
||||
. /start-utils
|
||||
. ${SCRIPTS:-/}start-utils
|
||||
isDebugging && set -x
|
||||
set -o pipefail
|
||||
|
||||
export SERVER="minecraft_server.${VANILLA_VERSION// /_}.jar"
|
||||
|
||||
if [ ! -e $SERVER ] || [ -n "$FORCE_REDOWNLOAD" ]; then
|
||||
echo "Downloading $SERVER ..."
|
||||
log "Downloading $SERVER ..."
|
||||
debug "Finding version manifest for $VANILLA_VERSION"
|
||||
versionManifestUrl=$(curl -fsSL 'https://launchermeta.mojang.com/mc/game/version_manifest.json' | jq --arg VANILLA_VERSION "$VANILLA_VERSION" --raw-output '[.versions[]|select(.id == $VANILLA_VERSION)][0].url')
|
||||
result=$?
|
||||
if [ $result != 0 ]; then
|
||||
echo "ERROR failed to obtain version manifest URL ($result)"
|
||||
log "ERROR failed to obtain version manifest URL ($result)"
|
||||
exit 1
|
||||
fi
|
||||
if [ $versionManifestUrl = "null" ]; then
|
||||
echo "ERROR couldn't find a matching manifest entry for $VANILLA_VERSION"
|
||||
log "ERROR couldn't find a matching manifest entry for $VANILLA_VERSION"
|
||||
exit 1
|
||||
fi
|
||||
debug "Found version manifest at $versionManifestUrl"
|
||||
@@ -23,7 +24,10 @@ if [ ! -e $SERVER ] || [ -n "$FORCE_REDOWNLOAD" ]; then
|
||||
serverDownloadUrl=$(curl -fsSL ${versionManifestUrl} | jq --raw-output '.downloads.server.url')
|
||||
result=$?
|
||||
if [ $result != 0 ]; then
|
||||
echo "ERROR failed to obtain version manifest from $versionManifestUrl ($result)"
|
||||
log "ERROR failed to obtain version manifest from $versionManifestUrl ($result)"
|
||||
exit 1
|
||||
elif [ $serverDownloadUrl = null ]; then
|
||||
log "ERROR version $VANILLA_VERSION does not provide a server download"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
@@ -34,10 +38,12 @@ if [ ! -e $SERVER ] || [ -n "$FORCE_REDOWNLOAD" ]; then
|
||||
curl $verbose -fsSL -o $SERVER $serverDownloadUrl
|
||||
result=$?
|
||||
if [ $result != 0 ]; then
|
||||
echo "ERROR failed to download server from $serverDownloadUrl ($result)"
|
||||
log "ERROR failed to download server from $serverDownloadUrl ($result)"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
isDebugging && ls -l
|
||||
|
||||
# Continue to Final Setup
|
||||
exec /start-finalSetup01World $@
|
||||
exec ${SCRIPTS:-/}start-finalSetupWorld $@
|
||||
|
||||
30
start-deployYatopia
Normal file
30
start-deployYatopia
Normal file
@@ -0,0 +1,30 @@
|
||||
#!/bin/bash
|
||||
set -euo pipefail
|
||||
IFS=$'\n\t'
|
||||
|
||||
. ${SCRIPTS:-/}start-utils
|
||||
isDebugging && set -x
|
||||
|
||||
: ${VANILLA_VERSION:?}
|
||||
: ${RELEASE:=stable}
|
||||
: ${FORCE_REDOWNLOAD:=false}
|
||||
|
||||
requireEnum RELEASE stable latest
|
||||
|
||||
export SERVER="yatopia-${RELEASE}-${VANILLA_VERSION}.jar"
|
||||
|
||||
if [ ! -f "$SERVER" ] || isTrue "$FORCE_REDOWNLOAD"; then
|
||||
downloadUrl="https://api.yatopiamc.org/v2/${RELEASE}Build/download?branch=ver/${VANILLA_VERSION}"
|
||||
log "Downloading Yatopia from $downloadUrl ..."
|
||||
if ! curl -fsSL -o "$SERVER" "$downloadUrl"; then
|
||||
log "ERROR: failed to download from $downloadUrl (status=$?)"
|
||||
exit 3
|
||||
fi
|
||||
fi
|
||||
|
||||
# Normalize on Spigot for later operations
|
||||
export TYPE=SPIGOT
|
||||
export SKIP_LOG4J_CONFIG=true
|
||||
|
||||
# Continue to Final Setup
|
||||
exec ${SCRIPTS:-/}start-finalSetupWorld $@
|
||||
@@ -1,50 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
if [ $TYPE = "FEED-THE-BEAST" ]; then
|
||||
worldDest=$FTB_BASE_DIR/$LEVEL
|
||||
else
|
||||
worldDest=/data/$LEVEL
|
||||
fi
|
||||
|
||||
# If no world exists and a URL for a world is supplied, download it and unpack
|
||||
if [[ "$WORLD" ]] && [ ! -d "$worldDest" ]; 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 $worldDest ]; 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" $worldDest
|
||||
fi
|
||||
done
|
||||
fi
|
||||
if [ "$TYPE" = "SPIGOT" ]; then
|
||||
# Reorganise if a Spigot server
|
||||
echo "Moving End and Nether maps to Spigot location"
|
||||
[ -d "$worldDest/DIM1" ] && mv -f "$worldDest/DIM1" "/data/${LEVEL}_the_end"
|
||||
[ -d "$worldDest/DIM-1" ] && mv -f "$worldDest/DIM-1" "/data/${LEVEL}_nether"
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
if [[ -d $WORLD ]]; then
|
||||
if [[ ! -d $worldDest ]]; then
|
||||
echo "Cloning world directory from $WORLD ..."
|
||||
cp -r $WORLD $worldDest
|
||||
else
|
||||
echo "Skipping clone from $WORLD since $worldDest exists"
|
||||
fi
|
||||
else
|
||||
echo "Invalid URL given for world: Must be HTTP or HTTPS and a ZIP file"
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
exec /start-finalSetup02Modpack $@
|
||||
@@ -1,109 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# CURSE_URL_BASE used in manifest downloads below
|
||||
CURSE_URL_BASE=${CURSE_URL_BASE:-https://minecraft.curseforge.com/projects}
|
||||
|
||||
# Remove old mods/plugins
|
||||
if [ "$REMOVE_OLD_MODS" = "TRUE" ]; then
|
||||
if [ "$TYPE" = "SPIGOT" ]; then
|
||||
rm -rf /data/plugins/*
|
||||
else
|
||||
rm -rf /data/mods/*
|
||||
fi
|
||||
fi
|
||||
|
||||
# If supplied with a URL for a modpack (simple zip of jars), download it and unpack
|
||||
if [[ "$MODPACK" ]]; then
|
||||
EFFECTIVE_MODPACK_URL=$(curl -Ls -o /dev/null -w %{url_effective} $MODPACK)
|
||||
case "X$EFFECTIVE_MODPACK_URL" in
|
||||
X[Hh][Tt][Tt][Pp]*.zip)
|
||||
echo "Downloading mod/plugin pack via HTTP"
|
||||
echo " from $EFFECTIVE_MODPACK_URL ..."
|
||||
if ! curl -sSL -o /tmp/modpack.zip "$EFFECTIVE_MODPACK_URL"; then
|
||||
echo "ERROR: failed to download from $EFFECTIVE_MODPACK_URL"
|
||||
exit 2
|
||||
fi
|
||||
|
||||
if [ "$TYPE" = "SPIGOT" ]; then
|
||||
mkdir -p /data/plugins
|
||||
if ! unzip -o -d /data/plugins /tmp/modpack.zip; then
|
||||
echo "ERROR: failed to unzip the modpack from $EFFECTIVE_MODPACK_URL"
|
||||
fi
|
||||
else
|
||||
mkdir -p /data/mods
|
||||
if ! unzip -o -d /data/mods /tmp/modpack.zip; then
|
||||
echo "ERROR: failed to unzip the modpack from $EFFECTIVE_MODPACK_URL"
|
||||
fi
|
||||
fi
|
||||
rm -f /tmp/modpack.zip
|
||||
;;
|
||||
*)
|
||||
echo "Invalid URL given for modpack: Must be HTTP or HTTPS and a ZIP file"
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
# If supplied with a URL for a plugin download it.
|
||||
if [[ "$MODS" ]]; then
|
||||
for i in ${MODS//,/ }
|
||||
do
|
||||
EFFECTIVE_MOD_URL=$(curl -Ls -o /dev/null -w %{url_effective} $i)
|
||||
case "X$EFFECTIVE_MOD_URL" in
|
||||
X[Hh][Tt][Tt][Pp]*.jar)
|
||||
echo "Downloading mod/plugin via HTTP"
|
||||
echo " from $EFFECTIVE_MOD_URL ..."
|
||||
if ! curl -sSL -o /tmp/${EFFECTIVE_MOD_URL##*/} $EFFECTIVE_MOD_URL; then
|
||||
echo "ERROR: failed to download from $EFFECTIVE_MOD_URL to /tmp/${EFFECTIVE_MOD_URL##*/}"
|
||||
exit 2
|
||||
fi
|
||||
|
||||
if [ "$TYPE" = "SPIGOT" ]; then
|
||||
mkdir -p /data/plugins
|
||||
mv /tmp/${EFFECTIVE_MOD_URL##*/} /data/plugins/${EFFECTIVE_MOD_URL##*/}
|
||||
else
|
||||
mkdir -p /data/mods
|
||||
mv /tmp/${EFFECTIVE_MOD_URL##*/} /data/mods/${EFFECTIVE_MOD_URL##*/}
|
||||
fi
|
||||
rm -f /tmp/${EFFECTIVE_MOD_URL##*/}
|
||||
;;
|
||||
*)
|
||||
echo "Invalid URL given for modpack: Must be HTTP or HTTPS and a JAR file"
|
||||
;;
|
||||
esac
|
||||
done
|
||||
fi
|
||||
|
||||
if [[ "$MANIFEST" ]]; then
|
||||
EFFECTIVE_MANIFEST_URL=$(curl -Ls -o /dev/null -w %{url_effective} $MANIFEST)
|
||||
case "X$EFFECTIVE_MANIFEST_URL" in
|
||||
X*.json)
|
||||
if [ -f "${EFFECTIVE_MANIFEST_URL}" ]; then
|
||||
MOD_DIR=${FTB_BASE_DIR:-/data}/mods
|
||||
if [ ! -d "$MOD_DIR" ]
|
||||
then
|
||||
echo "Creating mods dir $MOD_DIR"
|
||||
mkdir -p "$MOD_DIR"
|
||||
fi
|
||||
echo "Starting manifest download..."
|
||||
cat "${EFFECTIVE_MANIFEST_URL}" | jq -r '.files[] | (.projectID|tostring) + " " + (.fileID|tostring)'| while read -r p f
|
||||
do
|
||||
if [ ! -f $MOD_DIR/${p}_${f}.jar ]
|
||||
then
|
||||
redirect_url="$(curl -Ls -o /dev/null -w %{url_effective} ${CURSE_URL_BASE}/${p})"
|
||||
url="$redirect_url/download/${f}/file"
|
||||
echo Downloading curseforge mod $url
|
||||
# Manifest usually doesn't have mod names. Using id should be fine, tho
|
||||
curl -sSL "${url}" -o $MOD_DIR/${p}_${f}.jar
|
||||
fi
|
||||
done
|
||||
else
|
||||
echo "Could not find manifest file, unsufficient privs, or malformed path."
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
echo "Invalid manifest file for modpack. Please make sure it is a .json file."
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
exec /start-finalSetup03Modconfig $@
|
||||
@@ -1,146 +0,0 @@
|
||||
#!/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
|
||||
}
|
||||
|
||||
function customizeServerProps {
|
||||
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-name" "$SERVER_NAME"
|
||||
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"
|
||||
setServerProp "level-type" "${LEVEL_TYPE^^}"
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
# Deploy server.properties file
|
||||
if [[ ${TYPE} == "FEED-THE-BEAST" ]]; then
|
||||
export SERVER_PROPERTIES=${FTB_DIR}/server.properties
|
||||
echo "detected FTB, changing properties path to ${SERVER_PROPERTIES}"
|
||||
fi
|
||||
|
||||
if [ ! -e "$SERVER_PROPERTIES" ]; then
|
||||
echo "Creating server.properties in ${SERVER_PROPERTIES}"
|
||||
cp /tmp/server.properties "$SERVER_PROPERTIES"
|
||||
customizeServerProps
|
||||
elif [ -n "${OVERRIDE_SERVER_PROPERTIES}" ]; then
|
||||
case ${OVERRIDE_SERVER_PROPERTIES^^} in
|
||||
TRUE|1)
|
||||
customizeServerProps
|
||||
;;
|
||||
*)
|
||||
echo "server.properties already created, skipping"
|
||||
;;
|
||||
esac
|
||||
else
|
||||
echo "server.properties already created, skipping"
|
||||
fi
|
||||
|
||||
exec /start-finalSetup05EnvVariables $@
|
||||
@@ -1,15 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
if [ "$REPLACE_ENV_VARIABLES" = "TRUE" ]; then
|
||||
echo "Replacing env variables in configs that match the prefix $ENV_VARIABLE_PREFIX..."
|
||||
while IFS='=' read -r name value ; do
|
||||
# check if name of env variable matches the prefix
|
||||
# sanity check environment variables to avoid code injections
|
||||
if [[ "$name" = $ENV_VARIABLE_PREFIX* ]] && [[ $value =~ ^[0-9a-zA-Z_:/=?.+\-]*$ ]] && [[ $name =~ ^[0-9a-zA-Z_\-]*$ ]]; then
|
||||
echo "Replacing $name with $value ..."
|
||||
find /data/ -type f \( -name "*.yml" -or -name "*.yaml" -or -name "*.txt" -or -name "*.cfg" -or -name "*.properties" \) -exec sed -i 's#${'"$name"'}#'"$value"'#g' {} \;
|
||||
fi
|
||||
done < <(env)
|
||||
fi
|
||||
|
||||
exec /start-minecraftFinalSetup $@
|
||||
51
start-finalSetupEnvVariables
Normal file
51
start-finalSetupEnvVariables
Normal file
@@ -0,0 +1,51 @@
|
||||
#!/bin/bash
|
||||
|
||||
. ${SCRIPTS:-/}start-utils
|
||||
|
||||
: ${ENV_VARIABLE_PREFIX:=CFG_}
|
||||
|
||||
if isTrue "${REPLACE_ENV_VARIABLES}"; then
|
||||
log "Replacing env variables in configs that match the prefix $ENV_VARIABLE_PREFIX ..."
|
||||
|
||||
# File excludes
|
||||
fileExcludes=
|
||||
for f in ${REPLACE_ENV_VARIABLES_EXCLUDES}; do
|
||||
fileExcludes="${fileExcludes} -not -name $f"
|
||||
done
|
||||
|
||||
# Directory excludes (recursive)
|
||||
dirExcludes=$(join_by " -o -path " ${REPLACE_ENV_VARIABLES_EXCLUDE_PATHS})
|
||||
if [[ $dirExcludes ]]; then
|
||||
dirExcludes=" -type d ( -path ${dirExcludes} ) -prune -o"
|
||||
fi
|
||||
|
||||
isDebugging && echo "Using find file exclusions: $fileExcludes"
|
||||
isDebugging && echo "Using find directory exclusions: $dirExcludes"
|
||||
|
||||
for name in $(compgen -v $ENV_VARIABLE_PREFIX); do
|
||||
# check if name of env variable matches the prefix
|
||||
# sanity check environment variables to avoid code injections
|
||||
# Read content from file environment
|
||||
if [[ $name = *"_FILE" ]]; then
|
||||
value=$(<${!name})
|
||||
name="${name%_FILE}"
|
||||
else
|
||||
value=${!name}
|
||||
fi
|
||||
|
||||
log "Replacing $name with $value ..."
|
||||
|
||||
value=${value//\\/\\\\}
|
||||
value=${value//#/\\#}
|
||||
|
||||
find /data/ \
|
||||
$dirExcludes \
|
||||
-type f \
|
||||
\( -name "*.yml" -or -name "*.yaml" -or -name "*.txt" -or -name "*.cfg" \
|
||||
-or -name "*.conf" -or -name "*.properties" \) \
|
||||
$fileExcludes \
|
||||
-exec sed -i 's#${'"$name"'}#'"$value"'#g' {} \;
|
||||
done
|
||||
fi
|
||||
|
||||
exec ${SCRIPTS:-/}start-minecraftFinalSetup $@
|
||||
@@ -1,11 +1,13 @@
|
||||
#!/bin/bash
|
||||
|
||||
. ${SCRIPTS:-/}start-utils
|
||||
|
||||
# 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 ..."
|
||||
log "Downloading mod/plugin configs via HTTP"
|
||||
log " from $MODCONFIG ..."
|
||||
curl -sSL -o /tmp/modconfig.zip "$MODCONFIG"
|
||||
if [ "$TYPE" = "SPIGOT" ]; then
|
||||
mkdir -p /data/plugins
|
||||
@@ -17,9 +19,9 @@ case "X$MODCONFIG" in
|
||||
rm -f /tmp/modconfig.zip
|
||||
;;
|
||||
*)
|
||||
echo "Invalid URL given for modconfig: Must be HTTP or HTTPS and a ZIP file"
|
||||
log "Invalid URL given for modconfig: Must be HTTP or HTTPS and a ZIP file"
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
exec /start-finalSetup04ServerProperties $@
|
||||
exec ${SCRIPTS:-/}start-finalSetupMounts $@
|
||||
186
start-finalSetupModpack
Normal file
186
start-finalSetupModpack
Normal file
@@ -0,0 +1,186 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e -o pipefail
|
||||
|
||||
. ${SCRIPTS:-/}start-utils
|
||||
if isDebugging; then
|
||||
set -x
|
||||
fi
|
||||
|
||||
# CURSE_URL_BASE used in manifest downloads below
|
||||
CURSE_URL_BASE=${CURSE_URL_BASE:-https://minecraft.curseforge.com/projects}
|
||||
|
||||
# Remove old mods/plugins
|
||||
if isTrue ${REMOVE_OLD_MODS}; then
|
||||
remove_mods_dest="/data/mods"
|
||||
case ${TYPE} in
|
||||
SPIGOT|BUKKIT|PAPER)
|
||||
remove_mods_dest="/data/plugins"
|
||||
;;
|
||||
esac
|
||||
|
||||
# only try to remove existing mods dir
|
||||
if [ -d "$remove_mods_dest" ]; then
|
||||
log "Removing old mods in $remove_mods_dest..."
|
||||
find $remove_mods_dest -mindepth 1 -maxdepth ${REMOVE_OLD_MODS_DEPTH:-16} -wholename "${REMOVE_OLD_MODS_INCLUDE:-*}" -not -wholename "${REMOVE_OLD_MODS_EXCLUDE}" -delete
|
||||
else
|
||||
log "Directory $remove_mods_dest does not exist; removing nothing."
|
||||
fi
|
||||
fi
|
||||
|
||||
# If supplied with a URL for a modpack (simple zip of jars), download it and unpack
|
||||
if [[ "$MODPACK" ]]; then
|
||||
if isURL "${MODPACK}"; then
|
||||
if [[ "${MODPACK}" == *.zip ]]; then
|
||||
downloadUrl="${MODPACK}"
|
||||
else
|
||||
downloadUrl=$(curl -Ls -o /dev/null -w %{effective_url} $MODPACK)
|
||||
if ! [[ $downloadUrl == *.zip ]]; then
|
||||
log "ERROR Invalid URL given for MODPACK: $downloadUrl resolved from $MODPACK"
|
||||
log " Must be HTTP or HTTPS and a ZIP file"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
log "Downloading mod/plugin pack via HTTP"
|
||||
log " from $downloadUrl ..."
|
||||
if ! curl -sSL -o /tmp/modpack.zip "$downloadUrl"; then
|
||||
log "ERROR: failed to download from $downloadUrl"
|
||||
exit 2
|
||||
fi
|
||||
|
||||
if [ "$TYPE" = "SPIGOT" ]; then
|
||||
mkdir -p /data/plugins
|
||||
if ! unzip -o -d /data/plugins /tmp/modpack.zip; then
|
||||
log "ERROR: failed to unzip the modpack from $downloadUrl"
|
||||
fi
|
||||
else
|
||||
mkdir -p /data/mods
|
||||
if ! unzip -o -d /data/mods /tmp/modpack.zip; then
|
||||
log "ERROR: failed to unzip the modpack from $downloadUrl"
|
||||
fi
|
||||
fi
|
||||
rm -f /tmp/modpack.zip
|
||||
|
||||
else
|
||||
log "ERROR Invalid URL given for MODPACK: $MODPACK"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
# If supplied with a URL for a plugin download it.
|
||||
if [[ "$MODS" ]]; then
|
||||
if [ "$TYPE" = "SPIGOT" ]; then
|
||||
out_dir=/data/plugins
|
||||
else
|
||||
out_dir=/data/mods
|
||||
fi
|
||||
mkdir -p "$out_dir"
|
||||
|
||||
for i in ${MODS//,/ }
|
||||
do
|
||||
if isURL $i; then
|
||||
log "Downloading mod/plugin $i ..."
|
||||
if isValidFileURL jar "$i"; then
|
||||
if ! curl -fsSL -o "${out_dir}/$(getFilenameFromUrl "${i}")" "${i}"; then
|
||||
log "ERROR: failed to download from $i into $out_dir"
|
||||
exit 2
|
||||
fi
|
||||
else
|
||||
effective_url=$(resolveEffectiveUrl "$i")
|
||||
if isValidFileURL jar "${effective_url}"; then
|
||||
out_file=$(getFilenameFromUrl "${effective_url}")
|
||||
if ! curl -fsSL -o "${out_dir}/$out_file" "${effective_url}"; then
|
||||
log "ERROR: failed to download from $i into $out_dir"
|
||||
exit 2
|
||||
fi
|
||||
else
|
||||
log "ERROR: $effective_url resolved from $i is not a valid jar URL"
|
||||
exit 2
|
||||
fi
|
||||
fi
|
||||
else
|
||||
log "ERROR Invalid URL given in MODS: $i"
|
||||
exit 2
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
if [[ "$MANIFEST" ]]; then
|
||||
if [[ -e "$MANIFEST" ]]; then
|
||||
EFFECTIVE_MANIFEST_FILE=$MANIFEST
|
||||
elif isURL "$MANIFEST"; then
|
||||
EFFECTIVE_MANIFEST_FILE=/tmp/manifest.json
|
||||
EFFECTIVE_MANIFEST_URL=$(curl -Ls -o /dev/null -w %{effective_url} $MANIFEST)
|
||||
curl -Ls -o $EFFECTIVE_MANIFEST_FILE "$EFFECTIVE_MANIFEST_URL"
|
||||
else
|
||||
log "MANIFEST='$MANIFEST' is not a valid manifest url or location"
|
||||
exit 2
|
||||
fi
|
||||
|
||||
case "X$EFFECTIVE_MANIFEST_FILE" in
|
||||
X*.json)
|
||||
if [ -f "${EFFECTIVE_MANIFEST_FILE}" ]; then
|
||||
MOD_DIR=${FTB_BASE_DIR:-/data}/mods
|
||||
if [ ! -d "$MOD_DIR" ]
|
||||
then
|
||||
log "Creating mods dir $MOD_DIR"
|
||||
mkdir -p "$MOD_DIR"
|
||||
fi
|
||||
log "Starting manifest download..."
|
||||
cat "${EFFECTIVE_MANIFEST_FILE}" | jq -r '.files[] | (.projectID|tostring) + " " + (.fileID|tostring)'| while read -r p f
|
||||
do
|
||||
if [ ! -f $MOD_DIR/${p}_${f}.jar ]
|
||||
then
|
||||
redirect_url="$(curl -Ls -o /dev/null -w %{effective_url} ${CURSE_URL_BASE}/${p})"
|
||||
url="$redirect_url/download/${f}/file"
|
||||
log Downloading curseforge mod $url
|
||||
# Manifest usually doesn't have mod names. Using id should be fine, tho
|
||||
curl -sSL "${url}" -o $MOD_DIR/${p}_${f}.jar
|
||||
fi
|
||||
done
|
||||
else
|
||||
log "Could not find manifest file, unsufficient privs, or malformed path."
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
log "Invalid manifest file for modpack. Please make sure it is a .json file."
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
if [[ "${GENERIC_PACK}" ]]; then
|
||||
if isURL "${GENERIC_PACK}"; then
|
||||
log "Downloading generic pack ..."
|
||||
curl -fsSL -o /tmp/generic_pack.zip "${GENERIC_PACK}"
|
||||
GENERIC_PACK=/tmp/generic_pack.zip
|
||||
fi
|
||||
|
||||
sum_file=/data/.generic_pack.sum
|
||||
if ! sha256sum -c ${sum_file} -s 2> /dev/null; then
|
||||
base_dir=/tmp/generic_pack_base
|
||||
mkdir -p ${base_dir}
|
||||
isDebugging && ls -l "${GENERIC_PACK}"
|
||||
unzip -q -d ${base_dir} "${GENERIC_PACK}"
|
||||
if [ -f /data/manifest.txt ]; then
|
||||
log "Manifest exists from older generic pack, cleaning up ..."
|
||||
while read f; do
|
||||
rm -rf "/data/${f}"
|
||||
done < /data/manifest.txt
|
||||
find /data/* -type d -exec rmdir --ignore-fail-on-non-empty {} +
|
||||
rm -f /data/manifest.txt
|
||||
fi
|
||||
log "Writing generic pack manifest ... "
|
||||
find ${base_dir} -type f -print0 | xargs -0 -I {} echo "{}" | sed "s#${base_dir}/##" > /data/manifest.txt
|
||||
log "Applying generic pack ..."
|
||||
IFS='
|
||||
'
|
||||
set -f
|
||||
for d in $(find ${base_dir} -type d); do mkdir -p "$(sed "s#${base_dir}#/data#" <<< $d)"; done
|
||||
for f in $(find ${base_dir} -type f); do cp -f "$f" "$(sed "s#${base_dir}#/data#" <<< $f)"; done
|
||||
rm -rf ${base_dir}
|
||||
sha256sum "${GENERIC_PACK}" > ${sum_file}
|
||||
fi
|
||||
fi
|
||||
|
||||
exec ${SCRIPTS:-/}start-finalSetupModconfig $@
|
||||
38
start-finalSetupMounts
Executable file
38
start-finalSetupMounts
Executable file
@@ -0,0 +1,38 @@
|
||||
#!/bin/bash
|
||||
|
||||
. ${SCRIPTS:-/}start-utils
|
||||
|
||||
: ${PLUGINS_SYNC_UPDATE:=true}
|
||||
|
||||
isDebugging && set -x
|
||||
|
||||
if [ -d /plugins ]; then
|
||||
case ${TYPE} in
|
||||
SPIGOT|BUKKIT|PAPER|MAGMA)
|
||||
mkdir -p /data/plugins
|
||||
log "Copying plugins over..."
|
||||
if isTrue ${PLUGINS_SYNC_UPDATE}; then
|
||||
updateArg="--update"
|
||||
fi
|
||||
# Copy plugins over using rsync to allow deeply nested updates of plugins
|
||||
rsync -a --out-format="update:%f:Last Modified %M" --prune-empty-dirs $updateArg /plugins /data
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
# If any modules have been provided, copy them over
|
||||
if [ -d /mods ]; then
|
||||
log "Copying any mods over..."
|
||||
mkdir -p /data/mods
|
||||
rsync -a --out-format="update:%f:Last Modified %M" "${rsyncArgs[@]}" --prune-empty-dirs --update /mods /data
|
||||
fi
|
||||
|
||||
: ${COPY_CONFIG_DEST:="/data/config"}
|
||||
|
||||
if [ -d /config ]; then
|
||||
log "Copying any configs from /config to $COPY_CONFIG_DEST"
|
||||
mkdir -p $COPY_CONFIG_DEST
|
||||
rsync -a --out-format="update:%f:Last Modified %M" "${rsyncArgs[@]}" --prune-empty-dirs --update /config/ $COPY_CONFIG_DEST
|
||||
fi
|
||||
|
||||
exec ${SCRIPTS:-/}start-finalSetupServerProperties $@
|
||||
220
start-finalSetupServerProperties
Normal file
220
start-finalSetupServerProperties
Normal file
@@ -0,0 +1,220 @@
|
||||
#!/bin/bash
|
||||
|
||||
. ${SCRIPTS:-/}start-utils
|
||||
|
||||
: ${SERVER_PROPERTIES:=/data/server.properties}
|
||||
|
||||
# FUNCTIONS
|
||||
function setServerProp {
|
||||
local prop=$1
|
||||
local var=$2
|
||||
if [ -n "$var" ]; then
|
||||
# normalize booleans
|
||||
case ${var^^} in
|
||||
TRUE|FALSE)
|
||||
var=${var,,} ;;
|
||||
esac
|
||||
if grep "${prop}" "$SERVER_PROPERTIES" > /dev/null; then
|
||||
log "Setting ${prop} to '${var}' in ${SERVER_PROPERTIES}"
|
||||
sed -i "/^${prop}\s*=/ c ${prop}=${var//\\/\\\\}" "$SERVER_PROPERTIES"
|
||||
else
|
||||
log "Adding ${prop} with '${var}' in ${SERVER_PROPERTIES}"
|
||||
echo "${prop}=${var//\\/\\\\}" >> "$SERVER_PROPERTIES"
|
||||
fi
|
||||
else
|
||||
isDebugging && log "Skip setting ${prop}"
|
||||
fi
|
||||
}
|
||||
|
||||
function customizeServerProps {
|
||||
if [ -n "$WHITELIST" ]; then
|
||||
log "Creating whitelist"
|
||||
setServerProp "whitelist" "true"
|
||||
setServerProp "white-list" "true"
|
||||
else
|
||||
log "Disabling whitelist"
|
||||
setServerProp "whitelist" "false"
|
||||
setServerProp "white-list" "false"
|
||||
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-name" "$SERVER_NAME"
|
||||
setServerProp "server-ip" "$SERVER_IP"
|
||||
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 "spawn-protection" "$SPAWN_PROTECTION"
|
||||
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"
|
||||
setServerProp "level-type" "${LEVEL_TYPE^^}"
|
||||
setServerProp "resource-pack" "$RESOURCE_PACK"
|
||||
setServerProp "resource-pack-sha1" "$RESOURCE_PACK_SHA1"
|
||||
setServerProp "player-idle-timeout" "$PLAYER_IDLE_TIMEOUT"
|
||||
setServerProp "broadcast-console-to-ops" "$BROADCAST_CONSOLE_TO_OPS"
|
||||
setServerProp "broadcast-rcon-to-ops" "$BROADCAST_RCON_TO_OPS"
|
||||
setServerProp "enable-jmx-monitoring" "$ENABLE_JMX"
|
||||
setServerProp "sync-chunk-writes" "$SYNC_CHUNK_WRITES"
|
||||
setServerProp "enable-status" "$ENABLE_STATUS"
|
||||
setServerProp "entity-broadcast-range-percentage" "$ENTITY_BROADCAST_RANGE_PERCENTAGE"
|
||||
setServerProp "function-permission-level" "$FUNCTION_PERMISSION_LEVEL"
|
||||
setServerProp "network-compression-threshold" "$NETWORK_COMPRESSION_THRESHOLD"
|
||||
setServerProp "op-permission-level" "$OP_PERMISSION_LEVEL"
|
||||
setServerProp "prevent-proxy-connections" "$PREVENT_PROXY_CONNECTIONS"
|
||||
setServerProp "use-native-transport" "$USE_NATIVE_TRANSPORT"
|
||||
setServerProp "enforce-whitelist" "$ENFORCE_WHITELIST"
|
||||
|
||||
if [ -n "$DIFFICULTY" ]; then
|
||||
case $DIFFICULTY in
|
||||
peaceful|0)
|
||||
if versionLessThan 1.13; then
|
||||
DIFFICULTY=0
|
||||
else
|
||||
DIFFICULTY=peaceful
|
||||
fi
|
||||
;;
|
||||
easy|1)
|
||||
if versionLessThan 1.13; then
|
||||
DIFFICULTY=1
|
||||
else
|
||||
DIFFICULTY=easy
|
||||
fi
|
||||
;;
|
||||
normal|2)
|
||||
if versionLessThan 1.13; then
|
||||
DIFFICULTY=2
|
||||
else
|
||||
DIFFICULTY=normal
|
||||
fi
|
||||
;;
|
||||
hard|3)
|
||||
if versionLessThan 1.13; then
|
||||
DIFFICULTY=3
|
||||
else
|
||||
DIFFICULTY=hard
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
log "DIFFICULTY must be peaceful, easy, normal, or hard."
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
setServerProp "difficulty" "$DIFFICULTY"
|
||||
fi
|
||||
|
||||
if [ -n "$MODE" ]; then
|
||||
log "Setting mode"
|
||||
MODE_LC=$( echo $MODE | tr '[:upper:]' '[:lower:]' )
|
||||
case $MODE_LC in
|
||||
su*|0)
|
||||
if versionLessThan 1.13; then
|
||||
MODE=0
|
||||
else
|
||||
MODE=survival
|
||||
fi
|
||||
;;
|
||||
c*|1)
|
||||
if versionLessThan 1.13; then
|
||||
MODE=1
|
||||
else
|
||||
MODE=creative
|
||||
fi
|
||||
;;
|
||||
a*|2)
|
||||
if versionLessThan 1.13; then
|
||||
MODE=2
|
||||
else
|
||||
MODE=adventure
|
||||
fi
|
||||
;;
|
||||
sp*|3)
|
||||
if versionLessThan 1.13; then
|
||||
MODE=3
|
||||
else
|
||||
MODE=spectator
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
log "ERROR: Invalid game mode: $MODE"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
setServerProp "gamemode" "$MODE"
|
||||
fi
|
||||
}
|
||||
|
||||
# Deploy server.properties file
|
||||
if [[ ${TYPE} == "FEED-THE-BEAST" ]]; then
|
||||
export SERVER_PROPERTIES=${FTB_DIR}/server.properties
|
||||
log "detected FTB, changing properties path to ${SERVER_PROPERTIES}"
|
||||
fi
|
||||
|
||||
if [ ! -e "$SERVER_PROPERTIES" ]; then
|
||||
log "Creating server.properties in ${SERVER_PROPERTIES}"
|
||||
cp /tmp/server.properties "$SERVER_PROPERTIES"
|
||||
customizeServerProps
|
||||
elif [ -n "${OVERRIDE_SERVER_PROPERTIES}" ]; then
|
||||
case ${OVERRIDE_SERVER_PROPERTIES^^} in
|
||||
TRUE|1)
|
||||
customizeServerProps
|
||||
;;
|
||||
*)
|
||||
log "server.properties already created, skipping"
|
||||
;;
|
||||
esac
|
||||
else
|
||||
log "server.properties already created, skipping"
|
||||
fi
|
||||
|
||||
if isTrue "${ENABLE_AUTOPAUSE}"; then
|
||||
current_max_tick=$( grep 'max-tick-time' "$SERVER_PROPERTIES" | sed -r 's/( )+//g' | awk -F= '{print $2}' )
|
||||
if (( $current_max_tick > 0 && $current_max_tick < 86400000 )); then
|
||||
log "Warning: The server.properties for the server doesn't have the Server Watchdog (effectively) disabled."
|
||||
log "Warning (cont): Autopause functionality resuming the process might trigger the Watchdog and restart the server completely."
|
||||
log "Warning (cont): Set the max-tick-time property to a high value (or disable the Watchdog with value -1 for versions 1.8.1+)."
|
||||
fi
|
||||
fi
|
||||
|
||||
if isDebugging; then
|
||||
log "DEBUG Dumping server.properties"
|
||||
cat /data/server.properties
|
||||
fi
|
||||
|
||||
exec ${SCRIPTS:-/}start-finalSetupEnvVariables $@
|
||||
74
start-finalSetupWorld
Normal file
74
start-finalSetupWorld
Normal file
@@ -0,0 +1,74 @@
|
||||
#!/bin/bash
|
||||
|
||||
. ${SCRIPTS:-/}start-utils
|
||||
set -e
|
||||
isDebugging && set -x
|
||||
|
||||
: ${LEVEL:=world}
|
||||
export LEVEL
|
||||
|
||||
if [ $TYPE = "FEED-THE-BEAST" ]; then
|
||||
worldDest=$FTB_DIR/$LEVEL
|
||||
else
|
||||
worldDest=/data/$LEVEL
|
||||
fi
|
||||
|
||||
if [[ "$WORLD" ]] && ( isTrue "${FORCE_WORLD_COPY}" || [ ! -d "$worldDest" ] ); then
|
||||
if isTrue "${FORCE_WORLD_COPY}"; then
|
||||
log "Removing existing world data in $worldDest ${worldDest}_nether ${worldDest}_the_end"
|
||||
rm -rf "$worldDest" \
|
||||
"${worldDest}_nether" \
|
||||
"${worldDest}_the_end"
|
||||
fi
|
||||
|
||||
if isURL $WORLD; then
|
||||
curl -fsSL "$WORLD" -o /tmp/world.zip
|
||||
zipSrc=/tmp/world.zip
|
||||
elif [[ "$WORLD" =~ .*\.zip ]]; then
|
||||
zipSrc="$WORLD"
|
||||
fi
|
||||
|
||||
if [[ "$zipSrc" ]]; then
|
||||
log "Unzipping world"
|
||||
|
||||
# Stage contents so that the correct subdirectory can be picked off
|
||||
mkdir -p /tmp/world-data
|
||||
(cd /tmp/world-data && unzip -o -q "$zipSrc")
|
||||
|
||||
if [ "$TYPE" = "SPIGOT" ]; then
|
||||
baseDirs=$(find /tmp/world-data -name "level.dat" -not -path "*_nether*" -not -path "*_the_end*" -exec dirname "{}" \;)
|
||||
else
|
||||
baseDirs=$(find /tmp/world-data -name "level.dat" -exec dirname "{}" \;)
|
||||
fi
|
||||
|
||||
count=$(echo "$baseDirs" | wc -l)
|
||||
if [[ $count -gt 1 ]]; then
|
||||
baseDir="$(echo "$baseDirs" | sed -n ${WORLD_INDEX:-1}p)"
|
||||
baseName=$(basename "$baseDir")
|
||||
log "WARN multiple levels found, picking: $baseName"
|
||||
elif [[ $count -gt 0 ]]; then
|
||||
baseDir="$baseDirs"
|
||||
else
|
||||
log "ERROR invalid world content"
|
||||
exit 1
|
||||
fi
|
||||
rsync --remove-source-files --recursive --delete "$baseDir/" "$worldDest"
|
||||
if [ "$TYPE" = "SPIGOT" ]; then
|
||||
log "Copying end and nether ..."
|
||||
[ -d "${baseDir}_nether" ] && rsync --remove-source-files --recursive --delete "${baseDir}_nether/" "${worldDest}_nether"
|
||||
[ -d "${baseDir}_the_end" ] && rsync --remove-source-files --recursive --delete "${baseDir}_the_end/" "${worldDest}_the_end"
|
||||
fi
|
||||
else
|
||||
log "Cloning world directory from $WORLD ..."
|
||||
rsync --recursive --delete "${WORLD%/}"/ "$worldDest"
|
||||
fi
|
||||
|
||||
if [ "$TYPE" = "SPIGOT" ]; then
|
||||
# Reorganise if a Spigot server
|
||||
log "Moving End and Nether maps to Spigot location"
|
||||
[ -d "$worldDest/DIM1" ] && mv -f "$worldDest/DIM1" "${worldDest}_the_end"
|
||||
[ -d "$worldDest/DIM-1" ] && mv -f "$worldDest/DIM-1" "${worldDest}_nether"
|
||||
fi
|
||||
fi
|
||||
|
||||
exec ${SCRIPTS:-/}start-finalSetupModpack $@
|
||||
@@ -1,80 +1,77 @@
|
||||
#!/bin/bash
|
||||
|
||||
. /start-utils
|
||||
. ${SCRIPTS:-/}start-utils
|
||||
isDebugging && set -x
|
||||
|
||||
if [ -n "$OPS" -a ! -e ops.txt.converted ]; then
|
||||
echo "Setting ops"
|
||||
echo $OPS | awk -v RS=, '{print}' >> ops.txt
|
||||
if [ -n "$OPS" ]; then
|
||||
log "Updating ops"
|
||||
rm -f /data/ops.txt.converted
|
||||
echo $OPS | awk -v RS=, '{print}' > /data/ops.txt
|
||||
fi
|
||||
if isTrue "${OVERRIDE_OPS}"; then
|
||||
log "Recreating ops.json file at server startup"
|
||||
rm -f /data/ops.json
|
||||
fi
|
||||
|
||||
if [ -n "$WHITELIST" -a ! -e white-list.txt.converted ]; then
|
||||
echo "Setting whitelist"
|
||||
echo $WHITELIST | awk -v RS=, '{print}' >> white-list.txt
|
||||
if [ -n "$WHITELIST" ]; then
|
||||
log "Updating whitelist"
|
||||
rm -f /data/white-list.txt.converted
|
||||
echo $WHITELIST | awk -v RS=, '{print}' > /data/white-list.txt
|
||||
fi
|
||||
if isTrue "${OVERRIDE_WHITELIST}"; then
|
||||
log "Recreating whitelist.json file at server startup"
|
||||
rm -f /data/whitelist.json
|
||||
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
|
||||
if [ -n "$ICON" ]; then
|
||||
if [ ! -e server-icon.png ] || [ "${OVERRIDE_ICON}" == "TRUE" ]; then
|
||||
log "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
|
||||
log "Converting image to 64x64 PNG..."
|
||||
convert /tmp/icon.img -resize 64x64! /data/server-icon.png
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
if isTrue ${ENABLE_ROLLING_LOGS:-false}; then
|
||||
# Set up log configuration
|
||||
LOGFILE="/data/log4j2.xml"
|
||||
if [ ! -e "$LOGFILE" ]; then
|
||||
log "Creating log4j2.xml in ${LOGFILE}"
|
||||
cp /tmp/log4j2.xml "$LOGFILE"
|
||||
else
|
||||
echo "Converting image to 64x64 PNG..."
|
||||
convert /tmp/icon.img -resize 64x64! /data/server-icon.png
|
||||
log "log4j2.xml already created, skipping"
|
||||
fi
|
||||
JVM_OPTS="-Dlog4j.configurationFile=/data/log4j2.xml ${JVM_OPTS}"
|
||||
fi
|
||||
|
||||
# Make sure files exist and are valid JSON (for pre-1.12 to 1.12 upgrades)
|
||||
echo "Checking for JSON files."
|
||||
JSON_FILES=$(find . -maxdepth 1 -name '*.json')
|
||||
log "Checking for JSON files."
|
||||
JSON_FILES=$(find /data -maxdepth 1 -name '*.json')
|
||||
for j in $JSON_FILES; do
|
||||
if [[ $(python -c "print open('$j').read().strip()==''") = True ]]; then
|
||||
echo "Fixing JSON $j"
|
||||
if [[ $(cat "$j" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//') == "" ]]; then
|
||||
log "Fixing JSON $j"
|
||||
echo '[]' > $j
|
||||
fi
|
||||
done
|
||||
|
||||
|
||||
# If any modules have been provided, copy them over
|
||||
mkdir -p /data/mods
|
||||
if [ -d /mods ]; then
|
||||
echo "Copying any mods over..."
|
||||
rsync -a --out-format="update:%f:Last Modified %M" --prune-empty-dirs --update /mods /data
|
||||
fi
|
||||
|
||||
[ -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
|
||||
|
||||
mkdir -p /data/plugins
|
||||
if [ "$TYPE" = "SPIGOT" ]; then
|
||||
if [ -d /plugins ]; then
|
||||
echo "Copying any Bukkit plugins over..."
|
||||
# Copy plugins over using rsync to allow deeply nested updates of plugins
|
||||
# only updates files if the source file is newer and print updated files
|
||||
rsync -a --out-format="update:%f:Last Modified %M" --prune-empty-dirs --update /plugins /data
|
||||
fi
|
||||
fi
|
||||
|
||||
EXTRA_ARGS=""
|
||||
# Optional disable console
|
||||
if [[ ${CONSOLE} = false || ${CONSOLE} = FALSE ]]; then
|
||||
EXTRA_ARGS+="--noconsole"
|
||||
if versionLessThan 1.14 && [[ ${CONSOLE,,} = false ]]; then
|
||||
EXTRA_ARGS+=" --noconsole"
|
||||
fi
|
||||
|
||||
# Optional disable GUI for headless servers
|
||||
if [[ ${GUI} = false || ${GUI} = FALSE ]]; then
|
||||
EXTRA_ARGS="${EXTRA_ARGS} nogui"
|
||||
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}}"
|
||||
log "Setting initial memory to ${INIT_MEMORY:=${MEMORY}} and max to ${MAX_MEMORY:=${MEMORY}}"
|
||||
|
||||
expandedDOpts=
|
||||
if [ -n "$JVM_DD_OPTS" ]; then
|
||||
@@ -84,46 +81,161 @@ if [ -n "$JVM_DD_OPTS" ]; then
|
||||
done
|
||||
fi
|
||||
|
||||
mcServerRunnerArgs="--stop-duration 60s"
|
||||
if isTrue ${ENABLE_JMX}; then
|
||||
: ${JMX_PORT:=7091}
|
||||
JVM_OPTS="${JVM_OPTS}
|
||||
-Dcom.sun.management.jmxremote.local.only=false
|
||||
-Dcom.sun.management.jmxremote.port=${JMX_PORT}
|
||||
-Dcom.sun.management.jmxremote.rmi.port=${JMX_PORT}
|
||||
-Dcom.sun.management.jmxremote.authenticate=false
|
||||
-Dcom.sun.management.jmxremote.ssl=false
|
||||
-Dcom.sun.management.jmxremote.host=${JMX_BINDING:-0.0.0.0}
|
||||
-Djava.rmi.server.hostname=${JMX_HOST:-localhost}"
|
||||
|
||||
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
|
||||
log "JMX is enabled. Make sure you have port forwarding for ${JMX_PORT}"
|
||||
fi
|
||||
|
||||
if [ ! -e "${FTB_DIR}/whitelist.json" -a -e /data/white-list.txt ]; then
|
||||
cp -f /data/white-list.txt ${FTB_DIR}/
|
||||
fi
|
||||
if isTrue "${USE_AIKAR_FLAGS}"; then
|
||||
# From https://mcflags.emc.gs/
|
||||
|
||||
cp -f /data/eula.txt "${FTB_DIR}/"
|
||||
if (( $(normalizeMemSize "${MAX_MEMORY}") >= $(normalizeMemSize 12g) )); then
|
||||
log "Using Aikar's >12GB flags"
|
||||
G1NewSizePercent=40
|
||||
G1MaxNewSizePercent=50
|
||||
G1HeapRegionSize=16M
|
||||
G1ReservePercent=15
|
||||
InitiatingHeapOccupancyPercent=20
|
||||
else
|
||||
log "Using Aikar's flags"
|
||||
G1NewSizePercent=30
|
||||
G1MaxNewSizePercent=40
|
||||
G1HeapRegionSize=8M
|
||||
G1ReservePercent=20
|
||||
InitiatingHeapOccupancyPercent=15
|
||||
fi
|
||||
|
||||
cat > "${FTB_DIR}/settings-local.sh" <<EOF
|
||||
export MIN_RAM="${INIT_MEMORY}"
|
||||
export MAX_RAM="${MAX_MEMORY}"
|
||||
export JAVA_PARAMETERS="-Xms${INIT_MEMORY} $expandedDOpts"
|
||||
EOF
|
||||
JVM_XX_OPTS="${JVM_XX_OPTS}
|
||||
-XX:+UseG1GC
|
||||
-XX:+ParallelRefProcEnabled
|
||||
-XX:MaxGCPauseMillis=200
|
||||
-XX:+UnlockExperimentalVMOptions
|
||||
-XX:+DisableExplicitGC
|
||||
-XX:+AlwaysPreTouch
|
||||
-XX:G1NewSizePercent=${G1NewSizePercent}
|
||||
-XX:G1MaxNewSizePercent=${G1MaxNewSizePercent}
|
||||
-XX:G1HeapRegionSize=${G1HeapRegionSize}
|
||||
-XX:G1ReservePercent=${G1ReservePercent}
|
||||
-XX:G1HeapWastePercent=5
|
||||
-XX:G1MixedGCCountTarget=4
|
||||
-XX:InitiatingHeapOccupancyPercent=${InitiatingHeapOccupancyPercent}
|
||||
-XX:G1MixedGCLiveThresholdPercent=90
|
||||
-XX:G1RSetUpdatingPauseTimePercent=5
|
||||
-XX:SurvivorRatio=32
|
||||
-XX:+PerfDisableSharedMem
|
||||
-XX:MaxTenuringThreshold=1
|
||||
-Dusing.aikars.flags=https://mcflags.emc.gs
|
||||
-Daikars.new.flags=true
|
||||
"
|
||||
fi
|
||||
|
||||
# patch CurseForge cfg file, if present
|
||||
if [ -f "${FTB_DIR}/settings.cfg" ]; then
|
||||
sed -i "s/MAX_RAM=[^;]*/MAX_RAM=${MAX_MEMORY}/" "${FTB_DIR}/settings.cfg"
|
||||
fi
|
||||
if isTrue "${USE_LARGE_PAGES}"; then
|
||||
JVM_XX_OPTS="${JVM_XX_OPTS}
|
||||
-XX:+UseLargePagesInMetaspace
|
||||
"
|
||||
fi
|
||||
|
||||
cd "${FTB_DIR}"
|
||||
echo "Running FTB ${FTB_SERVER_START} in ${FTB_DIR} ..."
|
||||
if isTrue "${DEBUG_MEMORY}"; then
|
||||
log "Memory usage and availability (in MB)"
|
||||
uname -a
|
||||
free -m
|
||||
fi
|
||||
|
||||
JVM_OPTS="-Xms${INIT_MEMORY} -Xmx${MAX_MEMORY} ${JVM_OPTS}"
|
||||
|
||||
function copyFilesForCurseForge() {
|
||||
# copy player modification files unconditionally since their
|
||||
# processing into json is additive anyway
|
||||
[ -f /data/ops.txt ] && cp -f /data/ops.txt "${FTB_DIR}/"
|
||||
[ -f /data/white-list.txt ] && cp -f /data/white-list.txt "${FTB_DIR}/"
|
||||
|
||||
if [ ! -e "${FTB_DIR}/server-icon.png" -a -e /data/server-icon.png ]; then
|
||||
cp -f /data/server-icon.png "${FTB_DIR}/"
|
||||
fi
|
||||
|
||||
cp -f /data/eula.txt "${FTB_DIR}/"
|
||||
}
|
||||
|
||||
mcServerRunnerArgs="--stop-duration ${STOP_DURATION:-60}s"
|
||||
if [[ ${TYPE} == "CURSE_INSTANCE" ]]; then
|
||||
if isTrue ${DEBUG_EXEC}; then
|
||||
set -x
|
||||
fi
|
||||
exec mc-server-runner ${mcServerRunnerArgs} "${FTB_SERVER_START}"
|
||||
exec mc-server-runner ${mcServerRunnerArgs} \
|
||||
--cf-instance-file "${CURSE_INSTANCE_JSON}" \
|
||||
java $JVM_XX_OPTS $JVM_OPTS $expandedDOpts -jar _SERVERJAR_ "$@" $EXTRA_ARGS
|
||||
elif [[ ${TYPE} == "FEED-THE-BEAST" && "${SERVER}" ]]; then
|
||||
copyFilesForCurseForge
|
||||
|
||||
cd "${FTB_DIR}"
|
||||
log "Starting CurseForge server in ${FTB_DIR}..."
|
||||
if isTrue ${DEBUG_EXEC}; then
|
||||
set -x
|
||||
fi
|
||||
exec mc-server-runner ${bootstrapArgs} ${mcServerRunnerArgs} java $JVM_XX_OPTS $JVM_OPTS $expandedDOpts -jar $(basename "${SERVER}") "$@" $EXTRA_ARGS
|
||||
elif [[ ${TYPE} == "FEED-THE-BEAST" ]]; then
|
||||
mcServerRunnerArgs="${mcServerRunnerArgs} --shell bash"
|
||||
|
||||
copyFilesForCurseForge
|
||||
|
||||
cat > "${FTB_DIR}/settings-local.sh" <<EOF
|
||||
export MIN_RAM="${INIT_MEMORY}"
|
||||
export MAX_RAM="${MAX_MEMORY}"
|
||||
export JAVA_PARAMETERS="${JVM_XX_OPTS} -Xms${INIT_MEMORY} ${JVM_OPTS} $expandedDOpts"
|
||||
EOF
|
||||
|
||||
# patch CurseForge cfg file, if present
|
||||
if [ -f "${FTB_DIR}/settings.cfg" ]; then
|
||||
sed -i "s/MAX_RAM=[^;]*/MAX_RAM=${MAX_MEMORY}/" "${FTB_DIR}/settings.cfg"
|
||||
fi
|
||||
|
||||
cd "${FTB_DIR}"
|
||||
log "Running FTB ${FTB_SERVER_START} in ${FTB_DIR} ..."
|
||||
|
||||
finalArgs=(
|
||||
"${FTB_SERVER_START}"
|
||||
)
|
||||
|
||||
if isTrue ${DEBUG_EXEC}; then
|
||||
set -x
|
||||
fi
|
||||
if isTrue ${EXEC_DIRECTLY:-false}; then
|
||||
"${finalArgs[@]}"
|
||||
else
|
||||
exec mc-server-runner ${mcServerRunnerArgs} "${finalArgs[@]}"
|
||||
fi
|
||||
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
|
||||
|
||||
echo "Starting the Minecraft server..."
|
||||
JVM_OPTS="-Xms${INIT_MEMORY} -Xmx${MAX_MEMORY} ${JVM_OPTS}"
|
||||
log "Starting the Minecraft server..."
|
||||
|
||||
finalArgs=(
|
||||
$JVM_XX_OPTS
|
||||
$JVM_OPTS
|
||||
$expandedDOpts
|
||||
-jar $SERVER
|
||||
"$@" $EXTRA_ARGS
|
||||
)
|
||||
|
||||
if isTrue ${DEBUG_EXEC}; then
|
||||
set -x
|
||||
fi
|
||||
exec mc-server-runner ${bootstrapArgs} ${mcServerRunnerArgs} java $JVM_XX_OPTS $JVM_OPTS $expandedDOpts -jar $SERVER "$@" $EXTRA_ARGS
|
||||
|
||||
if isTrue ${EXEC_DIRECTLY:-false}; then
|
||||
exec java "${finalArgs[@]}"
|
||||
else
|
||||
exec mc-server-runner ${bootstrapArgs} ${mcServerRunnerArgs} java "${finalArgs[@]}"
|
||||
fi
|
||||
fi
|
||||
|
||||
58
start-spiget
Normal file
58
start-spiget
Normal file
@@ -0,0 +1,58 @@
|
||||
#!/bin/bash
|
||||
set -euo pipefail
|
||||
IFS=$'\n\t'
|
||||
|
||||
. ${SCRIPTS:-/}start-utils
|
||||
handleDebugMode
|
||||
|
||||
: ${SPIGET_RESOURCES:=}
|
||||
|
||||
containsJars() {
|
||||
file=${1?}
|
||||
|
||||
pat='\.jar$'
|
||||
|
||||
while read -r line; do
|
||||
if [[ $line =~ $pat ]]; then
|
||||
return 0
|
||||
fi
|
||||
done <<< $(unzip -l "$file")
|
||||
|
||||
return 1
|
||||
}
|
||||
|
||||
getResourceFromSpiget() {
|
||||
resource=${1?}
|
||||
|
||||
log "Downloading resource ${resource} ..."
|
||||
|
||||
tmpfile="/tmp/${resource}.zip"
|
||||
url="https://api.spiget.org/v2/resources/${resource}/download"
|
||||
if ! curl -o "${tmpfile}" -fsSL -H "User-Agent: itzg/minecraft-server" "${extraCurlArgs[@]}" "${url}"; then
|
||||
log "ERROR failed to download resource '${resource}' from ${url}"
|
||||
exit 2
|
||||
fi
|
||||
|
||||
mkdir -p /data/plugins
|
||||
if containsJars "${tmpfile}"; then
|
||||
log "Extracting contents of resource ${resource} into plugins"
|
||||
unzip -o -q -d /data/plugins "${tmpfile}"
|
||||
rm "${tmpfile}"
|
||||
else
|
||||
log "Moving resource ${resource} into plugins"
|
||||
mv "${tmpfile}" "/data/plugins/${resource}.jar"
|
||||
fi
|
||||
|
||||
}
|
||||
|
||||
if [[ ${SPIGET_RESOURCES} ]]; then
|
||||
log "Getting plugins via Spiget"
|
||||
IFS=',' read -r -a resources <<< "${SPIGET_RESOURCES}"
|
||||
for resource in "${resources[@]}"
|
||||
do
|
||||
getResourceFromSpiget "${resource}"
|
||||
done
|
||||
fi
|
||||
|
||||
# Continue to Final Setup
|
||||
exec ${SCRIPTS:-/}start-finalSetupWorld $@
|
||||
162
start-utils
162
start-utils
@@ -1,42 +1,176 @@
|
||||
#!/bin/bash
|
||||
|
||||
function isURL {
|
||||
function join_by() {
|
||||
local d=$1
|
||||
shift
|
||||
echo -n "$1"
|
||||
shift
|
||||
printf "%s" "${@/#/$d}"
|
||||
}
|
||||
|
||||
function isURL() {
|
||||
local value=$1
|
||||
|
||||
if [[ ${value:0:8} == "https://" || ${value:0:7} = "http://" ]]; then
|
||||
if [[ ${value:0:8} == "https://" || ${value:0:7} == "http://" ]]; then
|
||||
return 0
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
function isTrue {
|
||||
function isValidFileURL() {
|
||||
suffix=${1:?Missing required suffix arg}
|
||||
url=${2:?Missing required url arg}
|
||||
|
||||
[[ "$url" == http*://*.${suffix} || "$url" == http*://*.${suffix}\?* ]]
|
||||
}
|
||||
|
||||
function resolveEffectiveUrl() {
|
||||
url="${1:?Missing required url argument}"
|
||||
if ! curl -Ls -o /dev/null -w %{url_effective} "$url"; then
|
||||
log "ERROR failed to resolve effective URL from $url"
|
||||
exit 2
|
||||
fi
|
||||
}
|
||||
|
||||
function getFilenameFromUrl() {
|
||||
url="${1:?Missing required url argument}"
|
||||
strippedOfQuery="${url%\?*}"
|
||||
basename "$strippedOfQuery"
|
||||
}
|
||||
|
||||
function isTrue() {
|
||||
local value=${1,,}
|
||||
|
||||
result=
|
||||
|
||||
case ${value} in
|
||||
true|on)
|
||||
result=0
|
||||
;;
|
||||
*)
|
||||
result=1
|
||||
;;
|
||||
true | on)
|
||||
result=0
|
||||
;;
|
||||
*)
|
||||
result=1
|
||||
;;
|
||||
esac
|
||||
|
||||
return ${result}
|
||||
}
|
||||
|
||||
function isDebugging {
|
||||
if [[ ${DEBUG^^} = TRUE ]]; then
|
||||
function isDebugging() {
|
||||
if isTrue "${DEBUG:-false}"; then
|
||||
return 0
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
function debug {
|
||||
function handleDebugMode() {
|
||||
if isDebugging; then
|
||||
echo "DEBUG: $*"
|
||||
set -x
|
||||
extraCurlArgs=(-v)
|
||||
fi
|
||||
}
|
||||
}
|
||||
|
||||
function debug() {
|
||||
if isDebugging; then
|
||||
log "DEBUG: $*"
|
||||
fi
|
||||
}
|
||||
|
||||
function logn() {
|
||||
echo -n "[init] $*"
|
||||
}
|
||||
|
||||
function log() {
|
||||
echo "[init] $*"
|
||||
}
|
||||
|
||||
function logAutopause() {
|
||||
echo "[Autopause loop] $*"
|
||||
}
|
||||
|
||||
function logAutopauseAction() {
|
||||
echo "[$(date -Iseconds)] [Autopause] $*"
|
||||
}
|
||||
|
||||
function normalizeMemSize() {
|
||||
local scale=1
|
||||
case ${1,,} in
|
||||
*k)
|
||||
scale=1024
|
||||
;;
|
||||
*m)
|
||||
scale=1048576
|
||||
;;
|
||||
*g)
|
||||
scale=1073741824
|
||||
;;
|
||||
esac
|
||||
|
||||
val=${1:0:-1}
|
||||
echo $((val * scale))
|
||||
}
|
||||
|
||||
function versionLessThan() {
|
||||
local activeParts
|
||||
IFS=. read -ra activeParts <<<"${VANILLA_VERSION}"
|
||||
|
||||
local givenParts
|
||||
IFS=. read -ra givenParts <<<"$1"
|
||||
|
||||
if ((${#activeParts[@]} < 2)); then
|
||||
return 1
|
||||
fi
|
||||
|
||||
if ((${#activeParts[@]} == 2)); then
|
||||
if ((activeParts[0] < givenParts[0])) ||
|
||||
((activeParts[0] == givenParts[0] && activeParts[1] < givenParts[1])); then
|
||||
return 0
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
else
|
||||
if ((activeParts[0] < givenParts[0])) ||
|
||||
((activeParts[0] == givenParts[0] && activeParts[1] < givenParts[1])) ||
|
||||
((activeParts[0] == givenParts[0] && activeParts[1] == givenParts[1] && activeParts[2] < givenParts[2])); then
|
||||
return 0
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
requireVar() {
|
||||
if [ ! -v $1 ]; then
|
||||
log "ERROR: $1 is required to be set"
|
||||
exit 1
|
||||
fi
|
||||
if [ -z "${!1}" ]; then
|
||||
log "ERROR: $1 is required to be set"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
requireEnum() {
|
||||
var=${1?}
|
||||
shift
|
||||
|
||||
for allowed in $*; do
|
||||
if [[ ${!var} = $allowed ]]; then
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
|
||||
log "ERROR: $var must be set to one of $@"
|
||||
# exit 1
|
||||
}
|
||||
|
||||
function writeEula() {
|
||||
if ! echo "# Generated via Docker
|
||||
# $(date)
|
||||
eula=${EULA,,}
|
||||
" >/data/eula.txt; then
|
||||
log "ERROR: unable to write eula to /data. Please make sure attached directory is writable by uid=${UID}"
|
||||
exit 2
|
||||
fi
|
||||
}
|
||||
|
||||
18
start-validateCurseInstance
Executable file
18
start-validateCurseInstance
Executable file
@@ -0,0 +1,18 @@
|
||||
#!/bin/bash
|
||||
|
||||
. ${SCRIPTS:-/}start-utils
|
||||
|
||||
if ! [[ -v CURSE_INSTANCE_JSON ]]; then
|
||||
log "ERROR: CURSE_INSTANCE_JSON needs to be set"
|
||||
exit 2
|
||||
elif ! [ -f "${CURSE_INSTANCE_JSON}" ] && [ -f "${CURSE_INSTANCE_JSON}/minecraftinstance.json" ]; then
|
||||
CURSE_INSTANCE_JSON="${CURSE_INSTANCE_JSON}/minecraftinstance.json"
|
||||
elif ! [ -f "${CURSE_INSTANCE_JSON}" ]; then
|
||||
log "ERROR: CURSE_INSTANCE_JSON file does not exist: ${CURSE_INSTANCE_JSON}"
|
||||
exit 2
|
||||
fi
|
||||
|
||||
log "Resolved CURSE_INSTANCE_JSON as ${CURSE_INSTANCE_JSON}"
|
||||
|
||||
# Continue to Final Setup
|
||||
exec ${SCRIPTS:-/}start-finalSetupWorld "$@"
|
||||
17
tests/docker-compose.test.yml
Normal file
17
tests/docker-compose.test.yml
Normal file
@@ -0,0 +1,17 @@
|
||||
version: "3.8"
|
||||
|
||||
services:
|
||||
sut:
|
||||
depends_on:
|
||||
- mc
|
||||
image: itzg/mc-monitor:0.6.0
|
||||
command: status --host mc --retry-interval 1s --retry-limit 120
|
||||
mc:
|
||||
restart: "no"
|
||||
build:
|
||||
context: ..
|
||||
cache_from:
|
||||
- itzg/minecraft-server:latest
|
||||
environment:
|
||||
EULA: "TRUE"
|
||||
|
||||
17
tests/test.sh
Executable file
17
tests/test.sh
Executable file
@@ -0,0 +1,17 @@
|
||||
#!/bin/bash
|
||||
|
||||
cd $(dirname $0)
|
||||
|
||||
failed=false
|
||||
args="-f docker-compose.test.yml"
|
||||
docker-compose $args run sut || failed=true
|
||||
echo "
|
||||
Result: failed=$failed"
|
||||
|
||||
$failed && docker-compose $args logs mc
|
||||
docker-compose $args down -v
|
||||
|
||||
if $failed; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user