Guest User

script

a guest
Apr 1st, 2020
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.35 KB | None | 0 0
  1. root@ubuntu:/opt/minecraft/bukkit/logs# cat /etc/systemd/system/[email protected]
  2. #!/bin/bash
  3. # Source: https://github.com/agowa338/MinecraftSystemdUnit/
  4. # License: MIT
  5. [Unit]
  6. Description=Minecraft Server %i
  7. After=network.target
  8.  
  9. [Service]
  10. WorkingDirectory=/opt/minecraft/%i
  11. PrivateUsers=true
  12. # Users Database is not available for within the unit, only root and minecraft is available, everybody else is nobody
  13. User=minecraft
  14. Group=minecraft
  15. ProtectSystem=full
  16. # Read only mapping of /usr /boot and /etc
  17. ProtectHome=true
  18. # /home, /root and /run/user seem to be empty from within the unit. It is recommended to enable this setting for all long-running services (in particular network-facing ones).
  19. ProtectKernelTunables=true
  20. # /proc/sys, /sys, /proc/sysrq-trigger, /proc/latency_stats, /proc/acpi, /proc/timer_stats, /proc/fs and /proc/irq will be read-only within the unit. It is recommended to turn this on for most services.
  21. # Implies MountFlags=slave
  22. ProtectKernelModules=true
  23. # Block module system calls, also /usr/lib/modules. It is recommended to turn this on for most services that do not need special file systems or extra kernel modules to work
  24. # Implies NoNewPrivileges=yes
  25. ProtectControlGroups=true
  26. # It is hence recommended to turn this on for most services.
  27. # Implies MountAPIVFS=yes
  28.  
  29. ExecStart=/bin/sh -c '/usr/bin/screen -DmS mc-%i /usr/bin/java -server -DIReallyKnowWhatIAmDoingISwear -XX:ParallelGCThreads=4 -Xmx3G -Xms3G -jar bukkit-current.jar nogui'
  30.  
  31. ExecReload=/usr/bin/screen -p 0 -S mc-%i -X eval 'stuff "reload"\\015'
  32.  
  33. ExecStop=/usr/bin/screen -p 0 -S mc-%i -X eval 'stuff "say SERVER SHUTTING DOWN. Saving map..."\\015'
  34. ExecStop=/usr/bin/screen -p 0 -S mc-%i -X eval 'stuff "save-all"\\015'
  35. ExecStop=/usr/bin/screen -p 0 -S mc-%i -X eval 'stuff "stop"\\015'
  36. ExecStop=/bin/sleep 10
  37.  
  38. Restart=on-failure
  39. RestartSec=60s
  40.  
  41. [Install]
  42. WantedBy=multi-user.target
  43.  
  44. #########
  45. # HowTo
  46. #########
  47. #
  48. # Create a directory in /opt/minecraft/XX where XX is a name like 'survival'
  49. # Add minecraft_server.jar into dir with other conf files for minecraft server
  50. #
  51. # Enable/Start systemd service
  52. # systemctl enable minecraft@survival
  53. # systemctl start minecraft@survival
  54. #
  55. # To run multiple servers simply create a new dir structure and enable/start it
  56. # systemctl enable minecraft@creative
  57. # systemctl start minecraft@creative
Advertisement
Add Comment
Please, Sign In to add comment