From aef98f9f34dd975459507e9cdec22b5d6ecd5a9d Mon Sep 17 00:00:00 2001 From: Harsh Shandilya Date: Mon, 2 Jan 2023 13:43:55 +0530 Subject: [PATCH] feat: add minecraft scripts --- minecraft/start.sh | 3 +++ minecraft/stop.sh | 3 +++ minecraft/update.sh | 22 ++++++++++++++++++++++ 3 files changed, 28 insertions(+) create mode 100644 minecraft/start.sh create mode 100644 minecraft/stop.sh create mode 100644 minecraft/update.sh diff --git a/minecraft/start.sh b/minecraft/start.sh new file mode 100644 index 0000000..f0cee92 --- /dev/null +++ b/minecraft/start.sh @@ -0,0 +1,3 @@ +#!/usr/bin/env bash + +java -Xms10G -Xmx10G -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 paper-"$(cat .paper-version)".jar nogui diff --git a/minecraft/stop.sh b/minecraft/stop.sh new file mode 100644 index 0000000..30e62e8 --- /dev/null +++ b/minecraft/stop.sh @@ -0,0 +1,3 @@ +#!/usr/bin/env bash + +/opt/minecraft/tools/mcrcon/mcrcon -H 127.0.0.1 -P 25575 -p "${MCRCON_PASSWORD}" stop diff --git a/minecraft/update.sh b/minecraft/update.sh new file mode 100644 index 0000000..cdec519 --- /dev/null +++ b/minecraft/update.sh @@ -0,0 +1,22 @@ +#!/usr/bin/env bash + +set -euo pipefail + +function update_paper() { + local CURRENT_VERSION LATEST_VERSION + CURRENT_VERSION="$(cat .paper-version)" + LATEST_VERSION="$(curl -s 'https://papermc.io/api/v2/projects/paper/versions/1.19.3' -H 'accept: application/json' | jq .builds[-1])" + echo "Currently running version is ${CURRENT_VERSION}" + echo "Latest version is 1.19.3-${LATEST_VERSION}" + [ -f "paper-1.19.3-${LATEST_VERSION}.jar" ] && return + echo "Updating to 1.19.3-${LATEST_VERSION}" + curl --progress-bar -L "https://papermc.io/api/v2/projects/paper/versions/1.19.3/builds/${LATEST_VERSION}/downloads/paper-1.19.3-${LATEST_VERSION}.jar" -o "paper-1.19.3-${LATEST_VERSION}.jar" + echo "1.19.3-${LATEST_VERSION}" >.paper-version +} + +function cleanup_previous_jars() { + find . -maxdepth 1 -type f -name 'paper-*.jar' | sort -r | tail -n +3 | xargs rm -v +} + +update_paper +cleanup_previous_jars