Skip to content

Control Paper Minecraft server with systemd

License

Notifications You must be signed in to change notification settings

AtomicSponge/paper-systemd

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

42 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Paper MC systemd scripts

Steps for using the provided scripts and setting up the Paper MC server as a systemd service. This will allow you to control the server with systemctl and interact with it using the minecraft command.


Create Service Account

Create a user account named minecraft. This will be the service account for running the server.

sudo useradd -m -r minecraft
sudo passwd minecraft

Download Paper MC

Log into the minecraft service account. Download Paper server from: https://papermc.io/software/paper

Place the server in /home/minecraft/paper then rename the Paper server executable file to server.jar.

Using the commands below, replacing for the correct download URL and filename:

mkdir paper
cd paper
wget https://api.papermc.io/v2/projects/paper/GETLATESTFROMWEBSITE
mv paper-x.xx.x-xxx.jar server.jar

Note: If this is the first time you're running Paper on your server, you'll want to manually run it at this point to agree to its EULA.

Run:

java -Xms4G -Xmx4G -jar server.jar --nogui

And follow the on screen prompts.

Configure scripts

Switch back to your primary account with sudo access.

Clone this repo:

git clone https://github.com/AtomicSponge/paper-systemd.git
cd paper-systemd

Place the file minecraft in /usr/local/bin and make sure it has execute permissions by running:

chmod 555 minecraft
sudo mv minecraft /usr/local/bin

Place files minecraft.service and minecraft.socket in /etc/systemd/system:

sudo mv minecraft.service /etc/systemd/system
sudo mv minecraft.socket /etc/systemd/system

Then to start the service run:

sudo systemctl enable minecraft

Memory Setting

Default memory setting is 4GB, to change edit minecraft.service and update the following under ExecStart to your desired values:

-Xms4096M -Xmx4096M

Usage

Commands are passed to the server via the provided script.

To run commands, enter the server command after minecraft:

minecraft kick PlayerName

Note: Do not use / before the command name

To view server output use the journalctl command.

For example, this will monitor the log:

journalctl -u minecraft -f

References

For a list of server commands see: https://minecraft.fandom.com/wiki/Commands

Service script is using the Aikar's flags from: https://docs.papermc.io/misc/tools/start-script-gen

journalctl manual: https://www.freedesktop.org/software/systemd/man/latest/journalctl.html#

Adapted from: https://unix.stackexchange.com/a/612118