2020-02-23 23:45:11 -06:00
|
|
|
#
|
|
|
|
# Licensed under the terms of the MIT license
|
|
|
|
# Source: https://github.com/agowa338/MinecraftSystemdUnit/
|
|
|
|
# vim:ft=dosini:
|
|
|
|
#
|
|
|
|
|
|
|
|
[Unit]
|
|
|
|
Description=Minecraft Server %i
|
|
|
|
After=network.target
|
|
|
|
|
|
|
|
[Service]
|
|
|
|
User=minecraft
|
|
|
|
Group=mc-admin
|
|
|
|
WorkingDirectory=/var/minecraft/%i
|
2020-07-21 13:32:16 -05:00
|
|
|
PrivateUsers=true
|
|
|
|
ProtectSystem=full
|
|
|
|
ProtectHome=true
|
2020-02-23 23:45:11 -06:00
|
|
|
# Implies MountFlags=slave
|
2020-07-21 13:32:16 -05:00
|
|
|
ProtectKernelTunables=true
|
2020-02-23 23:45:11 -06:00
|
|
|
# Implies NoNewPrivileges=yes
|
2020-07-21 13:32:16 -05:00
|
|
|
ProtectKernelModules=true
|
2020-02-23 23:45:11 -06:00
|
|
|
# Implies MountAPIVFS=yes
|
2020-07-21 13:32:16 -05:00
|
|
|
ProtectControlGroups=true
|
2020-02-23 23:45:11 -06:00
|
|
|
|
2020-06-01 21:56:39 -05:00
|
|
|
ExecStart=/bin/sh -c '/usr/bin/screen -DmS %i /usr/bin/java -Xms{{ mcheapmin }}M -Xmx{{ mcheapmax }}M -jar server.jar nogui'
|
2020-02-23 23:45:11 -06:00
|
|
|
|
2020-06-01 21:56:39 -05:00
|
|
|
ExecReload=/usr/bin/screen -p 0 -S %i -X eval 'stuff "reload"\\015'
|
2020-02-23 23:45:11 -06:00
|
|
|
|
2020-06-01 21:56:39 -05:00
|
|
|
ExecStop=/usr/bin/screen -p 0 -S %i -X eval 'stuff "say Server is going down: Service was stopped"\\015'
|
|
|
|
ExecStop=/usr/bin/screen -p 0 -S %i -X eval 'stuff "save-all"\\015'
|
|
|
|
ExecStop=/usr/bin/screen -p 0 -S %i -X eval 'stuff "stop"\\015'
|
|
|
|
ExecStop=/bin/sleep 5
|
2020-02-23 23:45:11 -06:00
|
|
|
|
2020-03-25 08:30:03 -05:00
|
|
|
Restart=always
|
2020-06-22 12:07:07 -05:00
|
|
|
# Restart after 24hrs
|
|
|
|
RuntimeMaxSecs=86400
|
2020-02-24 00:18:41 -06:00
|
|
|
|
|
|
|
[Install]
|
|
|
|
WantedBy=multi-user.target
|