|
12 years ago 2 |
There are many ways to administer a minecraft server. This minecraft server tutorial will achieve a boot script which will allow minecraft administrators gain access via ssh in a shared configuration. The ability to work in a shared configuration allows for multiple administrators to be able to log in and out of a "server" computer without having to shut the minecraft server down. This alleaviates the problem of needing to keep a ssh pipe open, for if the ssh connection dies, the minecraft server stops and kicks all users.
This solution is to create a script which ran,
Install Screen
Create $MINECRAFT_HOME folder and variable so we don't need to type it so much
Download Minecraft
Create the file ~/startMinecraft.sh
Copy the following and paste the following code into into terminal window with the key combination Ctrl-Insert
#!/bin/bash
#@Author grimdestripador
#@Copyright 2013 grimdestripador released as Public Domain
#Configure your minecraft folder which contains minecraft_server.jar and the world folder.
export MINECRAFT_HOME=/usr/local/bin/minecraft
echo Starting backup of $MINECRAFT_HOME
tar cf ~/mcBackup`date +%s`.tar $MINECRAFT_HOME/*
echo Backup location: ~/mcBackup`date +%s`.tar
echo .
echo .
echo Spawning background daemon SCREEN named minecraft.
echo To resume: type screen -r minecraft.
echo To detach from screen: press the magic sequence: ctrl-A, D.
echo To quit minecraft:1) type at terminal: screen -r minecraft
echo . . . . . . . . . 2) type: stop
echo .
#Change user working directory for preparation of "java -jar" command
cd $MINECRAFT_HOME
#Check to see if a minecraft screen is already running
lineCount=`screen -r minecraft | grep "There is no screen to be resumed matching minecraft." | wc -l`
#Start the minecraft server in a detached screen named "minecraft" if its not running
#Launch the command line interface for minecraft if it is arealdy running.
if [ $lineCount -eq 1 ]
then
echo linecount: $lineCount. Starting in a deteched screen named minecraft. Use screen -r minecraft to view.
screen -dmS minecraft java -Xms1024M -Xmx1024M -jar $MINECRAFT_HOME/minecraft_server.jar nogui
else
echo lineCount: $lineCount. Minecraft is already running. Use screen -r minecraft to view. Running now.
screen -r minecraft
fi