Skip to content

Instantly share code, notes, and snippets.

@PetrGlad
Last active August 29, 2015 14:25
Show Gist options
  • Save PetrGlad/a700b210b675deed81a6 to your computer and use it in GitHub Desktop.
Save PetrGlad/a700b210b675deed81a6 to your computer and use it in GitHub Desktop.
Minecraft on Raspberry Pi
#!/bin/bash
# Use this to attach to running server and issue admin commands
tmux attach -t minecraft
#!/bin/bash
PIDFILE=$HOME/.mc-tunnel.pid
if [ -f $PIDFILE ]
then
echo "Closing."
cat $PIDFILE | xargs kill
rm $PIDFILE
else
echo "Already closed. (No $PIDFILE)"
fi
#!/bin/bash
# Use remote relay host to listen from behind NAT
PIDFILE=$HOME/.mc-tunnel.pid
if [ -f $PIDFILE ]
then
echo "RM tunnel is already open. ($PIDFILE exists)"
else
echo "Opening RM tunnel"
ssh -N -R 0.0.0.0:25565:localhost:25565 minecraft@a-host-with-public-ip &
echo $! > $PIDFILE
fi
# Require: Java 8 (older ones perform significantly worse); git; ssh; tmux
# Install spigot - Modified MC server based on Bukkit
# See https://www.spigotmc.org/
# Building locally: download latest BuildTools.jar from https://hub.spigotmc.org/jenkins/job/BuildTools/
java -jar BuildTools.jar
#!/bin/bash
# MC Server gets commands from stdio so we just wrap it into tmux session
# Adjust spigot*.jar name according to latest version
MC_CMD="java -Xmx512M -Xms128M -XX:+CMSIncrementalPacing -XX:ParallelGCThreads=4 -XX:+AggressiveOpts -jar spigot-1.8.7.jar nogui"
MC_HOME="/home/pi/minecraft-server/" # Server JAR should be located here
if [ `tmux list-sessions | grep minecraft | wc -l` == 1 ]
then
echo "Minecraft session already exists."
else
echo "Launcing minecraft session"
cd $MC_HOME
tmux new-session -s minecraft -d "$MC_CMD"
fi
# You can start this remotely with ssh pi@raspberrypi-host ./start-minecraft
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment