-
-
Save dd-han/0ed20035cb7c7e07c8b0cdf64196773b to your computer and use it in GitHub Desktop.
Minecraft systemd unit file that uses tmux instead of screen
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
root@dd-han-minecrafts:~# cat /etc/systemd/system/minecraft@.service | |
[Unit] | |
Description=Minecraft Server %i | |
After=network.target | |
[Service] | |
#PrivateTmp=true | |
WorkingDirectory=/home/dd-han/minecraft/%i | |
User=dd-han | |
Type=oneshot | |
RemainAfterExit=yes | |
KillMode=none | |
ExecStart=/usr/bin/tmux new-session -s mc-%i -d '/usr/bin/java -Xmx1024M -jar minecraft_server.jar nogui' | |
ExecStop=/usr/bin/tmux send-keys -t mc-%i:0.0 'say SERVER SHUTTING DOWN. Saving map...' C-m 'save-all' C-m 'stop' C-m | |
ExecStop=/bin/sleep 2 | |
[Install] | |
WantedBy=multi-user.target | |
######### | |
# HowTo | |
######### | |
# | |
# Create directory in /home/dd-han/minecraft/XX where XX is a name like 'survival' | |
# Add minecraft_server.jar into dir with other conf files for minecraft server | |
# | |
# Enable/Start systemd service | |
# systemctl enable minecraft@survival | |
# systemctl start minecraft@survival | |
# | |
# To run multiple servers simply create a new dir structure and enable/start it | |
# systemctl enable minecraft@creative | |
# systemctl start minecraft@creative |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment