Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add env to toggle to automatically generate palworldsettings #342

Merged
merged 6 commits into from
Feb 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading