This script will automatically download and configure the Paper Minecraft server on your Raspberry Pi!
For the full article and guide visit https://jamesachambers.com/raspberry-pi-minecraft-server-script-with-startup-service/
curl https://raw.githubusercontent.com/TheRemote/RaspberryPiMinecraft/master/SetupMinecraft.sh | bash
To get help you may open an issue here or visit my web site at https://jamesachambers.com/raspberry-pi-minecraft-server-script-with-startup-service/ which contains lots of comments from myself and users helping each other out! If a new version of Minecraft is out and the script hasn't been updated yet you can change it in the SetupMinecraft.sh script. If you use the command nano SetupMinecraft.sh it will be the first line in the file like this:
Version="1.18.1"
AllowLocalCopy="1"
Make sure to change AllowLocalCopy="1" to tell the script you want to actually run the local copy instead of the latest version.
Note that for this to work the Paper Minecraft server must also have released the latest version or the download will fail. You can check here: https://papermc.io/downloads
Sometimes if you have multiple versions of Java installed the wrong version of Java will be selected as the default. If the server didn't start check that the right version of Java is selected with this command:
If you get the message "update-alternatives: error: no alternatives for java" then you only have one version of Java installed and can skip to the next section.
If you are presented with a list of choices then your machine has multiple versions of Java installed. It will look like this:
update-alternatives: warning: /etc/alternatives/java has been changed (manually or by a script); switching to manual updates only
There are 2 choices for the alternative java (providing /usr/bin/java).
Selection Path Priority Status
------------------------------------------------------------
0 /usr/lib/jvm/java-11-openjdk-amd64/bin/java 1101 auto mode
1 /usr/lib/jvm/java-11-openjdk-amd64/bin/java 1101 manual mode
2 /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java 1081 manual mode
You will usually want to just select the newest version of OpenJDK that is listed so you would type 0 and press enter. In some cases on some platforms you may want to switch to the official Oracle JDK although I strongly recommend sticking with OpenJDK!
- Raspberry Pi OS - Bullseye/Buster/Stretch
- Ubuntu / Ubuntu Server 21.10 / 20.04 (LTS)
- Debian 11 Bullseye / Debian 10 Buster / Debian 9 Stretch
- Arch Linux
- TinkerOS Stretch
People have expressed some interest in this (you are all saints, thank you, truly)
- PayPal: 05jchambers@gmail.com
- Venmo: @JamesAChambers
- CashApp: $theremote
- Bitcoin (BTC): 3H6wkPnL1Kvne7dJQS8h7wB4vndB9KxZP7
- Update OpenJDK installation paths
- Switched from JDK to JRE to save space
- Added Adoptium OpenJDK support for s390x and ppc64le architectures
- Add -DPaper.IgnoreJavaVersion=true to allow OpenJDK 17 to run the older Paper Minecraft versions (thanks NotMick, issue #39
- Added screen -wipe to beginning of start.sh to prevent a startup issue that could occur if there was a "dead" screen instance (thanks grimholme)
- Fix Adoptium arm and aarch64 OpenJDK links (thanks 407pilot, issue #38
- Update Adoptium OpenJDK version
- Add safety check for backups to make sure folder exists before pruning
- Fixed a problem with restart.sh having a #!/bin/sh at the top which could cause restart.sh to run in a POSIX shell that doesn't recognize the [[ operator (thanks jmswan, issue #37
- Fixed "route" command used to detect internet access to be compatible with Debian
- Fixed mistake in new multicore compression (thanks pmcmorris) and related mistake in SetupMinecraft.sh dependency check
- Remove "jre" folder if JDK installation fails so it will attempt to download a fresh copy upon running SetupMinecraft.sh again
- Added support for the tar command to use multiple CPU cores instead of a single core. This should speed up backups and reduce instances of when it takes longer to back up than the server's startup time (thanks SudosFTW, issue #36)
- Fixed issue that prevented detecting a broken OpenJDK installation
- Added language headers to OpenJDK download
- Dedicated OpenJDK 17 install is now used (stored in your server's directory) to avoid apt / snap issues
- Create "logs" folder for new servers to avoid harmless error messages (cleanup)
- Add new "jre" folder to backup command's ignore list to avoid bloated backups
- Removed snapd installation as the snapd repository will only install OpenJDK 18 or higher which won't work with Paper
- Paper still does not support OpenJDK 18 and will give errors using a version that high
- Working on a new more reliable method to install OpenJDK 17
- Removed obsolete requirement not allowing OpenJDK versions above 17 as Paper now supports this
- Update to 1.18.2 -- make sure you have backups first if you are upgrading from an existing server!
- Update to 1.18.1 -- make sure you have backups first if you are upgrading from an existing server!
- Update to 1.18 -- make sure you have backups first if you are upgrading from an existing server!
- Update to allow OpenJDK 17 which is now the default "snap"
- Update to Paper Minecraft Server API v2
- Fixed a missing -A parameter for a curl command (thanks davie2000, issue #27)
- Added PATH variable to scripts to improve compatibility on some distros
- Server now fixes permissions upon startup
- Switched from wget to curl to fix spacing issues experienced by some users
- Added error redirection to crontab line to help diagnose failures during scheduled restarts
- Fixed an issue where SetupMinecraft.sh could throw an error if no Java version was installed
- Fixed server name prompt
- Added username missing to fix service issue
- Reduced memory recommendation by 100MB to allow more space for the OS / other processes since newer versions of Minecraft are requiring more memory. Remember, if you don't leave enough memory for other things the Minecraft server will crash for memory issues, but it's because you set it too high (counterintuitive I know) and didn't leave enough for the OS and it killed your Minecraft server to prevent the entire OS from crashing.
- Added in check to ensure start.sh and other scripts are not being ran as root. If this happens you have to use sudo screen -r to find the screen and the permissions will be wrong since root isn't the owner of the server files
- If you know you ran the script/server as root (which starts creating files owned by root instead of the regular user) and your server won't start/is wonky run the fixpermissions script from your server folder with ./fixpermissions.sh and it will correct them for you!
- Added safety check for path to server -- please use the default path of ~ if you aren't familiar with fully qualified Linux paths/directories -- you really don't want to change the safe defaults unless you have a really specific need.
- Fixed a issue that was causing backups to not rotate (it should only keep 10). Thanks Olli
- Update to 1.17.1
- Update documentation to explain new AllowLocalCopy="1" flag. This flag tells the script not to run the latest online version and to run the local copy. You want to use this if you are changing the version or making any modifications to the script itself before running it.
- Added update.sh convenience script that calls the latest version of SetupMinecraft.sh
- Fixed a bug where having an OpenJDK greater than 16 was not triggering the snap configuration (usually only seen on the cutting edge Ubuntu flavors)
- Fixed an issue with SetupMinecraft.sh saving scripts to the home folder instead of the minecraft folder (thanks Ryan A J.)
- Add option to choose a custom directory instead of forcing the home path
- Removed installation of OpenJDK above OpenJDK 16 as the Paper Minecraft server is not working with versions higher than 16
- If you have a higher version of Java installed use the following command: sudo update-alternatives –config java and select OpenJDK 16
- 1.17 Release
- Make sure you have backups and take copies of your backups and place them outside the Minecraft folder to be 100% safe
- Once running the new version you can't go back to the old one without restoring a backup because it writes new stuff in your server the old version doesn't understand and crashes on
- As long as you have backups you should be okay!
- Raised minimum OpenJDK requirement to 16 in preparation for the 1.17 Paper Minecraft server release
- If a new enough OpenJDK is not available in apt (Raspberry Pi OS is on OpenJDK 11 for example) it will be installed via snapd
- If snapd is not installed it will ask you if you want to install it (reboot required) or abort
- After the reboot run SetupMinecraft.sh again and it will finish installing OpenJDK 16! Be patient, it can take some time, even 10-15 minutes on a good connection and longer on a bad one
- Sorry for the inconvenience, there isn't an easier way to get it until the Raspberry Pi OS apt repositories are updated!
- Fixed syntax error (thanks aruthir!)
- Added OpenJDK 17 and 18 placeholders for prerequisite installations
- Added a fallback to the non-headless JRE for platforms that don't offer that metapackage
- Paper Minecraft 1.17 is not yet available but should be soon. If you go to https://papermc.io/api/v1/paper/ and see 1.17 in the list it's available and you can change the version variable at the very top of SetupMinecraft.sh otherwise it hasn't been released yet. Should be soon!
- Lowered amount of recommended memory by a flat 200MB due to so many people having "Out of Memory" errors
- Note: Nobody has ever really been "out of memory" on the Pi since like the Pi 1. The problem is you're using TOO MUCH.
- If you're getting memory related crashes you need to turn your memory DOWN. The server will recommend lower amounts going forward.
- Added backup rotation - server keeps the last 10 backups by default
- If you want to change the amount of backups held it is located in the "start.sh" script with a comment of '# Rotate backups -- keep most recent 10'
- This adds a little responsibility for saving really old backups but fixes the issue I and many others have had of the server getting filled with backups and crashing
- Update to 1.16.5
- Server now takes ownership of server files on each start to prevent folks a whole heap of trouble and heartache when restoring backups/moving files/etc.
- Added check to make sure script isn't being ran as sudo to prevent installing to the /root folder
- Update to 1.16.4
- Fixed a bug where if your username on the Pi was Minecraft it would cause the script to break (thanks Minecraftschurli, pull request #20)
- Fixed a bug that could cause OpenJDK 10 to try to be installed even if OpenJDK 11 installation was successful
- Update to 1.16.3
- Update to 1.16.2
- Update to 1.16.1
- Update to 1.15.2
- Backup system now takes a backup of your entire server folder (minus logs and cache) instead of just the world folders. This mean it now backs up things like server.properties and other worlds if you are running a multiverse setup.
- Updated to version 1.15.1
- Added more information to script installation warnings to help with initial configuration
- Added warning to 2700MB limit on 32 bit operating systems explaining that you can lift the 3 GB limit by using a 64 bit Pi distribution
- Cleaned up Java installation in setup script
- Fixed a silly bug causing recommended memory to be stuck at 2700
- Improved server startup detection after running SetupMinecraft
- Added terminal colors to improve visibility
- Cleaned up script substantially by breaking out duplicate code to functions
- Fixed issue where when reconfiguring an existing server you would not be prompted to configure daily reboots
- Removed /boot/config.txt tweaks as they are no longer compatible with Pi 4
- To prevent startup failure on 32bit ARM the maximum memory for the Minecraft server is capped at 2700MB. This is a per process limitation of 32 bit on ARM and Linux. This restriction can be lifted by using a 64 bit operating system.
- Updated development version to 1.14.4
- Added OpenJDK 13 support
- Removed bc dependency to improve portability
- Raspberry Pi 4 support (all memory sizes)
- Updated development version to 1.14.3
- Fixed issue that could cause 1.13.2 servers to crash when going to the Nether
- Added option to select stable or development version
- Current stable version of the Paper Minecraft server is 1.13.2
- If you want to install 1.14.2 you may select to do so during installation
- Be aware that 1.14.2 continues to have severe performance issues for the entire Minecraft server/hosting community. After playing on it myself and talking to the Paper developers I can personally state that performance on 1.14.2 is really bad right now and highly recommend sticking with the stable version.
- OpenJDK 12 and OpenJDK 10 package checks added into the script
- Script will attempt to install OpenJDK 10 from package on Raspbian if it isn't in apt
- Added many paper.yml, bukkit.yml and spigot.yml changes to server config files to help with the ongoing lag affecting all Minecraft servers in 1.14
- To configure them open start.sh in nano after running SetupMinecraft and you will see the different options and what they do
- Updated Java certificates installer link
- Fixed bug where changing GPU memory wasn't being applied
- Updated to 1.14.2
- Updated to 1.14.1
- Changed StopChecks++ to StopChecks=$((StopChecks+1)) to improve portability (thanks Jason B.)
- Added TimeoutStartSec=600 to server to prevent it being killed if taking longer than usual to download paperclip
- Added x86_64 support
- Changed Paper download URL to use API (Issue #7 Fix)
- Added \n to beginning of printf to config.txt to prevent adding our line to the end of another config line
- Added support for OpenJDK 8 to improve portability
- Added Armbian support
- Tinkerboard platform now supported. Other Armbian capable boards should also work
- Added ca
- certificates
- java OpenJDK 11 fix for a broken package on some platforms
- Added checks for paper.yml and world backup folders before attempting to back up
- Fixed portability issue with route vs /sbin/route
- Shared GPU memory reduction and MicroSD overclock now supported on distros that use /boot/firmware/config.txt such as Ubuntu Server and Debian
- Removed vcgencmd usage for portability to other distros
- Added check for sudo for compatibility with more distros
- Improved MicroSD clock detection
- Setup now sets paper.yml option for watchdog warnings to wait until 120 seconds after the server starts to suppress excessive warnings
- Added a configuration option for memory to dedicate to the Minecraft server (along with a recommended amount)
- Added support for Debian and Ubuntu Server Raspberry Pi distros
- Server now installs OpenJDK
- 11
- jre
- headless if it is available, otherwise OpenJDK 9 will be selected
- Improved CPU architecture detection
- Added sudo, net
- tools, wget to server dependencies to improve portability
- Removed absolute paths from scripts to improve portability
- MicroSD overclock and GPU memory split config are now split if vcgencmd is not present (non
- Raspbian systems)
- The SetupMinecraft.sh script will now update all of your scripts to the latest version when ran and reinstall the startup service
- Implemented a workaround for Java 9 installation since the ca
- certificates
- java package broke in Raspbian on the 16th
- Server now starts correctly on Raspbian Full (Raspbian Lite still highly recommended due to more available memory)
- Added network connectivity check before attempting to update server
- skips update if no connection available to prevent .jar corruption
- Service now waits up to 20 seconds for network connectivity before starting up to prevent service starting before server gets an IP address
- Fixed typo in stop.sh that was causing server to say it wasn't running when it was
- Removed unnecessary sleep time on stop.sh script so it returns as soon as the minecraft server closes
- Added automatic backups performed when server starts (located in minecraft/backups)
- Added check to make sure service isn't already running when started
- Added optional service configuration to start minecraft automatically on boot
- Added optional daily reboot configuration via Cron in setup script
- Added a check in the installer to make sure Java was installed properly before continuing
- Installer script now goes into the started screen window after installation
- Server now checks for updates to the server on startup
- Script now checks to make sure we are running on the ARMv7 CPU architecture with 1024MB of RAM to ensure Java 9 works
- Script helps you overclock SD card and change gpu_mem to 16MB
- Increased memory usage of server from 800MB to 850MB due to gpu_mem tweak
- Improved reliability and validation checks on setup script