forked from Joshix-1/Lightcord
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLULI.sh
319 lines (287 loc) · 10.2 KB
/
LULI.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
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
#!/bin/bash
# Original script by https://github.com/GermanBread
# Lightcord unified Linux installer by Germanbread
# Some variables
ALLOW_NIXOS='false'
GLOBAL_INSTALL_DIR='/opt'
LOCAL_INSTALL_DIR="$HOME/.lightcord"
# URL for downloads
ICON='https://raw.githubusercontent.com/Lightcord/Lightcord/master/discord.png'
LC_APPIMAGE='https://lightcord.org/api/gh/releases/Lightcord/Lightcord/dev/lightcord-linux-x86_64.AppImage'
LC='https://lightcord.org/api/v1/gh/releases/Lightcord/Lightcord/dev/lightcord-linux-x64.zip'
# Fallback URL
ALT_LC_APPIMAGE='https://github.com/Lightcord/Lightcord/releases/latest/download/Lightcord-linux-x86_64.AppImage'
ALT_LC='https://github.com/Lightcord/Lightcord/releases/latest/download/lightcord-linux-x64.zip'
# Some helper funtions
function Info {
tput setaf 8
tput bold
printf "==> "
tput setaf 15
printf "$1\n"
tput sgr0
}
function SubInfo {
tput setaf 8
printf "> "
printf "$1\n"
tput sgr0
}
function Warning {
tput setaf 3
tput bold
printf "==> "
tput setaf 11
printf "$1\n"
tput sgr0
}
function Error {
tput setaf 1
tput bold
printf "==> "
tput setaf 9
printf "$1\n"
tput sgr0
}
if [[ $TERM == dumb ]]; then
exit
fi
if [[ "$(whoami)" == "root" ]]; then
Error "Don't run this script as root"
exit
fi
# Check if unzip is installed
if [ ! -e /usr/bin/unzip ]; then
Warning "Unzip does not seem to be installed!\n\tThis script depends on this package.\n\tInstall unzip and restart this script.\n\tPress enter if you believe that this is a false-positive."
read
fi
cat << "logo_end"
_ _ _ _ _
| | (_)__ _| |_| |_ __ ___ _ _ __| |
| |__| / _` | ' \ _/ _/ _ \ '_/ _` |
|____|_\__, |_||_\__\__\___/_| \__,_|
|___/
Unified Linux Installer and Updater
logo_end
# First, we need to figure out what kind of install the user wants (AppImage or System-wide?)
printf "Please select\n"
printf "1: Install Lightcord for all users\n"
printf "2: Install Lightcord only for you (Appimage install)\n"
printf "\n"
#Repeat only if the user hasn't entered an integer...
while ! [[ $method =~ ^[0-9]+$ ]];
do
read method;
# If the entered value was not an integer, prompt the user again
if ! [[ $method =~ ^[0-9]+$ ]]; then
sleep 1
printf "$(tput setaf 9)Please try again$(tput sgr0)\n"
printf "1: Install Lightcord for all users\n"
printf "2: Install Lightcord only for you (Appimage install)\n"
printf "\n"
fi
done
if [[ $method == 1 ]]; then
Warning "Warning:\n\tBlindly running software as root is a massive security issue.\n\tIf you don't fully trust the software you're running DON'T RUN IT AS ROOT.\n\tIf you know exactly what you are doing, continue.\n\tOtherwise restart this script and choose the second option."
if [ -d "/nix" ] && [ $ALLOW_NIXOS == 'false' ]; then
Error "Error:\n\tUsing the global install option on NixOS is not supported due to the way this distribution handles software not present in the repositories.\n\tUse the AppImage install method instead.\n\tIf you still plan on installing Lightcord this way, change the \"ALLOW_NIXOS\" variable in this script to any value other than \"false\".\n\tYou should also modify the installation path variables if you want LC to not be wiped by NixOS."
exit;
fi # We want to prevent NixOS users from installing LC this way because:
# A) NixOS is very "special" i.e. it blocks LC from running
# B) /opt gets cleared upon boot
Info "Please enter your password to proceed"
sudo -K
if [[ "$(sudo whoami)" != "root" ]]; then
Error "Authentication failed"
exit
fi
Info "Authentication complete"
fi
case $method in
1)
#Standard installer
tput setaf 208
tput sgr0
printf "Please select\n"
printf "1: Install Lightcord\n"
printf "2: Uninstall Lightcord\n"
printf "3: Update Lightcord\n"
printf "\n"
#Repeat only if the user hasn't entered an integer...
while ! [[ $selection =~ ^[0-9]+$ ]];
do
read selection;
# If the entered value was not an integer, prompt the user again
if ! [[ $selection =~ ^[0-9]+$ ]]; then
sleep 1;
printf "$(tput setaf 9)Please try again$(tput sgr0)\n";
printf "1: Install Lightcord\n";
printf "2: Uninstall Lightcord\n";
printf "3: Update Lightcord\n"
printf "\n";
fi
done
case $selection in
1) # Install LC
Info "Installing Lightcord"
SubInfo "Preparing"
rm -rf Lightcord.*;
rm -rf Lightcord;
rm -rf lightcord-linux-x64.*;
SubInfo "Downloading Lightcord"
wget -qO lightcord-linux-x64.zip $LC;
if [ ! $? ]; then
SubInfo "Trying alternate URL"
wget -qO lightcord-linux-x64.zip $ALT_LC;
fi
unzip -qq lightcord-linux-x64.zip -d Lightcord;
cd Lightcord;
chmod +x ./lightcord;
cd ..;
sudo mv Lightcord/ $GLOBAL_INSTALL_DIR;
SubInfo "Downloading Lightcord icon"
wget -qO lightcord.png $ICON;
sudo mkdir -p /usr/share/pixmaps;
sudo mv lightcord.png /usr/share/pixmaps;
SubInfo "Creating Desktop entry"
echo -e "[Desktop Entry]\nName=Lightcord\nComment[fr_FR]=Un client Discord simple et personalisable\nComment=A simple - customizable - Discord Client\nExec=$GLOBAL_INSTALL_DIR/Lightcord/lightcord\nIcon=lightcord\nTerminal=false\nType=Application\nCategories=Network;InstantMessaging;P2P;" > Lightcord.desktop
sudo mv Lightcord.desktop /usr/share/applications/Lightcord.desktop
sudo chmod +x /usr/share/applications/Lightcord.desktop;
SubInfo "Cleaning up"
rm -rf Lightcord.*;
rm -rf Lightcord;
rm -rf lightcord-linux-x64.*;
;;
2) # Uninstall LC
Info "Uninstalling Lightcord"
SubInfo "Deleting Lightcord folder"
sudo rm -r $GLOBAL_INSTALL_DIR/Lightcord;
SubInfo "Deleting Lightcord icon"
sudo rm /usr/share/pixmaps/lightcord.png;
SubInfo "Deleting Desktop entry"
sudo rm /usr/share/applications/Lightcord.desktop;
sudo rm -f /home/*/.local/share/applications/Lightcord.desktop;
;;
3) # Update LC
Info 'Updating Lightcord'
SubInfo "Preparing"
rm -rf Lightcord.*;
rm -rf Lightcord;
rm -rf lightcord-linux-x64.*;
SubInfo "Deleting Lightcord"
sudo rm -r $GLOBAL_INSTALL_DIR/Lightcord;
SubInfo "Downloading Lightcord"
wget -qO lightcord-linux-x64.zip $LC;
if [ ! $? ]; then
SubInfo "Trying alternate URL"
wget -qO lightcord-linux-x64.zip $ALT_LC;
fi
unzip -qq lightcord-linux-x64.zip -d Lightcord;
cd Lightcord;
chmod +x ./lightcord;
cd ..;
sudo mv Lightcord/ $GLOBAL_INSTALL_DIR;
SubInfo "Cleaning up"
rm -rf Lightcord.*;
rm -rf Lightcord;
rm -rf lightcord-linux-x64.*;
;;
*) # Do nothing
Error 'Aborting install'
;;
esac
;;
2)
# Appimage installer
if [[ $TERM == dumb ]]; then
exit;
fi
tput setaf 208
tput sgr0
printf "Please select\n";
printf "1: Install Lightcord\n";
printf "2: Uninstall Lightcord\n";
printf "3: Update Lightcord\n"
printf "\n";
while ! [[ $selection =~ ^[0-9]+$ ]];
do
read selection;
# If the entered value was not an integer, prompt the user again
if ! [[ $selection =~ ^[0-9]+$ ]]; then
sleep 1;
printf "$(tput setaf 9)Please try again$(tput sgr0)\n";
printf "1: Install Lightcord\n";
printf "2: Uninstall Lightcord\n";
printf "3: Update Lightcord\n"
printf "\n";
fi
done
case $selection in
1) # Install LC
Info 'Installing Lightcord'
SubInfo "Downloading Lightcord"
wget -qO lightcord.AppImage $LC_APPIMAGE;
if [ ! $? ]; then
SubInfo "Trying alternate URL"
wget -qO lightcord.AppImage $ALT_LC_APPIMAGE;
fi
SubInfo "Downloading Lightcord icon"
wget -qO lightcord.png $ICON;
mkdir -p $LOCAL_INSTALL_DIR;
mv lightcord.AppImage $LOCAL_INSTALL_DIR;
chmod +x $LOCAL_INSTALL_DIR/lightcord.AppImage ;
mkdir -p ~/.local/share/icons/hicolor/512x512/apps
mv lightcord.png ~/.local/share/icons/hicolor/512x512/apps;
SubInfo "Creating local desktop entry"
echo -e "[Desktop Entry]\nName=Lightcord\nComment[fr_FR]=Un client Discord simple et personalisable\nComment=A simple - customizable - Discord Client\nExec=$LOCAL_INSTALL_DIR/lightcord.AppImage\nIcon=lightcord\nTerminal=false\nType=Application\nCategories=Network;InstantMessaging;P2P;" >> ~/.local/share/applications/lightcord.desktop;
SubInfo "Cleaning up"
;;
2) # Uninstall LC
Info 'Uninstalling Lightcord'
SubInfo "Deleting Lightcord folder"
rm -r $LOCAL_INSTALL_DIR;
SubInfo "Deleting Lightcord icon"
rm ~/.local/share/icons/hicolor/512x512/apps/lightcord.png;
SubInfo "Deleting desktop entry"
rm ~/.local/share/applications/lightcord.desktop;
;;
3) # Update LC
Info 'Updating Lightcord'
SubInfo "Deleting Lightcord"
rm $LOCAL_INSTALL_DIR/lightcord.AppImage;
SubInfo "Downloading Lightcord"
wget -qO lightcord.AppImage $LC_APPIMAGE;
if [ ! $? ]; then
SubInfo "Trying alternate URL"
wget -qO lightcord.AppImage $ALT_LC_APPIMAGE;
fi
mkdir -p $LOCAL_INSTALL_DIR;
mv lightcord.AppImage $LOCAL_INSTALL_DIR;
chmod +x $LOCAL_INSTALL_DIR/lightcord.AppImage;
SubInfo "Cleaning up"
;;
*)
Error 'Aborting install'
;;
esac
;;
*)
Error 'Aborting install'
;;
esac
printf "Do you want to keep the install script? [y/N] "; # Ask if the script should delete itself
read a;
case $a in
y)
Info "Kept install script"
exit;
;;
Y)
Info "Kept install script"
exit;
;;
esac
# Remove the script
rm LULI.sh;
Info "Removed install script"
exit;