-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdiscord-installer
More file actions
executable file
·93 lines (79 loc) · 1.98 KB
/
discord-installer
File metadata and controls
executable file
·93 lines (79 loc) · 1.98 KB
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#!/bin/sh
# yeh, really...
# but if you are reading this then you are a degenerate too!
myname=${0##*/}
config="${XDG_CONFIG_HOME:-$HOME/.config}/discord-installer/configrc"
disable_notifs=""
channel="stable"
if [ -e "$config" ]; then
. "$config"
fi
install_dir=/tmp/discord-installer
notif_me () {
if [ -z "$disable_notifs" ]; then
notify-send -i discord-canary "$1"
else
printf '[%s]: %s\n\n' "$myname" "$1"
fi
}
_update () {
mkdir -p "$install_dir"
STABLE="https://discord.com/api/download?platform=linux&format=deb"
CANARY="https://discord.com/api/download/canary?platform=linux&format=deb"
case "$channel" in
stable)
URL="$STABLE"
;;
canary)
URL="$CANARY"
;;
*)
notif_me "invalid channel ${channel}, use stable or canary, exiting now."
exit 1
;;
esac
wget -c -P "$install_dir"/ --content-disposition "$URL"
}
_install () {
has_tty=""
if tty | grep -qF -e "dev/tty" -e "dev/pts"; then
has_tty=1
fi
if [ -n "$has_tty" ]; then
sudo apt install "$install_dir"/discord-*.*.deb -y
else
if [ -n "$SUDO_ASKPASS" ]; then
sudo -A apt install "$install_dir"/discord-*.*.deb -y
else
pkexec apt install "$install_dir"/discord-*.*.deb -y
fi
fi
}
_clean () {
rm "$install_dir"/discord-*.*.deb
}
_better () {
type betterdiscordctl || betterdiscordinstaller
betterdiscordctl -v reinstall
}
_upgrade () {
_clean
notif_me "Downloading update"
_update
notif_me "Installing update"
_install
notif_me "Installed update"
# _better
_clean
}
if tty | grep -qF -e "dev/tty"; then
disable_notifs=1
notif_me "running inside a tty, maybe consider installing this stuff when you got a GUI"
fi
case "$1" in
"update") _update ;;
"upgrade") _upgrade ;;
"install") _install ;;
"clean") _clean ;;
"better") _better ;;
esac