diff --git a/scripts/auto_reboot.sh b/scripts/auto_reboot.sh index 527fa89ab..13f1de424 100644 --- a/scripts/auto_reboot.sh +++ b/scripts/auto_reboot.sh @@ -22,11 +22,11 @@ fi if [[ "${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" + RCON "broadcast The_Server_will_reboot_in_${i}_Minutes" sleep "1m" done - rcon-cli -c /home/steam/server/rcon.yaml save - rcon-cli -c /home/steam/server/rcon.yaml "shutdown 1" + RCON save + RCON "shutdown 1" exit 0 fi diff --git a/scripts/backup.sh b/scripts/backup.sh index ab5b5c525..119ffa126 100644 --- a/scripts/backup.sh +++ b/scripts/backup.sh @@ -4,7 +4,7 @@ source "/home/steam/server/helper_functions.sh" 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") diff --git a/scripts/helper_functions.sh b/scripts/helper_functions.sh index 61bcac876..4be52b842 100644 --- a/scripts/helper_functions.sh +++ b/scripts/helper_functions.sh @@ -75,7 +75,7 @@ get_player_count() { echo 0 return 0 fi - player_list=$(rcon-cli -c /home/steam/server/rcon.yaml "ShowPlayers") + player_list=$(RCON "ShowPlayers") echo -n "${player_list}" | wc -l } @@ -128,6 +128,11 @@ DiscordMessage() { fi } +# RCON Call +RCON() { + local args="$1" + echo rcon-cli -c /home/steam/server/rcon.yaml "$args" +} # Returns 0 if Update Required @@ -138,9 +143,9 @@ LogAction "Checking for new update" temp_file=$(mktemp) http_code=$(curl https://api.steamcmd.net/v1/info/2394010 --output "$temp_file" --silent --location --write-out "%{http_code}") +TARGET_MANIFEST=$(grep -Po '"2394012".*"gid": "\d+"' <"$temp_file" | sed -r 's/.*("[0-9]+")$/\1/') -CURRENTBUILD=$(awk '/buildid/{ print $2 }' < /palworld/steamapps/appmanifest_2394010.acf) -TARGETBUILD=$(grep -P '"public": {"buildid": "\d+"' -o <"$temp_file" | sed -r 's/.*("[0-9]+")$/\1/') +CURRENT_MANIFEST=$(awk '/manifest/{count++} count==2 {print $2; exit}' /palworld/steamapps/appmanifest_2394010.acf) rm "$temp_file" if [ "$http_code" -ne 200 ]; then @@ -149,16 +154,16 @@ if [ "$http_code" -ne 200 ]; then return 2 fi -if [ -z "$TARGETBUILD" ]; then +if [ -z "$TARGET_MANIFEST" ]; then LogError "The server response does not contain the expected BuildID. Unable to check for updates!" DiscordMessage "Steam servers response does not contain the expected BuildID. Unable to check for updates!" "failure" return 2 fi -if [ "$CURRENTBUILD" != "$TARGETBUILD" ]; then +if [ "$CURRENT_MANIFEST" != "$TARGET_MANIFEST" ]; then LogInfo "An Update Is Available." - LogInfo "Current Version: $CURRENTBUILD" - LogInfo "Latest Version: $TARGETBUILD." + LogInfo "Current Version: $CURRENT_MANIFEST" + LogInfo "Latest Version: $TARGET_MANIFEST." return 0 fi diff --git a/scripts/init.sh b/scripts/init.sh index b9508dc06..219be9bb6 100644 --- a/scripts/init.sh +++ b/scripts/init.sh @@ -19,8 +19,8 @@ term_handler() { DiscordMessage "${DISCORD_PRE_SHUTDOWN_MESSAGE}" "in-progress" if [ "${RCON_ENABLED,,}" = true ]; then - rcon-cli save - rcon-cli "shutdown 1" + RCON save + RCON "shutdown 1" else # Does not save kill -SIGTERM "$(pidof PalServer-Linux-Test)" fi diff --git a/scripts/restore.sh b/scripts/restore.sh index 5b96d80e9..9f4bac15b 100644 --- a/scripts/restore.sh +++ b/scripts/restore.sh @@ -63,8 +63,8 @@ if [ -f "$BACKUP_FILE" ]; then if [ "${RCON_ENABLED}" = true ]; then LogAction "Shutting Down Server" - rcon-cli -c /home/steam/server/rcon.yaml save - rcon-cli -c /home/steam/server/rcon.yaml "shutdown 1" + RCON save + RCON "shutdown 1" else LogWarn "RCON is not enabled. Please enable RCON to use this feature. Unable to restore backup." exit 1 diff --git a/scripts/update.sh b/scripts/update.sh index 66c69321b..5489bf5c9 100644 --- a/scripts/update.sh +++ b/scripts/update.sh @@ -24,10 +24,10 @@ fi 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-cli -c /home/steam/server/rcon.yaml "broadcast The_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-cli -c /home/steam/server/rcon.yaml "shutdown 1" \ No newline at end of file +RCON "shutdown 1" \ No newline at end of file