From f51c02c697f5c136800c4c0beff05c89508c6ee8 Mon Sep 17 00:00:00 2001 From: "Jason M. Wood" Date: Mon, 24 Jun 2013 12:43:11 -0600 Subject: [PATCH] Copy the old forum post into the README --- README | 260 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 259 insertions(+), 1 deletion(-) diff --git a/README b/README index 50e6182..6c85d8c 100644 --- a/README +++ b/README @@ -1,4 +1,262 @@ MinecraftServerControlScript ============================= -Powerful command-line control for Linux-powered Minecraft servers +A powerful command-line control script for Linux-powered Minecraft servers. + + +Installation +To get your server to run the script on startup, and cleanly down the server on shutdown, you need to copy the script to /etc/init.d, set execute permissions on the file, and instruct the system to use the script on startup and shutdown. The following commands will work in Debian and Ubuntu like environments, ymmv in others. + +sudo cp minecraft_server /etc/init.d/minecraft_server +sudo chmod 755 /etc/init.d/minecraft_server +sudo update-rc.d minecraft_server defaults + + +For security reasons, the script uses a user account named minecraft rather than root. As such, you need to create the user before using this script: + +sudo adduser minecraft + + +If the Minecraft server software is not located when the server start command is issued, the software will be downloaded to the proper location: /home/minecraft/minecraft_server/minecraft_server.jar + + +Requirements +I've made an attempt to utilize only features that are normally installed in most Linux and UNIX environments in this script, but there are a few requirements that this script has that may not already be in place: + + Java 6 JDK - The Minecraft server software requires this. + Perl 5 - Most, if not all, Unix and Linux like systems have this preinstalled. + GNU Screen - Allows the script to run the Java process as a background daemon and send commands to the server. + GNU Wget - Allows the script to download software updates via the internet. + rdiff-backup - Allows the script to efficiently run backups. + Iptables - Although not explicitly required, a good firewall should be installed. + +If you are running Debian or Ubuntu, you can make sure that these are installed by running: + +sudo apt-get install openjdk-6-jdk perl screen wget rdiff-backup iptables + + + +Mapping Software +The script now uses the Minecraft Overviewer mapping software to generate maps of your worlds. You can download premade binaries for supported systems (Debian/Ubuntu, CentOS/RHEL/Fedora), or build your own binary from source if needed. + + +Multiple Worlds +The script can handle running multiple Minecraft world servers, just add each server to the /home/minecraft/worlds.conf file that will be generated on the first run. Do not include the IP address information if it is not needed. + +Example worlds.conf file for two worlds named alpha and beta and the ports that they run on. This file will be generated if missing. + +Note: The world name should not contain a space. Leave the ip address blank if it is not needed. + +# Minecraft world configuration file +# +alpha 25565 +beta 25566 +gamma 25567 +delta 25568 +epsilon 25569 + + + +Firewall / NAT +If you have a firewall installed on your computer, or a router using NAT installed in your network, you will need to route some ports to your server. Instructions on how to accomplish this are beyond the scope of this post, but here are some things you will need to know: + + The default port for the Minecraft server is: 25565. + If you wish to run multiple world servers using this script, you will want to open a range of ports (for example 25565 - 25575). + +If you are using iptables, and you should be, here is a very basic ruleset that you can use. + +*filter +:INPUT DROP [0:0] +:FORWARD DROP [0:0] +:OUTPUT DROP [0:0] + +# Handle loopback addresses +-A INPUT -i lo -j ACCEPT +-A OUTPUT -o lo -j ACCEPT + +# Allow outbound packets if state related, and inbound if established +-A OUTPUT -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT +-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT + +# Drop stealth scans +-A INPUT -i eth0 -p tcp -m tcp --tcp-flags FIN,SYN,RST,PSH,ACK,URG NONE +-A INPUT -i eth0 -p tcp -m tcp --tcp-flags SYN,FIN SYN,FIN +-A INPUT -i eth0 -p tcp -m tcp --tcp-flags SYN,RST SYN,RST +-A INPUT -i eth0 -p tcp -m tcp --tcp-flags FIN,RST FIN,RST +-A INPUT -i eth0 -p tcp -m tcp --tcp-flags ACK,FIN FIN +-A INPUT -i eth0 -p tcp -m tcp --tcp-flags ACK,URG URG + +# Allow ICMP pings +-A OUTPUT -p icmp -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT +-A INPUT -p icmp -m state --state ESTABLISHED,RELATED -j ACCEPT + +# Allow port 22 for SSH +-A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT + +# Allow port 80 for HTTP +-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT + +# Allow port 443 for HTTPS +-A INPUT -m state --state NEW -m tcp -p tcp --dport 443 -j ACCEPT + +# Allow ports 25565 - 25575 for Minecraft world servers +-A INPUT -m state --state NEW -m tcp -p tcp --dport 25565:25575 -j ACCEPT + +COMMIT + + + +Usage + +All commands below assume that you are running them as either the minecraft user or as root (through sudo). + +Note: If the script is run as the root user, all important server processes will be started using the minecraft user for security purposes. + +su minecraft +/etc/init.d/minecraft_server