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 | diff --git a/scripts/init.sh b/scripts/init.sh index f1b5bf2a5..23028beea 100644 --- a/scripts/init.sh +++ b/scripts/init.sh @@ -17,4 +17,18 @@ 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() { + if [ "${RCON_ENABLED}" = true ]; then + rcon-cli save + rcon-cli shutdown 1 + else # Does not save + kill -SIGTERM "$(pidof PalServer-Linux-Test)" + fi + tail --pid=$killpid -f 2>/dev/null +} + +trap 'term_handler' SIGTERM + +./start.sh & +killpid="$!" +wait $killpid