From d34204a62de39ad725135cb42f77e200baa7369b Mon Sep 17 00:00:00 2001 From: luatan Date: Mon, 29 Jan 2024 19:05:47 +0100 Subject: [PATCH 01/25] add update check script --- scripts/update.sh | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 scripts/update.sh diff --git a/scripts/update.sh b/scripts/update.sh new file mode 100644 index 000000000..b18949baa --- /dev/null +++ b/scripts/update.sh @@ -0,0 +1,24 @@ +#!/bin/bash + +if [ "${UPDATE_ON_BOOT}" = false ]; then + echo "Update on Boot needs to be enabled for auto updating" + exit +fi + +CURRENTBUILD=$(cat /palworld/steamapps/appmanifest_2394010.acf | awk '/buildid/{ print $2 }') +TARGETBUILD=$(curl https://api.steamcmd.net/v1/info/2394010 --silent | grep -P '"public": {"buildid": "\d+"' -o | sed -r 's/.*("[0-9]+")$/\1/') + +if [ "$CURRENTBUILD" != "$TARGETBUILD" ]; then + echo "New Build was found. Updating the server from $CURRENTBUILD to $TARGETBUILD." + if [ "${RCON_ENABLED}" = true ]; then + rm /palworld/steamapps/appmanifest_2394010.acf + rcon-cli -c /home/steam/server/rcon.yaml "broadcast "The_Server_will_update_in_${WARN_MINUTES}_Minutes"" + sleep "${WARN_MINUTES}m" + rcon-cli -c /home/steam/server/rcon.yaml save + rcon-cli -c /home/steam/server/rcon.yaml "shutdown 1" + else + kill -SIGTERM "$(pidof PalServer-Linux-Test)" + fi +else + echo "The Server is up to date!" +fi \ No newline at end of file From 6328abf374c7b93d34d375204fc708a8cfd02065 Mon Sep 17 00:00:00 2001 From: luatan Date: Mon, 29 Jan 2024 19:06:13 +0100 Subject: [PATCH 02/25] add script and created env variables --- Dockerfile | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 21a55e18c..1f9d3fa8c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -42,11 +42,15 @@ ENV PORT= \ TZ=UTC \ SERVER_DESCRIPTION= \ BACKUP_ENABLED=true \ - BACKUP_CRON_EXPRESSION="0 0 * * *" + BACKUP_CRON_EXPRESSION="0 0 * * *" \ + UPDATE_ENABLED=true \ + UPDATE_CRON_EXPRESSION="0 * * * *" \ + WARN_MINUTES=15 COPY ./scripts/* /home/steam/server/ -RUN chmod +x /home/steam/server/init.sh /home/steam/server/start.sh /home/steam/server/backup.sh && \ - mv /home/steam/server/backup.sh /usr/local/bin/backup +RUN chmod +x /home/steam/server/init.sh /home/steam/server/start.sh /home/steam/server/backup.sh /home/steam/server/update.sh && \ + mv /home/steam/server/backup.sh /usr/local/bin/backup && \ + mv /home/steam/server/update.sh /usr/local/bin/update WORKDIR /home/steam/server From bbf89ba3a52cea1c83f4afa43d11ae853ef646e3 Mon Sep 17 00:00:00 2001 From: luatan Date: Mon, 29 Jan 2024 19:06:50 +0100 Subject: [PATCH 03/25] added another cronjob --- scripts/start.sh | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/scripts/start.sh b/scripts/start.sh index 40edf2ff8..4348303b3 100644 --- a/scripts/start.sh +++ b/scripts/start.sh @@ -292,7 +292,15 @@ fi if [ "${BACKUP_ENABLED}" = true ]; then echo "BACKUP_ENABLED=${BACKUP_ENABLED}" - echo "$BACKUP_CRON_EXPRESSION bash /usr/local/bin/backup" > "/home/steam/server/crontab" + echo "$BACKUP_CRON_EXPRESSION bash /usr/local/bin/backup" >> "/home/steam/server/crontab" +fi + +if [ "${UPDATE_ENABLED}" = true ]; then + echo "UPDATE_ENABLED=${UPDATE_ENABLED}" + echo "$UPDATE_CRON_EXPRESSION bash /usr/local/bin/update" >> "/home/steam/server/crontab" +fi + +if [ "${UPDATE_ENABLED}" = true ] || [ "${BACKUP_ENABLED}" = true ]; then supercronic "/home/steam/server/crontab" & fi From bdfacf03499f58eae235054cecf38a16965dc98a Mon Sep 17 00:00:00 2001 From: luatan Date: Mon, 29 Jan 2024 19:05:47 +0100 Subject: [PATCH 04/25] add update check script --- scripts/update.sh | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 scripts/update.sh diff --git a/scripts/update.sh b/scripts/update.sh new file mode 100644 index 000000000..b18949baa --- /dev/null +++ b/scripts/update.sh @@ -0,0 +1,24 @@ +#!/bin/bash + +if [ "${UPDATE_ON_BOOT}" = false ]; then + echo "Update on Boot needs to be enabled for auto updating" + exit +fi + +CURRENTBUILD=$(cat /palworld/steamapps/appmanifest_2394010.acf | awk '/buildid/{ print $2 }') +TARGETBUILD=$(curl https://api.steamcmd.net/v1/info/2394010 --silent | grep -P '"public": {"buildid": "\d+"' -o | sed -r 's/.*("[0-9]+")$/\1/') + +if [ "$CURRENTBUILD" != "$TARGETBUILD" ]; then + echo "New Build was found. Updating the server from $CURRENTBUILD to $TARGETBUILD." + if [ "${RCON_ENABLED}" = true ]; then + rm /palworld/steamapps/appmanifest_2394010.acf + rcon-cli -c /home/steam/server/rcon.yaml "broadcast "The_Server_will_update_in_${WARN_MINUTES}_Minutes"" + sleep "${WARN_MINUTES}m" + rcon-cli -c /home/steam/server/rcon.yaml save + rcon-cli -c /home/steam/server/rcon.yaml "shutdown 1" + else + kill -SIGTERM "$(pidof PalServer-Linux-Test)" + fi +else + echo "The Server is up to date!" +fi \ No newline at end of file From a3736017e5c21579c2c153f46c5fb766267d6563 Mon Sep 17 00:00:00 2001 From: luatan Date: Mon, 29 Jan 2024 19:06:13 +0100 Subject: [PATCH 05/25] add script and created env variables --- Dockerfile | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 21a55e18c..1f9d3fa8c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -42,11 +42,15 @@ ENV PORT= \ TZ=UTC \ SERVER_DESCRIPTION= \ BACKUP_ENABLED=true \ - BACKUP_CRON_EXPRESSION="0 0 * * *" + BACKUP_CRON_EXPRESSION="0 0 * * *" \ + UPDATE_ENABLED=true \ + UPDATE_CRON_EXPRESSION="0 * * * *" \ + WARN_MINUTES=15 COPY ./scripts/* /home/steam/server/ -RUN chmod +x /home/steam/server/init.sh /home/steam/server/start.sh /home/steam/server/backup.sh && \ - mv /home/steam/server/backup.sh /usr/local/bin/backup +RUN chmod +x /home/steam/server/init.sh /home/steam/server/start.sh /home/steam/server/backup.sh /home/steam/server/update.sh && \ + mv /home/steam/server/backup.sh /usr/local/bin/backup && \ + mv /home/steam/server/update.sh /usr/local/bin/update WORKDIR /home/steam/server From 0a9b13e128527e65bdad05f7bc6d5b4c3f65e409 Mon Sep 17 00:00:00 2001 From: luatan Date: Mon, 29 Jan 2024 19:06:50 +0100 Subject: [PATCH 06/25] added another cronjob --- scripts/start.sh | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/scripts/start.sh b/scripts/start.sh index 40edf2ff8..4348303b3 100644 --- a/scripts/start.sh +++ b/scripts/start.sh @@ -292,7 +292,15 @@ fi if [ "${BACKUP_ENABLED}" = true ]; then echo "BACKUP_ENABLED=${BACKUP_ENABLED}" - echo "$BACKUP_CRON_EXPRESSION bash /usr/local/bin/backup" > "/home/steam/server/crontab" + echo "$BACKUP_CRON_EXPRESSION bash /usr/local/bin/backup" >> "/home/steam/server/crontab" +fi + +if [ "${UPDATE_ENABLED}" = true ]; then + echo "UPDATE_ENABLED=${UPDATE_ENABLED}" + echo "$UPDATE_CRON_EXPRESSION bash /usr/local/bin/update" >> "/home/steam/server/crontab" +fi + +if [ "${UPDATE_ENABLED}" = true ] || [ "${BACKUP_ENABLED}" = true ]; then supercronic "/home/steam/server/crontab" & fi From 74959bf57f4137e4c3b3ce39ccc1d7af5f47fa7b Mon Sep 17 00:00:00 2001 From: luatan Date: Mon, 29 Jan 2024 19:24:24 +0100 Subject: [PATCH 07/25] change default value to 30 --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 1f9d3fa8c..4e2c7df2f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -45,7 +45,7 @@ ENV PORT= \ BACKUP_CRON_EXPRESSION="0 0 * * *" \ UPDATE_ENABLED=true \ UPDATE_CRON_EXPRESSION="0 * * * *" \ - WARN_MINUTES=15 + WARN_MINUTES=30 COPY ./scripts/* /home/steam/server/ RUN chmod +x /home/steam/server/init.sh /home/steam/server/start.sh /home/steam/server/backup.sh /home/steam/server/update.sh && \ From a6364d4894e2bfab79cdc436e09fed659041b9cb Mon Sep 17 00:00:00 2001 From: luatan Date: Mon, 29 Jan 2024 19:37:36 +0100 Subject: [PATCH 08/25] default is disabled because real world test is missing --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 4e2c7df2f..c8b4527c9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -43,7 +43,7 @@ ENV PORT= \ SERVER_DESCRIPTION= \ BACKUP_ENABLED=true \ BACKUP_CRON_EXPRESSION="0 0 * * *" \ - UPDATE_ENABLED=true \ + UPDATE_ENABLED=false \ UPDATE_CRON_EXPRESSION="0 * * * *" \ WARN_MINUTES=30 From c3483fedb773abb478db30ec24f1d553546f11ac Mon Sep 17 00:00:00 2001 From: luatan Date: Mon, 29 Jan 2024 20:38:20 +0100 Subject: [PATCH 09/25] added description and env variables --- README.md | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/README.md b/README.md index eb05d26c7..cdde163b4 100644 --- a/README.md +++ b/README.md @@ -177,6 +177,9 @@ It is highly recommended you set the following environment values before startin | BACKUP_ENABLED | Enables automatic backups | true | true/false | | DELETE_OLD_BACKUPS | Delete backups after a certain number of days | false | true/false | | OLD_BACKUP_DAYS | How many days to keep backups | 30 | any positive integer | +| UPDATE_CRON_EXPRESSION | Setting affects frequency of automatic updates. | 0 0 \* \* \* | Needs a Cron-Expression - See [Configuring Automatic Backups with Cron](#configuring-automatic-backups-with-cron) | +| UPDATE_ENABLED | Enables automatic updates | true | true/false | +| WARN_MINUTES | How long to wait to update the server, after the player were informed. | 30 | !0 | *highly recommended to set @@ -260,6 +263,24 @@ BACKUP_CRON_EXPRESSION is a cron expression, in a Cron-Expression you define an Set BACKUP_CRON_EXPRESSION to change the default schedule. Example Usage: If BACKUP_CRON_EXPRESSION to `0 2 * * *`, the backup script will run every day at 2:00 AM. +## Configuring Automatic Updates with Cron + +To be able to use automatic Updates with this Server the following environment variables **have** to be set to `true`: +* RCON_ENABLED +* UPDATE_ON_BOOT + +Set UPDATE_ENABLED enable or disable automatic backups (Default is disabled) + +UPDATE_CRON_EXPRESSION is a cron expression, in a Cron-Expression you define an interval for when to run jobs. + +> [!TIP] +> This image uses Supercronic for crons +> see [supercronic](https://github.com/aptible/supercronic#crontab-format) +> or +> [Crontab Generat](https://crontab-generator.org). + +Set UPDATE_CRON_EXPRESSION to change the default schedule. + ## Editing Server Settings ### With Environment Variables From 8715740ed96d77b28b1d6d4b9a1dfa3c0df4e5eb Mon Sep 17 00:00:00 2001 From: luatan Date: Mon, 29 Jan 2024 21:29:14 +0100 Subject: [PATCH 10/25] fix linting --- scripts/update.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/update.sh b/scripts/update.sh index b18949baa..b68731029 100644 --- a/scripts/update.sh +++ b/scripts/update.sh @@ -2,17 +2,17 @@ if [ "${UPDATE_ON_BOOT}" = false ]; then echo "Update on Boot needs to be enabled for auto updating" - exit + exit 1 fi -CURRENTBUILD=$(cat /palworld/steamapps/appmanifest_2394010.acf | awk '/buildid/{ print $2 }') +CURRENTBUILD=$(awk '/buildid/{ print $2 }' < palworld/steamapps/appmanifest_2394010.acf) TARGETBUILD=$(curl https://api.steamcmd.net/v1/info/2394010 --silent | grep -P '"public": {"buildid": "\d+"' -o | sed -r 's/.*("[0-9]+")$/\1/') if [ "$CURRENTBUILD" != "$TARGETBUILD" ]; then echo "New Build was found. Updating the server from $CURRENTBUILD to $TARGETBUILD." if [ "${RCON_ENABLED}" = true ]; then rm /palworld/steamapps/appmanifest_2394010.acf - rcon-cli -c /home/steam/server/rcon.yaml "broadcast "The_Server_will_update_in_${WARN_MINUTES}_Minutes"" + rcon-cli -c /home/steam/server/rcon.yaml "broadcast The_Server_will_update_in_${WARN_MINUTES}_Minutes" sleep "${WARN_MINUTES}m" rcon-cli -c /home/steam/server/rcon.yaml save rcon-cli -c /home/steam/server/rcon.yaml "shutdown 1" From 411fa4ecf6bd73ef5aeecc2b2151675e71edbd26 Mon Sep 17 00:00:00 2001 From: Luatan <74045606+Luatan@users.noreply.github.com> Date: Mon, 29 Jan 2024 22:50:05 +0100 Subject: [PATCH 11/25] Apply suggestions from code review Co-authored-by: Carlos Martinez --- README.md | 1 + scripts/start.sh | 4 ++-- scripts/update.sh | 4 ++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index cdde163b4..00b51cb27 100644 --- a/README.md +++ b/README.md @@ -266,6 +266,7 @@ Example Usage: If BACKUP_CRON_EXPRESSION to `0 2 * * *`, the backup script will ## Configuring Automatic Updates with Cron To be able to use automatic Updates with this Server the following environment variables **have** to be set to `true`: + * RCON_ENABLED * UPDATE_ON_BOOT diff --git a/scripts/start.sh b/scripts/start.sh index 4348303b3..7182c020c 100644 --- a/scripts/start.sh +++ b/scripts/start.sh @@ -295,12 +295,12 @@ if [ "${BACKUP_ENABLED}" = true ]; then echo "$BACKUP_CRON_EXPRESSION bash /usr/local/bin/backup" >> "/home/steam/server/crontab" fi -if [ "${UPDATE_ENABLED}" = true ]; then +if [ "${UPDATE_ENABLED}" = true ] && [ "${UPDATE_ON_BOOT}" = "true" ]; then echo "UPDATE_ENABLED=${UPDATE_ENABLED}" echo "$UPDATE_CRON_EXPRESSION bash /usr/local/bin/update" >> "/home/steam/server/crontab" fi -if [ "${UPDATE_ENABLED}" = true ] || [ "${BACKUP_ENABLED}" = true ]; then +if ([ "${UPDATE_ENABLED}" = true ] && [ "${UPDATE_ON_BOOT}" = "true" ]) || "${BACKUP_ENABLED}" = true ]; then supercronic "/home/steam/server/crontab" & fi diff --git a/scripts/update.sh b/scripts/update.sh index b68731029..c96e041fc 100644 --- a/scripts/update.sh +++ b/scripts/update.sh @@ -14,10 +14,10 @@ if [ "$CURRENTBUILD" != "$TARGETBUILD" ]; then rm /palworld/steamapps/appmanifest_2394010.acf rcon-cli -c /home/steam/server/rcon.yaml "broadcast The_Server_will_update_in_${WARN_MINUTES}_Minutes" sleep "${WARN_MINUTES}m" - rcon-cli -c /home/steam/server/rcon.yaml save + backup rcon-cli -c /home/steam/server/rcon.yaml "shutdown 1" else - kill -SIGTERM "$(pidof PalServer-Linux-Test)" + echo "An update is available however auto updating without rcon is not supported" fi else echo "The Server is up to date!" From 169135752cc55b2a93c97fcad55be5ec643e9bbf Mon Sep 17 00:00:00 2001 From: luatan Date: Mon, 29 Jan 2024 23:26:14 +0100 Subject: [PATCH 12/25] changed env variables --- Dockerfile | 6 +++--- scripts/start.sh | 6 +++--- scripts/update.sh | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Dockerfile b/Dockerfile index c8b4527c9..acaf6c779 100644 --- a/Dockerfile +++ b/Dockerfile @@ -43,9 +43,9 @@ ENV PORT= \ SERVER_DESCRIPTION= \ BACKUP_ENABLED=true \ BACKUP_CRON_EXPRESSION="0 0 * * *" \ - UPDATE_ENABLED=false \ - UPDATE_CRON_EXPRESSION="0 * * * *" \ - WARN_MINUTES=30 + AUTO_UPDATE_ENABLED=false \ + AUTO_UPDATE_CRON_EXPRESSION="0 * * * *" \ + AUTO_UPDATE_WARN_MINUTES=30 COPY ./scripts/* /home/steam/server/ RUN chmod +x /home/steam/server/init.sh /home/steam/server/start.sh /home/steam/server/backup.sh /home/steam/server/update.sh && \ diff --git a/scripts/start.sh b/scripts/start.sh index 7182c020c..c8209cfb8 100644 --- a/scripts/start.sh +++ b/scripts/start.sh @@ -295,12 +295,12 @@ if [ "${BACKUP_ENABLED}" = true ]; then echo "$BACKUP_CRON_EXPRESSION bash /usr/local/bin/backup" >> "/home/steam/server/crontab" fi -if [ "${UPDATE_ENABLED}" = true ] && [ "${UPDATE_ON_BOOT}" = "true" ]; then - echo "UPDATE_ENABLED=${UPDATE_ENABLED}" +if [ "${AUTO_UPDATE_ENABLED}" = true ] && [ "${UPDATE_ON_BOOT}" = "true" ]; then + echo "UPDATE_ENABLED=${AUTO_UPDATE_ENABLED}" echo "$UPDATE_CRON_EXPRESSION bash /usr/local/bin/update" >> "/home/steam/server/crontab" fi -if ([ "${UPDATE_ENABLED}" = true ] && [ "${UPDATE_ON_BOOT}" = "true" ]) || "${BACKUP_ENABLED}" = true ]; then +if ([ "${AUTO_UPDATE_ENABLED}" = true ] && [ "${UPDATE_ON_BOOT}" = "true" ]) || "${BACKUP_ENABLED}" = true ]; then supercronic "/home/steam/server/crontab" & fi diff --git a/scripts/update.sh b/scripts/update.sh index c96e041fc..dd4307183 100644 --- a/scripts/update.sh +++ b/scripts/update.sh @@ -12,8 +12,8 @@ if [ "$CURRENTBUILD" != "$TARGETBUILD" ]; then echo "New Build was found. Updating the server from $CURRENTBUILD to $TARGETBUILD." if [ "${RCON_ENABLED}" = true ]; then rm /palworld/steamapps/appmanifest_2394010.acf - rcon-cli -c /home/steam/server/rcon.yaml "broadcast The_Server_will_update_in_${WARN_MINUTES}_Minutes" - sleep "${WARN_MINUTES}m" + rcon-cli -c /home/steam/server/rcon.yaml "broadcast The_Server_will_update_in_${AUTO_UPDATE_WARN_MINUTES}_Minutes" + sleep "${AUTO_UPDATE_WARN_MINUTES}m" backup rcon-cli -c /home/steam/server/rcon.yaml "shutdown 1" else From 8ec566dc87eff434571d76426dc65b6ca1cefe66 Mon Sep 17 00:00:00 2001 From: luatan Date: Mon, 29 Jan 2024 23:33:17 +0100 Subject: [PATCH 13/25] clarification about restarting the container --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 00b51cb27..840e8d938 100644 --- a/README.md +++ b/README.md @@ -270,6 +270,8 @@ To be able to use automatic Updates with this Server the following environment v * RCON_ENABLED * UPDATE_ON_BOOT +you will also need to use the restart policy `always` or `unless-stopped`. The example docker run command and docker compose file in [How to Use](#how-to-use) already use the needed policy + Set UPDATE_ENABLED enable or disable automatic backups (Default is disabled) UPDATE_CRON_EXPRESSION is a cron expression, in a Cron-Expression you define an interval for when to run jobs. From 56a74864de8e57df17e5a9761f57e7f9f652bdb8 Mon Sep 17 00:00:00 2001 From: Luatan <74045606+Luatan@users.noreply.github.com> Date: Mon, 29 Jan 2024 23:39:21 +0100 Subject: [PATCH 14/25] Update scripts/update.sh Co-authored-by: Carlos Martinez --- scripts/update.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/update.sh b/scripts/update.sh index dd4307183..2ba80515e 100644 --- a/scripts/update.sh +++ b/scripts/update.sh @@ -5,7 +5,7 @@ if [ "${UPDATE_ON_BOOT}" = false ]; then exit 1 fi -CURRENTBUILD=$(awk '/buildid/{ print $2 }' < palworld/steamapps/appmanifest_2394010.acf) +CURRENTBUILD=$(awk '/buildid/{ print $2 }' < /palworld/steamapps/appmanifest_2394010.acf) TARGETBUILD=$(curl https://api.steamcmd.net/v1/info/2394010 --silent | grep -P '"public": {"buildid": "\d+"' -o | sed -r 's/.*("[0-9]+")$/\1/') if [ "$CURRENTBUILD" != "$TARGETBUILD" ]; then From 4d6a5b5223f5b945985d0f8e4588f03e3fb8660e Mon Sep 17 00:00:00 2001 From: luatan Date: Mon, 29 Jan 2024 23:52:14 +0100 Subject: [PATCH 15/25] remove crontab on every restart and fixed env var --- scripts/start.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/scripts/start.sh b/scripts/start.sh index c8209cfb8..bf73192b5 100644 --- a/scripts/start.sh +++ b/scripts/start.sh @@ -289,6 +289,7 @@ if [ -n "${RCON_PORT}" ]; then sed -i "s/RCONPort=[0-9]*/RCONPort=$RCON_PORT/" /palworld/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini fi +rm -f "/home/steam/server/crontab" if [ "${BACKUP_ENABLED}" = true ]; then echo "BACKUP_ENABLED=${BACKUP_ENABLED}" @@ -296,8 +297,8 @@ if [ "${BACKUP_ENABLED}" = true ]; then fi if [ "${AUTO_UPDATE_ENABLED}" = true ] && [ "${UPDATE_ON_BOOT}" = "true" ]; then - echo "UPDATE_ENABLED=${AUTO_UPDATE_ENABLED}" - echo "$UPDATE_CRON_EXPRESSION bash /usr/local/bin/update" >> "/home/steam/server/crontab" + echo "AUTO_UPDATE_ENABLED=${AUTO_UPDATE_ENABLED}" + echo "$AUTO_UPDATE_CRON_EXPRESSION bash /usr/local/bin/update" >> "/home/steam/server/crontab" fi if ([ "${AUTO_UPDATE_ENABLED}" = true ] && [ "${UPDATE_ON_BOOT}" = "true" ]) || "${BACKUP_ENABLED}" = true ]; then From 71d7107e68f36f4d077dfe4f856dd311ca599b72 Mon Sep 17 00:00:00 2001 From: Luatan <74045606+Luatan@users.noreply.github.com> Date: Mon, 29 Jan 2024 23:58:40 +0100 Subject: [PATCH 16/25] do not update if Targetbuild is empty Co-authored-by: Carlos Martinez --- scripts/update.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/update.sh b/scripts/update.sh index 2ba80515e..58dfae605 100644 --- a/scripts/update.sh +++ b/scripts/update.sh @@ -8,7 +8,7 @@ fi CURRENTBUILD=$(awk '/buildid/{ print $2 }' < /palworld/steamapps/appmanifest_2394010.acf) TARGETBUILD=$(curl https://api.steamcmd.net/v1/info/2394010 --silent | grep -P '"public": {"buildid": "\d+"' -o | sed -r 's/.*("[0-9]+")$/\1/') -if [ "$CURRENTBUILD" != "$TARGETBUILD" ]; then +if [ -n "$TARGETBUILD" ] && [ "$CURRENTBUILD" != "$TARGETBUILD" ]; then echo "New Build was found. Updating the server from $CURRENTBUILD to $TARGETBUILD." if [ "${RCON_ENABLED}" = true ]; then rm /palworld/steamapps/appmanifest_2394010.acf From c12cc6776e6f7ecc3281fe9e35aedabcb13d6032 Mon Sep 17 00:00:00 2001 From: luatan Date: Tue, 30 Jan 2024 00:00:25 +0100 Subject: [PATCH 17/25] update environment variables in docs --- README.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 840e8d938..e88c0f88f 100644 --- a/README.md +++ b/README.md @@ -177,9 +177,9 @@ It is highly recommended you set the following environment values before startin | BACKUP_ENABLED | Enables automatic backups | true | true/false | | DELETE_OLD_BACKUPS | Delete backups after a certain number of days | false | true/false | | OLD_BACKUP_DAYS | How many days to keep backups | 30 | any positive integer | -| UPDATE_CRON_EXPRESSION | Setting affects frequency of automatic updates. | 0 0 \* \* \* | Needs a Cron-Expression - See [Configuring Automatic Backups with Cron](#configuring-automatic-backups-with-cron) | -| UPDATE_ENABLED | Enables automatic updates | true | true/false | -| WARN_MINUTES | How long to wait to update the server, after the player were informed. | 30 | !0 | +| AUTO_UPDATE_CRON_EXPRESSION | Setting affects frequency of automatic updates. | 0 0 \* \* \* | Needs a Cron-Expression - See [Configuring Automatic Backups with Cron](#configuring-automatic-backups-with-cron) | +| AUTO_UPDATE_ENABLED | Enables automatic updates | true | true/false | +| AUTO_UPDATE_WARN_MINUTES | How long to wait to update the server, after the player were informed. | 30 | !0 | *highly recommended to set @@ -272,9 +272,9 @@ To be able to use automatic Updates with this Server the following environment v you will also need to use the restart policy `always` or `unless-stopped`. The example docker run command and docker compose file in [How to Use](#how-to-use) already use the needed policy -Set UPDATE_ENABLED enable or disable automatic backups (Default is disabled) +Set AUTO_UPDATE_ENABLED enable or disable automatic backups (Default is disabled) -UPDATE_CRON_EXPRESSION is a cron expression, in a Cron-Expression you define an interval for when to run jobs. +AUTO_UPDATE_CRON_EXPRESSION is a cron expression, in a Cron-Expression you define an interval for when to run jobs. > [!TIP] > This image uses Supercronic for crons @@ -282,7 +282,7 @@ UPDATE_CRON_EXPRESSION is a cron expression, in a Cron-Expression you define an > or > [Crontab Generat](https://crontab-generator.org). -Set UPDATE_CRON_EXPRESSION to change the default schedule. +Set AUTO_UPDATE_CRON_EXPRESSION to change the default schedule. ## Editing Server Settings From 90a71776d7d5ede5282ebfca2744aec740a18bbf Mon Sep 17 00:00:00 2001 From: Luatan <74045606+Luatan@users.noreply.github.com> Date: Tue, 30 Jan 2024 00:04:24 +0100 Subject: [PATCH 18/25] Update README.md Co-authored-by: Carlos Martinez --- README.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index e88c0f88f..724d262b9 100644 --- a/README.md +++ b/README.md @@ -270,7 +270,12 @@ To be able to use automatic Updates with this Server the following environment v * RCON_ENABLED * UPDATE_ON_BOOT -you will also need to use the restart policy `always` or `unless-stopped`. The example docker run command and docker compose file in [How to Use](#how-to-use) already use the needed policy +> [!IMPORTANT] +> +> If docker restart is not set to policy `always` or `unless-stopped` then the server will shutdown and will need to be +> manually restarted. +> +> The example docker run command and docker compose file in [How to Use](#how-to-use) already use the needed policy Set AUTO_UPDATE_ENABLED enable or disable automatic backups (Default is disabled) From 582a71563a1f26db3e8216b573b268e7dfe796af Mon Sep 17 00:00:00 2001 From: Luatan <74045606+Luatan@users.noreply.github.com> Date: Tue, 30 Jan 2024 00:26:15 +0100 Subject: [PATCH 19/25] Remove extra spaces Co-authored-by: Carlos Martinez --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 724d262b9..106526949 100644 --- a/README.md +++ b/README.md @@ -271,10 +271,10 @@ To be able to use automatic Updates with this Server the following environment v * UPDATE_ON_BOOT > [!IMPORTANT] -> +> > If docker restart is not set to policy `always` or `unless-stopped` then the server will shutdown and will need to be -> manually restarted. -> +> manually restarted. +> > The example docker run command and docker compose file in [How to Use](#how-to-use) already use the needed policy Set AUTO_UPDATE_ENABLED enable or disable automatic backups (Default is disabled) From b73dabf9aaee3c42a995522d3e84ec902fc41f2c Mon Sep 17 00:00:00 2001 From: Luatan <74045606+Luatan@users.noreply.github.com> Date: Tue, 30 Jan 2024 00:33:40 +0100 Subject: [PATCH 20/25] Set the default value to false in Readme.md Co-authored-by: Carlos Martinez --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 106526949..5f362f9ac 100644 --- a/README.md +++ b/README.md @@ -178,7 +178,7 @@ It is highly recommended you set the following environment values before startin | DELETE_OLD_BACKUPS | Delete backups after a certain number of days | false | true/false | | OLD_BACKUP_DAYS | How many days to keep backups | 30 | any positive integer | | AUTO_UPDATE_CRON_EXPRESSION | Setting affects frequency of automatic updates. | 0 0 \* \* \* | Needs a Cron-Expression - See [Configuring Automatic Backups with Cron](#configuring-automatic-backups-with-cron) | -| AUTO_UPDATE_ENABLED | Enables automatic updates | true | true/false | +| AUTO_UPDATE_ENABLED | Enables automatic updates | false | true/false | | AUTO_UPDATE_WARN_MINUTES | How long to wait to update the server, after the player were informed. | 30 | !0 | *highly recommended to set From b72faba224f8455e7aa710a069b5db9904056f17 Mon Sep 17 00:00:00 2001 From: Luatan <74045606+Luatan@users.noreply.github.com> Date: Tue, 30 Jan 2024 00:36:02 +0100 Subject: [PATCH 21/25] Removed quotes from UPDATE_ON_BOOT check --- scripts/start.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/start.sh b/scripts/start.sh index bf73192b5..512e690fd 100644 --- a/scripts/start.sh +++ b/scripts/start.sh @@ -296,12 +296,12 @@ if [ "${BACKUP_ENABLED}" = true ]; then echo "$BACKUP_CRON_EXPRESSION bash /usr/local/bin/backup" >> "/home/steam/server/crontab" fi -if [ "${AUTO_UPDATE_ENABLED}" = true ] && [ "${UPDATE_ON_BOOT}" = "true" ]; then +if [ "${AUTO_UPDATE_ENABLED}" = true ] && [ "${UPDATE_ON_BOOT}" = true ]; then echo "AUTO_UPDATE_ENABLED=${AUTO_UPDATE_ENABLED}" echo "$AUTO_UPDATE_CRON_EXPRESSION bash /usr/local/bin/update" >> "/home/steam/server/crontab" fi -if ([ "${AUTO_UPDATE_ENABLED}" = true ] && [ "${UPDATE_ON_BOOT}" = "true" ]) || "${BACKUP_ENABLED}" = true ]; then +if ([ "${AUTO_UPDATE_ENABLED}" = true ] && [ "${UPDATE_ON_BOOT}" = true ]) || "${BACKUP_ENABLED}" = true ]; then supercronic "/home/steam/server/crontab" & fi From 9ec6350ac96da18b2ebb9aeacd2e5d81e2ed50fe Mon Sep 17 00:00:00 2001 From: luatan Date: Tue, 30 Jan 2024 08:12:12 +0100 Subject: [PATCH 22/25] changed AUTO_UPDATE_CRON_EXPRESSION default value to hourly --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 724d262b9..35ca7ea30 100644 --- a/README.md +++ b/README.md @@ -177,7 +177,7 @@ It is highly recommended you set the following environment values before startin | BACKUP_ENABLED | Enables automatic backups | true | true/false | | DELETE_OLD_BACKUPS | Delete backups after a certain number of days | false | true/false | | OLD_BACKUP_DAYS | How many days to keep backups | 30 | any positive integer | -| AUTO_UPDATE_CRON_EXPRESSION | Setting affects frequency of automatic updates. | 0 0 \* \* \* | Needs a Cron-Expression - See [Configuring Automatic Backups with Cron](#configuring-automatic-backups-with-cron) | +| AUTO_UPDATE_CRON_EXPRESSION | Setting affects frequency of automatic updates. | 0 \* \* \* \* | Needs a Cron-Expression - See [Configuring Automatic Backups with Cron](#configuring-automatic-backups-with-cron) | | AUTO_UPDATE_ENABLED | Enables automatic updates | true | true/false | | AUTO_UPDATE_WARN_MINUTES | How long to wait to update the server, after the player were informed. | 30 | !0 | From 4fb73aabba52d43de6f8446f327f88e19d0b89c6 Mon Sep 17 00:00:00 2001 From: luatan Date: Tue, 30 Jan 2024 10:00:13 +0100 Subject: [PATCH 23/25] check server response and react accordingly --- scripts/update.sh | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/scripts/update.sh b/scripts/update.sh index 58dfae605..3c33aa868 100644 --- a/scripts/update.sh +++ b/scripts/update.sh @@ -2,13 +2,27 @@ if [ "${UPDATE_ON_BOOT}" = false ]; then echo "Update on Boot needs to be enabled for auto updating" - exit 1 + exit 0 fi +temp_file=$(mktemp) +http_code=$(curl https://api.steamcmd.net/v1/info/2394010 --output $temp_file --silent --location --write-out "%{http_code}") + CURRENTBUILD=$(awk '/buildid/{ print $2 }' < /palworld/steamapps/appmanifest_2394010.acf) -TARGETBUILD=$(curl https://api.steamcmd.net/v1/info/2394010 --silent | grep -P '"public": {"buildid": "\d+"' -o | sed -r 's/.*("[0-9]+")$/\1/') +TARGETBUILD=$(grep -P '"public": {"buildid": "\d+"' -o <"$temp_file" | sed -r 's/.*("[0-9]+")$/\1/') +rm $temp_file + +if [ "$http_code" -ne 200 ]; then + echo "There was a problem reaching the Steam api. Unable to check for updates!" + exit 1 +fi + +if [ -z "$TARGETBUILD" ]; then + echo "The server response does not contain the expected BuildID. Unable to check for updates!" + exit 1 +fi -if [ -n "$TARGETBUILD" ] && [ "$CURRENTBUILD" != "$TARGETBUILD" ]; then +if [ "$CURRENTBUILD" != "$TARGETBUILD" ]; then echo "New Build was found. Updating the server from $CURRENTBUILD to $TARGETBUILD." if [ "${RCON_ENABLED}" = true ]; then rm /palworld/steamapps/appmanifest_2394010.acf From 4d222b1f2744e1854252d1285e87b2c8bdd92f19 Mon Sep 17 00:00:00 2001 From: Luatan <74045606+Luatan@users.noreply.github.com> Date: Tue, 30 Jan 2024 22:36:39 +0100 Subject: [PATCH 24/25] Add missing bracket --- scripts/start.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/start.sh b/scripts/start.sh index 512e690fd..c9d8bc010 100644 --- a/scripts/start.sh +++ b/scripts/start.sh @@ -301,7 +301,7 @@ if [ "${AUTO_UPDATE_ENABLED}" = true ] && [ "${UPDATE_ON_BOOT}" = true ]; then echo "$AUTO_UPDATE_CRON_EXPRESSION bash /usr/local/bin/update" >> "/home/steam/server/crontab" fi -if ([ "${AUTO_UPDATE_ENABLED}" = true ] && [ "${UPDATE_ON_BOOT}" = true ]) || "${BACKUP_ENABLED}" = true ]; then +if ([ "${AUTO_UPDATE_ENABLED}" = true ] && [ "${UPDATE_ON_BOOT}" = true ]) || [ "${BACKUP_ENABLED}" = true ]; then supercronic "/home/steam/server/crontab" & fi From 9ed95d3eb48d6c87e6783af0628695218cc5832a Mon Sep 17 00:00:00 2001 From: Thijs van Loef Date: Wed, 31 Jan 2024 12:58:29 +0100 Subject: [PATCH 25/25] fix linting --- scripts/start.sh | 2 +- scripts/update.sh | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/start.sh b/scripts/start.sh index c9d8bc010..5ef45017a 100644 --- a/scripts/start.sh +++ b/scripts/start.sh @@ -301,7 +301,7 @@ if [ "${AUTO_UPDATE_ENABLED}" = true ] && [ "${UPDATE_ON_BOOT}" = true ]; then echo "$AUTO_UPDATE_CRON_EXPRESSION bash /usr/local/bin/update" >> "/home/steam/server/crontab" fi -if ([ "${AUTO_UPDATE_ENABLED}" = true ] && [ "${UPDATE_ON_BOOT}" = true ]) || [ "${BACKUP_ENABLED}" = true ]; then +if { [ "${AUTO_UPDATE_ENABLED}" = true ] && [ "${UPDATE_ON_BOOT}" = true ]; } || [ "${BACKUP_ENABLED}" = true ]; then supercronic "/home/steam/server/crontab" & fi diff --git a/scripts/update.sh b/scripts/update.sh index 3c33aa868..c523c4c71 100644 --- a/scripts/update.sh +++ b/scripts/update.sh @@ -6,11 +6,11 @@ if [ "${UPDATE_ON_BOOT}" = false ]; then fi temp_file=$(mktemp) -http_code=$(curl https://api.steamcmd.net/v1/info/2394010 --output $temp_file --silent --location --write-out "%{http_code}") +http_code=$(curl https://api.steamcmd.net/v1/info/2394010 --output "$temp_file" --silent --location --write-out "%{http_code}") CURRENTBUILD=$(awk '/buildid/{ print $2 }' < /palworld/steamapps/appmanifest_2394010.acf) TARGETBUILD=$(grep -P '"public": {"buildid": "\d+"' -o <"$temp_file" | sed -r 's/.*("[0-9]+")$/\1/') -rm $temp_file +rm "$temp_file" if [ "$http_code" -ne 200 ]; then echo "There was a problem reaching the Steam api. Unable to check for updates!"