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

Adding more user friendly checks #228

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
2042a28
Added checks for permissions and exit codes
Dashboy1998 Jan 30, 2024
2451183
Merge branch 'main' into Checks-for-directories
Dashboy1998 Jan 30, 2024
92c5116
Fixed incorrect words
Dashboy1998 Jan 30, 2024
05ccc9b
Added readable for PalServer.sh
Dashboy1998 Jan 30, 2024
9caa996
Changed a check from a dir to a file
Dashboy1998 Jan 30, 2024
9d7b13d
Removed executable check for config
Dashboy1998 Jan 30, 2024
8faec9b
Removed return as it's not used
Dashboy1998 Jan 30, 2024
68db41c
Added exit for cd
Dashboy1998 Jan 30, 2024
555bd33
Changed so it only works for regular files
Dashboy1998 Jan 31, 2024
ea2e546
Moved exits
Dashboy1998 Jan 31, 2024
9f6b530
Updated readme
Dashboy1998 Jan 31, 2024
ed0a200
Added space between bash function brackets
Dashboy1998 Jan 31, 2024
0fbbc48
Updated scripts for linter
Dashboy1998 Jan 31, 2024
432bcda
Merge branch 'main' into Checks-for-directories
Dashboy1998 Jan 31, 2024
2c9a499
Now supports case insensitive booleans
Dashboy1998 Jan 31, 2024
3f84214
Checks if variables are booleans
Dashboy1998 Jan 31, 2024
85d1cdb
Added future check functions
Dashboy1998 Jan 31, 2024
4de54e8
Removed future functions
Dashboy1998 Jan 31, 2024
89de825
Changed return false values to 1
Dashboy1998 Jan 31, 2024
2fcfffc
Removed changes in init.sh
Dashboy1998 Jan 31, 2024
c6a126b
Added disable=SC2317 back in for trap func
Dashboy1998 Jan 31, 2024
65e0bf4
Added quotes around var for pid
Dashboy1998 Jan 31, 2024
2d1d1d2
Removed exit code on cd exit
Dashboy1998 Jan 31, 2024
001c242
Added additional message if palserver.sh does not exist
Dashboy1998 Jan 31, 2024
d16ebcc
Removed repeated message
Dashboy1998 Jan 31, 2024
8b8f44c
Added exit to failure
Dashboy1998 Jan 31, 2024
ee4ad12
Updated check for readability
Dashboy1998 Jan 31, 2024
5e880ac
Merge branch 'main' into Checks-for-directories
Dashboy1998 Feb 2, 2024
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
5 changes: 0 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -188,11 +188,6 @@ It is highly recommended you set the following environment values before startin

*** Required for docker stop to save and gracefully close the server

> [!IMPORTANT]
> Boolean values used in environment variables are case-sensitive because they are used in the shell script.
>
> They must be set using exactly `true` or `false` for the option to take effect.

### Game Ports

| Port | Info |
Expand Down
4 changes: 2 additions & 2 deletions scripts/backup.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

if [ "${RCON_ENABLED}" = true ]; then
if [ "${RCON_ENABLED,,}" = true ]; then
rcon-cli -c /home/steam/server/rcon.yaml save
fi

Expand All @@ -17,7 +17,7 @@ fi

echo "backup created at $FILE_PATH"

if [ "${DELETE_OLD_BACKUPS}" = true ]; then
if [ "${DELETE_OLD_BACKUPS,,}" = true ]; then
if [ -z "${OLD_BACKUP_DAYS}" ]; then
echo "Unable to deleted old backups, OLD_BACKUP_DAYS is empty."
elif [[ "${OLD_BACKUP_DAYS}" =~ ^[0-9]+$ ]]; then
Expand Down
3 changes: 2 additions & 1 deletion scripts/init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ fi
mkdir -p /palworld/backups
chown -R steam:steam /palworld /home/steam/

