diff --git a/scripts/auto_reboot.sh b/scripts/auto_reboot.sh index 313df8b4c..13f1de424 100644 --- a/scripts/auto_reboot.sh +++ b/scripts/auto_reboot.sh @@ -2,29 +2,32 @@ # shellcheck source=/dev/null source "/home/steam/server/helper_functions.sh" -if [ "${RCON_ENABLED,,}" = true ]; then - if [ "${AUTO_REBOOT_EVEN_IF_PLAYERS_ONLINE,,}" != true ]; then - players_count=$(get_player_count) +if [ "${RCON_ENABLED,,}" != true ]; then + LogWarn "Unable to reboot. RCON is required." + exit 0 +fi - if [ "$players_count" -gt 0 ]; then - echo "There are ${players_count} players online. Skipping auto reboot." - exit 1 - fi - fi +if [ -z "${AUTO_REBOOT_WARN_MINUTES}" ]; then + LogError "Unable to auto reboot, AUTO_REBOOT_WARN_MINUTES is empty." + exit 0 +fi - if [ -z "${AUTO_REBOOT_WARN_MINUTES}" ]; then - echo "Unable to auto reboot, AUTO_REBOOT_WARN_MINUTES is empty." - elif [[ "${AUTO_REBOOT_WARN_MINUTES}" =~ ^[0-9]+$ ]]; then - for ((i = "${AUTO_REBOOT_WARN_MINUTES}" ; i > 0 ; i--)); do - rcon-cli -c /home/steam/server/rcon.yaml "broadcast The_Server_will_reboot_in_${i}_Minutes" - sleep "1m" - done +if [ "${AUTO_REBOOT_EVEN_IF_PLAYERS_ONLINE,,}" != true ]; then + players_count=$(get_player_count) + if [ "$players_count" -gt 0 ]; then + LogWarn "There are ${players_count} players online. Skipping auto reboot." + exit 0 + fi +fi - rcon-cli -c /home/steam/server/rcon.yaml save - rcon-cli -c /home/steam/server/rcon.yaml "shutdown 1" - else - echo "Unable to auto reboot, AUTO_REBOOT_WARN_MINUTES is not an integer: ${AUTO_REBOOT_WARN_MINUTES}" - fi -else - echo "Unable to reboot. RCON is required." +if [[ "${AUTO_REBOOT_WARN_MINUTES}" =~ ^[0-9]+$ ]]; then + for ((i = "${AUTO_REBOOT_WARN_MINUTES}" ; i > 0 ; i--)); do + RCON "broadcast The_Server_will_reboot_in_${i}_Minutes" + sleep "1m" + done + RCON save + RCON "shutdown 1" + exit 0 fi + +LogError "Unable to auto reboot, AUTO_REBOOT_WARN_MINUTES is not an integer: ${AUTO_REBOOT_WARN_MINUTES}" \ No newline at end of file diff --git a/scripts/backup.sh b/scripts/backup.sh index c82909e5a..119ffa126 100644 --- a/scripts/backup.sh +++ b/scripts/backup.sh @@ -1,49 +1,43 @@ #!/bin/bash +# shellcheck source=/dev/null +source "/home/steam/server/helper_functions.sh" -if [ -n "${DISCORD_WEBHOOK_URL}" ]; then - /home/steam/server/discord.sh "Creating backup..." "in-progress" & -fi - +DiscordMessage "Creating backup..." "in-progress" if [ "${RCON_ENABLED,,}" = true ]; then - rcon-cli -c /home/steam/server/rcon.yaml save + RCON save fi DATE=$(date +"%Y-%m-%d_%H-%M-%S") FILE_PATH="/palworld/backups/palworld-save-${DATE}.tar.gz" cd /palworld/Pal/ || exit -echo "Creating backup" +LogAction "Creating backup" tar -zcf "$FILE_PATH" "Saved/" if [ "$(id -u)" -eq 0 ]; then chown steam:steam "$FILE_PATH" fi +LogInfo "Backup created at ${FILE_PATH}" +DiscordMessage "Backup created at ${FILE_PATH}" "success" + +if [ "${DELETE_OLD_BACKUPS,,}" != true ]; then + exit 0 +fi + +if [ -z "${OLD_BACKUP_DAYS}" ]; then + LogWarn "Unable to delete old backups, OLD_BACKUP_DAYS is empty." + DiscordMessage "Unable to delete old backups, OLD_BACKUP_DAYS is empty." "warn" + exit 0 +fi -echo "Backup created at ${FILE_PATH}" -if [ -n "${DISCORD_WEBHOOK_URL}" ]; then - /home/steam/server/discord.sh "Backup created at ${FILE_PATH}" "success" +if [[ "${OLD_BACKUP_DAYS}" =~ ^[0-9]+$ ]]; then + LogAction "Removing Old Backups" + LogInfo "Removing backups older than ${OLD_BACKUP_DAYS} days" + DiscordMessage "Removing backups older than ${OLD_BACKUP_DAYS} days..." "in-progress" + find /palworld/backups/ -mindepth 1 -maxdepth 1 -mtime "+${OLD_BACKUP_DAYS}" -type f -name 'palworld-save-*.tar.gz' -print -delete + DiscordMessage "Removed backups older than ${OLD_BACKUP_DAYS} days" "success" + exit 0 fi -if [ "${DELETE_OLD_BACKUPS,,}" = true ]; then - - if [ -z "${OLD_BACKUP_DAYS}" ]; then - echo "Unable to delete old backups, OLD_BACKUP_DAYS is empty." - if [ -n "${DISCORD_WEBHOOK_URL}" ]; then - /home/steam/server/discord.sh "Unable to delete old backups, OLD_BACKUP_DAYS is empty." "warn" - fi - elif [[ "${OLD_BACKUP_DAYS}" =~ ^[0-9]+$ ]]; then - echo "Removing backups older than ${OLD_BACKUP_DAYS} days" - if [ -n "${DISCORD_WEBHOOK_URL}" ] && [ -n "${DISCORD_PRE_BACKUP_DELETE_MESSAGE}" ]; then - /home/steam/server/discord.sh "Removing backups older than ${OLD_BACKUP_DAYS} days..." "in-progress" & - fi - find /palworld/backups/ -mindepth 1 -maxdepth 1 -mtime "+${OLD_BACKUP_DAYS}" -type f -name 'palworld-save-*.tar.gz' -print -delete - if [ -n "${DISCORD_WEBHOOK_URL}" ]; then - /home/steam/server/discord.sh "Removed backups older than ${OLD_BACKUP_DAYS} days" "success" - fi - else - echo "Unable to delete old backups, OLD_BACKUP_DAYS is not an integer. OLD_BACKUP_DAYS=${OLD_BACKUP_DAYS}" - if [ -n "${DISCORD_WEBHOOK_URL}" ]; then - /home/steam/server/discord.sh "Unable to delete old backups, OLD_BACKUP_DAYS is not an integer. OLD_BACKUP_DAYS=${OLD_BACKUP_DAYS}" "failure" - fi - fi -fi \ No newline at end of file +LogError "Unable to delete old backups, OLD_BACKUP_DAYS is not an integer. OLD_BACKUP_DAYS=${OLD_BACKUP_DAYS}" +DiscordMessage "Unable to delete old backups, OLD_BACKUP_DAYS is not an integer. OLD_BACKUP_DAYS=${OLD_BACKUP_DAYS}" "failure" \ No newline at end of file diff --git a/scripts/compile-settings.sh b/scripts/compile-settings.sh index 4c4f93ce8..d314b42e0 100755 --- a/scripts/compile-settings.sh +++ b/scripts/compile-settings.sh @@ -9,17 +9,17 @@ mkdir -p "$config_dir" || exit # If file exists then check if it is writable if [ -f "$config_file" ]; then if ! isWritable "$config_file"; then - echo "Unable to create $config_file" + LogError "Unable to create $config_file" exit 1 fi # If file does not exist then check if the directory is writable elif ! isWritable "$config_dir"; then # Exiting since the file does not exist and the directory is not writable. - echo "Unable to create $config_file" + LogError "Unable to create $config_file" exit 1 fi -echo "Compiling PalWorldSettings.ini..." +LogAction "Compiling PalWorldSettings.ini" export DIFFICULTY=${DIFFICULTY:-None} export DAYTIME_SPEEDRATE=${DAYTIME_SPEEDRATE:-1.000000} @@ -158,4 +158,4 @@ cat > "$config_file" </dev/null done @@ -45,7 +45,7 @@ fi mapfile -t restore_pids < <(pgrep restore) if [ "${#restore_pids[@]}" -ne 0 ]; then - echo "Waiting for restore to finish" + LogInfo "Waiting for restore to finish" for pid in "${restore_pids[@]}"; do tail --pid="$pid" -f 2>/dev/null done diff --git a/scripts/restore.sh b/scripts/restore.sh index 207748fb3..9f4bac15b 100644 --- a/scripts/restore.sh +++ b/scripts/restore.sh @@ -1,9 +1,11 @@ #!/bin/bash +# shellcheck source=/dev/null +source "/home/steam/server/helper_functions.sh" # Backup file directory path BACKUP_DIRECTORY_PATH="/palworld/backups" -# Resotre path +# Restore path RESTORE_PATH="/palworld/Pal" # Copy the save file before restore temporary path @@ -11,84 +13,84 @@ TMP_SAVE_PATH="/palworld/backups/restore-"$(date +"%Y-%m-%d_%H-%M-%S") # shellcheck disable=SC2317 term_error_handler() { - echo "An error occurred during server shutdown." + LogError "An error occurred during server shutdown." exit 1 } # shellcheck disable=SC2317 restore_error_handler() { - printf "\033[0;31mAn error occurred during restore.\033[0m\n" + LogError "Error occurred during restore." if [ -d "$TMP_SAVE_PATH/Saved" ]; then read -rp "I have a backup before recovery can proceed. Do you want to recovery it? (y/n): " RUN_ANSWER if [[ ${RUN_ANSWER,,} == "y" ]]; then rm -rf "$RESTORE_PATH/Saved" mv "$TMP_SAVE_PATH/Saved" "$RESTORE_PATH" - printf "\e[0;32mRecovery complete.\e[0m\n" + PrintSuccess "Recovery Complete" fi fi - echo "Clean up the temporary directory." + LogInfo "Clean up the temporary directory." rm -rf "$TMP_PATH" "$TMP_SAVE_PATH" exit 1 } if [ "${RCON_ENABLED}" != true ]; then - echo "RCON is not enabled. Please enable RCON to use this feature." + LogWarn "RCON is not enabled. Please enable RCON to use this feature." exit 1 fi # Show up backup list -echo "Backup List:" +LogInfo "Backup List:" mapfile -t BACKUP_FILES < <(find "$BACKUP_DIRECTORY_PATH" -type f -name "*.tar.gz" | sort) select BACKUP_FILE in "${BACKUP_FILES[@]}"; do if [ -n "$BACKUP_FILE" ]; then - echo "Selected backup: $BACKUP_FILE" + LogInfo "Selected backup: $BACKUP_FILE" break else - echo "Invalid selection. Please try again." + LogWarn "Invalid selection. Please try again." fi done if [ -f "$BACKUP_FILE" ]; then - printf "\033[0;31mThis script has been designed to help you restore; however, I am not responsible for any data loss. It is recommended that you create a backup beforehand, and in the event of script failure, be prepared to restore it manually.\033[0m\n" - echo "Do you understand the above and would you like to proceed with this command?" + LogInfo "This script has been designed to help you restore; however, I am not responsible for any data loss. It is recommended that you create a backup beforehand, and in the event of script failure, be prepared to restore it manually." + LogInfo "Do you understand the above and would you like to proceed with this command?" read -rp "When you run it, the server will be stopped and the recovery will proceed. (y/n): " RUN_ANSWER if [[ ${RUN_ANSWER,,} == "y" ]]; then - printf "\e[0;32m*****STARTING PROCESS*****\e[0m\n" + LogAction "Starting Recovery Process" # Shutdown server trap 'term_error_handler' ERR if [ "${RCON_ENABLED}" = true ]; then - printf "\e[0;32m*****SHUTDOWN SERVER*****\e[0m\n" - rcon-cli -c /home/steam/server/rcon.yaml save - rcon-cli -c /home/steam/server/rcon.yaml "shutdown 1" + LogAction "Shutting Down Server" + RCON save + RCON "shutdown 1" else - echo "RCON is not enabled. Please enable RCON to use this feature. Unable to restore backup." + LogWarn "RCON is not enabled. Please enable RCON to use this feature. Unable to restore backup." exit 1 fi mapfile -t server_pids < <(pgrep PalServer-Linux-Test) if [ "${#server_pids[@]}" -ne 0 ]; then - echo "Waiting for Palworld to exit.." + LogInfo "Waiting for Palworld to exit.." for pid in "${server_pids[@]}"; do tail --pid="$pid" -f 2>/dev/null done fi - printf "\e[0;32mShutdown complete.\e[0m\n" + LogSuccess "Shutdown Complete" trap - ERR trap 'restore_error_handler' ERR - - printf "\e[0;32m*****START RESTORE*****\e[0m\n" + + LogAction "Starting Restore" # Recheck the backup file if [ -f "$BACKUP_FILE" ]; then # Copy the save file before restore if [ -d "$RESTORE_PATH/Saved" ]; then - echo "Saves the current state before the restore proceeds." - echo "$TMP_SAVE_PATH" + LogInfo "Saves the current state before the restore proceeds." + LogInfo "$TMP_SAVE_PATH" mkdir -p "$TMP_SAVE_PATH" if [ "$(id -u)" -eq 0 ]; then chown steam:steam "$TMP_SAVE_PATH" @@ -98,8 +100,7 @@ if [ -f "$BACKUP_FILE" ]; then while [ ! -d "$TMP_SAVE_PATH/Saved" ]; do sleep 1 done - - printf "\e[0;32mSave complete.\e[0m\n" + LogSuccess "Save Complete" fi # Create tmp directory @@ -116,22 +117,20 @@ if [ -f "$BACKUP_FILE" ]; then # Move the backup file to the restore directory \cp -rf -f "$TMP_PATH/Saved/" "$RESTORE_PATH" - - echo "Clean up the temporary directory." + LogInfo "Clean up the temporary directory." rm -rf "$TMP_PATH" "$TMP_SAVE_PATH" - - printf "\e[0;32mRestore complete!!!! Please restart the Docker container\e[0m\n" - + LogSuccess "Restore Complete" + LogInfo "Please restart the container" exit 0 else - echo "The selected backup file does not exist." + LogError "The selected backup file does not exist." exit 1 fi else - echo "Abort the recovery." + LogWarn "Abort the recovery." exit 1 fi else - echo "The selected backup file does not exist." + LogError "The selected backup file does not exist." exit 1 fi \ No newline at end of file diff --git a/scripts/start.sh b/scripts/start.sh index 704e9e879..9a0fa4b08 100644 --- a/scripts/start.sh +++ b/scripts/start.sh @@ -14,23 +14,27 @@ architecture=$(dpkg --print-architecture) # Get host kernel page size kernel_page_size=$(getconf PAGESIZE) -# Check kernel page size for arm64 hosts before running steamcmd +# Check kernel page size for arm64 hosts before running steamcmdac if [ "$architecture" == "arm64" ] && [ "$kernel_page_size" != "4096" ]; then - echo "Only ARM64 hosts with 4k page size is supported." + LogError "Only ARM64 hosts with 4k page size is supported." exit 1 fi -if [ "${UPDATE_ON_BOOT,,}" = true ]; then - printf "\e[0;32m%s\e[0m\n" "*****STARTING INSTALL/UPDATE*****" - - if [ -n "${DISCORD_WEBHOOK_URL}" ] && [ -n "${DISCORD_PRE_UPDATE_BOOT_MESSAGE}" ]; then - /home/steam/server/discord.sh "${DISCORD_PRE_UPDATE_BOOT_MESSAGE}" "in-progress" & - fi - - /home/steam/steamcmd/steamcmd.sh +@sSteamCmdForcePlatformType linux +@sSteamCmdForcePlatformBitness 64 +force_install_dir "/palworld" +login anonymous +app_update 2394010 validate +quit +IsInstalled +ServerInstalled=$? +if [ "$ServerInstalled" == 1 ]; then + LogInfo "Server installation not detected." + LogAction "Starting Installation" + InstallServer +fi - if [ -n "${DISCORD_WEBHOOK_URL}" ] && [ -n "${DISCORD_POST_UPDATE_BOOT_MESSAGE}" ]; then - /home/steam/server/discord.sh "${DISCORD_POST_UPDATE_BOOT_MESSAGE}" "success" +# Update Only If Already Installed +if [ "$ServerInstalled" == 0 ] && [ "${UPDATE_ON_BOOT,,}" == true ]; then + UpdateRequired + IsUpdateRequired=$? + if [ "$IsUpdateRequired" == 0 ]; then + LogAction "Starting Update" + InstallServer fi fi @@ -46,13 +50,17 @@ else STARTCOMMAND=("./PalServer.sh") fi + +#Validate Installation if ! fileExists "${STARTCOMMAND[0]}"; then - echo "Try restarting with UPDATE_ON_BOOT=true" + LogError "Server Not Installed Properly" exit 1 fi + isReadable "${STARTCOMMAND[0]}" || exit isExecutable "${STARTCOMMAND[0]}" || exit +# Prepare Arguments if [ -n "${PORT}" ]; then STARTCOMMAND+=("-port=${PORT}") fi @@ -70,14 +78,12 @@ if [ "${MULTITHREADING,,}" = true ]; then 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!***" + LogAction "GENERATING CONFIG" + LogWarn "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*****" - + LogAction "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 @@ -90,31 +96,30 @@ if [ "${DISABLE_GENERATE_SETTINGS,,}" = true ]; then 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***" + LogAction "GENERATING CONFIG" + LogInfo "Using Env vars to create PalWorldSettings.ini" /home/steam/server/compile-settings.sh || exit fi -printf "\e[0;32m%s\e[0m\n" "*****GENERATING CRONTAB*****" - +LogAction "GENERATING CRONTAB" rm -f "/home/steam/server/crontab" if [ "${BACKUP_ENABLED,,}" = true ]; then - echo "BACKUP_ENABLED=${BACKUP_ENABLED,,}" - echo "Adding cronjob for auto backups" + LogInfo "BACKUP_ENABLED=${BACKUP_ENABLED,,}" + LogInfo "Adding cronjob for auto backups" echo "$BACKUP_CRON_EXPRESSION bash /usr/local/bin/backup" >> "/home/steam/server/crontab" supercronic -quiet -test "/home/steam/server/crontab" || exit fi if [ "${AUTO_UPDATE_ENABLED,,}" = true ] && [ "${UPDATE_ON_BOOT}" = true ]; then - echo "AUTO_UPDATE_ENABLED=${AUTO_UPDATE_ENABLED,,}" - echo "Adding cronjob for auto updating" + LogInfo "AUTO_UPDATE_ENABLED=${AUTO_UPDATE_ENABLED,,}" + LogInfo "Adding cronjob for auto updating" echo "$AUTO_UPDATE_CRON_EXPRESSION bash /usr/local/bin/update" >> "/home/steam/server/crontab" supercronic -quiet -test "/home/steam/server/crontab" || exit fi if [ "${AUTO_REBOOT_ENABLED,,}" = true ] && [ "${RCON_ENABLED,,}" = true ]; then - echo "AUTO_REBOOT_ENABLED=${AUTO_REBOOT_ENABLED,,}" - echo "Adding cronjob for auto rebooting" + LogInfo "AUTO_REBOOT_ENABLED=${AUTO_REBOOT_ENABLED,,}" + LogInfo "Adding cronjob for auto rebooting" echo "$AUTO_REBOOT_CRON_EXPRESSION bash /home/steam/server/auto_reboot.sh" >> "/home/steam/server/crontab" supercronic -quiet -test "/home/steam/server/crontab" || exit fi @@ -122,9 +127,9 @@ fi if { [ "${AUTO_UPDATE_ENABLED,,}" = true ] && [ "${UPDATE_ON_BOOT,,}" = true ]; } || [ "${BACKUP_ENABLED,,}" = true ] || \ [ "${AUTO_REBOOT_ENABLED,,}" = true ]; then supercronic "/home/steam/server/crontab" & - echo "Cronjobs started" + LogInfo "Cronjobs started" else - echo "No Cronjobs found" + LogInfo "No Cronjobs found" fi # Configure RCON settings @@ -134,16 +139,11 @@ default: password: "${ADMIN_PASSWORD}" EOL -printf "\e[0;32m%s\e[0m\n" "*****STARTING SERVER*****" -if [ -n "${DISCORD_WEBHOOK_URL}" ] && [ -n "${DISCORD_PRE_START_MESSAGE}" ]; then - /home/steam/server/discord.sh "${DISCORD_PRE_START_MESSAGE}" "success" & -fi +LogAction "Starting Server" +DiscordMessage "${DISCORD_PRE_START_MESSAGE}" "success" echo "${STARTCOMMAND[*]}" "${STARTCOMMAND[@]}" -if [ -n "${DISCORD_WEBHOOK_URL}" ] && [ -n "${DISCORD_POST_SHUTDOWN_MESSAGE}" ]; then - /home/steam/server/discord.sh "${DISCORD_POST_SHUTDOWN_MESSAGE}" "failure" -fi - -exit 0 +DiscordMessage "${DISCORD_POST_SHUTDOWN_MESSAGE}" "failure" +exit 0 \ No newline at end of file diff --git a/scripts/update.sh b/scripts/update.sh index f9b6528ce..5489bf5c9 100644 --- a/scripts/update.sh +++ b/scripts/update.sh @@ -2,57 +2,32 @@ # shellcheck source=/dev/null source "/home/steam/server/helper_functions.sh" -if [ "${UPDATE_ON_BOOT}" = false ]; then - echo "Update on Boot needs to be enabled for auto updating" - if [ -n "${DISCORD_WEBHOOK_URL}" ]; then - /home/steam/server/discord.sh "Update on Boot needs to be enabled for auto updating" "warn" - fi - exit 0 +UpdateRequired +updateRequired=$? +# Check if Update was actually required +if [ "$updateRequired" != 0 ]; then + exit 0 fi -temp_file=$(mktemp) -http_code=$(curl https://api.steamcmd.net/v1/info/2394010 --output "$temp_file" --silent --location --write-out "%{http_code}") - -CURRENT_MANIFEST=$(awk '/manifest/{count++} count==2 {print $2; exit}' /palworld/steamapps/appmanifest_2394010.acf) -TARGET_MANIFEST=$(grep -Po '"2394012".*"gid": "\d+"' <"$temp_file" | sed -r 's/.*("[0-9]+")$/\1/') -rm "$temp_file" - -if [ "$http_code" -ne 200 ]; then - echo "There was a problem reaching the Steam api. Unable to check for updates!" - if [ -n "${DISCORD_WEBHOOK_URL}" ]; then - /home/steam/server/discord.sh "There was a problem reaching the Steam api. Unable to check for updates!" "failure" & - fi +if [ "${UPDATE_ON_BOOT}" = false ]; then + LogWarn "An update is available however, UPDATE_ON_BOOT needs to be enabled for auto updating" + DiscordMessage "An update is available however, UPDATE_ON_BOOT needs to be enabled for auto updating" "warn" exit 1 fi -if [ -z "$TARGET_MANIFEST" ]; then - echo "The server response does not contain the expected BuildID. Unable to check for updates!" - if [ -n "${DISCORD_WEBHOOK_URL}" ]; then - /home/steam/server/discord.sh "Steam servers response does not contain the expected BuildID. Unable to check for updates!" "failure" & - fi +if [ "${RCON_ENABLED,,}" = false ]; then + LogWarn "An update is available however auto updating without rcon is not supported" + DiscordMessage "An update is available however auto updating without rcon is not supported" "warn" exit 1 fi -echo "player count: $(get_player_count)" -if [ "$CURRENT_MANIFEST" != "$TARGET_MANIFEST" ]; then - if [ "${RCON_ENABLED,,}" != true ]; then - echo "An update is available however auto updating without rcon is not supported" - if [ -n "${DISCORD_WEBHOOK_URL}" ]; then - /home/steam/server/discord.sh "An update is available however auto updating without rcon is not supported" "warn" - fi - exit 0 - fi - echo "New Build was found. Updating the server from $CURRENT_MANIFEST to $TARGET_MANIFEST." - rm /palworld/steamapps/appmanifest_2394010.acf - if [ "$(get_player_count)" -gt 0 ]; then - if [ -n "${DISCORD_WEBHOOK_URL}" ]; then - /home/steam/server/discord.sh "Server will update in ${AUTO_UPDATE_WARN_MINUTES} minutes" "info" & - fi - rcon-cli -c /home/steam/server/rcon.yaml "broadcast Server_will_update_in_${AUTO_UPDATE_WARN_MINUTES}_Minutes" - sleep "${AUTO_UPDATE_WARN_MINUTES}m" - fi - backup - rcon-cli -c /home/steam/server/rcon.yaml "shutdown 1" -else - echo "The Server is up to date!" -fi \ No newline at end of file +if [ "$(get_player_count)" -gt 0 ]; then + LogAction "Updating the server from $CURRENT_MANIFEST to $TARGET_MANIFEST." + DiscordMessage "Server will update in ${AUTO_UPDATE_WARN_MINUTES} minutes" + RCON "broadcast The_Server_will_update_in_${AUTO_UPDATE_WARN_MINUTES}_Minutes" + sleep "${AUTO_UPDATE_WARN_MINUTES}m" +fi + +rm /palworld/steamapps/appmanifest_2394010.acf +backup +RCON "shutdown 1" \ No newline at end of file