|
| 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 | + |
0 commit comments