-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathQ
More file actions
386 lines (363 loc) · 8.31 KB
/
Q
File metadata and controls
386 lines (363 loc) · 8.31 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
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
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
#!/bin/bash
DIRQL="$HOME/qlauncher"
QLS="$DIRQL/qlauncher.sh"
function help ()
{
echo -e "\nUsage: Q [OPTION]...\n"
echo "Main Usage :"
echo " -s, --s, -start, --start start Qlauncher service"
echo " -c, --c, -stop, --stop stop Qlauncher service"
echo " -r, --r, -restart, --restart restart Qlauncher service"
echo " -i, --i, -check, --check check Qlauncher tick"
echo " -l, --l, -status, --status show status container"
echo " -b, --b, -bind, --bind get Qlauncher QR Code"
echo -e "\nMiscellaneous :"
echo " -p, --p, -port, --port check port status"
echo " -d, --d, -rem, --rem remove 'Exited' container"
echo " -u, --u, -cpu, --cpu show total cpu usage"
echo " -v, --v, -update, --update update this script"
echo " -k, --k, -swap, --swap add or remove swap"
echo " -n, --n, -hostname, --hostname change hostname"
echo " -w, --w, -about, --about see magic"
echo
echo "Report this script to: <https://github.com/jakues/autoinstal-qlauncher/issues>"
echo "Report Qlauncher bugs to: <https://github.com/poseidon-network/qlauncher-linux/issues>"
echo "Qlauncher github: <https://github.com/poseidon-network/qlauncher-linux>"
echo "Poseidon Network home page: <https://poseidon.network/>"
echo
}
function null ()
{
echo -e "\nUsage: Q [OPTION]...\n"
echo -e "Try 'Q --help' for more information.\n"
}
################
## main usage ##
################
function start ()
{
if [[ ! $TRUE ]]
then
echo -e "\033[0;32m"
$QLS start >/dev/null 2>&1 > /var/log/Q &
echo -n 'Starting Qlauncher ... '
PID=$!
delay=${SPINNER_DELAY:-0.25}
i=1
sp="/-\|"
while [ -d /proc/$PID ]
do
printf "\b${sp:i++%${#sp}:1}"
sleep $delay
done
sleep 7
echo "OK !!!"
clear
echo -e "\033[0;33m"
read -p "Are you want to check it ? [Y/y/N/n]" -n 1 -r
echo -e "\033[0;37m"
if [[ ! $REPLY =~ ^[Yy]$ ]]
then
exit 1
else
clear
status | lolcat
fi
else
echo -e "\n\033[0;31mQlauncher Already Running\033[0;37m\n"
exit 1
fi
}
function stop ()
{
if [[ ! $TRUE ]]
then
exit 1
echo -e "\n\033[0;31mQlauncher Not Running\033[0;37m\n"
else
echo -e "\033[0;31m"
sleep 7
$QLS stop >/dev/null 2>&1 > /var/log/Q &
echo -n 'Stopping Qlauncher ... '
PID=$!
delay=${SPINNER_DELAY:-0.25}
i=1
sp="/-\|"
while [ -d /proc/$PID ]
do
printf "\b${sp:i++%${#sp}:1}"
sleep $delay
done
echo "OK !!!"
clear
echo -e "\033[0;33m"
read -p "Are you want to check it ? [Y/y/N/n]" -n 1 -r
echo -e "\033[0;37m"
if [[ ! $REPLY =~ ^[Yy]$ ]]
then
exit 1
else
clear
check | lolcat
fi
fi
}
function restart ()
{
echo -e "\033[0;32m"
$QLS restart >/dev/null 2>&1 > /var/log/Q &
echo -n 'Restarting Qlauncher ... '
PID=$!
delay=${SPINNER_DELAY:-0.25}
i=1
sp="/-\|"
while [ -d /proc/$PID ]
do
printf "\b${sp:i++%${#sp}:1}"
sleep $delay
done
sleep 7
echo "OK !!!"
clear
echo -e "\033[0;33m"
read -p "Are you want to check it ? [Y/y/N/n]" -n 1 -r
echo -e "\033[0;37m"
if [[ ! $REPLY =~ ^[Yy]$ ]]
then
exit 1
else
clear
status | lolcat
fi
}
function check ()
{
echo
$QLS check
echo
}
TRUE=$(check | grep '"edgecore_alive":"true"')
function status ()
{
clear
echo -e "\n\n"
docker ps -a
echo -e "\n"
}
function bind ()
{
echo -e "\nPlease open this URL on your browser : \n"
$QLS bind | cut -c 44-120
echo
}
#################
##Miscellaneous##
#################
function port ()
{
nmap -p 443,32440-32449 127.0.0.1
echo
}
function rem ()
{
echo -e "\n\033[1;31mRemoving 'Exited' Container ...\n"
sleep 1
docker rm $(docker ps -a -f status=exited -q)
echo -e "\033[0;33m"
read -p "Are you want to check it ? [Y/y/N/n]" -n 1 -r
echo -e "\033[0;37m"
if [[ ! $REPLY =~ ^[Yy]$ ]]
then
exit 1
else
clear
status | lolcat
fi
}
function cpu ()
{
echo -e "\033[1;32m\nCpu Usage\n"
awk '{u=$2+$4; t=$2+$4+$5; if (NR==1){u1=u; t1=t;} else print ($2+$4-u1) * 100 / (t-t1) "%"; }' \
<(grep 'cpu ' /proc/stat) <(sleep 1;grep 'cpu ' /proc/stat)
echo -e "\033[0;37m"
}
function update ()
{
apt-get update -y
curl -o /usr/bin/Q https://raw.githubusercontent.com/jakues/autoinstal-qlauncher/master/conf/Q
chmod +x /usr/bin/Q
clear
about
exit
}
function swap ()
{
sw2="Pick an option:"
sw3=("Add swap" "Enable swap" "Disable swap" "Tune swap" "Remove swap")
sw4=$(grep -q "swapfile" /etc/fstab)
clear
echo
free -wth
echo -e "\n"
PS3="$sw2"
select opt in "${sw3[@]}" "Quit"; do
echo
case "$REPLY" in
1 ) echo "Checking swap file ..."
if [[ ! $sw4 -ne 0 ]]; then
echo -e "\nSwap file not found !!!"
sleep 1
echo -e "\nAdding swap file ...\n"
fallocate -l 2040M /swapfile
chmod 600 /swapfile
mkswap /swapfile
swapon /swapfile
echo "/swapfile none swap defaults 0 0" >> /etc/fstab
else
echo -e "\nSwap file found !!!"
fi
echo
free -wth
echo
exit 1
;;
2 ) swapon /swapfile
sleep 1
echo -e "\nOK swap enabled\n"
echo
free -wth
echo
exit 1
;;
3 ) swapoff /swapfile
sleep 1
echo -e "\nOK swap disabled\n"
echo
free -wth
echo
exit 1
;;
4 ) echo
sudo sysctl vm.swappiness=0
echo "vm.swappiness=0" >> /etc/sysctl.conf
sudo sysctl vm.overcommit_memory=1
echo "vm.overcommit_memory=1" >> /etc/sysctl.conf
echo "Tune Swap Done"
exit 1
;;
5 ) echo "Checking swap file ..."
if [[ ! $sw4 -eq 0 ]]; then
echo -e "\nSwap file not found !!!"
else
echo -e "Swap found !!!"
sleep 1
echo -e "\nRemoving swap file ...\n"
sed -i '/swapfile/d' /etc/fstab
echo "3" > /proc/sys/vm/drop_caches
swapoff -a
rm -f /swapfile
fi
echo
free -wth
echo
exit 1
;;
$(( ${#sw3[@]}+1 )) )
clear
echo "Kbye"
sleep 1 && clear
exit
echo ""; break;;
*) echo "Invalid option. Try another one.";continue;;
esac
done
}
function hostname ()
{
if [ "$(id -u)" != "0" ] ; then
echo "Sorry, you are not root user"
exit
fi
read -r -p "Enter new hostname : " NEW_HOSTNAME
echo
CUR_HOSTNAME=$(cat /etc/hostname)
echo "The current hostname is $CUR_HOSTNAME"
echo
hostnamectl set-hostname "${NEW_HOSTNAME}"
sudo sed -i "s/$CUR_HOSTNAME/$NEW_HOSTNAME/g" /etc/hosts
sudo sed -i "s/$CUR_HOSTNAME/$NEW_HOSTNAME/g" /etc/hostname
echo
echo "The new hostname is $NEW_HOSTNAME"
echo
read -p "Reboot now ? [Y/y/N/n]" -n 1 -r
if [[ ! $REPLY =~ ^[Yy]$ ]]
then
exit 1
else
reboot
fi
}
function about ()
{
echo -e "\n\033[1;36m@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\033[1;37m"
echo -e "\033[1;36m@@\033[1;37mScript Auto Install Qlauncher-Lelenux\033[1;36m@@\033[1;37m"
echo -e "\033[1;36m@@\033[1;37m Original Script by Jakues™\033[1;36m @@\033[1;37m"
echo -e "\033[1;36m@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\033[1;37m"
echo -e "\nYou can donate me to address below\n\n"
echo -e "\n\033[1;32mBTC: bc1q8lshj8wxmf3cegvqc5atefy8q8pylmar5swxph\033[0;37m\n"
echo -e "\n\033[1;32mERC20: 0x50D232369c7A4A77055ed129ee653bE18DFd78ab\033[0;37m\n"
echo -e "\n\033[1;32mBNB: bnb1v7np68j0mh4xg53rhyrze7shfkgj4tt8psyggk\033[0;37m\n"
echo -e "\n\033[1;32mTRC20: TQLcDqU7SC7PCdUtL5JmyTEzZx6Cq5tmdg\033[0;37m\n"
echo
}
#################
###Buster Call###
#################
case "$1" in
-s|--s|-start|--start)
start
;;
-c|--c|-stop|--stop)
stop
;;
-r|--r|-restart|--restart)
restart
;;
-i|--i|-check|--check)
check | lolcat
;;
-l|--l|-status|--status)
clear
status | lolcat
;;
-b|--b|-bind|--bind)
bind | lolcat
;;
-p|--p|-port|--port)
port | lolcat
;;
-d|--d|-rem|--rem)
rem
;;
-u|--u|-cpu|--cpu)
cpu
;;
-v|--v|-update|--update)
update
;;
-k|--k|-swap|--swap)
swap
;;
-n|--n|-hostname|--hostname)
hostname
;;
-w|--w|-about|--about)
about
;;
--help)
help | lolcat
;;
*)
null | lolcat
;;
esac