Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Minecraft SystemD Script
[Unit]
Description=Minecraft Server %i
[Service]
WorkingDirectory=/home/minecraft/server-%i
User=minecraft
ExecStart=/usr/bin/screen -DmS mc-%i ./start.sh
ExecStop=/usr/bin/screen -p 0 -S mc-%i -X eval 'stuff "say ATTENTION ATTENTION ATTENTION."\\015'
ExecStop=/usr/bin/screen -p 0 -S mc-%i -X eval 'stuff "say SERVER IS SHUTTING DOWN IMMEDIATELY."\\015'
ExecStop=/usr/bin/screen -p 0 -S mc-%i -X eval 'stuff "say Saving map..."\\015'
ExecStop=/usr/bin/screen -p 0 -S mc-%i -X eval 'stuff "save-all"\\015'
ExecStop=/usr/bin/screen -p 0 -S mc-%i -X eval 'stuff "stop"\\015'
ExecStop=/bin/sleep 2
[Install]
WantedBy=multi-user.target
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment