You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

38 lines
869 B

  1. # -*- mode: shell-script -*-
  2. MINECRAFT_PATH="$SERVICE_CONFIGSTORE/opt/apps/minecraft"
  3. MINECRAFT_DATA="/var/lib/minecraft"
  4. minecraft:init-binary() {
  5. local version="$1"
  6. MINECRAFT_BINARY="${MINECRAFT_PATH}/minecraft_server.${version}.jar"
  7. if ! [ -f "$MINECRAFT_BINARY" ]; then
  8. mkdir -p "${MINECRAFT_PATH}"
  9. wget "https://docker.0k.io/downloads/minecraft_server.${version}.jar" \
  10. -O "$MINECRAFT_BINARY"
  11. fi
  12. init-config-add "
  13. $SERVICE_NAME:
  14. volumes:
  15. - \"${MINECRAFT_BINARY}:${MINECRAFT_DATA}/server.jar\"
  16. "
  17. }
  18. minecraft:init-command() {
  19. local threads="${1:-4}" mem="${2:-2048M}"
  20. init-config-add "
  21. $SERVICE_NAME:
  22. command:
  23. - java
  24. - -Xmx${mem}
  25. - -Xms${mem}
  26. - -XX:ParallelGCThreads=${threads}
  27. - -jar
  28. - server.jar
  29. - nogui
  30. "
  31. echo "eula=TRUE" > "$SERVICE_DATASTORE/${MINECRAFT_DATA}/eula.txt"
  32. }