Skip to content

Instantly share code, notes, and snippets.

@VitorBlog
Last active May 15, 2024 22:11
Show Gist options
  • Save VitorBlog/1d8f1170923e2c1f71e1403cd1679e19 to your computer and use it in GitHub Desktop.
Save VitorBlog/1d8f1170923e2c1f71e1403cd1679e19 to your computer and use it in GitHub Desktop.
Debian discord updater

Debian Discord Updater

Keeping your Discord client up-to-date is now hassle-free with this simple updater script.

Usage

Just execute the script, and it will handle the update process seamlessly.

Setting Up Automatic Updates

To ensure Discord update on boot, follow these steps:

  1. Open the crontab file using the command:

    sudo crontab -e
  2. When prompted to select an editor, choose your preferred one. For example:

    Select an editor. To change later, run 'select-editor'.
      1. /bin/nano        <---- easiest
      2. /usr/bin/vim.tiny
      3. /bin/ed
    
    Choose 1-3 [1]: 1
    
  3. Add the following line to the end of the file, replacing <path/to/discord-updater.sh> with the actual path to your discord-updater.sh script:

    @reboot /path/to/discord-updater.sh
  4. In some cases, you may need to enable the cron service by running:

    sudo systemctl enable cron.service

Now, your Discord client will automatically update upon system reboot.

#!/bin/bash
discordUrl="https://discord.com/api/download?platform=linux&format=deb"
build_info=$(cat /usr/share/discord/resources/build_info.json)
version=$(echo $build_info | grep -o '"version": "[^"]*"' | sed 's/"version": "\(.*\)"/\1/')
echo "Checking discord version..."
if [[ $(curl -Ls -o /dev/null -w %{url_effective} $discordUrl | grep -o '[0-9]*\.[0-9]*\.[0-9]*\.deb') != "$version.deb" ]] ;
then
echo "Updating discord to new version..."
curl -L -o /tmp/discord.deb $discordUrl
sudo dpkg -i /tmp/discord.deb
discord
else
echo "Discord is updated."
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment