# HG changeset patch # User Luke Hoersten # Date 1626657436 18000 # Node ID ae19501f52514463223053583aa4e01104603ed3 # Parent 40b78af863372db4a556041ecf1d68884c0b96ec Updated minecraft to be multi-world and minimized world size. diff -r 40b78af86337 -r ae19501f5251 minecraft/aws-s3-backup/files/minecraft-s3-backup-lifecycle.json --- a/minecraft/aws-s3-backup/files/minecraft-s3-backup-lifecycle.json Sun Jul 18 17:43:46 2021 -0500 +++ b/minecraft/aws-s3-backup/files/minecraft-s3-backup-lifecycle.json Sun Jul 18 20:17:16 2021 -0500 @@ -5,7 +5,7 @@ "Filter": {}, "Status": "Enabled", "NoncurrentVersionExpiration": { - "NoncurrentDays": 5 + "NoncurrentDays": 30 } } ] diff -r 40b78af86337 -r ae19501f5251 minecraft/aws-s3-backup/files/minecraft-s3-backup.sh --- a/minecraft/aws-s3-backup/files/minecraft-s3-backup.sh Sun Jul 18 17:43:46 2021 -0500 +++ b/minecraft/aws-s3-backup/files/minecraft-s3-backup.sh Sun Jul 18 20:17:16 2021 -0500 @@ -1,10 +1,12 @@ #!/bin/bash -BUCKET=$1 +BACKUP_WORLD_NAME=$1 BACKUP_DIR=$2 -BACKUP_TAR="/tmp/$BUCKET.tgz" +BUCKET=$3 +BACKUP_TAR_DIR=$4 +BACKUP_TAR="${BACKUP_TAR_DIR}/${BUCKET}.tgz" -tar -zc -f $BACKUP_TAR $BACKUP_DIR +tar -zc -f $BACKUP_TAR -C $BACKUP_DIR $BACKUP_WORLD_NAME {$BACKUP_WORLD_NAME}_nether ${BACKUP_WORLD_NAME}_the_end aws s3 mb "s3://$BUCKET/" aws s3api put-bucket-versioning --bucket "$BUCKET" --versioning-configuration Status=Enabled aws s3api put-bucket-lifecycle-configuration --bucket "$BUCKET" --lifecycle-configuration "file:///usr/local/share/minecraft-s3-backup-lifecycle.json" diff -r 40b78af86337 -r ae19501f5251 minecraft/aws-s3-backup/handlers/main.yaml --- a/minecraft/aws-s3-backup/handlers/main.yaml Sun Jul 18 17:43:46 2021 -0500 +++ b/minecraft/aws-s3-backup/handlers/main.yaml Sun Jul 18 20:17:16 2021 -0500 @@ -1,5 +1,5 @@ --- - name: reload s3 backup service - systemd: name="minecraft-s3-backup@{{minecraft_s3_backup_bucket}}.service" enabled="yes" daemon_reload="yes" + systemd: name="minecraft-s3-backup@{{minecraft_s3_backup_world_name}}.service" enabled="yes" daemon_reload="yes" become: yes diff -r 40b78af86337 -r ae19501f5251 minecraft/aws-s3-backup/tasks/main.yaml --- a/minecraft/aws-s3-backup/tasks/main.yaml Sun Jul 18 17:43:46 2021 -0500 +++ b/minecraft/aws-s3-backup/tasks/main.yaml Sun Jul 18 20:17:16 2021 -0500 @@ -14,13 +14,20 @@ dest: "/usr/local/share/minecraft-s3-backup-lifecycle.json" mode: "0755" +- name: create minecraft tar dir + become: yes + file: + path: "{{minecraft_s3_backup_tar_dir}}" + mode: "0755" + state: "directory" + - name: configure minecraft s3 backup systemd service become: yes template: src: "minecraft-s3-backup@.service.j2" - dest: "/lib/systemd/system/minecraft-s3-backup@{{minecraft_s3_backup_bucket}}.service" + dest: "/lib/systemd/system/minecraft-s3-backup@{{minecraft_s3_backup_world_name}}.service" notify: reload s3 backup service - name: ensure minecraft s3 backup service is started become: yes - systemd: name="minecraft-s3-backup@{{minecraft_s3_backup_bucket}}.service" enabled="yes" + systemd: name="minecraft-s3-backup@{{minecraft_s3_backup_world_name}}.service" enabled="yes" diff -r 40b78af86337 -r ae19501f5251 minecraft/aws-s3-backup/templates/minecraft-s3-backup@.service.j2 --- a/minecraft/aws-s3-backup/templates/minecraft-s3-backup@.service.j2 Sun Jul 18 17:43:46 2021 -0500 +++ b/minecraft/aws-s3-backup/templates/minecraft-s3-backup@.service.j2 Sun Jul 18 20:17:16 2021 -0500 @@ -3,7 +3,7 @@ [Service] Type=oneshot -ExecStart=/usr/local/bin/minecraft-s3-backup.sh %i "{{minecraft_s3_backup_dir}}" +ExecStart=/usr/local/bin/minecraft-s3-backup.sh %i "{{minecraft_s3_backup_dir}}" "{{minecraft_s3_backup_bucket}}" "{{minecraft_s3_backup_tar_dir}}" [Install] WantedBy=aws-s3-backup.target diff -r 40b78af86337 -r ae19501f5251 minecraft/server/defaults/main.yaml --- a/minecraft/server/defaults/main.yaml Sun Jul 18 17:43:46 2021 -0500 +++ b/minecraft/server/defaults/main.yaml Sun Jul 18 20:17:16 2021 -0500 @@ -1,7 +1,6 @@ --- minecraft_user: "minecraft" -minecraft_fork: "vanilla" # paper minecraft_parent_dir: "/opt" minecraft_motd: "A Minecraft Server" minecraft_mem: "2G" @@ -9,14 +8,13 @@ minecraft_difficulty: "hard" minecraft_whitelist: "true" minecraft_view_distance: "10" - -minecraft_vanilla_hash: "0a269b5f2c5b93b1712d0f5dc43b6182b9ab254e" +minecraft_world_name: "world" # https://papermc.io minecraft_paper_version: "1.17.1" minecraft_paper_build: "98" -minecreat_paper_plugins_enabled: +minecreat_plugins_enabled: - "dynmap" - "geyser" diff -r 40b78af86337 -r ae19501f5251 minecraft/server/handlers/main.yaml --- a/minecraft/server/handlers/main.yaml Sun Jul 18 17:43:46 2021 -0500 +++ b/minecraft/server/handlers/main.yaml Sun Jul 18 20:17:16 2021 -0500 @@ -2,4 +2,4 @@ - name: restart minecraft become: yes - systemd: name="minecraft.service" state="restarted" daemon_reload="yes" + systemd: name="minecraft@{{minecraft_world_name}}.service" state="restarted" daemon_reload="yes" diff -r 40b78af86337 -r ae19501f5251 minecraft/server/tasks/main.yaml --- a/minecraft/server/tasks/main.yaml Sun Jul 18 17:43:46 2021 -0500 +++ b/minecraft/server/tasks/main.yaml Sun Jul 18 20:17:16 2021 -0500 @@ -2,19 +2,11 @@ - name: add minecraft user become: yes - user: name="{{minecraft_user}}" home="{{minecraft_dir}}" + user: name="{{minecraft_user}}" home="{{minecraft_parent_dir}}/minecraft" - name: install adoptopenjdk include_tasks: adoptopenjdk.yaml -- name: set minecraft fork - set_fact: minecraft_url="{{minecraft_vanilla_url}}" - when: minecraft_fork == "vanilla" - -- name: set minecraft fork - set_fact: minecraft_url="{{minecraft_paper_url}}" - when: minecraft_fork == "paper" - - name: create minecraft dir become: yes file: @@ -72,8 +64,7 @@ - name: install plugins include_tasks: "{{item}}.yaml" - loop: "{{minecreat_paper_plugins_enabled}}" - when: minecraft_fork == "paper" + loop: "{{minecreat_plugins_enabled}}" - name: create server.properties become: yes @@ -94,6 +85,7 @@ notify: restart minecraft loop: - {key: "motd", value: "{{minecraft_motd}}"} + - {key: "level-name", value: "{{minecraft_world_name}}"} - {key: "level-seed", value: "{{minecraft_seed}}"} - {key: "difficulty", value: "{{minecraft_difficulty}}"} - {key: "white-list", value: "{{minecraft_whitelist}}"} @@ -104,10 +96,10 @@ - name: install systemd service become: yes template: - src: "minecraft.service.j2" - dest: "/lib/systemd/system/minecraft.service" + src: "minecraft@.service.j2" + dest: "/lib/systemd/system/minecraft@.service" notify: restart minecraft - name: ensure service is started become: yes - systemd: name="minecraft.service" enabled="yes" state="started" + systemd: name="minecraft@{{minecraft_world_name}}.service" enabled="yes" state="started" diff -r 40b78af86337 -r ae19501f5251 minecraft/server/templates/minecraft.service.j2 --- a/minecraft/server/templates/minecraft.service.j2 Sun Jul 18 17:43:46 2021 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,22 +0,0 @@ -[Unit] -Description=Minecraft Server -Documentation=https://minecraft.gamepedia.com/Tutorials/Setting_up_a_server - -Wants=network.target -After=network.target - -[Service] -User={{minecraft_user}} -Group={{minecraft_user}} -WorkingDirectory={{minecraft_dir}} -Restart=on-failure -RestartSec=20 5 -ExecStart=/usr/bin/java -Xms{{minecraft_mem}} -Xmx{{minecraft_mem}} -XX:+UseG1GC -XX:+ParallelRefProcEnabled -XX:MaxGCPauseMillis=200 -XX:+UnlockExperimentalVMOptions -XX:+DisableExplicitGC -XX:+AlwaysPreTouch -XX:G1NewSizePercent=30 -XX:G1MaxNewSizePercent=40 -XX:G1HeapRegionSize=8M -XX:G1ReservePercent=20 -XX:G1HeapWastePercent=5 -XX:G1MixedGCCountTarget=4 -XX:InitiatingHeapOccupancyPercent=15 -XX:G1MixedGCLiveThresholdPercent=90 -XX:G1RSetUpdatingPauseTimePercent=5 -XX:SurvivorRatio=32 -XX:+PerfDisableSharedMem -XX:MaxTenuringThreshold=1 -Dusing.aikars.flags=https://mcflags.emc.gs -Daikars.new.flags=true -jar server.jar nogui - -PrivateTmp=true -ProtectSystem=full -NoNewPrivileges=true -PrivateDevices=true - -[Install] -WantedBy=multi-user.target diff -r 40b78af86337 -r ae19501f5251 minecraft/server/templates/minecraft@.service.j2 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/minecraft/server/templates/minecraft@.service.j2 Sun Jul 18 20:17:16 2021 -0500 @@ -0,0 +1,20 @@ +[Unit] +Description=Minecraft Server %I +Documentation=https://minecraft.gamepedia.com/Tutorials/Setting_up_a_server +After=network.target + +[Service] +User={{minecraft_user}} +Group={{minecraft_user}} +WorkingDirectory={{minecraft_parent_dir}}/minecraft/%i +Restart=on-failure +RestartSec=20 5 +ExecStart=/usr/bin/java -Xms{{minecraft_mem}} -Xmx{{minecraft_mem}} -XX:+UseG1GC -XX:+ParallelRefProcEnabled -XX:MaxGCPauseMillis=200 -XX:+UnlockExperimentalVMOptions -XX:+DisableExplicitGC -XX:+AlwaysPreTouch -XX:G1NewSizePercent=30 -XX:G1MaxNewSizePercent=40 -XX:G1HeapRegionSize=8M -XX:G1ReservePercent=20 -XX:G1HeapWastePercent=5 -XX:G1MixedGCCountTarget=4 -XX:InitiatingHeapOccupancyPercent=15 -XX:G1MixedGCLiveThresholdPercent=90 -XX:G1RSetUpdatingPauseTimePercent=5 -XX:SurvivorRatio=32 -XX:+PerfDisableSharedMem -XX:MaxTenuringThreshold=1 -Dusing.aikars.flags=https://mcflags.emc.gs -Daikars.new.flags=true -jar server.jar nogui + +PrivateTmp=true +ProtectSystem=full +NoNewPrivileges=true +PrivateDevices=true + +[Install] +WantedBy=multi-user.target diff -r 40b78af86337 -r ae19501f5251 minecraft/server/vars/main.yaml --- a/minecraft/server/vars/main.yaml Sun Jul 18 17:43:46 2021 -0500 +++ b/minecraft/server/vars/main.yaml Sun Jul 18 20:17:16 2021 -0500 @@ -1,8 +1,7 @@ --- -minecraft_dir: "{{minecraft_parent_dir}}/minecraft/{{minecraft_fork}}" -minecraft_paper_url: "https://papermc.io/api/v1/paper/{{minecraft_paper_version}}/{{minecraft_paper_build}}/download" -minecraft_vanilla_url: "https://launcher.mojang.com/v1/objects/{{minecraft_vanilla_hash}}/server.jar" +minecraft_dir: "{{minecraft_parent_dir}}/minecraft/{{minecraft_world_name}}" +minecraft_url: "https://papermc.io/api/v1/paper/{{minecraft_paper_version}}/{{minecraft_paper_build}}/download" # paper is a spigot derivative minecraft_dynmap_url: "http://dynmap.us/builds/dynmap/Dynmap-{{minecraft_dynmap_version}}-spigot.jar"