I like playing Minecraft on a PC more than on mobile even though I own both. Further, I prefer to play on a server so that I can play with my kids even if I’m out of town.
I run the server side on a Virtual Private Server. My first action is to run screen so the console can be detached, in case of internet issues. I run the server as root, which is not strictly necessary, via sudo minecraft. /usr/local/bin is part of my execution path.
One of the first lines of my minecraft script calls server_select.sh which allows me to have multiple server side worlds. This allows me to run the family world most of the time, but allows me to have a private world as well.
I run minecraft_server.jar in a until do loop so that in the event of a server crash, I only have to wait 30 seconds before I can try to reconnect. If I enter the “/stop” command at the console, the server exits cleanly and doesn’t restart. This way I’m not running a server when I don’t expect player to be around. The VPS should have 5GB of memory but I run other servers at the same time so I limit the game to 2GB.
The minecraft_server.jar points to the most recent server version. I keep a copy of older versions just in case.
echo “Starting minecraft”
until java -Xmx2048M -Xms1024M -jar /usr/local/minecraft/minecraft_server.jar nogui
echo “Crashed… sleeping.”
echo “Clean quit”
Server select, as mentioned above, changes which world is loaded by the minecraft server. The server automatically calls the server.properites file in the minecraft working directory. I put the server.properties file in the world’s sub-directory and make a symbolic link from minecraft working directory to the world of interest. The world’s directory is a parameter in the server.properties file. The “default” world is a symbolic link to the directory I expect to use most often. Notice that if server_select is not given an argument, “$1” will be an empty string.
if [ -z “$1″ ]
echo “Selecting $SERVER_NAME”
ln -snf “$SERVER_NAME/server.properties” .
ls -l server.properties