tf2-trigger/checker.sh

22 lines
1.1 KiB
Bash
Executable File

#!/bin/bash
if [ -f .env ]
then
export $(cat .env | xargs)
fi
version=`curl -s "https://ql.syncore.org/api/query?hosts=88.198.49.46%3A$1" | jq -r .servers[0].info.serverVersion`
up_to_date=`curl -s "https://api.steampowered.com/ISteamApps/UpToDateCheck/v1/?appid=440&version=${version}" | jq -r .response.up_to_date`
if $up_to_date
then
echo "Server is up to date, nothin todo."
else
new_version=`curl -s "https://api.steampowered.com/ISteamApps/UpToDateCheck/v1/?appid=440&version=${version}" | jq -r .response.required_version`
echo "$2: There has been an update, server version: ${version}, newest version: ${new_version}":
curl -H "Content-Type: application/json" -d "{\"username\": \"Server Updater\", \"content\": \"$2: There has been an update, server version: $version, newest version: $new_version\"}" $discord_webhook
(cd ~/docker/tf2; docker compose exec tf2dm-1 ./rcon -H 88.198.49.46 -p $1 -P $rcon_password changelevel cp_process_final)
curl -H "Content-Type: application/json" -d "{\"username\": \"Server Updater\", \"content\": \"$2 has been updated to the newest version: $new_version\"}" $discord_webhook_changelog
fi