Last active
July 18, 2024 00:34
-
-
Save kueller/57a93bf231fb6240335ff2ca5a4121dc to your computer and use it in GitHub Desktop.
Script to auto-update Discord on Linux when you have a manual install with a tarball. Change $BIN_DIR and $DOWNLOAD_DIR to fit your locations.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Setup: | |
# Change BIN_DIR to one folder *above* where your Discord is installed | |
# and set DOWNLOAD_DIR to whatever directory you want the temporary | |
# download to go to. | |
# | |
# Then simply launch this script instead of the Discord executable. | |
DISCORD_URL="https://discord.com/api/download?platform=linux&format=tar.gz" | |
# User custom variables | |
BIN_DIR="/level/above/discord" | |
DOWNLOAD_DIR="/your/downloads/directory" | |
DISCORD_DIR="$BIN_DIR/Discord" | |
INFO_FILE="$DISCORD_DIR/resources/build_info.json" | |
CURL_WRITE_OTP="%{redirect_url}" | |
CURRENT_VER=$( \ | |
cat $INFO_FILE | \ | |
sed -z "s/\n/ /g" | \ | |
python -c \ | |
"import json; d=json.loads(input()); print(d['version'])" | |
) | |
CURRENT_URL=$(\ | |
curl -Is -o /dev/null \ | |
-w $CURL_WRITE_OTP \ | |
$DISCORD_URL | |
) | |
LATEST_VER=$( echo $CURRENT_URL | cut -d "/" -f 6 ) | |
LATEST_FILENAME=$( echo $CURRENT_URL | cut -d "/" -f 7 ) | |
if [ $CURRENT_VER != $LATEST_VER ]; then | |
wget -O $DOWNLOAD_DIR/$LATEST_FILENAME "$DISCORD_URL" | |
tar -xvf $DOWNLOAD_DIR/$LATEST_FILENAME -C $BIN_DIR | |
rm $DOWNLOAD_DIR/$LATEST_FILENAME | |
fi | |
$DISCORD_DIR/Discord |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment