From 84d6876b74aeea563223aa7c978691c1bea0bcf9 Mon Sep 17 00:00:00 2001 From: Merith-TK Date: Tue, 13 May 2025 19:32:22 +0000 Subject: [PATCH] adjust shit --- Dockerfile | 4 ++-- docker-compose.yml | 11 +++++++++ entrypoint.sh | 58 +++++++++++++++++++++++++--------------------- 3 files changed, 44 insertions(+), 29 deletions(-) create mode 100644 docker-compose.yml diff --git a/Dockerfile b/Dockerfile index ec60e46..8082410 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,7 +5,7 @@ RUN apt-get update && \ apt-get clean && \ rm -rf /var/lib/apt/lists/* - WORKDIR /data +WORKDIR /data COPY entrypoint.sh /entrypoint.sh RUN chmod +x /entrypoint.sh -ENTRYPOINT ["/bin/bash", "/entrypoint.sh"] +ENTRYPOINT ["/entrypoint.sh"] diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..44a81aa --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,11 @@ +version: "3.8" + +services: + geyser: + build: . + # image: git.merith.xyz/oci/geyser:nightly + ports: + - 19132:19132 + volumes: + - ./data:/data + diff --git a/entrypoint.sh b/entrypoint.sh index dfeb73e..1a0711e 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,33 +1,37 @@ -#!/bin/sh +#!/bin/bash +set -euo pipefail + cd /data -wget -O /data/geyser.jar.new https://download.geysermc.org/v2/projects/geyser/versions/latest/builds/latest/downloads/standalone -GEYSER_NEWHASH=$(sha256sum /data/geyser.jar.new | cut -d' ' -f1) -if [ ! -f /data/geyser.jar ]; then - echo "Installing Geyser..." - mv /data/geyser.jar.new /data/geyser.jar -fi -GEYSER_OLDHASH=$(sha256sum /data/geyser.jar | cut -d' ' -f1) -if [ "$NEWHASH" != "$OLDHASH" ]; then - echo "Updating Geyser..." - mv /data/geyser.jar.new /data/geyser.jar -fi +JAR_PATH="geyser.jar" +TMP_JAR="geyser.jar.new" +DOWNLOAD_URL="https://download.geysermc.org/v2/projects/geyser/versions/latest/builds/latest/downloads/standalone" -echo "Updating GeyserConnect..." -if [ -z "$GH_TOKEN" ]; then - echo "No GH_TOKEN set, cannot update GeyserConnect." +echo "Downloading latest Geyser standalone JAR..." +wget -q -O "$TMP_JAR" "$DOWNLOAD_URL" + +# Get new JAR hash +if [[ -f "$TMP_JAR" ]]; then + NEW_HASH=$(sha256sum "$TMP_JAR" | awk '{print $1}') else - - GEYSERCONNECT_BUILD=$(curl -s https://api.github.com/repos/GeyserMC/GeyserConnect/actions/workflows/build.yml/runs | jq -r '.workflow_runs[0].id') - # TODO: FIX THIS URL - GEYSERCONNECT_URL=$(curl -s https://api.github.com/repos/GeyserMC/GeyserConnect/actions/runs/5027683930/artifacts | jq -r '.artifacts[0].archive_download_url') - curl -L \ - -H "Accept: application/vnd.github+json" \ - -H "Authorization: Bearer $GH_TOKEN" \ - -H "X-GitHub-Api-Version: 2022-11-28" \ - $GEYSERCONNECT_URL --output geyserconnect.zip - unzip -o geyserconnect.zip GeyserConnect.jar - mv GeyserConnect.jar extensions/GeyserConnect.jar + echo "Download failed or empty. Aborting." + exit 1 fi -java -jar geyser.jar \ No newline at end of file +# Install or update if necessary +if [[ ! -f "$JAR_PATH" ]]; then + echo "No existing Geyser JAR found. Installing..." + mv "$TMP_JAR" "$JAR_PATH" +else + OLD_HASH=$(sha256sum "$JAR_PATH" | awk '{print $1}') + if [[ "$NEW_HASH" != "$OLD_HASH" ]]; then + echo "New version detected. Updating Geyser..." + mv "$TMP_JAR" "$JAR_PATH" + else + echo "Geyser is already up to date." + rm -f "$TMP_JAR" + fi +fi + +echo "Starting Geyser..." +exec java -jar "$JAR_PATH"