Skip to content

Commit

Permalink
feat: Add CUSTOM_SERVER_TAG variable to download versions other than …
Browse files Browse the repository at this point in the history
…LATEST
  • Loading branch information
0ffz committed Oct 12, 2024
1 parent 1272132 commit d555aac
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions scripts/dev/download_server
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit d555aac

Please sign in to comment.