From 7e5b1a656a03a6dea7737bdb27ffcfaab1522839 Mon Sep 17 00:00:00 2001 From: "Carlos M. Martinez" Date: Wed, 24 Jan 2024 18:25:12 -0500 Subject: [PATCH 1/7] Added graceful shutdown using rcon --- scripts/init.sh | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/scripts/init.sh b/scripts/init.sh index f1b5bf2..6174c44 100644 --- a/scripts/init.sh +++ b/scripts/init.sh @@ -17,4 +17,20 @@ if [ "${UPDATE_ON_BOOT}" = true ]; then su steam -c '/home/steam/steamcmd/steamcmd.sh +force_install_dir "/palworld" +login anonymous +app_update 2394010 validate +quit' fi -./start.sh +term_handler() { + rcon-cli shutdown 1 + while true + do + rcon-cli info + if [ $? -ne 0 ]; then + break + fi + sleep 1 + done +} + +trap 'term_handler' SIGTERM + +./start.sh & +killpid="$!" +wait $killpid From 38f42551c8bba6a7533e4519564aa60a9675e1f5 Mon Sep 17 00:00:00 2001 From: "Carlos M. Martinez" Date: Wed, 24 Jan 2024 18:44:15 -0500 Subject: [PATCH 2/7] Added shutdown without rcon --- scripts/init.sh | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/scripts/init.sh b/scripts/init.sh index 6174c44..bb34a4f 100644 --- a/scripts/init.sh +++ b/scripts/init.sh @@ -18,15 +18,20 @@ if [ "${UPDATE_ON_BOOT}" = true ]; then fi term_handler() { - rcon-cli shutdown 1 - while true - do - rcon-cli info - if [ $? -ne 0 ]; then - break - fi - sleep 1 - done + if [ ${RCON_ENABLED} = true ]; then + rcon-cli shutdown 1 + while true + do + rcon-cli info + if [ $? -ne 0 ]; then + break + fi + sleep 1 + done + else # Not graceful + kill -SIGTERM $(pidof PalServer-Linux-Test) + tail --pid=$(pidof PalServer-Linux-Test) -f 2>/dev/null + fi } trap 'term_handler' SIGTERM From 945977237b7858e01652e109dc5f9bfb331e1e63 Mon Sep 17 00:00:00 2001 From: "Carlos M. Martinez" Date: Wed, 24 Jan 2024 19:00:25 -0500 Subject: [PATCH 3/7] Fixed saving issue. --- scripts/init.sh | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/scripts/init.sh b/scripts/init.sh index bb34a4f..1975028 100644 --- a/scripts/init.sh +++ b/scripts/init.sh @@ -19,19 +19,12 @@ fi term_handler() { if [ ${RCON_ENABLED} = true ]; then + rcon-cli save rcon-cli shutdown 1 - while true - do - rcon-cli info - if [ $? -ne 0 ]; then - break - fi - sleep 1 - done else # Not graceful - kill -SIGTERM $(pidof PalServer-Linux-Test) - tail --pid=$(pidof PalServer-Linux-Test) -f 2>/dev/null + kill -SIGTERM $killpid fi + tail --pid=$killpid -f 2>/dev/null } trap 'term_handler' SIGTERM From a7e4a58f8a20563c0344cf5c9af221dc59c38a45 Mon Sep 17 00:00:00 2001 From: "Carlos M. Martinez" Date: Wed, 24 Jan 2024 19:08:04 -0500 Subject: [PATCH 4/7] Updated kill for no rcon --- scripts/init.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/init.sh b/scripts/init.sh index 1975028..6f70094 100644 --- a/scripts/init.sh +++ b/scripts/init.sh @@ -21,8 +21,8 @@ term_handler() { if [ ${RCON_ENABLED} = true ]; then rcon-cli save rcon-cli shutdown 1 - else # Not graceful - kill -SIGTERM $killpid + else # Does not save + kill -SIGTERM $(pidof PalServer-Linux-Test) fi tail --pid=$killpid -f 2>/dev/null } From 4d9a78494249756df65036e01f166497d7c11bd5 Mon Sep 17 00:00:00 2001 From: "Carlos M. Martinez" Date: Wed, 24 Jan 2024 19:11:56 -0500 Subject: [PATCH 5/7] Updated documentation --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index b23efda..5215e95 100644 --- a/README.md +++ b/README.md @@ -108,7 +108,7 @@ It is highly recommended you set the following environment values before startin | SERVER_PASSWORD | Secure your community server with a password | | "string" | | ADMIN_PASSWORD | Secure administration access in the server with a password | | "string" | | UPDATE_ON_BOOT** | Update/Install the server when the docker container starts (THIS HAS TO BE ENABLED THE FIRST TIME YOU RUN THE CONTAINER) | true | true/false | -| RCON_ENABLED | Enable RCON for the Palworld server | true | true/false | +| RCON_ENABLED*** | Enable RCON for the Palworld server | true | true/false | | RCON_PORT | RCON port to connect to | 25575 | 1024-65535 | | QUERY_PORT | Query port used to communicate with Steam servers | 27015 | 1024-65535 | @@ -116,6 +116,8 @@ It is highly recommended you set the following environment values before startin ** Make sure you know what you are doing when running this option enabled +*** Required for docker stop to save and gracefully close the server + ### Game Ports | Port | Info | From 81a2e907b63e5b0d8a285966120fab134bba58b2 Mon Sep 17 00:00:00 2001 From: emmanuel <154705254+codesmith-emmy@users.noreply.github.com> Date: Thu, 25 Jan 2024 17:59:11 +0100 Subject: [PATCH 6/7] Fix: Typo in documentation --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index fdcc4bf..d527f93 100644 --- a/README.md +++ b/README.md @@ -134,13 +134,13 @@ It is highly recommended you set the following environment values before startin ## Using RCON RCON is enabled by default for the palworld-server-docker image. -Opening the RCON cli is quite easy: +Opening the RCON CLI is quite easy: ```bash docker exec -it palworld-server rcon-cli ``` -This will open a CLI that use can use to write commands to the Palworld Server. +This will open a CLI that uses RCON to write commands to the Palworld Server. ### List of server commands @@ -161,7 +161,7 @@ For a full list of commands go to: [https://tech.palworldgame.com/server-command ## Creating a backup -To create a backup of the game's save at the current point in time, use the command. +To create a backup of the game's save at the current point in time, use the command: ```bash docker exec palworld-server backup From 9d03e933e0466e07be62257ce7e47b10c62f8299 Mon Sep 17 00:00:00 2001 From: Thijs van Loef Date: Thu, 25 Jan 2024 18:23:14 +0100 Subject: [PATCH 7/7] add quotes to prevent word splitting --- scripts/init.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/init.sh b/scripts/init.sh index 6f70094..23028be 100644 --- a/scripts/init.sh +++ b/scripts/init.sh @@ -18,11 +18,11 @@ if [ "${UPDATE_ON_BOOT}" = true ]; then fi term_handler() { - if [ ${RCON_ENABLED} = true ]; then + if [ "${RCON_ENABLED}" = true ]; then rcon-cli save rcon-cli shutdown 1 else # Does not save - kill -SIGTERM $(pidof PalServer-Linux-Test) + kill -SIGTERM "$(pidof PalServer-Linux-Test)" fi tail --pid=$killpid -f 2>/dev/null }