From c5556e0378e3a8f5877f149a574651bc261cde8e Mon Sep 17 00:00:00 2001 From: Nathaniel Cook Date: Mon, 30 May 2016 13:51:45 -0600 Subject: [PATCH] update readme --- README.md | 104 ++++++++++++++++++++++++++ src/{minecraftctl => minecraftctl.sh} | 5 +- 2 files changed, 107 insertions(+), 2 deletions(-) create mode 100644 README.md rename src/{minecraftctl => minecraftctl.sh} (98%) diff --git a/README.md b/README.md new file mode 100644 index 0000000..aa4f1b2 --- /dev/null +++ b/README.md @@ -0,0 +1,104 @@ +# Minecraft Server + +This project defines a template systemd service unit file for hosting several minecraft servers. +Since once you have one you are going to want another ;) + +# Install + +This system runs the minecraft server in a docker container as such you must first install docker. + +Run `make install` as root and the files will be copied to the appropriate locations. + +You should also create a minecraft user to own the server files. + +``` +useradd minecraft +``` + +NOTE: `grep` and `sed` are also required in order to watch the minecraft logs for various events. + +## AUR Package + +An AUR package is in the works... + +# Usage + +With this project installed you can run multple different minecraft worlds on the same host. +Each is given a name and can be configured in an `/etc/minecraft/` file. + +## EULA + +Minecraft requires that you accept the EULA in order to run a server. +Either add `EULA=true` to all your `/etc/minecraft/` files, or edit the `minecraftctl.sh` script to set `EULA=true` for all worlds. + +## Running a server + +To start a new server run: + +``` +sudo systemctl start minecraftd@survival.service +``` + +To enable the server on boot run: + +``` +sudo systemctl enable minecraftd@survival.service +``` + +## Custom Config + +You can customize the configuration of a server by setting environment vars in `/etc/minecraft/` + +For example to run on a different port and version you could use: + +``` +PORT=25566 +VERSION=1.8.9 +``` + +in the file `/etc/minecraft/survival`. + +All `server.properties` are available to be set. + +## Ephemeral server + +If you want to host a specific puzzle or adventure world you can use both the `EPHEMERAL` and `WORLD` vars. + +``` +EPHEMERAL=true +WORLD=http://minecraft.example.com/myworld.zip +``` + +Now everytime the server is started is will download a fresh copy of the world and launch it. +Without the `EPHEMERAL` var the world will only be downloaded to first time. + +## Backups + +Along with the service template a systemd.timer is provided to run backups of a server. + +For example: + +``` +sudo systemctl enable minecraftd-backup@survival.timer +``` + +this will enable weekly backups of the `survival` server. +Backups are stored in the default `$DATA_DIR/$BACKUP_DIR` which is `/srv/minecraft//backups` if you want to copy them offsite you will need to manage that yourself. + + +## Further custimization + +Not everything that is possible to customize has been mentioned here. +Take a look at the `minecraftctl.sh` script as it is written to be extensible. + +# Portability + +These scripts work on my host ;) (arch linux). +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. + +# Thanks + +This project leverages the work of the https://hub.docker.com/r/itzg/minecraft-server/ docker container for minecraft. +Also many of these concepts in the `minecraftctl.sh` script where inspired by https://aur.archlinux.org/packages/minecraft-server/. +Many thanks to both projects for making this one possible. + diff --git a/src/minecraftctl b/src/minecraftctl.sh similarity index 98% rename from src/minecraftctl rename to src/minecraftctl.sh index ecb6d95..819fec8 100755 --- a/src/minecraftctl +++ b/src/minecraftctl.sh @@ -51,6 +51,7 @@ running() { return $? } +# Check if anyone is online is_anyone_online() { player_count=$(game_command list "players online:" | sed -r 's/.*([[:digit:]]+)\/[[:digit:]]+ players online:.*/\1/') test $player_count -ne 0 @@ -78,7 +79,7 @@ start() { $vol_mount \ -p $PORT:25565 \ -e "JVM_OPTS=-Xmx${MAXHEAP}M -Xms${MINHEAP}M" \ - -e EULA=true \ + -e "EULA=$EULA" \ -e "VERSION=$VERSION" \ -e "DIFFICULTY=$DIFFICULTY" \ -e "WHITELIST=$WHITELIST" \ @@ -214,7 +215,7 @@ restart) start ;; backup) - backup + backup ;; *) usage