12/16/2023 0 Comments Minecraft server starter by![]() ![]() We use launch.sh as a wrapper, and have screen run launch.sh as an unprivileged user called $SERVER_USER. Unfortunately, screen doesn’t appear to take a function as an argument. We want to run the server in screen to allow issuing commands, such as list, to the server. ![]() usr/bin/java $JAVAOPTS -jar $MINECRAFT_JAR nogui 2>&1 \ This is done in config.sh in the start function: The remaining output is filtered through grep to discard INFO messages. The number of players is captured to the file specified by $PLAYERS_FILE. The list command is a Minecraft server command that lists the number of players online. All output is first piped to a sed script that watches for the response to a list command. We add to this command a filter to filter out the INFO messages, and to capture the number of players. Screen and the server commandĪ typical Minecraft server is started with a command that looks something like /usr/bin/java $JAVAOPTS -jar $MINECRAFT_JAR nogui. ![]() I use port 25555, but you can configure this with $LOCAL_PORT. Note that since the meta-server is binding port 25565, your server must use a different port. Now when someone tries to connect to your server on port 25565, the meta-server will run the file /usr/bin/tekkit-start. We install this file in /etc/xinetd.d/tekkit, and have xinetd reread configuration files, for instance, via systemctl reload xinetd. The meta-server is a server that manages servers by binding to the server’s port, starting the server when a client attempts to connect, then forwarding all traffic to the server. To automatically start the server, we use xinetd, a ‘super-server’ (or as I prefer, ‘meta-server’). Finally, we have to route traffic between the server and the meta-server that is watching to start the server on-demand. We also need to be sure to start only one instance of the server. We must ensure any user that tries to connect sees a message alerting them that the server is not up now, but will be shortly. The article expects the binaries to be installed in /usr/bin/tekkit. The only hard-coded path in the scripts should be /etc/tekkit-on-demand/config.sh. This article, and the scripts to a lesser extend, expect files to be in particular places. These scripts should work with any Minecraft server I personally use Tekkit. I will assume you know how to run and install a Minecraft server. You don’t really need to understand them use this, but I won’t explain them here. These scripts make use of lots of ‘standard’ tools such as a screen, sed, grep, and tr, and ‘less standard’ ones like netcat, pgrep, and xinetd. I use cronie as my crontab implementation. I run Arch Linux on all my machines, including my server. AssumptionsĪ couple of notes before we get started. I also heavily referenced this wiki to understand the minecraft ping protocol to get MOTD even when the server is down, letting users know the server is starting up.ĭisclaimer: This code probably has at least one bug. In particular, I wanted more abstraction, the website seems to mangle the bits of code posted there, and a couple of things were left unexplained. It’s quite well written, but I made my own changes to suite my needs and expanded on some things. Most of this I gleemed by reading this article at. I sought a way to automatically bring the server up when I wanted to play and shut it down when I wasn’t playing for a while. My VPS is not very powerful, and running a Minecraft server when I stop playing for months is a huge waste of resources. I have a VPS that I probably under use, so I decided to run the server there for when I do play with my friends. Lately when I do play, I’ve bene playing with a slightly modified version of Tekkit and running my own server. Sometimes I play a lot of minecraft and sometimes I just stop playing for months. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |