diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index c5f9eff0..1334f78f 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -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 }} diff --git a/Dockerfile b/Dockerfile index cbea3cfa..c70afa33 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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/* @@ -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 && \ @@ -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 && \ diff --git a/scripts/helper_functions.sh b/scripts/helper_functions.sh index 7a7c92a9..c0a6ce42 100644 --- a/scripts/helper_functions.sh +++ b/scripts/helper_functions.sh @@ -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" +} \ No newline at end of file diff --git a/scripts/helper_install.sh b/scripts/helper_install.sh index 1f0a826c..19021bb5 100644 --- a/scripts/helper_install.sh +++ b/scripts/helper_install.sh @@ -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 @@ -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 diff --git a/scripts/start.sh b/scripts/start.sh index a747ad76..4025bb76 100644 --- a/scripts/start.sh +++ b/scripts/start.sh @@ -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!" @@ -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"