2020-12-28 12:27:18 -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=minecraft
|
|
|
|
WorkingDirectory={{ minecraft_home }}/%i
|
2021-01-01 00:32:41 -06:00
|
|
|
EnvironmentFile={{ minecraft_home }}/%i/env
|
2020-12-28 12:27:18 -06:00
|
|
|
PrivateUsers=true
|
|
|
|
ProtectSystem=full
|
|
|
|
ProtectHome=true
|
|
|
|
# Implies MountFlags=slave
|
|
|
|
ProtectKernelTunables=true
|
|
|
|
# Implies NoNewPrivileges=yes
|
|
|
|
ProtectKernelModules=true
|
|
|
|
# Implies MountAPIVFS=yes
|
|
|
|
ProtectControlGroups=true
|
|
|
|
|
2021-01-01 00:32:41 -06:00
|
|
|
ExecStart=/bin/sh -c '/usr/bin/screen -DmS %i /usr/bin/java -Xms${JRE_XMS} -Xmx${JRE_XMX} -jar server.jar nogui'
|
2020-12-28 12:27:18 -06:00
|
|
|
|
|
|
|
ExecReload=/usr/bin/screen -p 0 -S %i -X eval 'stuff "reload"\\015'
|
|
|
|
|
|
|
|
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'
|
2021-01-01 18:25:04 -06:00
|
|
|
ExecStop=/bin/sleep ${MC_RESTART_DELAY}
|
2020-12-28 12:27:18 -06:00
|
|
|
|
|
|
|
Restart=always
|
|
|
|
# Restart after 24hrs
|
|
|
|
RuntimeMaxSecs=86400
|
|
|
|
|
|
|
|
[Install]
|
|
|
|
WantedBy=multi-user.target
|