Skip to content

Commit

Permalink
fix: Get latest custom server release from github correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
0ffz committed Oct 6, 2024
1 parent 9ca9c0e commit 613079d
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ RUN wget -nv -q -O keepup.zip https://github.com/MineInAbyss/Keepup/releases/dow

FROM itzg/minecraft-server:java21-graalvm as minecraft
LABEL org.opencontainers.image.authors="Offz <[email protected]>"
RUN dnf install -y ansible-core rclone wget unzip jq openssh
RUN dnf install -y ansible-core rclone wget unzip jq openssh attr
COPY --from=helper /keepup /usr/local
ENV\
KEEPUP=true\
Expand Down
26 changes: 21 additions & 5 deletions scripts/dev/download_server
Original file line number Diff line number Diff line change
@@ -1,10 +1,26 @@
#!/bin/sh
set -e

if [ "$CUSTOM_SERVER_URL" ]; then
if [ ! "$CUSTOM_SERVER" ]; then
export CUSTOM_SERVER=server.jar
PREFIX="[Download Server]"
if [ "$CUSTOM_SERVER_REPO" ]; then
[ ! "$CUSTOM_SERVER" ] && export CUSTOM_SERVER=./server.jar

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)

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')\
-q --show-progress -O "$CUSTOM_SERVER"

setfattr -n user.release-date -v "$LATEST_RELEASE_DATE" "$CUSTOM_SERVER"
chmod +x "$CUSTOM_SERVER"
else
echo "$PREFIX Server is up to date"
fi
echo "Checking for server updates from $CUSTOM_SERVER_URL"
wget -N -q --show-progress "$CUSTOM_SERVER_URL" -c --output-document="$CUSTOM_SERVER"
fi

0 comments on commit 613079d

Please sign in to comment.