If you are using discord
package from pacman
from time to time you get message that you need to download discord extract the package and replace existing /opt/discord
directory with new one.
This script is to automate this process. When you download discord archive (tar.gz
) from the discord prompt it will be placed in ~/Downloads
. This script will look for this archive, unpack it and place new archive in coorect place. Now discord should work when you open it again.
#!/bin/bash
NEW_DISORD_ARCHIVE=$(find ~/Downloads/ -name "discord-*.tar.gz" -printf '%T+ %p\n' | sort | tail -n 1 | cut -d' ' -f2)
DISCORD_LOCATION=/opt/discord
DISCORD_TMP_LOCATION=/tmp/Discord
if [ "$EUID" -eq 0 ]; then
echo "Please run as regular user"
exit
fi
if [ ! -f "$NEW_DISORD_ARCHIVE" ]; then
echo "Please download discord archive first"
exit
fi
rm -rf "$DISCORD_TMP_LOCATION"
tar -xf "$NEW_DISORD_ARCHIVE" -C /tmp/
sudo rm -rf "$DISCORD_LOCATION"
sudo mv "$DISCORD_TMP_LOCATION" "$DISCORD_LOCATION"
rm -rf "$NEW_DISORD_ARCHIVE"