Skip to content

Commit

Permalink
Merge pull request #513 from loef-dev/main
Browse files Browse the repository at this point in the history
Add Container version checking
  • Loading branch information
thijsvanloef committed Mar 29, 2024
2 parents 540e07b + 7a22482 commit d18d03c
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,5 @@ jobs:
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta.outputs.tags }}
build-args: |
GIT_VERSION_TAG=${{ github.event.release.tag_name }}
8 changes: 8 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
gettext-base=0.21-12 \
xdg-user-dirs=0.18-1 \
jo=1.9-1 \
jq=1.6-2.1 \
netcat-traditional=1.10-47 \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
Expand Down Expand Up @@ -145,6 +146,9 @@ ENV HOME=/home/steam \
ARM_COMPATIBILITY_MODE=false \
DISABLE_GENERATE_ENGINE=true

# Passed from Github Actions
ARG GIT_VERSION_TAG=unspecified

COPY ./scripts /home/steam/server/

RUN chmod +x /home/steam/server/*.sh && \
Expand All @@ -153,6 +157,10 @@ RUN chmod +x /home/steam/server/*.sh && \
mv /home/steam/server/restore.sh /usr/local/bin/restore

WORKDIR /home/steam/server

# Make GIT_VERSION_TAG file to be able to check the version
RUN echo $GIT_VERSION_TAG > GIT_VERSION_TAG

RUN touch rcon.yaml crontab && \
mkdir -p /home/steam/Steam/package && \
chown steam:steam /home/steam/Steam/package && \
Expand Down
25 changes: 25 additions & 0 deletions scripts/helper_functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -259,3 +259,28 @@ countdown_message() {
fi
return "$return_val"
}

container_version_check() {
local current_version
local latest_version

current_version=$(cat /home/steam/server/GIT_VERSION_TAG)
latest_version=$(get_latest_version)

if [ "${current_version}" != "${latest_version}" ]; then
LogWarn "New version available: ${latest_version}"
LogWarn "Learn how to update the container: https://palworld-server-docker.loef.dev/guides/update-the-container"
else
LogSuccess "The container is up to date!"

fi
}
# Get latest release version from thijsvanloef/palworld-server-docker repository
# Returns the latest release version
get_latest_version() {
local latest_version

latest_version=$(curl https://api.github.com/repos/thijsvanloef/palworld-server-docker/releases/latest -s | jq .name -r)

echo "$latest_version"
}
4 changes: 2 additions & 2 deletions scripts/helper_install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ EOL
# Returns 1 if Update NOT Required
# Returns 2 if Check Failed
UpdateRequired() {
LogAction "Checking for new update"
LogAction "Checking for new Palworld Server updates"

#define local variables
local CURRENT_MANIFEST LATEST_MANIFEST temp_file http_code updateAvailable
Expand Down Expand Up @@ -102,7 +102,7 @@ UpdateRequired() {

# Warn if version is locked
if [ "$updateAvailable" == false ]; then
LogSuccess "The Server is up to date!"
LogSuccess "The server is up to date!"
return 1
fi

Expand Down
5 changes: 5 additions & 0 deletions scripts/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,9 @@ if [ "${TARGET_MANIFEST_ID}" == "3750364703337203431" ] && [ "${RCON_ENABLED,,}"
STARTCOMMAND+=("-rcon")
fi

LogAction "Checking for available container updates"
container_version_check

if [ "${DISABLE_GENERATE_SETTINGS,,}" = true ]; then
LogAction "GENERATING CONFIG"
LogWarn "Env vars will not be applied due to DISABLE_GENERATE_SETTINGS being set to TRUE!"
Expand Down Expand Up @@ -130,8 +133,10 @@ fi
if [ "${DISABLE_GENERATE_ENGINE,,}" = false ]; then
/home/steam/server/compile-engine.sh || exit
fi

LogAction "GENERATING CRONTAB"
truncate -s 0 "/home/steam/server/crontab"

if [ "${BACKUP_ENABLED,,}" = true ]; then
LogInfo "BACKUP_ENABLED=${BACKUP_ENABLED,,}"
LogInfo "Adding cronjob for auto backups"
Expand Down

0 comments on commit d18d03c

Please sign in to comment.