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/6] 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 f1b5bf2a5..6174c44bb 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/6] 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 6174c44bb..bb34a4fed 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/6] 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 bb34a4fed..197502876 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/6] 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 197502876..6f70094fb 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/6] Updated documentation --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index b23efdaaf..5215e95c6 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 9d03e933e0466e07be62257ce7e47b10c62f8299 Mon Sep 17 00:00:00 2001 From: Thijs van Loef Date: Thu, 25 Jan 2024 18:23:14 +0100 Subject: [PATCH 6/6] 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 6f70094fb..23028beea 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 }