From d555aac4f471a8f25a1f441c3cf93e34ef3a1a85 Mon Sep 17 00:00:00 2001 From: Danielle Voznyy Date: Sat, 12 Oct 2024 16:08:11 -0400 Subject: [PATCH] feat: Add CUSTOM_SERVER_TAG variable to download versions other than LATEST --- scripts/dev/download_server | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/scripts/dev/download_server b/scripts/dev/download_server index 9406250..4f6c7e8 100644 --- a/scripts/dev/download_server +++ b/scripts/dev/download_server @@ -4,18 +4,20 @@ set -e PREFIX="[Init]" if [ "$CUSTOM_SERVER_REPO" ]; then [ ! "$CUSTOM_SERVER" ] && export CUSTOM_SERVER=./server.jar + [ ! "$CUSTOM_SERVER_TAG" ] && export CUSTOM_SERVER_TAG=latest echo "$PREFIX Checking for server updates from $CUSTOM_SERVER_REPO" - export LATEST_RELEASE_DATE=$(curl -s "https://api.github.com/repos/$CUSTOM_SERVER_REPO/releases/latest" | jq -r '.published_at' 2>/dev/null) - export CURRENT_RELEASE_DATE=$(getfattr --only-values -n user.release-date "$CUSTOM_SERVER" 2>/dev/null) + GITHUB_API = "https://api.github.com/repos/$CUSTOM_SERVER_REPO/releases/$CUSTOM_SERVER_TAG" + LATEST_RELEASE_DATE=$(curl -s "$GITHUB_API" | jq -r '.published_at' 2>/dev/null) + CURRENT_RELEASE_DATE=$(getfattr --only-values -n user.release-date "$CUSTOM_SERVER" 2>/dev/null) echo "$PREFIX Latest release date: $LATEST_RELEASE_DATE" echo "$PREFIX Current release date: $CURRENT_RELEASE_DATE" if [ "$LATEST_RELEASE_DATE" != "$CURRENT_RELEASE_DATE" ]; then echo "$PREFIX Downloading new release, release date: $LATEST_RELEASE_DATE" - wget $(curl -s https://api.github.com/repos/$CUSTOM_SERVER_REPO/releases/latest | jq -r '.assets[] | select(.name | contains ("jar")) | .browser_download_url')\ + wget $(curl -s "$GITHUB_API" | jq -r '.assets[] | select(.name | contains ("jar")) | .browser_download_url')\ -q --show-progress -O "$CUSTOM_SERVER" setfattr -n user.release-date -v "$LATEST_RELEASE_DATE" "$CUSTOM_SERVER"