-
Notifications
You must be signed in to change notification settings - Fork 0
/
discord.sh
52 lines (43 loc) · 1.71 KB
/
discord.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/bin/bash
update_discord () {
curl -L "https://discord.com/api/download?platform=linux&format=tar.gz" -o "/tmp/$new_version.tar.gz"
if [ -d ~/.local/bin/Discord ]; then
rm -rf ~/.local/bin/Discord
fi
if [ ! -d ~/.local/bin ]; then
mkdir -p ~/.local/bin
fi
tar -xf "/tmp/$new_version.tar.gz" -C ~/.local/bin
rm "/tmp/$new_version.tar.gz"
echo "$new_version" > ~/.discordv
}
# script starts here
cd ~
if [ -f ~/.discordv ]; then
installed_version=$(cat ~/.discordv)
filename=$(basename "$(curl -s -L -I "https://discord.com/api/download?platform=linux&format=tar.gz" | grep -i "location" | awk '{print $2}' | tr -d '\r')")
new_version=$(echo "$filename" | grep -oP '(?<=discord-)[0-9.]+')
if [[ "$new_version" > "$installed_version" ]]; then
notify-send "New version available: $new_version"
update_discord
cd ~/.local/bin/Discord
./Discord --no-sandbox --disable-gpu-sandbox &
exit 0
else
notify-send "No new version available. Lauching Discord..."
cd ~/.local/bin/Discord
./Discord --no-sandbox --disable-gpu-sandbox &
exit 0
fi
else
echo "The ~/.discordv file does not exist. Cannot check for updates."
if [ ! -d ~/.local/bin/Discord ]; then
notify-send "Discord not installed. Downloading Discord..."
filename=$(basename "$(curl -s -L -I "https://discord.com/api/download?platform=linux&format=tar.gz" | grep -i "location" | awk '{print $2}' | tr -d '\r')")
new_version=$(echo "$filename" | grep -oP '(?<=discord-)[0-9.]+')
update_discord
cd ~/.local/bin/Discord
./Discord --no-sandbox --disable-gpu-sandbox &
exit 0
fi
fi