# shellcheck disable=SC2317
term_handler() {
if [ "${RCON_ENABLED}" = true ]; then
if [ "${RCON_ENABLED,,}" = true ]; then
rcon-cli save
rcon-cli "shutdown 1"
else # Does not save
Expand Down
217 changes: 183 additions & 34 deletions scripts/start.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,84 @@
#!/bin/bash

if [ "${UPDATE_ON_BOOT}" = true ]; then
printf "\e[0;32m*****STARTING INSTALL/UPDATE*****\e[0m\n"
/home/steam/steamcmd/steamcmd.sh +@sSteamCmdForcePlatformType linux +@sSteamCmdForcePlatformBitness 64 +force_install_dir "/palworld" +login anonymous +app_update 2394010 validate +quit
dirExists() {
local path="$1"
local return_val=0
if ! [ -d "${path}" ]; then
echo "${path} does not exist."
return_val=1
fi
return "$return_val"
}

fileExists() {
local path="$1"
local return_val=0
if ! [ -f "${path}" ]; then
echo "${path} does not exist."
return_val=1
fi
return "$return_val"
}

isReadable() {
local path="$1"
local return_val=0
if ! [ -r "${path}" ]; then
echo "${path} is not readable."
return_val=1
fi
return "$return_val"
}

isWritable() {
local path="$1"
local return_val=0
if ! [ -w "${path}" ]; then
echo "${path} is not writable."
return_val=1
fi
return "$return_val"
}

isExecutable() {
local path="$1"
local return_val=0
if ! [ -x "${path}" ]; then
echo "${path} is not executable."
return_val=1
fi
return "$return_val"
}

isBoolean() {
local bool="$1"
[ "${bool,,}" = true ] || [ "${bool,,}" = false ]
}

dirExists "/palworld" || exit
isWritable "/palworld" || exit
isExecutable "/palworld" || exit

cd /palworld || exit

if isBoolean "${UPDATE_ON_BOOT}"; then
if [ "${UPDATE_ON_BOOT,,}" = true ]; then
printf "\e[0;32m*****STARTING INSTALL/UPDATE*****\e[0m\n"
/home/steam/steamcmd/steamcmd.sh +@sSteamCmdForcePlatformType linux +@sSteamCmdForcePlatformBitness 64 +force_install_dir "/palworld" +login anonymous +app_update 2394010 validate +quit
fi
else
echo "UPDATE_ON_BOOT is not true/false, assuming false"
fi

STARTCOMMAND=("./PalServer.sh")

if ! fileExists "${STARTCOMMAND[0]}"; then
echo "Try restarting with UPDATE_ON_BOOT=true"
exit 1
fi
isReadable "${STARTCOMMAND[0]}" || exit
isExecutable "${STARTCOMMAND[0]}" || exit

if [ -n "${PORT}" ]; then
STARTCOMMAND+=("-port=${PORT}")
fi
Expand All @@ -15,16 +87,21 @@ if [ -n "${QUERY_PORT}" ]; then
STARTCOMMAND+=("-queryport=${QUERY_PORT}")
fi

if [ "${COMMUNITY}" = true ]; then
STARTCOMMAND+=("EpicApp=PalServer")
fi

if [ "${MULTITHREADING}" = true ]; then
STARTCOMMAND+=("-useperfthreads" "-NoAsyncLoadingThread" "-UseMultithreadForDS")
if isBoolean "${COMMUNITY}"; then
if [ "${COMMUNITY,,}" = true ]; then
STARTCOMMAND+=("EpicApp=PalServer")
fi
else
echo "COMMUNITY is not true/false, assuming false"
fi
if isBoolean "${MULTITHREADING}"; then
if [ "${MULTITHREADING,,}" = true ]; then
STARTCOMMAND+=("-useperfthreads" "-NoAsyncLoadingThread" "-UseMultithreadForDS")
fi
else
echo "MULTITHREADING is not true/false, assuming false"
fi

cd /palworld || exit

printf "\e[0;32m*****CHECKING FOR EXISTING CONFIG*****\e[0m\n"

# shellcheck disable=SC2143
Expand All @@ -40,6 +117,9 @@ if [ ! "$(grep -s '[^[:space:]]' /palworld/Pal/Saved/Config/LinuxServer/PalWorld
cp /palworld/DefaultPalWorldSettings.ini /palworld/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini
fi

fileExists "/palworld/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini" || exit
isWritable "/palworld/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini" || exit

escape_sed() {
printf '%s\n' "$1" | sed -e 's:[][\/.^$*]:\\&:g'
}
Expand Down Expand Up @@ -179,27 +259,51 @@ if [ -n "${DEATH_PENALTY}" ]; then
fi
if [ -n "${ENABLE_PLAYER_TO_PLAYER_DAMAGE}" ]; then
echo "ENABLE_PLAYER_TO_PLAYER_DAMAGE=$ENABLE_PLAYER_TO_PLAYER_DAMAGE"
sed -E -i "s/bEnablePlayerToPlayerDamage=[a-zA-Z]*/bEnablePlayerToPlayerDamage=$ENABLE_PLAYER_TO_PLAYER_DAMAGE/" /palworld/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini
if isBoolean "${ENABLE_PLAYER_TO_PLAYER_DAMAGE}"; then
sed -E -i "s/bEnablePlayerToPlayerDamage=[a-zA-Z]*/bEnablePlayerToPlayerDamage=$ENABLE_PLAYER_TO_PLAYER_DAMAGE/" /palworld/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini
else
echo "ENABLE_PLAYER_TO_PLAYER_DAMAGE is not true/false, unable to change value"
fi
fi
if [ -n "${ENABLE_FRIENDLY_FIRE}" ]; then
echo "ENABLE_FRIENDLY_FIRE=$ENABLE_FRIENDLY_FIRE"
sed -E -i "s/bEnableFriendlyFire=[a-zA-Z]*/bEnableFriendlyFire=$ENABLE_FRIENDLY_FIRE/" /palworld/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini
if isBoolean "${ENABLE_FRIENDLY_FIRE}"; then
sed -E -i "s/bEnableFriendlyFire=[a-zA-Z]*/bEnableFriendlyFire=$ENABLE_FRIENDLY_FIRE/" /palworld/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini
else
echo "ENABLE_FRIENDLY_FIRE is not true/false, unable to change value"
fi
fi
if [ -n "${ENABLE_INVADER_ENEMY}" ]; then
echo "ENABLE_INVADER_ENEMY=$ENABLE_INVADER_ENEMY"
sed -E -i "s/bEnableInvaderEnemy=[a-zA-Z]*/bEnableInvaderEnemy=$ENABLE_INVADER_ENEMY/" /palworld/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini
if isBoolean "${ENABLE_INVADER_ENEMY}"; then
sed -E -i "s/bEnableInvaderEnemy=[a-zA-Z]*/bEnableInvaderEnemy=$ENABLE_INVADER_ENEMY/" /palworld/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini
else
echo "ENABLE_INVADER_ENEMY is not true/false, unable to change value"
fi
fi
if [ -n "${ACTIVE_UNKO}" ]; then
echo "ACTIVE_UNKO=$ACTIVE_UNKO"
sed -E -i "s/bActiveUNKO=[a-zA-Z]*/bActiveUNKO=$ACTIVE_UNKO/" /palworld/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini
if isBoolean "${ACTIVE_UNKO}"; then
sed -E -i "s/bActiveUNKO=[a-zA-Z]*/bActiveUNKO=$ACTIVE_UNKO/" /palworld/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini
else
echo "ACTIVE_UNKO is not true/false, unable to change value"
fi
fi
if [ -n "${ENABLE_AIM_ASSIST_PAD}" ]; then
echo "ENABLE_AIM_ASSIST_PAD=$ENABLE_AIM_ASSIST_PAD"
sed -E -i "s/bEnableAimAssistPad=[a-zA-Z]*/bEnableAimAssistPad=$ENABLE_AIM_ASSIST_PAD/" /palworld/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini
if isBoolean "${ENABLE_AIM_ASSIST_PAD}"; then
sed -E -i "s/bEnableAimAssistPad=[a-zA-Z]*/bEnableAimAssistPad=$ENABLE_AIM_ASSIST_PAD/" /palworld/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini
else
echo "ENABLE_AIM_ASSIST_PAD is not true/false, unable to change value"
fi
fi
if [ -n "${ENABLE_AIM_ASSIST_KEYBOARD}" ]; then
echo "ENABLE_AIM_ASSIST_KEYBOARD=$ENABLE_AIM_ASSIST_KEYBOARD"
sed -E -i "s/bEnableAimAssistKeyboard=[a-zA-Z]*/bEnableAimAssistKeyboard=$ENABLE_AIM_ASSIST_KEYBOARD/" /palworld/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini
if isBoolean "${ENABLE_AIM_ASSIST_KEYBOARD}"; then
sed -E -i "s/bEnableAimAssistKeyboard=[a-zA-Z]*/bEnableAimAssistKeyboard=$ENABLE_AIM_ASSIST_KEYBOARD/" /palworld/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini
else
echo "ENABLE_AIM_ASSIST_KEYBOARD is not true/false, unable to change value"
fi
fi
if [ -n "${DROP_ITEM_MAX_NUM}" ]; then
echo "DROP_ITEM_MAX_NUM=$DROP_ITEM_MAX_NUM"
Expand All @@ -223,7 +327,11 @@ if [ -n "${DROP_ITEM_ALIVE_MAX_HOURS}" ]; then
fi
if [ -n "${AUTO_RESET_GUILD_NO_ONLINE_PLAYERS}" ]; then
echo "AUTO_RESET_GUILD_NO_ONLINE_PLAYERS=$AUTO_RESET_GUILD_NO_ONLINE_PLAYERS"
sed -E -i "s/bAutoResetGuildNoOnlinePlayers=[a-zA-Z]*/bAutoResetGuildNoOnlinePlayers=$AUTO_RESET_GUILD_NO_ONLINE_PLAYERS/" /palworld/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini
if isBoolean "${AUTO_RESET_GUILD_NO_ONLINE_PLAYERS}"; then
sed -E -i "s/bAutoResetGuildNoOnlinePlayers=[a-zA-Z]*/bAutoResetGuildNoOnlinePlayers=$AUTO_RESET_GUILD_NO_ONLINE_PLAYERS/" /palworld/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini
else
echo "AUTO_RESET_GUILD_NO_ONLINE_PLAYERS is not true/false, unable to change value"
fi
fi
if [ -n "${AUTO_RESET_GUILD_TIME_NO_ONLINE_PLAYERS}" ]; then
echo "AUTO_RESET_GUILD_TIME_NO_ONLINE_PLAYERS=$AUTO_RESET_GUILD_TIME_NO_ONLINE_PLAYERS"
Expand All @@ -243,35 +351,67 @@ if [ -n "${WORK_SPEED_RATE}" ]; then
fi
if [ -n "${IS_MULTIPLAY}" ]; then
echo "IS_MULTIPLAY=$IS_MULTIPLAY"
sed -E -i "s/bIsMultiplay=[a-zA-Z]*/bIsMultiplay=$IS_MULTIPLAY/" /palworld/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini
if isBoolean "${IS_MULTIPLAY}"; then
sed -E -i "s/bIsMultiplay=[a-zA-Z]*/bIsMultiplay=$IS_MULTIPLAY/" /palworld/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini
else
echo "IS_MULTIPLAY is not true/false, unable to change value"
fi
fi
if [ -n "${IS_PVP}" ]; then
echo "IS_PVP=$IS_PVP"
sed -E -i "s/bIsPvP=[a-zA-Z]*/bIsPvP=$IS_PVP/" /palworld/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini
if isBoolean "${IS_PVP}"; then
sed -E -i "s/bIsPvP=[a-zA-Z]*/bIsPvP=$IS_PVP/" /palworld/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini
else
echo "IS_PVP is not true/false, unable to change value"
fi
fi
if [ -n "${CAN_PICKUP_OTHER_GUILD_DEATH_PENALTY_DROP}" ]; then
echo "CAN_PICKUP_OTHER_GUILD_DEATH_PENALTY_DROP=$CAN_PICKUP_OTHER_GUILD_DEATH_PENALTY_DROP"
sed -E -i "s/bCanPickupOtherGuildDeathPenaltyDrop=[a-zA-Z]*/bCanPickupOtherGuildDeathPenaltyDrop=$CAN_PICKUP_OTHER_GUILD_DEATH_PENALTY_DROP/" /palworld/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini
if isBoolean "${CAN_PICKUP_OTHER_GUILD_DEATH_PENALTY_DROP}"; then
sed -E -i "s/bCanPickupOtherGuildDeathPenaltyDrop=[a-zA-Z]*/bCanPickupOtherGuildDeathPenaltyDrop=$CAN_PICKUP_OTHER_GUILD_DEATH_PENALTY_DROP/" /palworld/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini
else
echo "CAN_PICKUP_OTHER_GUILD_DEATH_PENALTY_DROP is not true/false, unable to change value"
fi
fi
if [ -n "${ENABLE_NON_LOGIN_PENALTY}" ]; then
echo "ENABLE_NON_LOGIN_PENALTY=$ENABLE_NON_LOGIN_PENALTY"
sed -E -i "s/bEnableNonLoginPenalty=[a-zA-Z]*/bEnableNonLoginPenalty=$ENABLE_NON_LOGIN_PENALTY/" /palworld/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini
if isBoolean "${ENABLE_NON_LOGIN_PENALTY}"; then
sed -E -i "s/bEnableNonLoginPenalty=[a-zA-Z]*/bEnableNonLoginPenalty=$ENABLE_NON_LOGIN_PENALTY/" /palworld/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini
else
echo "ENABLE_NON_LOGIN_PENALTY is not true/false, unable to change value"
fi
fi
if [ -n "${ENABLE_FAST_TRAVEL}" ]; then
echo "ENABLE_FAST_TRAVEL=$ENABLE_FAST_TRAVEL"
sed -E -i "s/bEnableFastTravel=[a-zA-Z]*/bEnableFastTravel=$ENABLE_FAST_TRAVEL/" /palworld/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini
if isBoolean "${ENABLE_FAST_TRAVEL}"; then
sed -E -i "s/bEnableFastTravel=[a-zA-Z]*/bEnableFastTravel=$ENABLE_FAST_TRAVEL/" /palworld/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini
else
echo "ENABLE_FAST_TRAVEL is not true/false, unable to change value"
fi
fi
if [ -n "${IS_START_LOCATION_SELECT_BY_MAP}" ]; then
echo "IS_START_LOCATION_SELECT_BY_MAP=$IS_START_LOCATION_SELECT_BY_MAP"
sed -E -i "s/bIsStartLocationSelectByMap=[a-zA-Z]*/bIsStartLocationSelectByMap=$IS_START_LOCATION_SELECT_BY_MAP/" /palworld/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini
if isBoolean "${IS_START_LOCATION_SELECT_BY_MAP}"; then
sed -E -i "s/bIsStartLocationSelectByMap=[a-zA-Z]*/bIsStartLocationSelectByMap=$IS_START_LOCATION_SELECT_BY_MAP/" /palworld/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini
else
echo "IS_START_LOCATION_SELECT_BY_MAP is not true/false, unable to change value"
fi
fi
if [ -n "${EXIST_PLAYER_AFTER_LOGOUT}" ]; then
echo "EXIST_PLAYER_AFTER_LOGOUT=$EXIST_PLAYER_AFTER_LOGOUT"
sed -E -i "s/bExistPlayerAfterLogout=[a-zA-Z]*/bExistPlayerAfterLogout=$EXIST_PLAYER_AFTER_LOGOUT/" /palworld/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini
if isBoolean "${EXIST_PLAYER_AFTER_LOGOUT}"; then
sed -E -i "s/bExistPlayerAfterLogout=[a-zA-Z]*/bExistPlayerAfterLogout=$EXIST_PLAYER_AFTER_LOGOUT/" /palworld/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini
else
echo "EXIST_PLAYER_AFTER_LOGOUT is not true/false, unable to change value"
fi
fi
if [ -n "${ENABLE_DEFENSE_OTHER_GUILD_PLAYER}" ]; then
echo "ENABLE_DEFENSE_OTHER_GUILD_PLAYER=$ENABLE_DEFENSE_OTHER_GUILD_PLAYER"
sed -E -i "s/bEnableDefenseOtherGuildPlayer=[a-zA-Z]*/bEnableDefenseOtherGuildPlayer=$ENABLE_DEFENSE_OTHER_GUILD_PLAYER/" /palworld/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini
if isBoolean "${ENABLE_DEFENSE_OTHER_GUILD_PLAYER}"; then
sed -E -i "s/bEnableDefenseOtherGuildPlayer=[a-zA-Z]*/bEnableDefenseOtherGuildPlayer=$ENABLE_DEFENSE_OTHER_GUILD_PLAYER/" /palworld/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini
else
echo "ENABLE_DEFENSE_OTHER_GUILD_PLAYER is not true/false, unable to change value"
fi
fi
if [ -n "${COOP_PLAYER_MAX_NUM}" ]; then
echo "COOP_PLAYER_MAX_NUM=$COOP_PLAYER_MAX_NUM"
Expand All @@ -284,7 +424,11 @@ if [ -n "${REGION}" ]; then
fi
if [ -n "${USEAUTH}" ]; then
echo "USEAUTH=$USEAUTH"
sed -E -i "s/bUseAuth=[a-zA-Z]*/bUseAuth=$USEAUTH/" /palworld/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini
if isBoolean "${USEAUTH}"; then
sed -E -i "s/bUseAuth=[a-zA-Z]*/bUseAuth=$USEAUTH/" /palworld/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini
else
echo "USEAUTH is not true/false, unable to change value"
fi
fi
if [ -n "${BAN_LIST_URL}" ]; then
BAN_LIST_URL=$(sed -e 's/^"\(.*\)"$/\1/' -e "s/^'\(.*\)'$/\1/" <<< "$BAN_LIST_URL")
Expand All @@ -301,18 +445,23 @@ if [ -n "${RCON_PORT}" ]; then
fi

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

echo "$BACKUP_CRON_EXPRESSION bash /usr/local/bin/backup" >> "/home/steam/server/crontab"

if isBoolean "${BACKUP_ENABLED}"; then
if [ "${BACKUP_ENABLED,,}" = true ]; then
echo "BACKUP_ENABLED=${BACKUP_ENABLED}"

echo "$BACKUP_CRON_EXPRESSION bash /usr/local/bin/backup" >> "/home/steam/server/crontab"
fi
else
echo "BACKUP_ENABLED is not true/false, assuming false"
fi

if [ "${AUTO_UPDATE_ENABLED}" = true ] && [ "${UPDATE_ON_BOOT}" = true ]; then
if [ "${AUTO_UPDATE_ENABLED,,}" = true ] && [ "${UPDATE_ON_BOOT,,}" = true ]; then
echo "AUTO_UPDATE_ENABLED=${AUTO_UPDATE_ENABLED}"
echo "$AUTO_UPDATE_CRON_EXPRESSION bash /usr/local/bin/update" >> "/home/steam/server/crontab"
fi

if { [ "${AUTO_UPDATE_ENABLED}" = true ] && [ "${UPDATE_ON_BOOT}" = true ]; } || [ "${BACKUP_ENABLED}" = true ]; then
if { [ "${AUTO_UPDATE_ENABLED,,}" = true ] && [ "${UPDATE_ON_BOOT,,}" = true ]; } || [ "${BACKUP_ENABLED,,}" = true ]; then
supercronic "/home/steam/server/crontab" &
fi

Expand All @@ -326,4 +475,4 @@ EOL
printf "\e[0;32m*****STARTING SERVER*****\e[0m\n"
echo "${STARTCOMMAND[*]}"
"${STARTCOMMAND[@]}"

exit 0
4 changes: 2 additions & 2 deletions scripts/update.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

if [ "${UPDATE_ON_BOOT}" = false ]; then
if [ "${UPDATE_ON_BOOT,,}" = false ]; then
echo "Update on Boot needs to be enabled for auto updating"
exit 0
fi
Expand All @@ -24,7 +24,7 @@ fi

if [ "$CURRENTBUILD" != "$TARGETBUILD" ]; then
echo "New Build was found. Updating the server from $CURRENTBUILD to $TARGETBUILD."
if [ "${RCON_ENABLED}" = true ]; then
if [ "${RCON_ENABLED,,}" = true ]; then
rm /palworld/steamapps/appmanifest_2394010.acf
rcon-cli -c /home/steam/server/rcon.yaml "broadcast The_Server_will_update_in_${AUTO_UPDATE_WARN_MINUTES}_Minutes"
sleep "${AUTO_UPDATE_WARN_MINUTES}m"
Expand Down