Skip to content

Commit c5556e0

Browse files
committed
update readme
1 parent 39ae41c commit c5556e0

File tree

2 files changed

+107
-2
lines changed

2 files changed

+107
-2
lines changed

README.md

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
# Minecraft Server
2+
3+
This project defines a template systemd service unit file for hosting several minecraft servers.
4+
Since once you have one you are going to want another ;)
5+
6+
# Install
7+
8+
This system runs the minecraft server in a docker container as such you must first install docker.
9+
10+
Run `make install` as root and the files will be copied to the appropriate locations.
11+
12+
You should also create a minecraft user to own the server files.
13+
14+
```
15+
useradd minecraft
16+
```
17+
18+
NOTE: `grep` and `sed` are also required in order to watch the minecraft logs for various events.
19+
20+
## AUR Package
21+
22+
An AUR package is in the works...
23+
24+
# Usage
25+
26+
With this project installed you can run multple different minecraft worlds on the same host.
27+
Each is given a name and can be configured in an `/etc/minecraft/<name>` file.
28+
29+
## EULA
30+
31+
Minecraft requires that you accept the EULA in order to run a server.
32+
Either add `EULA=true` to all your `/etc/minecraft/<name>` files, or edit the `minecraftctl.sh` script to set `EULA=true` for all worlds.
33+
34+
## Running a server
35+
36+
To start a new server run:
37+
38+
```
39+
sudo systemctl start [email protected]
40+
```
41+
42+
To enable the server on boot run:
43+
44+
```
45+
sudo systemctl enable [email protected]
46+
```
47+
48+
## Custom Config
49+
50+
You can customize the configuration of a server by setting environment vars in `/etc/minecraft/<name>`
51+
52+
For example to run on a different port and version you could use:
53+
54+
```
55+
PORT=25566
56+
VERSION=1.8.9
57+
```
58+
59+
in the file `/etc/minecraft/survival`.
60+
61+
All `server.properties` are available to be set.
62+
63+
## Ephemeral server
64+
65+
If you want to host a specific puzzle or adventure world you can use both the `EPHEMERAL` and `WORLD` vars.
66+
67+
```
68+
EPHEMERAL=true
69+
WORLD=http://minecraft.example.com/myworld.zip
70+
```
71+
72+
Now everytime the server is started is will download a fresh copy of the world and launch it.
73+
Without the `EPHEMERAL` var the world will only be downloaded to first time.
74+
75+
## Backups
76+
77+
Along with the service template a systemd.timer is provided to run backups of a server.
78+
79+
For example:
80+
81+
```
82+
sudo systemctl enable [email protected]
83+
```
84+
85+
this will enable weekly backups of the `survival` server.
86+
Backups are stored in the default `$DATA_DIR/$BACKUP_DIR` which is `/srv/minecraft/<name>/backups` if you want to copy them offsite you will need to manage that yourself.
87+
88+
89+
## Further custimization
90+
91+
Not everything that is possible to customize has been mentioned here.
92+
Take a look at the `minecraftctl.sh` script as it is written to be extensible.
93+
94+
# Portability
95+
96+
These scripts work on my host ;) (arch linux).
97+
I have not tested them anywhere else, if you run into a bug please file on issue here on github or better yet submit a PR.
98+
99+
# Thanks
100+
101+
This project leverages the work of the https://hub.docker.com/r/itzg/minecraft-server/ docker container for minecraft.
102+
Also many of these concepts in the `minecraftctl.sh` script where inspired by https://aur.archlinux.org/packages/minecraft-server/.
103+
Many thanks to both projects for making this one possible.
104+

src/minecraftctl renamed to src/minecraftctl.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ running() {
5151
return $?
5252
}
5353

54+
# Check if anyone is online
5455
is_anyone_online() {
5556
player_count=$(game_command list "players online:" | sed -r 's/.*([[:digit:]]+)\/[[:digit:]]+ players online:.*/\1/')
5657
test $player_count -ne 0
@@ -78,7 +79,7 @@ start() {
7879
$vol_mount \
7980
-p $PORT:25565 \
8081
-e "JVM_OPTS=-Xmx${MAXHEAP}M -Xms${MINHEAP}M" \
81-
-e EULA=true \
82+
-e "EULA=$EULA" \
8283
-e "VERSION=$VERSION" \
8384
-e "DIFFICULTY=$DIFFICULTY" \
8485
-e "WHITELIST=$WHITELIST" \
@@ -214,7 +215,7 @@ restart)
214215
start
215216
;;
216217
backup)
217-
backup
218+
backup
218219
;;
219220
*)
220221
usage

0 commit comments

Comments
 (0)