Skip to content

Instantly share code, notes, and snippets.

@ScottJWalter
Last active September 13, 2018 20:29
Show Gist options
  • Save ScottJWalter/b257970edd64ecb543e6931f6fce5a70 to your computer and use it in GitHub Desktop.
Save ScottJWalter/b257970edd64ecb543e6931f6fce5a70 to your computer and use it in GitHub Desktop.
Installing minecraft server on raspberry pi
# This can be replaced with something that identifies the most current java8 version and automatically sets the following
# 3 variables
JAVA8_TARBALL = "jdk-8u171-linux-arm32-vfp-hflt.tar.gz"
JAVA8_URL = "http://download.oracle.com/otn-pub/java/jdk/8u171-b11/512cd62ec5174c3487ac17c61aaa89e8/${JAVA8_TARBALL}"
JDK_PATH = "jdk1.8.0_171"
MINECRAFT_VERSION = "1.13.1"
# connect to pi
ssh pi@minecraftpi
# get and unpack java8
cd /opt
sudo wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" ${JAVA8_URL}
sudo tar -zxvf ${JAVA8_TARBALL}
# Add this new version of java to the java registry
sudo update-alternatives --install /usr/bin/java java /opt/${JDK_PATH}/bin/java 1
sudo update-alternatives --install /usr/bin/javac javac /opt/${JDK_PATH}/bin/javac 1
# select the correct version of java to use (i.e. the on installed in /opt)
sudo update-alternatives --config java
sudo update-alternatives --config javac
# validate the correct version is used by default
java -version
javac -version
# clean up
sudo rm /opt/${JAVA8_TARBALL}
# update and upgrade
sudo apt-get update && sudo apt-get -y upgrade
# install git and screen
sudo apt-get install git
sudo apt-get install screen
# install minecraft
cd ~
mkdir minecraft
cd minecraft
wget https://hub.spigotmc.org/jenkins/job/BuildTools/lastSuccessfulBuild/artifact/target/BuildTools.jar
# build minecraft (NOTE: This will take upwards of an hour)
sudo java -jar BuildTools.jar --rev ${MINECRAFT_VERSION}
# run and configure Spigot Minecraft server
sudo java -Xms512M -Xmx1008M -jar /home/pi/minecraft/spigot-${MINECRAFT_VERSION}.jar nogui
# stop the server, edit the EULA, changing 'eula=true'
sudo nano eula.txt
# download and replace the server.properties file
wget https://www.linuxnorth.org/minecraft/server.properties
# Install the RaspberryJuice plugin to activate the Minecraft API
wget -O ~/minecraft/plugins/RaspberryJuice.jar https://dev.bukkit.org/projects/raspberryjuice/files/latest
# run the server a second time to build the initial world
sudo java -Xms512M -Xmx1008M -jar /home/pi/minecraft/spigot-${MINECRAFT_VERSION}.jar nogui
@ScottJWalter
Copy link
Author

ScottJWalter commented Sep 11, 2018

Finally, edit/create /home/pi/startup/minecraft.sh:

if ! screen -list | grep -q "minecraft"; then
  cd /home/pi/minecraft && java -jar  -Xms512M -Xmx1008M spigot-${MINECRAFT_VERSION}.jar nogui
fi

And, to auto launch on boot, edit /etc/rc.local, adding before exit 0:

screen -S minecraft -d -m /home/pi/startup/minecraft.sh

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment