Guest User

script

a guest
Apr 2nd, 2020
1,069
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.27 KB | None | 0 0
  1. #!/bin/bash
  2. # Source: https://github.com/agowa338/MinecraftSystemdUnit/
  3. # License: MIT
  4. [Unit]
  5. Description=Minecraft Server %i
  6. After=network.target
  7.  
  8. [Service]
  9. WorkingDirectory=/opt/minecraft/%i
  10. PrivateUsers=true
  11. # Users Database is not available for within the unit, only root and minecraft is available, everybody else is nobody
  12. User=minecraft
  13. Group=minecraft
  14. ProtectSystem=full
  15. # Read only mapping of /usr /boot and /etc
  16. ProtectHome=true
  17. # /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).
  18. ProtectKernelTunables=true
  19. # /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.
  20. # Implies MountFlags=slave
  21. ProtectKernelModules=true
  22. # 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
  23. # Implies NoNewPrivileges=yes
  24. ProtectControlGroups=true
  25. # It is hence recommended to turn this on for most services.
  26. # Implies MountAPIVFS=yes
  27.  
  28. 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'
  29.  
  30. ExecReload=/usr/bin/screen -p 0 -S mc-%i -X eval 'stuff "reload"\\015'
  31.  
  32. ExecStop=/usr/bin/screen -p 0 -S mc-%i -X eval 'stuff "say SERVER SHUTTING DOWN. Saving map..."\\015'
  33. ExecStop=/usr/bin/screen -p 0 -S mc-%i -X eval 'stuff "save-all"\\015'
  34. ExecStop=/usr/bin/screen -p 0 -S mc-%i -X eval 'stuff "stop"\\015'
  35. ExecStop=/bin/sleep 10
  36.  
  37. Restart=on-failure
  38. #RestartSec=60s
  39.  
  40. [Install]
  41. WantedBy=multi-user.target
  42.  
  43. #########
  44. # HowTo
  45. #########
  46. #
  47. # Create a directory in /opt/minecraft/XX where XX is a name like 'survival'
  48. # Add minecraft_server.jar into dir with other conf files for minecraft server
  49. #
  50. # Enable/Start systemd service
  51. # systemctl enable minecraft@survival
  52. # systemctl start minecraft@survival
  53. #
  54. # To run multiple servers simply create a new dir structure and enable/start it
  55. # systemctl enable minecraft@creative
  56. # systemctl start minecraft@creative
Advertisement
Add Comment
Please, Sign In to add comment