From 50da19a9a140d17d8b53f9eb0805b0b7d033d12f Mon Sep 17 00:00:00 2001 From: Soper Date: Sun, 26 Dec 2021 22:49:30 -0500 Subject: [PATCH] first commit --- LICENSE | 9 +++++++++ README.md | 39 ++++++++++++++++++++++++++++++++++++++ eula.txt | 2 ++ info.yaml | 26 +++++++++++++++++++++++++ mc-server.service.template | 19 +++++++++++++++++++ start.bat | 3 +++ start.sh | 6 ++++++ 7 files changed, 104 insertions(+) create mode 100644 LICENSE create mode 100644 README.md create mode 100644 eula.txt create mode 100644 info.yaml create mode 100644 mc-server.service.template create mode 100644 start.bat create mode 100644 start.sh diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..3f28a5f --- /dev/null +++ b/LICENSE @@ -0,0 +1,9 @@ +MIT License + +Copyright (c) + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..7aed135 --- /dev/null +++ b/README.md @@ -0,0 +1,39 @@ +# Minecraft Server Template +This is a handful of important files, as well as some that make it easier for server administration, that I personally use for my Minecraft servers. + +To use this, just clone this repository, and edit the necessary files. + +## Usage & Disclaimers +### Minecraft EULA +The usage of this repository implies that you have agreed to the Minecraft EULA, which is necessary to run a Minecraft server. You can read that here: +https://account.mojang.com/documents/minecraft_eula + +### Server launch scripts +The `start.bat` and `start.sh` files are simple scripts that automate the launching of the Minecraft server, without having to manually type in +```sh +java -jar server.jar +``` +When using either file, you must change the appropriate variable to the name of the server jar you are using. For example, if you are using the [vanilla server jar](https://www.minecraft.net/en-us/download/server), you must change the `jarfile` variable to `minecraft_server.VERSION.jar`. + +### Service File +This file is used by Linux distributions that come with systemd. This file allows you to create a system service which allows you to control your Minecraft server via systemd commands. + +To use this file, you must be using a Linux distribution with `systemd` and `screen` installed. Most users can install `screen` via their distribution's package manager. + +Rename the file to something along the lines of `mc-server.service` (mc-server being whatever you choose to name it). Then, edit the file and replace everything in brackets `[]`, which should just be +``` +[SERVER_NAME] +[SERVER_DIRECTORY] +[USERNAME] +[SHORT_SERVER_NAME] +``` + +Now, you can register this file with systemd by using +```sh +systemctl enable /path/of/service_file.service +``` + +### info.yaml +The `info.yaml` file is used for administrators to better distinguish and organize their own Minecraft servers. I have found myself constantly juggling between a bunch of servers I previously created that I don't remember about. This file makes it easier to organize and prevent that situation. It is *not* necessary to use to run a server, and is entirely optional. + +Some server jars may use the `info.yaml` for other purposes. If that is the case for you, you may delete the `info.yaml` file that comes with this repository, or rename it if you find it useful. \ No newline at end of file diff --git a/eula.txt b/eula.txt new file mode 100644 index 0000000..f76c3f6 --- /dev/null +++ b/eula.txt @@ -0,0 +1,2 @@ +#By changing the setting below to TRUE you are indicating your agreement to our EULA (https://account.mojang.com/documents/minecraft_eula). +eula=true diff --git a/info.yaml b/info.yaml new file mode 100644 index 0000000..19b3878 --- /dev/null +++ b/info.yaml @@ -0,0 +1,26 @@ +#This is an info file for general information +#Makes it easier to differentiate between servers +#Version 1.0 + +server-name: #server name + basic-info: #general information + description: #server MOTD/description + mc-version: #change this to current minecraft version of server jar + server-info: #behind-the-scenes info + ip: #server address + port: 25565 #server port; minecraft defaults to 25565 + srv: true #change to false if this server does not have a SRV DNS record + is-modded: false + is-public: true + whitelist: #["user1","user2"] + server-jar: #server jar currently in use + meta-info: #Info about info + created-on: 0000-00-00 00:00:00 + created-by: #who created this server + created-ver: #version of minecraft server was created on + deploy-date: 0000-00-00 00:00:00 #day server was opened to public + deploy-jar: #server jar the server deployed with + is-retired: false #change to false if server is not meant to be active + retired-on: #0000-00-00 + retired-ver: #version of minecraft server was retired on + retire-jar: #server jar the server was retired with \ No newline at end of file diff --git a/mc-server.service.template b/mc-server.service.template new file mode 100644 index 0000000..3b3f670 --- /dev/null +++ b/mc-server.service.template @@ -0,0 +1,19 @@ +[Unit] +Description=[SERVER NAME] +After=local-fs.target network.target + +[Service] +WorkingDirectory=[SERVER DIRECTORY] +User=USERNAME +Group=USERNAME +Type=forking + +Environment="SERVERNAME=#Short Server Name" + +ExecStart=/usr/bin/screen -dmS $SERVERNAME -t console ./start.sh + +ExecStop=/usr/bin/screen -p console -S $SERVERNAME -X eval 'stuff \015' 'stuff \"stop\"\015' +ExecStop=/bin/bash -c "while ps -p $MAINPID > /dev/null; do /bin/sleep 1; done" + +[Install] +WantedBy=multi-user.target diff --git a/start.bat b/start.bat new file mode 100644 index 0000000..01a2d6e --- /dev/null +++ b/start.bat @@ -0,0 +1,3 @@ +set jarfile=server_jar_name.jar +java -Xmx8G -Xms3G -jar %jarfile% nogui -o true +PAUSE \ No newline at end of file diff --git a/start.sh b/start.sh new file mode 100644 index 0000000..647defc --- /dev/null +++ b/start.sh @@ -0,0 +1,6 @@ +#!/bin/sh + +jarfile="JARFILE" +cd "${0%/*}" +echo "${0%/*}" +java -Xmx8G -Xms3G -jar "$jarfile" nogui -o true