#!/bin/bash ################ # CHANGE THESE # ################ # path to your build_info.json file; include the file name DISCORD_BUILD_INFO_PATH="/usr/share/discord/resources/build_info.json" # for debian-based linux distributions (.deb installers) DISCORD_PLATFORM="linux" DISCORD_FORMAT="deb" ########################### # DON'T CHANGE THIS STUFF # ########################### # check for sudo if [ $(id -g) -ne 0 ]; then echo "Please run as sudo" exit 2 fi apt-get update && apt-get install -y jq # get currently installed version of Discord ver_current=$(jq -r ".version" "$DISCORD_BUILD_INFO_PATH") echo "Discord version $ver_current installed" # check latest available Discord version by looking at the headers of the latest Discord download URL pre_ver_available=$(curl -s -I "https://discord.com/api/download?platform=$DISCORD_PLATFORM&format=$DISCORD_FORMAT" | grep location) # trim everything before and after the version number ver_available="${pre_ver_available#*linux/}" ver_available="${ver_available%/*}" echo "Discord version $ver_available available" if [ "$ver_current" = "$ver_available" ] ; then echo "Discord is up to date!" exit 0 fi echo "Discord is not up to date, editing $DISCORD_BUILD_INFO_PATH" jq ".version = \"$ver_available\"" $DISCORD_BUILD_INFO_PATH > discord_build_info_tmp.json chmod 644 discord_build_info_tmp.json mv discord_build_info_tmp.json "$DISCORD_BUILD_INFO_PATH" killall Discord