blob: 3561cb28f49a4f03cb081bca052bedad9d863ec5 [file] [log] [blame] [raw]
[Unit]
Description=Minecraft server %I
After=network.target
[Service]
Type=simple
PrivateTmp=yes
ProtectSystem=yes
ProtectControlGroups=yes
; Those environment are useless due to limitations of systemd
;Environment=MINECRAFT_HOME=%h
;MINECRAFT_START_COMMAND="exec sh run.sh"
;EnvironmentFile=/etc/default/minecraft
; Hardcoded user name because systemd doesn't support using variables here
User=minecraft
; Cannot use 'WorkingDirectory=' due to '%h' will be expanded to empty string
;WorkingDirectory=%h/%I
;ExecStart=/bin/sh run.sh
; chdir(2) inside sh(1) instead
;ExecStart=/bin/sh -x -c "cd $MINECRAFT_HOME/%i/ && exec sh run.sh" ; Give up MINECRAFT_HOME
;ExecStart=/bin/sh -x -c "cd %h/%i/ && exec sh run.sh" ; '%h' will expending to /
ExecStart=/bin/sh -x -c "cd ~/%i/ && exec sh run.sh"
;StandardOutput=null
;StandardOutput=syslog
SyslogIdentifier=minecraft-server:%I
TimeoutStopSec=30s
Restart=on-failure
[Install]
WantedBy=multi-user.target