Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 52 additions & 24 deletions updatediscord.sh
Original file line number Diff line number Diff line change
@@ -1,28 +1,56 @@
#!/bin/bash
name="Discord"
tempname="discord.deb"
updateurl="https://discordapp.com/api/download?platform=linux&format=deb"
clear;
echo -e "Killing all Processes with name $name.";
# Killing all Processes using Discord name.
for KILLPID in `ps ax | grep $name | awk ' { print $1;}'`; do

if command -v dpkg &> /dev/null
then
PKG_TYPE="deb"
else
PKG_TYPE="tar.gz"
fi

PACKAGE="discord.$PKG_TYPE"
UPDATE_URL="https://discordapp.com/api/download?platform=linux&format=$PKG_TYPE"
RENAME=false


if [ $PKG_TYPE == "deb" ]
then
DPATH = "$HOME/Downloads"
elif [ -d "/usr/lib64/discord" ]
DPATH = "/usr/lib64"
RENAME=true
elif [ -d "usr/lib64/Discord" ]
DPATH = "/usr/lib64"
else
DPATH = "/usr/local/lib64"
fi

# Ensure our path exists
mkdir -p $DPATH

echo "Killing Discord processes!"
for KILLPID in `ps ax | grep Discord | awk ' { print $1;}'`; do
kill -9 $KILLPID &> /dev/null
done
echo -e "";
echo -e "Pulling $tempname from $updateurl";
# Pulling current version from Discord.com
wget "$updateurl" -O $pwd/$tempname >/dev/null 2>&1
echo -e "";
echo -e "Installing $tempname";
# Installing current version of Discord
dpkg -i $pwd/$tempname >/dev/null
echo -e "";
echo -e "Removing temp $tempname";
# Removing temp .deb file
rm -rf $tempname >/dev/null
echo -e "";
echo -e "Finished"
echo -e "";
echo -e "You can now launch Discord by typing: discord";
echo -e "";

echo "Downloading Discord updates"
wget $UPDATE_URL -O $DPATH/$PACKAGE

echo "Installing Discord updates"
cd $DPATH

if [ $PKG_TYPE == "deb" ]
then
dpkg -i $DPATH/$PACKAGE
else
tar xvf $PACKAGE
fi

if RENAME
then
rm -rf discord
mv Discord discord
fi

rm $PACKAGE

echo "Discord updated!"