Skip to content

Instantly share code, notes, and snippets.

@papamoose
Created May 14, 2024 06:06
Show Gist options
  • Save papamoose/2f6b653aeea68a58ba11c68ae131b5d7 to your computer and use it in GitHub Desktop.
Save papamoose/2f6b653aeea68a58ba11c68ae131b5d7 to your computer and use it in GitHub Desktop.
#!/bin/bash
url="https://discord.com/api/download?platform=linux"
remote_version=$(curl -sIL $url | grep location: | cut -d/ -f7 | sed -ne 's/discord-\([0-9.]*\)\.deb/\1/p' | tr -d '\r$')
local_version=$(dpkg-query -W -f'${Version}\n' discord)
rc=$(dpkg --compare-versions "${local_version}" "lt" "${remote_version}"; echo $?)
if [ $rc -eq 0 ]; then
curl -s -L -o /tmp/discord.deb "$url"
sudo dpkg -i /tmp/discord.deb
rm -f /tmp/discord.deb
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment