| [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 |