Skip to content

Commit

Permalink
Merge pull request thijsvanloef#342 from MSpreckels/toggle-generate-s…
Browse files Browse the repository at this point in the history
…ettings

Add env to toggle to automatically generate palworldsettings
  • Loading branch information
thijsvanloef authored Feb 11, 2024
2 parents 2c4d0e1 + 670a32a commit e51e238
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 5 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ It is highly recommended you set the following environment values before startin
| DISCORD_PRE_START_MESSAGE | Discord message sent when server begins to start | Server is started! | "string" |
| DISCORD_PRE_SHUTDOWN_MESSAGE | Discord message sent when server begins to shutdown | Server is shutting down... | "string" |
| DISCORD_POST_SHUTDOWN_MESSAGE | Discord message sent when server has stopped | Server is stopped! | "string" |
| DISABLE_GENERATE_SETTINGS | Whether to automatically generate the PalWorldSettings.ini | false | true/false |

*highly recommended to set

Expand Down
2 changes: 1 addition & 1 deletion scripts/compile-settings.sh
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ fi

cat > "$config_file" <<EOF
[/Script/Pal.PalGameWorldSettings]
$(envsubst < ./files/PalWorldSettings.ini.template | tr -d "\n\r")
$(envsubst < /home/steam/server/files/PalWorldSettings.ini.template | tr -d "\n\r")
EOF

echo "Compiling PalWorldSettings.ini done!"
30 changes: 26 additions & 4 deletions scripts/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@ dirExists "/palworld" || exit
isWritable "/palworld" || exit
isExecutable "/palworld" || exit

printf "\e[0;32m*****GENERATING CONFIGS*****\e[0m\n"

./compile-settings.sh || exit

cd /palworld || exit

# Get the architecture using dpkg
Expand Down Expand Up @@ -73,6 +69,32 @@ if [ "${MULTITHREADING,,}" = true ]; then
STARTCOMMAND+=("-useperfthreads" "-NoAsyncLoadingThread" "-UseMultithreadForDS")
fi

if [ "${DISABLE_GENERATE_SETTINGS,,}" = true ]; then
printf "\e[0;32m%s\e[0m\n" "*****CHECKING FOR EXISTING CONFIG*****"
printf "\e[0;32m%s\e[0m\n" "***Env vars will not be applied due to DISABLE_GENERATE_SETTINGS being set to TRUE!***"

# shellcheck disable=SC2143
if [ ! "$(grep -s '[^[:space:]]' /palworld/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini)" ]; then

printf "\e[0;32m%s\e[0m\n" "*****GENERATING CONFIG*****"

# Server will generate all ini files after first run.
if [ "$architecture" == "arm64" ]; then
timeout --preserve-status 15s ./PalServer-arm64.sh 1> /dev/null
else
timeout --preserve-status 15s ./PalServer.sh 1> /dev/null
fi

# Wait for shutdown
sleep 5
cp /palworld/DefaultPalWorldSettings.ini /palworld/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini
fi
else
printf "\e[0;32m%s\e[0m\n" "*****GENERATING CONFIG*****"
printf "\e[0;32m%s\e[0m\n" "***Using Env vars to create PalWorldSettings.ini***"
/home/steam/server/compile-settings.sh
fi

rm -f "/home/steam/server/crontab"
if [ "${BACKUP_ENABLED,,}" = true ]; then
echo "BACKUP_ENABLED=${BACKUP_ENABLED,,}"
Expand Down

0 comments on commit e51e238

Please sign in to comment.