forked from Aniverse/inexistence
-
Notifications
You must be signed in to change notification settings - Fork 0
/
inexistence.sh
3142 lines (2175 loc) · 124 KB
/
inexistence.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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/bin/bash
#
# https://github.com/Aniverse/inexistence
# Author: Aniverse
#
# bash <(curl -s https://raw.githubusercontent.com/Aniverse/inexistence/master/inexistence.sh)
# bash -c "$(wget --no-check-certificate -qO- https://github.com/Aniverse/inexistence/raw/master/inexistence.sh)"
#
# PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
# export PATH
# --------------------------------------------------------------------------------
SYSTEMCHECK=1
DISABLE=0
DeBUG=0
INEXISTENCEVER=1.0.7
INEXISTENCEDATE=2018.06.09
# --------------------------------------------------------------------------------
# 获取参数
OPTS=$(getopt -n "$0" -o dsyu:p: --long "yes,tr-skip,skip,debug,apt-yes,apt-no,swap-yes,swap-no,bbr-yes,bbr-no,flood-yes,flood-no,rdp-vnc,rdp-x2go,rdp-no,wine-yes,wine-no,tools-yes,tools-no,flexget-yes,flexget-no,rclone-yes,rclone-no,enable-ipv6,tweaks-yes,tweaks-no,mt-single,mt-double,mt-max,mt-half,user:,password:,webpass:,de:,delt:,qb:,rt:,tr:" -- "$@")
eval set -- "$OPTS"
while true; do
case "$1" in
-u | --user ) ANUSER="$2" ; shift ; shift ;;
-p | --password ) ANPASS="$2" ; shift ; shift ;;
--qb ) { if [[ $2 == ppa ]]; then QBVERSION='Install from PPA' ; elif [[ $2 == repo ]]; then QBVERSION='Install from repo' ; else QBVERSION=$2 ; fi ; } ; shift ; shift ;;
--rt ) { if [[ $2 == ppa ]]; then RTVERSION='Install from PPA' ; elif [[ $2 == repo ]]; then RTVERSION='Install from repo' ; else RTVERSION=$2 ; fi ; } ; shift ; shift ;;
--tr ) { if [[ $2 == ppa ]]; then TRVERSION='Install from PPA' ; elif [[ $2 == repo ]]; then TRVERSION='Install from repo' ; else TRVERSION=$2 ; fi ; } ; shift ; shift ;;
--de ) { if [[ $2 == ppa ]]; then DEVERSION='Install from PPA' ; elif [[ $2 == repo ]]; then DEVERSION='Install from repo' ; else DEVERSION=$2 ; fi ; } ; shift ; shift ;;
# --delt ) { if [[ $2 == ppa ]]; then DELTVERSION='Install from PPA' ; elif [[ $2 == repo ]]; then DELTVERSION='Install from repo' ; else DELTVERSION=$2 ; fi ; } ; shift ; shift ;;
-d | --debug ) DeBUG=1 ; shift ;;
-s | --skip ) SYSTEMCHECK=0 ; shift ;;
-y | --yes ) ForceYes=1 ; shift ;;
--tr-skip ) TRdefault=No ; shift ;;
--enable-ipv6 ) IPv6Opt=-i ; shift ;;
--apt-yes ) aptsources="Yes" ; shift ;;
--apt-no ) aptsources="No" ; shift ;;
--swap-yes ) USESWAP="Yes" ; shift ;;
--swap-no ) USESWAP="No" ; shift ;;
--bbr-yes ) InsBBR="Yes" ; shift ;;
--bbr-no ) InsBBR="No" ; shift ;;
--flood-yes ) InsFlood="Yes" ; shift ;;
--flood-no ) InsFlood="No" ; shift ;;
--rdp-vnc ) InsRDP="VNC" ; shift ;;
--rdp-x2go ) InsRDP="X2Go" ; shift ;;
--rdp-no ) InsRDP="No" ; shift ;;
--wine-yes ) InsWine="Yes" ; shift ;;
--wine-no ) InsWine="No" ; shift ;;
--tools-yes ) InsTools="Yes" ; shift ;;
--tools-no ) InsTools="No" ; shift ;;
--flexget-yes ) InsFlex="Yes" ; shift ;;
--flexget-no ) InsFlex="No" ; shift ;;
--rclone-yes ) InsRclone="Yes" ; shift ;;
--rclone-no ) InsRclone="No" ; shift ;;
--tweaks-yes ) UseTweaks="Yes" ; shift ;;
--tweaks-no ) UseTweaks="No" ; shift ;;
--mt-single ) MAXCPUS=1 ; shift ;;
--mt-double ) MAXCPUS=2 ; shift ;;
--mt-max ) MAXCPUS=$(nproc) ; shift ;;
--mt-half ) MAXCPUS=$(echo "$(nproc) / 2"|bc) ; shift ;;
-- ) shift; break ;;
* ) break ;;
esac
done
if [[ $DeBUG == 1 ]]; then
ANUSER=aniverse ; aptsources=Yes ; MAXCPUS=$(nproc)
fi
# --------------------------------------------------------------------------------
export DEBIAN_FRONTEND=noninteractive
export APT_LISTCHANGES_FRONTEND=none
local_packages=/etc/inexistence/00.Installation
# --------------------------------------------------------------------------------
### 颜色样式 ###
function _colors() {
black=$(tput setaf 0); red=$(tput setaf 1); green=$(tput setaf 2); yellow=$(tput setaf 3);
blue=$(tput setaf 4); magenta=$(tput setaf 5); cyan=$(tput setaf 6); white=$(tput setaf 7);
on_red=$(tput setab 1); on_green=$(tput setab 2); on_yellow=$(tput setab 3); on_blue=$(tput setab 4);
on_magenta=$(tput setab 5); on_cyan=$(tput setab 6); on_white=$(tput setab 7); bold=$(tput bold);
dim=$(tput dim); underline=$(tput smul); reset_underline=$(tput rmul); standout=$(tput smso);
reset_standout=$(tput rmso); normal=$(tput sgr0); alert=${white}${on_red}; title=${standout};
baihuangse=${white}${on_yellow}; bailanse=${white}${on_blue}; bailvse=${white}${on_green};
baiqingse=${white}${on_cyan}; baihongse=${white}${on_red}; baizise=${white}${on_magenta};
heibaise=${black}${on_white}; heihuangse=${on_yellow}${black}
jiacu=${normal}${bold}
shanshuo=$(tput blink); wuguangbiao=$(tput civis); guangbiao=$(tput cnorm)
CW="${bold}${baihongse} ERROR ${jiacu}";ZY="${baihongse}${bold} ATTENTION ${jiacu}";JG="${baihongse}${bold} WARNING ${jiacu}" ; }
_colors
# --------------------------------------------------------------------------------
# 增加 swap
function _use_swap() { dd if=/dev/zero of=/root/.swapfile bs=1M count=1024 ; mkswap /root/.swapfile ; swapon /root/.swapfile ; swapon -s ; }
# 关掉之前开的 swap
function _disable_swap() { swapoff /root/.swapfile ; rm -f /.swapfile ; }
# 用于退出脚本
export TOP_PID=$$
trap 'exit 1' TERM
# 判断是否在运行
function _if_running () { ps -ef | grep "$1" | grep -v grep > /dev/null && echo "${green}Running ${normal}" || echo "${red}Inactive${normal}" ; }
### 硬盘计算 ###
calc_disk() {
local total_size=0 ; local array=$@
for size in ${array[@]} ; do
[ "${size}" == "0" ] && size_t=0 || size_t=`echo ${size:0:${#size}-1}`
[ "`echo ${size:(-1)}`" == "K" ] && size=0
[ "`echo ${size:(-1)}`" == "M" ] && size=$( awk 'BEGIN{printf "%.1f", '$size_t' / 1024}' )
[ "`echo ${size:(-1)}`" == "T" ] && size=$( awk 'BEGIN{printf "%.1f", '$size_t' * 1024}' )
[ "`echo ${size:(-1)}`" == "G" ] && size=${size_t}
total_size=$( awk 'BEGIN{printf "%.1f", '$total_size' + '$size'}' )
done ; echo ${total_size} ; }
### 操作系统检测 ###
get_opsy() { [ -f /etc/redhat-release ] && awk '{print ($1,$3~/^[0-9]/?$3:$4)}' /etc/redhat-release && return
[ -f /etc/os-release ] && awk -F'[= "]' '/PRETTY_NAME/{print $3,$4,$5}' /etc/os-release && return
[ -f /etc/lsb-release ] && awk -F'[="]+' '/DESCRIPTION/{print $2}' /etc/lsb-release && return ; }
# --------------------------------------------------------------------------------
### 是否为 IPv4 地址(其实也不一定是) ###
function isValidIpAddress() { echo $1 | grep -qE '^[0-9][0-9]?[0-9]?\.[0-9][0-9]?[0-9]?\.[0-9][0-9]?[0-9]?\.[0-9][0-9]?[0-9]?$' ; }
### 是否为内网 IPv4 地址 ###
function isInternalIpAddress() { echo $1 | grep -qE '(192\.168\.((\d{1,2})|(1\d{2})|(2[0-4]\d)|(25[0-5]))\.((\d{1,2})$|(1\d{2})$|(2[0-4]\d)$|(25[0-5])$))|(172\.((1[6-9])|(2\d)|(3[0-1]))\.((\d{1,2})|(1\d{2})|(2[0-4]\d)|(25[0-5]))\.((\d{1,2})$|(1\d{2})$|(2[0-4]\d)$|(25[0-5])$))|(10\.((\d{1,2})|(1\d{2})|(2[0-4]\d)|(25[0-5]))\.((\d{1,2})|(1\d{2})|(2[0-4]\d)|(25[0-5]))\.((\d{1,2})$|(1\d{2})$|(2[0-4]\d)$|(25[0-5])$))' ; }
# --------------------------------------------------------------------------------
# 检查客户端是否已安装、客户端版本
function _check_install_1(){
client_location=$( command -v ${client_name} )
[[ "${client_name}" == "qbittorrent-nox" ]] && client_name=qb
[[ "${client_name}" == "transmission-daemon" ]] && client_name=tr
[[ "${client_name}" == "deluged" ]] && client_name=de
[[ "${client_name}" == "rtorrent" ]] && client_name=rt
[[ "${client_name}" == "flexget" ]] && client_name=flex
if [[ -a $client_location ]]; then
eval "${client_name}"_installed=Yes
else
eval "${client_name}"_installed=No
fi ; }
function _check_install_2(){
for apps in qbittorrent-nox deluged rtorrent transmission-daemon flexget rclone irssi ffmpeg mediainfo wget wine mono; do
client_name=$apps ; _check_install_1
done ; }
function _client_version_check(){
[[ $qb_installed == Yes ]] && qbtnox_ver=`qbittorrent-nox --version | awk '{print $2}' | sed "s/v//"`
[[ $de_installed == Yes ]] && deluged_ver=`deluged --version | grep deluged | awk '{print $2}'` && delugelt_ver=` deluged --version | grep libtorrent | grep -Eo "[01].[0-9]+.[0-9]+" `
[[ $rt_installed == Yes ]] && rtorrent_ver=`rtorrent -h | head -n1 | sed -ne 's/[^0-9]*\([0-9]*\.[0-9]*\.[0-9]*\)[^0-9]*/\1/p'`
[[ $tr_installed == Yes ]] && trd_ver=`transmission-daemon --help | head -n1 | awk '{print $2}'` ; }
# --------------------------------------------------------------------------------
### 随机数 ###
function _string() { perl -le 'print map {(a..z,A..Z,0..9)[rand 62] } 0..pop' 15 ; }
# --------------------------------------------------------------------------------
### 输入自己想要的软件版本 ###
function _inputversion() {
echo -e "\n${baihongse}${bold} ATTENTION ${normal} ${bold}Make sure to input the correct version${normal}"
read -ep "${bold}${yellow}Input the version you want: ${cyan}" inputversion; echo -n "${normal}" ; }
function _inputversionlt() {
echo -e "\n${baihongse}${bold} ATTENTION ${normal} ${bold}Make sure to input the correct version${normal}"
echo -e "${red}${bold} Here is a list of all the available versions${normal}\n"
wget -qO- "https://github.com/arvidn/libtorrent" | grep "data-name" | cut -d '"' -f2 | pr -3 -t ; echo
read -ep "${bold}${yellow}Input the version you want: ${cyan}" inputversion; echo -n "${normal}" ; }
### 检查系统是否被支持 ###
function _oscheck() {
if [[ ! "$SysSupport" == 1 ]]; then
echo -e "\n${bold}${red}Too young too simple! Only Debian 8, Debian 9 and Ubuntu 16.04 is supported by this script${normal}"
echo -e "${bold}If you want to run this script on unsupported distro, please edit this script to skip system check\nExiting...${normal}\n"
exit 1
fi ; }
# 进度显示
spinner() {
local pid=$1
local delay=0.25
local spinstr='|/-\'
while [ "$(ps a | awk '{print $1}' | grep $pid)" ]; do
local temp=${spinstr#?}
printf " [${bold}${yellow}%c${normal}] " "$spinstr"
local spinstr=$temp${spinstr%"$temp"}
sleep $delay
printf "\b\b\b\b\b\b"
done
printf " \b\b\b\b"
echo -ne "${OK}"
}
# --------------------------------------------------------------------------------
# --------------------- 系统检查 --------------------- #
function _intro() {
clear
# 检查是否以 root 权限运行脚本
if [[ ! $DeBUG == 1 ]]; then if [[ $EUID != 0 ]]; then echo -e "\n${title}${bold}Navie! I think this young man will not be able to run this script without root privileges.${normal}\n" ; exit 1
else echo -e "\n${green}${bold}Excited! You're running this script as root. Let's make some big news ... ${normal}" ; fi ; fi
arch=$( uname -m ) # 架构,可以识别 ARM
lbit=$( getconf LONG_BIT ) # 只显示多少位,无法识别 ARM
# 检查是否为 x86_64 架构
[[ ! $arch == x86_64 ]] && { echo -e "${title}${bold}Too simple! Only x86_64 is supported${normal}" ; exit 1 ; }
# 检查系统版本;不是 Ubuntu 或 Debian 的就不管了,反正不支持……
SysSupport=0
DISTRO=` awk -F'[= "]' '/PRETTY_NAME/{print $3}' /etc/os-release `
DISTROL=` echo $DISTRO | tr 'A-Z' 'a-z' `
CODENAME=` cat /etc/os-release | grep VERSION= | tr '[A-Z]' '[a-z]' | sed 's/\"\|(\|)\|[0-9.,]\|version\|lts//g' | awk '{print $2}' `
[[ $DISTRO == Ubuntu ]] && osversion=` grep -oE "[0-9.]+" /etc/issue `
[[ $DISTRO == Debian ]] && osversion=` cat /etc/debian_version `
[[ $CODENAME =~ (xenial|bionic|jessie|stretch) ]] && SysSupport=1
[[ $CODENAME =~ (wheezy|trusty) ]] && SysSupport=2
[[ $DeBUG == 1 ]] && echo "${bold}DISTRO=$DISTRO, CODENAME=$CODENAME, osversion=$osversion, SysSupport=$SysSupport${normal}"
# 如果系统是 Debian 7 或 Ubuntu 14.04,询问是否升级到 Debian 8 / Ubuntu 16.04
[[ $SysSupport == 2 ]] && _ask_distro_upgrade
# rTorrent 是否只能安装 feature-bind branch
[[ $CODENAME =~ (stretch|bionic) ]] && rtorrent_dev=1
# 检查本脚本是否支持当前系统,可以关闭此功能
[[ $SYSTEMCHECK == 1 ]] && [[ ! $distro_up == Yes ]] && _oscheck
# 装 wget 以防万一(虽然脚本一般情况下就是 wget 下来的……)
if [[ ! -n `command -v wget` ]]; then echo "${bold}Now the script is installing ${yellow}wget${jiacu} ...${normal}" ; apt-get install -y wget ; fi
[[ ! $? -eq 0 ]] && echo -e "${red}${bold}Failed to install wget, please check it and rerun once it is resolved${normal}\n" && kill -s TERM $TOP_PID
echo -e "${bold}Checking your server's public IPv4 address ...${normal}"
# serveripv4=$( ifconfig | grep -Eo 'inet (addr:)?([0-9]*\.){3}[0-9]*' | grep -Eo '([0-9]*\.){3}[0-9]*' | grep -v '127.0.0.1' )
# serveripv4=$( ifconfig -a|grep inet|grep -v 127.0.0.1|grep -v inet6|awk '{print $2}'|tr -d "addr:" )
serveripv4=$( ip route get 8.8.8.8 | awk '{print $3}' )
isInternalIpAddress "$serveripv4" || serveripv4=$( wget --no-check-certificate -t1 -T6 -qO- v4.ipv6-test.com/api/myip.php )
isValidIpAddress "$serveripv4" || serveripv4=$( wget --no-check-certificate -t1 -T6 -qO- checkip.dyndns.org | sed -e 's/.*Current IP Address: //' -e 's/<.*$//' )
isValidIpAddress "$serveripv4" || serveripv4=$( wget --no-check-certificate -t1 -T7 -qO- ipecho.net/plain )
isValidIpAddress "$serveripv4" || { echo "${bold}${red}${shanshuo}ERROR ${jiacu}${underline}Failed to detect your public IPv4 address, use internal address instead${normal}" ; serveripv4=$( ip route get 8.8.8.8 | awk '{print $3}' ) ; }
wget --no-check-certificate -t1 -T6 -qO- https://ipapi.co/json >~/ipapi 2>&1
ccoodde=$( cat ~/ipapi | grep \"country\" | awk -F '"' '{print $4}' ) 2>/dev/null
country=$( cat ~/ipapi | grep \"country_name\" | awk -F '"' '{print $4}' ) 2>/dev/null
regionn=$( cat ~/ipapi | grep \"region\" | awk -F '"' '{print $4}' ) 2>/dev/null
cityyyy=$( cat ~/ipapi | grep \"city\" | awk -F '"' '{print $4}' ) 2>/dev/null
isppppp=$( cat ~/ipapi | grep \"org\" | awk -F '"' '{print $4}' ) 2>/dev/null
asnnnnn=$( cat ~/ipapi | grep \"asn\" | awk -F '"' '{print $4}' ) 2>/dev/null
[[ $cityyyy == Singapore ]] && unset cityyyy
[[ $isppppp == "" ]] && isp="No ISP detected"
[[ $asnnnnn == "" ]] && isp="No ASN detected"
rm -f ~/ipapi 2>&1
echo "${bold}Checking your server's public IPv6 address ...${normal}"
serveripv6=$( wget -t1 -T5 -qO- v6.ipv6-test.com/api/myip.php | grep -Eo "[0-9a-z:]+" | head -n1 )
# serveripv6=$( wget --no-check-certificate -qO- -t1 -T8 ipv6.icanhazip.com )
# [ -n "$(grep 'eth0:' /proc/net/dev)" ] && wangka=eth0 || wangka=`cat /proc/net/dev |awk -F: 'function trim(str){sub(/^[ \t]*/,"",str); sub(/[ \t]*$/,"",str); return str } NR>2 {print trim($1)}' |grep -Ev '^lo|^sit|^stf|^gif|^dummy|^vmnet|^vir|^gre|^ipip|^ppp|^bond|^tun|^tap|^ip6gre|^ip6tnl|^teql|^venet|^he-ipv6|^docker' |awk 'NR==1 {print $0}'`
# wangka=` ifconfig -a | grep -B 1 $(ip route get 8.8.8.8 | awk 'NR==1 {print $NF}') | head -n1 | awk '{print $1}' | sed "s/:$//" `
# wangka=` ip route get 8.8.8.8 | awk '{print $5}' `
# serverlocalipv6=$( ip addr show dev $wangka | sed -e's/^.*inet6 \([^ ]*\)\/.*$/\1/;t;d' | head -n1 )
echo -e "${bold}Checking your server's specification ...${normal}"
kern=$( uname -r )
# Virt-what
wget --no-check-certificate -qO /usr/local/bin/virt-what https://github.com/Aniverse/inexistence/raw/master/03.Files/app/virt-what
mkdir -p /usr/lib/virt-what
wget --no-check-certificate -qO /usr/lib/virt-what/virt-what-cpuid-helper https://github.com/Aniverse/inexistence/raw/master/03.Files/app/virt-what-cpuid-helper
chmod +x /usr/local/bin/virt-what /usr/lib/virt-what/virt-what-cpuid-helper
virtua="$(virt-what)" 2>/dev/null
cname=$( awk -F: '/model name/ {name=$2} END {print name}' /proc/cpuinfo | sed 's/^[ \t]*//;s/[ \t]*$//' )
cputhreads=$( grep 'processor' /proc/cpuinfo | sort -u | wc -l )
cpucores_single=$( grep 'core id' /proc/cpuinfo | sort -u | wc -l )
cpunumbers=$( grep 'physical id' /proc/cpuinfo | sort -u | wc -l )
cpucores=$( expr $cpucores_single \* $cpunumbers )
[[ $cpunumbers == 2 ]] && CPUNum='Dual ' ; [[ $cpunumbers == 4 ]] && CPUNum='Quad ' ; [[ $cpunumbers == 8 ]] && CPUNum='Octa '
disk_size1=($( LANG=C df -hPl | grep -wvE '\-|none|tmpfs|devtmpfs|by-uuid|chroot|Filesystem' | awk '{print $2}' ))
disk_size2=($( LANG=C df -hPl | grep -wvE '\-|none|tmpfs|devtmpfs|by-uuid|chroot|Filesystem' | awk '{print $3}' ))
disk_total_size=$( calc_disk ${disk_size1[@]} )
disk_used_size=$( calc_disk ${disk_size2[@]} )
freq=$( awk -F: '/cpu MHz/ {freq=$2} END {print freq}' /proc/cpuinfo | sed 's/^[ \t]*//;s/[ \t]*$//' )
tram=$( free -m | awk '/Mem/ {print $2}' )
uram=$( free -m | awk '/Mem/ {print $3}' )
echo -e "${bold}Checking bittorrent clients' version ...${normal}"
_check_install_2
_client_version_check
# 有可能出现刚开的机器没有 apt update,直接 apt-cache policy 提示找不到包的情况
QB_repo_ver=` apt-cache policy qbittorrent-nox | grep -B1 http | grep -Eo "[234]\.[0-9.]+\.[0-9.]+" | head -n1 `
[[ -z $QB_repo_ver ]] && { [[ $CODENAME == bionic ]] && QB_repo_ver=4.0.3 ; [[ $CODENAME == xenial ]] && QB_repo_ver=3.3.1 ; [[ $CODENAME == jessie ]] && QB_repo_ver=3.1.10 ; [[ $CODENAME == stretch ]] && QB_repo_ver=3.3.7 ; }
QB_latest_ver=4.1.0
QB_latest_ver=` wget -qO- https://github.com/qbittorrent/qBittorrent/releases | grep releases/tag | grep -Eo "[45]\.[0-9.]+" | head -n1 `
DE_repo_ver=` apt-cache policy deluged | grep -B1 http | grep -Eo "[12]\.[0-9.]+\.[0-9.]+" | head -n1 `
[[ -z $DE_repo_ver ]] && { [[ $CODENAME == bionic ]] && DE_repo_ver=1.3.15 ; [[ $CODENAME == xenial ]] && DE_repo_ver=1.3.12 ; [[ $CODENAME == jessie ]] && DE_repo_ver=1.3.10 ; [[ $CODENAME == stretch ]] && DE_repo_ver=1.3.13 ; }
DE_latest_ver=1.3.15
DE_latest_ver=` wget -qO- https://dev.deluge-torrent.org/wiki/ReleaseNotes | grep wiki/ReleaseNotes | grep -Eo "[12]\.[0-9.]+" | sed 's/">/ /' | awk '{print $1}' | head -n1 `
# DE_github_latest_ver=` wget -qO- https://github.com/deluge-torrent/deluge/releases | grep releases/tag | grep -Eo "[12]\.[0-9.]+.*" | sed 's/\">//' | head -n1 `
TR_repo_ver=` apt-cache policy transmission-daemon | grep -B1 http | grep -Eo "[23]\.[0-9.]+" | head -n1 `
[[ -z $TR_repo_ver ]] && { [[ $CODENAME == bionic ]] && TR_repo_ver=2.92 ; [[ $CODENAME == xenial ]] && TR_repo_ver=2.84 ; [[ $CODENAME == jessie ]] && TR_repo_ver=2.84 ; [[ $CODENAME == stretch ]] && TR_repo_ver=2.92 ; }
TR_latest_ver=2.94
TR_latest_ver=` wget -qO- https://github.com/transmission/transmission/releases | grep releases/tag | grep -Eo "[23]\.[0-9.]+" | head -n1 `
clear
wget --no-check-certificate -t1 -T5 -qO- https://raw.githubusercontent.com/Aniverse/inexistence/master/03.Files/inexistence.logo.1
echo "${bold}---------- [System Information] ----------${normal}"
echo
echo -ne " IPv4 : "
if [[ "${serveripv4}" ]]; then
echo "${cyan}$serveripv4${normal}"
else
echo "${cyan}No Public IPv4 Address Found${normal}"
fi
echo -ne " IPv6 : "
if [[ "${serveripv6}" ]]; then
echo "${cyan}$serveripv6${normal}"
else
echo "${cyan}No IPv6 Address Found${normal}"
fi
echo -e " ASN & ISP : ${cyan}$asnnnnn, $isppppp${normal}"
echo -ne " Location : ${cyan}"
[[ ! $cityyyy == "" ]] && echo -ne "$cityyyy, "
[[ ! $regionn == "" ]] && echo -ne "$regionn, "
[[ ! $country == "" ]] && echo -ne "$country"
# [[ ! $ccoodde == "" ]] && echo -ne " / $ccoodde"
echo -e "${normal}"
echo -e " CPU : ${cyan}$CPUNum$cname${normal}"
echo -e " Cores : ${cyan}${freq} MHz, ${cpucores} Core(s), ${cputhreads} Thread(s)${normal}"
echo -e " Mem : ${cyan}$tram MB ($uram MB Used)${normal}"
echo -e " Disk : ${cyan}$disk_total_size GB ($disk_used_size GB Used)${normal}"
echo -e " OS : ${cyan}$DISTRO $osversion $CODENAME ($arch) ${normal}"
echo -e " Kernel : ${cyan}$kern${normal}"
echo -e " Script : ${cyan}$INEXISTENCEDATE${normal}"
echo -ne " Virt : "
if [[ "${virtua}" ]]; then
echo "${cyan}$virtua${normal}"
else
echo "${cyan}No Virtualization Detected${normal}"
fi
[[ ! $SYSTEMCHECK == 1 ]] && echo -e "\n${bold}${red}System Checking Skipped. Note that this script may not work on unsupported system${normal}"
echo
echo -e "${bold}For more information about this script, please refer the README on GitHub"
echo -e "Press ${on_red}Ctrl+C${normal} ${bold}to exit${jiacu}, or press ${bailvse}ENTER${normal} ${bold}to continue" ; [[ ! $ForceYes == 1 ]] && read input
}
# --------------------- 询问是否升级系统 --------------------- #
function _ask_distro_upgrade() {
[[ $CODENAME == wheezy || $CODENAME == trusty ]] && echo -e "\nYou are now running ${cyan}${bold}$DISTRO $osversion${normal}, which is not supported by this script"
[[ $CODENAME == wheezy ]] && { UPGRADE_DISTRO_1="Debian 8" ; UPGRADE_DISTRO_2="Debian 9" ; UPGRADE_CODENAME_1=jessie ; UPGRADE_CODENAME_2=stretch ; }
[[ $CODENAME == trusty ]] && { UPGRADE_DISTRO_1="Ubuntu 16.04" ; UPGRADE_DISTRO_2="Ubuntu 18.04" ; UPGRADE_CODENAME_1=xenial ; UPGRADE_CODENAME_2=bionic ; }
echo
echo -e "${green}01)${normal} Upgrade to ${cyan}$UPGRADE_DISTRO_1${normal} (Default)"
echo -e "${green}02)${normal} Upgrade to ${cyan}$UPGRADE_DISTRO_2${normal}"
echo -e "${green}03)${normal} Do NOT upgrade system and exit script"
echo -ne "${bold}${yellow}Would you like to upgrade your system?${normal} (Default ${cyan}01${normal}): " ; read -e responce
case $responce in
01 | 1 | "") distro_up=Yes && UPGRADE_CODENAME=$UPGRADE_CODENAME_1 && UPGRADE_DISTRO=$UPGRADE_DISTRO_1 ;;
02 | 2 ) distro_up=Yes && UPGRADE_CODENAME=$UPGRADE_CODENAME_2 && UPGRADE_DISTRO=$UPGRADE_DISTRO_2 && UPGRDAE2=Yes ;;
03 | 3 ) distro_up=No ;;
* ) distro_up=Yes && UPGRADE_CODENAME=$UPGRADE_CODENAME_2 && UPGRADE_DISTRO=$UPGRADE_DISTRO_1 ;;
esac
if [[ $distro_up == Yes ]]; then
echo -e "\n${bold}${baiqingse}Your system will be upgraded to ${baizise}${UPGRADE_DISTRO}${baiqingse} after reboot${normal}"
_distro_upgrade | tee /etc/00.distro_upgrade.log
else
echo -e "\n${baizise}Your system will ${baihongse}not${baizise} be upgraded${normal}"
fi
echo ; }
# --------------------- 录入账号密码部分 --------------------- #
# 向用户确认信息,Yes or No
function _confirmation(){
local answer
while true ; do
read answer
case $answer in [yY] | [yY][Ee][Ss] | "" ) return 0 ;;
[nN] | [nN][Oo] ) return 1 ;;
* ) echo "${bold}Please enter ${bold}${green}[Y]es${normal} or [${bold}${red}N${normal}]o";;
esac
done ; }
# 生成随机密码,genln=密码长度
function genpasswd() { local genln=$1 ; [ -z "$genln" ] && genln=12 ; tr -dc A-Za-z0-9 < /dev/urandom | head -c ${genln} | xargs ; }
# 检查用户名的有效性,抄自:https://github.com/Azure/azure-devops-utils
function validate_username() {
ANUSER="$1" ; local min=1 ; local max=32
# This list is not meant to be exhaustive. It's only the list from here: https://docs.microsoft.com/azure/virtual-machines/linux/usernames
local reserved_names=" adm admin audio backup bin cdrom crontab daemon dialout dip disk fax floppy fuse games gnats irc kmem landscape libuuid list lp mail man messagebus mlocate netdev news nobody nogroup operator plugdev proxy root sasl shadow src ssh sshd staff sudo sync sys syslog tape tty users utmp uucp video voice whoopsie www-data "
if [ -z "$ANUSER" ]; then
username_valid=empty
elif [ ${#ANUSER} -lt $min ] || [ ${#username} -gt $max ]; then
echo -e "${CW} The username must be between $min and $max characters${normal}"
username_valid=false
elif ! [[ "$ANUSER" =~ ^[a-z][-a-z0-9_]*$ ]]; then
echo -e "${CW} The username must contain only lowercase letters, digits, underscores and starts with a letter${normal}"
username_valid=false
elif [[ "$reserved_names" =~ " $ANUSER " ]]; then
echo -e "${CW} The username cannot be an Ubuntu reserved name${normal}"
username_valid=false
else
username_valid=true
fi
}
# 询问用户名
function _askusername(){ clear
validate_username $ANUSER
if [[ $username_valid == empty ]]; then
echo -e "${bold}${yellow}The script needs a username${jiacu}"
echo -e "This will be your primary user. It can be an existing user or a new user ${normal}"
_input_username
elif [[ $username_valid == false ]]; then
# echo -e "${JG} The preset username doesn't pass username check, please set a new username"
_input_username
elif [[ $username_valid == true ]]; then
# ANUSER=` echo $ANUSER | tr 'A-Z' 'a-z' `
echo -e "${bold}Username sets to ${blue}$ANUSER${normal}\n"
fi ; }
# 录入用户名
function _input_username(){
local answerusername ; local reinput_name
confirm_name=false
while [[ $confirm_name == false ]]; do
while [[ $answerusername = "" ]] || [[ $reinput_name = true ]] || [[ $username_valid = false ]]; do
reinput_name=false
read -ep "${bold}Enter username: ${blue}" answerusername ; echo -n "${normal}"
validate_username $answerusername
done
addname=$answerusername
echo -n "${normal}${bold}Confirm that username is ${blue}${addname}${normal}, ${bold}${green}[Y]es${normal} or [${bold}${red}N${normal}]o? "
read answer
case $answer in [yY] | [yY][Ee][Ss] | "" ) confirm_name=true ;;
[nN] | [nN][Oo] ) reinput_name=true ;;
* ) echo "${bold}Please enter ${bold}${green}[Y]es${normal} or [${bold}${red}N${normal}]o";;
esac
ANUSER=$addname
done ; echo ; }
# 一定程度上的密码复杂度检测:https://stackoverflow.com/questions/36524872/check-single-character-in-array-bash-for-password-generator
# 询问密码。目前的复杂度判断还不够 Flexget 的程度,但总比没有强……
function _askpassword() {
local password1 ; local password2 ; #local exitvalue=0
exec 3>&1 >/dev/tty
if [[ $ANPASS = "" ]]; then
echo "${bold}${yellow}The script needs a password, it will be used for Unix and WebUI${jiacu} "
echo "The password must consist of characters and numbers and at least 8 chars,"
echo "or you can leave it blank to generate a random password"
while [ -z $localpass ]; do
# echo -n "${bold}Enter the password: ${blue}" ; read -e password1
read -ep "${jiacu}Enter the password: ${blue}" password1 ; echo -n "${normal}"
if [ -z $password1 ]; then
localpass=$(genpasswd) ; # exitvalue=1
echo "${jiacu}Random password sets to ${blue}$localpass${normal}"
# At least [8] chars long
elif [ ${#password1} -lt 8 ]; then
echo "${bold}${red}ERROR${normal} ${bold}Password must be at least ${red}[8]${jiacu} chars long${normal}" && continue
# At least [1] number
elif ! echo "$password1" | grep -q '[0-9]'; then
echo "${bold}${red}ERROR${normal} ${bold}Password must have at least ${red}[1] number${normal}" && continue
# At least [1] letter
elif ! echo "$password1" | grep -q '[a-zA-Z]'; then
echo "${bold}${red}ERROR${normal} ${bold}Password must have at least ${red}[1] letter${normal}" && continue
else
while [[ $password2 = "" ]]; do
read -ep "${jiacu}Enter the new password again: ${blue}" password2 ; echo -n "${normal}"
done
if [ $password1 != $password2 ]; then
echo "${bold}${red}WARNING${normal} ${bold}Passwords do not match${normal}" ; unset password2
else
localpass=$password1
fi
fi
done
ANPASS=$localpass
exec >&3- ; echo ; # return $exitvalue
else
echo -e "${bold}Password sets to ${blue}$ANPASS${normal}\n"
fi ; }
# --------------------- 询问安装前是否需要更换软件源 --------------------- #
function _askaptsource() {
while [[ $aptsources = "" ]]; do
# read -ep "${bold}${yellow}Would you like to change sources list?${normal} [${cyan}Y${normal}]es or [N]o: " responce
echo -ne "${bold}${yellow}Would you like to change sources list?${normal} [${cyan}Y${normal}]es or [N]o: " ; read -e responce
case $responce in
[yY] | [yY][Ee][Ss] | "" ) aptsources=Yes ;;
[nN] | [nN][Oo] ) aptsources=No ;;
* ) aptsources=Yes ;;
esac
done
if [[ $aptsources == Yes ]]; then
echo "${bold}${baiqingse}/etc/apt/sources.list${normal} ${bold}will be replaced${normal}"
else
echo "${baizise}/etc/apt/sources.list will ${baihongse}not${baizise} be replaced${normal}"
fi
echo ; }
# --------------------- 询问编译安装时需要使用的线程数量 --------------------- #
function _askmt() {
while [[ $MAXCPUS = "" ]]; do
echo -e "${green}01)${normal} Use ${cyan}all${normal} available threads (Default)"
echo -e "${green}02)${normal} Use ${cyan}half${normal} of available threads"
echo -e "${green}03)${normal} Use ${cyan}one${normal} thread"
echo -e "${green}04)${normal} Use ${cyan}two${normal} threads"
# echo -e "${red}99)${normal} Do not compile, install softwares from repo"
# echo -e "${bold}${red}Note that${normal} ${bold}using more than one thread to compile may cause failure in some cases${normal}"
# read -ep "${bold}${yellow}How many threads do you want to use when compiling?${normal} (Default ${cyan}01${normal}): " version
echo -ne "${bold}${yellow}How many threads do you want to use when compiling?${normal} (Default ${cyan}01${normal}): " ; read -e responce
case $responce in
01 | 1 | "") MAXCPUS=$(nproc) ;;
02 | 2 ) MAXCPUS=$(echo "$(nproc) / 2"|bc) ;;
03 | 3 ) MAXCPUS=1 ;;
04 | 4 ) MAXCPUS=2 ;;
05 | 5 ) MAXCPUS=No ;;
* ) MAXCPUS=$(nproc) ;;
esac
done
if [[ $MAXCPUS == No ]]; then
echo -e "${bold}${baiqingse}Deluge/qBittorrent/Transmission will be installed from repo${normal}"
else
echo -e "${bold}${baiqingse}[${MAXCPUS}]${normal} ${bold}thread(s) will be used when compiling${normal}"
fi
echo ; }
# --------------------- 询问是否使用 swap --------------------- #
function _askswap() {
if [[ $USESWAP = "" ]] && [[ $tram -le 1926 ]]; then
echo -e "${bold}${red}Note that${normal} ${bold}Your RAM is below ${red}1926MB${jiacu}, memory may got exhausted when compiling${normal}"
# read -ep "${bold}${yellow}How many threads do you want to use when compiling?${normal} (Default ${cyan}01${normal}): " version
echo -ne "${bold}${yellow}Would you like to use swap when compiling?${normal} [${cyan}Y${normal}]es or [N]o: " ; read -e responce
case $responce in
[yY] | [yY][Ee][Ss] | "") USESWAP=Yes ;;
[nN] | [nN][Oo] ) USESWAP=No ;;
* ) USESWAP=Yes ;;
esac
if [[ $USESWAP == Yes ]]; then
echo -e "${bold}${baiqingse} 1GB Swap ${normal} will be used"
else
echo -e "${bold}Swap will not be used${normal}"
fi
echo
fi ; }
# --------------------- 询问需要安装的 qBittorrent 的版本 --------------------- #
# wget -qO- "https://github.com/qbittorrent/qBittorrent" | grep "data-name" | cut -d '"' -f2 | pr -4 -t ; echo
function _askqbt() {
while [[ $QBVERSION = "" ]]; do
echo -e "${green}01)${normal} qBittorrent ${cyan}3.3.7${normal}"
echo -e "${green}02)${normal} qBittorrent ${cyan}3.3.11${normal}"
echo -e "${green}03)${normal} qBittorrent ${cyan}3.3.14${normal}"
echo -e "${green}04)${normal} qBittorrent ${cyan}3.3.16${normal}"
echo -e "${green}11)${normal} qBittorrent ${cyan}4.0.2${normal}"
echo -e "${green}12)${normal} qBittorrent ${cyan}4.0.3${normal}"
echo -e "${green}13)${normal} qBittorrent ${cyan}4.0.4${normal}"
echo -e "${green}14)${normal} qBittorrent ${cyan}4.1.0${normal}"
echo -e "${green}15)${normal} qBittorrent ${cyan}4.1.1${normal}"
echo -e "${green}30)${normal} Select another version"
echo -e "${green}40)${normal} qBittorrent ${cyan}$QB_repo_ver${normal} from ${cyan}repo${normal}"
[[ $DISTRO == Ubuntu ]] &&
echo -e "${green}50)${normal} qBittorrent ${cyan}$QB_latest_ver${normal} from ${cyan}Stable PPA${normal}"
echo -e "${red}99)${normal} Do not install qBittorrent"
[[ $qb_installed == Yes ]] &&
echo -e "${bailanse}${bold} ATTENTION ${normal} ${blue}${bold}You have already installed ${underline}qBittorrent ${qbtnox_ver}${normal}"
#read -ep "${bold}${yellow}Which version do you want?${normal} (Default ${cyan}02${normal}): " version
echo -ne "${bold}${yellow}Which version of qBittorrent do you want?${normal} (Default ${cyan}13${normal}): " ; read -e version
case $version in
01 | 1) QBVERSION=3.3.7 ;;
02 | 2) QBVERSION=3.3.11 ;;
03 | 3) QBVERSION=3.3.14 ;;
04 | 4) QBVERSION=3.3.16 ;;
11) QBVERSION=4.0.2 ;;
12) QBVERSION=4.0.3 ;;
13) QBVERSION=4.0.4 ;;
14) QBVERSION=4.1.0 ;;
15) QBVERSION=4.1.1 ;;
21) QBVERSION='3.3.11 (Skip hash check)' ;;
30) _inputversion && QBVERSION="${inputversion}" ;;
40) QBVERSION='Install from repo' ;;
50) QBVERSION='Install from PPA' ;;
99) QBVERSION=No ;;
* | "") QBVERSION=4.0.4 ;;
esac
done
[[ $QBVERSION == '3.3.11 (Skip hash check)' ]] && QBPATCH=Yes
if [[ $QBVERSION == No ]]; then
echo "${baizise}qBittorrent will ${baihongse}not${baizise} be installed${normal}"
elif [[ $QBVERSION == "Install from repo" ]]; then
sleep 0
elif [[ $QBVERSION == "Install from PPA" ]]; then
if [[ $DISTRO == Debian ]]; then
echo -e "${bailanse}${bold} ATTENTION ${normal} ${bold}Your distribution is ${green}Debian${jiacu}, which is not supported by ${green}Ubuntu${jiacu} PPA"
echo -ne "Therefore "
QBVERSION='Install from repo'
else
echo "${bold}${baiqingse}qBittorrent $QB_latest_ver${normal} ${bold}will be installed from Stable PPA${normal}"
fi
else
echo "${bold}${baiqingse}qBittorrent ${QBVERSION}${normal} ${bold}will be installed${normal}"
fi
if [[ $QBVERSION == "Install from repo" ]]; then
echo "${bold}${baiqingse}qBittorrent $QB_repo_ver${normal} ${bold}will be installed from repository${normal}"
fi
echo ; }
# --------------------- 询问需要安装的 Deluge 版本 --------------------- #
# wget -qO- "http://download.deluge-torrent.org/source/" | grep -Eo "1\.3\.[0-9]+" | sort -u | pr -6 -t ; echo
function _askdeluge() {
while [[ $DEVERSION = "" ]]; do
echo -e "${green}01)${normal} Deluge ${cyan}1.3.11${normal}"
echo -e "${green}02)${normal} Deluge ${cyan}1.3.12${normal}"
echo -e "${green}03)${normal} Deluge ${cyan}1.3.13${normal}"
echo -e "${green}04)${normal} Deluge ${cyan}1.3.14${normal}"
echo -e "${green}05)${normal} Deluge ${cyan}1.3.15${normal}"
# echo -e "${green}21)${normal} Deluge ${cyan}1.3.15 (Skip hash check)${normal}"
echo -e "${green}30)${normal} Select another version"
echo -e "${green}40)${normal} Deluge ${cyan}$DE_repo_ver${normal} from ${cyan}repo${normal}"
[[ $DISTRO == Ubuntu ]] &&
echo -e "${green}50)${normal} Deluge ${cyan}$DE_latest_ver${normal} from ${cyan}PPA${normal}"
echo -e "${red}99)${normal} Do not install Deluge"
[[ $de_installed == Yes ]] &&
echo -e "${bailanse}${bold} ATTENTION ${normal} ${blue}${bold}You have already installed ${underline}Deluge ${deluged_ver}${reset_underline}${normal}"
#read -ep "${bold}${yellow}Which version do you want?${normal} (Default ${cyan}${dedefaultnum}${normal}): " version
echo -ne "${bold}${yellow}Which version of Deluge do you want?${normal} (Default ${cyan}05${normal}): " ; read -e version
case $version in
01 | 1) DEVERSION=1.3.11 ;;
02 | 2) DEVERSION=1.3.12 ;;
03 | 3) DEVERSION=1.3.13 ;;
04 | 4) DEVERSION=1.3.14 ;;
05 | 5) DEVERSION=1.3.15 ;;
11) DEVERSION=1.3.5 ;;
12) DEVERSION=1.3.6 ;;
13) DEVERSION=1.3.7 ;;
14) DEVERSION=1.3.8 ;;
15) DEVERSION=1.3.9 ;;
21) DEVERSION='1.3.15 (Skip hash check)' ;;
30) _inputversion && DEVERSION="${inputversion}" ;;
40) DEVERSION='Install from repo' ;;
50) DEVERSION='Install from PPA' ;;
99) DEVERSION=No ;;
* | "") DEVERSION=1.3.15 ;;
esac
done
[[ ` echo $DEVERSION | grep -oP "[0-9.]+" | awk -F '.' '{print $3}' ` -lt 11 ]] && DESSL=Yes
[[ $DEVERSION == '1.3.15 (Skip hash check)' ]] && DESKIP=Yes
if [[ $DEVERSION == No ]]; then
echo "${baizise}Deluge will ${baihongse}not${baizise} be installed${normal}"
# DELTVERSION=NoDeluge
elif [[ $DEVERSION == "Install from repo" ]]; then
sleep 0
elif [[ $DEVERSION == "Install from PPA" ]]; then
if [[ $DISTRO == Debian ]]; then
echo -e "${bailanse}${bold} ATTENTION ${normal} ${bold}Your Linux distribution is ${green}Debian${jiacu}, which is not supported by ${green}Ubuntu${jiacu} PPA"
echo -ne "Therefore "
DEVERSION='Install from repo'
else
echo "${bold}${baiqingse}Deluge $DE_latest_ver${normal} ${bold}will be installed from PPA${normal}"
fi
else
echo "${bold}${baiqingse}Deluge ${DEVERSION}${normal} ${bold}will be installed${normal}"
fi
if [[ $DEVERSION == "Install from repo" ]]; then
echo "${bold}${baiqingse}Deluge $DE_repo_ver${normal} ${bold}will be installed from repository${normal}"
fi
echo ; }
# 2018.04.26 禁用这个问题,统一使用 1.0.11
# --------------------- 询问需要安装的 Deluge libtorrent 版本 --------------------- #
# DELTVERSION=$( wget -qO- "https://github.com/arvidn/libtorrent" | grep "data-name" | cut -d '"' -f2 | grep "libtorrent-1_1_" | sort -t _ -n -k 3 | tail -n1 )
function _askdelt() {
while [[ $DELTVERSION = "" ]]; do
if [[ $DEVERSION == "Install from repo" ]]; then
DELTVERSION='Install from repo' && DeLTDefault=1
elif [[ $DEVERSION == "Install from PPA" ]]; then
DELTVERSION='Install from PPA' && DeLTDefault=1
else
# echo -e "${green}00)${normal} libtorrent-rasterbar ${cyan}0.16.19${normal} (NOT recommended)"
echo -e "${green}01)${normal} libtorrent-rasterbar ${cyan}1.0.11${normal}"
echo -e "${green}02)${normal} libtorrent-rasterbar ${cyan}1.1.7 ${normal}"
echo -e "${green}30)${normal} Select another version"
echo -e "${green}40)${normal} libtorrent-rasterbar ${cyan}$PYLT_repo_ver${normal} from ${cyan}repo${normal}"
[[ $DISTRO == Ubuntu ]] &&
echo -e "${green}50)${normal} libtorrent-rasterbar ${cyan}$DELT_PPA_ver${normal} from ${cyan}Deluge PPA${normal}"
# [[ $de_installed == Yes ]] &&
echo -e "${red}99)${normal} Do not install libtorrent-rasterbar AGAIN"
[[ $delugelt_ver ]] &&
echo -e "${bailanse}${bold} ATTENTION ${normal} ${blue}${bold}You have already installed ${underline}libtorrent-rasterbar ${delugelt_ver}${reset_underline}${normal}"
echo "${shanshuo}${baihongse}${bold} ATTENTION ${normal} ${blue}${bold}USE THE ${heihuangse}DEFAULT${normal}${blue}${bold} OPINION UNLESS YOU KNOW WHAT'S THIS${normal}"
# echo -e "${bailanse}${bold} 注意! ${normal} ${blue}${bold}如果你不知道这是什么玩意儿,请使用默认选项${normal}"
# read -ep "${bold}${yellow}Which version do you want?${normal} (Default ${cyan}01${normal}): " version
echo -ne "${bold}${yellow}Which version of libtorrent do you want?${normal} (Default ${cyan}01${normal}): " ; read -e version
case $version in
00 | 0) DELTVERSION=RC_0_16 ;;
01 | 1) DELTVERSION=1.0.11 && DeLTDefault=1 ;;
02 | 2) DELTVERSION=RC_1_1 ;;
03 | 3) DELTVERSION=RC_1_0 ;;
30) _inputversionlt && DELTVERSION="${inputversion}" ;;
40) DELTVERSION='Install from repo' ;;
50) DELTVERSION='Install from PPA' ;;
99) DELTVERSION=No ;;
"" | *) DELTVERSION=1.0.11 && DeLTDefault=1 ;;
esac
fi
if [[ ! $DeLTDefault == 1 ]]; then
echo -e "\n${bailanse}${bold} 注意!${normal} ${blue}${bold}不要老是想着搞个大新闻,不用默认选项很可能引发 bug!"
echo -e "只有某些特殊情况下才需要选择非默认选项,比如之前已经安装过了\n不然我都想把这个极容易导致翻车的选项直接去除改成强制选择默认的了 ……"
echo -ne "${yellow}即使如此你还是要选 ${blue}$DELTVERSION${jiacu} 这个选项么?${normal} [Y]es or [${cyan}N${normal}]o: " ; read -e confirm
case $confirm in
[yY] | [yY][Ee][Ss] ) Zuosi=Yes && echo -e "\n${bold}作死成功,翻车了别来汇报 bug,这个本来就是这样的 (╯‵□′)╯︵┻━┻ ${normal}\n" ;;
[nN] | [nN][Oo] | "" ) Zuosi=No && echo -e "\n${bold}那我再问你一次,这次你自己看着办吧${normal}\n" && unset DELTVERSION ;;
*) Zuosi=No && unset DELTVERSION && echo -e "\n${bold}那我还是再问你一遍吧,这次你自己看着办${normal}\n" ;;
esac
fi
done
DELTPKG=` echo "$DELTVERSION" | sed "s/_/\./g" | sed "s/libtorrent-//" `
[[ $DELTVERSION == RC_0_16 ]] && DELTPKG=` wget -qO- "https://github.com/arvidn/libtorrent" | grep "data-name" | cut -d '"' -f2 | grep "libtorrent-0_16_" | sort -t _ -n -k 3 | tail -n1 | sed "s/_/\./g" | sed "s/libtorrent-//" `
[[ $DELTVERSION == RC_1_0 ]] && DELTPKG=` wget -qO- "https://github.com/arvidn/libtorrent" | grep "data-name" | cut -d '"' -f2 | grep "libtorrent-1_0_" | sort -t _ -n -k 3 | tail -n1 | sed "s/_/\./g" | sed "s/libtorrent-//" `
[[ $DELTVERSION == RC_1_1 ]] && DELTPKG=` wget -qO- "https://github.com/arvidn/libtorrent" | grep "data-name" | cut -d '"' -f2 | grep "libtorrent-1_1_" | sort -t _ -n -k 3 | tail -n1 | sed "s/_/\./g" | sed "s/libtorrent-//" `
[[ $DELTVERSION == 1.0.11 ]] && DELTPKG=1.0.11
if [[ $DELTVERSION == "Install from repo" ]]; then
echo "${bold}${baiqingse}libtorrent-rasterbar $PYLT_repo_ver${normal} ${bold}will be installed from repository${normal}"
elif [[ $DELTVERSION == "Install from PPA" ]]; then
echo "${baiqingse}${bold}libtorrent-rasterbar $DELT_PPA_ver${normal} ${bold}will be installed from Deluge PPA${normal}"
elif [[ $DELTVERSION == No ]]; then
echo "${baiqingse}${bold}libtorrent-rasterbar ${delugelt_ver}${normal}${bold} will be used from system${normal}"
else
echo "${baiqingse}${bold}libtorrent-rasterbar ${DELTPKG}${normal} ${bold}will be installed${normal}"
fi
echo ; }
# --------------------- 询问需要安装的 rTorrent 版本 --------------------- #
function _askrt() {
while [[ $RTVERSION = "" ]]; do
[[ ! $rtorrent_dev == 1 ]] &&
echo -e "${green}01)${normal} rTorrent ${cyan}0.9.2${normal}" &&
echo -e "${green}02)${normal} rTorrent ${cyan}0.9.3${normal}" &&
echo -e "${green}03)${normal} rTorrent ${cyan}0.9.4${normal}" &&
echo -e "${green}04)${normal} rTorrent ${cyan}0.9.6${normal}" &&
echo -e "${green}11)${normal} rTorrent ${cyan}0.9.2${normal} (with IPv6 support)" &&
echo -e "${green}12)${normal} rTorrent ${cyan}0.9.3${normal} (with IPv6 support)" &&
echo -e "${green}13)${normal} rTorrent ${cyan}0.9.4${normal} (with IPv6 support)"
echo -e "${green}14)${normal} rTorrent ${cyan}0.9.6${normal} (with IPv6 support, feature-bind branch)"
echo -e "${green}15)${normal} rTorrent ${cyan}0.9.7${normal} (with IPv6 support)"
echo -e "${red}99)${normal} Do not install rTorrent"
[[ $rt_installed == Yes ]] &&
echo -e "${bailanse}${bold} ATTENTION ${normal} ${blue}${bold}You have already installed ${underline}rTorrent ${rtorrent_ver}${normal}"
# [[ $rt_installed == Yes ]] && echo -e "${bold}If you want to downgrade or upgrade rTorrent, use ${blue}rtupdate${normal}"
if [[ $rtorrent_dev == 1 ]]; then
echo "${bold}${red}Note that${normal} ${bold}${green}Debian 9${jiacu} and ${green}Ubuntu 18.04 ${jiacu}is only supported by ${green}rTorrent 0.9.6 and later${normal}"
#read -ep "${bold}${yellow}Which version do you want?${normal} (Default ${cyan}04${normal}): " version
echo -ne "${bold}${yellow}Which version of rTorrent do you want?${normal} (Default ${cyan}14${normal}): " ; read -e version
case $version in