Use SSH Screens with your Minecraft Server Script
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,
- use 'screen' to lauch minecarft in a detached named screen as a daemon (in the background) for if minecraft is being launched the first time
- use 'screen' to resume its terminal and give you command line interface with minecraft if the script is being ran while minecraft is already running. Screen has a detach magic key sequence Ctrl-A,D that is pressed to detach, aka logout of minecraft administration, without needing to shut the server down.
- sudo apt-get install screen -y
Create $MINECRAFT_HOME folder and variable so we don't need to type it so much
- export MINECRAFT_HOME=/opt/minecraft
- mkdir $MINECRAFT_HOME
- chmod 775 $MINECRAFT_HOME
- cd $MINECRAFT_HOME
- wget https://s3.amazonaws.com/MinecraftDownload/launcher/minecraft_server.jar
Create the file ~/startMinecraft.sh
- nano ~/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
Tags: SSH, screen, minecraft, minecraft_server.jar, nogui
Created: 1 year ago.
Last edited: 1 year ago.
Reviewed: 1 year ago.
Read 0 times.
No comments so far.
Other tutorials from grimdestripador
- Single Purpose Terminal Commands (CLI)
- Using the linux program called Screen to lauch a daemon at boot
- Formatting 1.5TB Western Digital EARS Drives
- Pyramid of Synergy, Manual Coding of the Synergy.conf file
- Install Oracle SQL Devleoper
- The Supreme Linux Mint 13 Media Server (NAS)
- Make Persistance File a Partition using casper-rw label
- Run Command on Login
- Installing sshfs for File Sharing
- The Supreme Linux Mint 13 Development Station
- How to Convert SFW to JPG
- Installing Webmin and configuring Samba Network Shares
- Advanced Conky Configurations with Linux Mint 14
- Dwarf Fortress Install With Sound Dependencies (OpenAl)
- Fixing nvidia-settings for Linux Mint 14 KDE
- Increase brightness or gamma from a dim video with WinFF and ffMpeg
- Custom Synergy Config - Dual Monitor Surround