forked from affvps/shell_for_ss_ssr_ssrr_kcptun_bbr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdebug.sh
2508 lines (2494 loc) · 107 KB
/
debug.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
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH
shell_version="2.0.7"
shell_download_link="https://raw.githubusercontent.com/onekeyshell/kcptun_for_ss_ssr/master/kcptun_for_ss_ssr-install.sh"
program_version_link="https://raw.githubusercontent.com/Jenking-Zhang/shell_for_ss_ssr_ssrr_kcptun_bbr/master/version.sh"
ss_libev_config="/etc/shadowsocks-libev/config.json"
ssr_config="/usr/local/shadowsocksR/shadowsocksR.json"
ssrr_config="/usr/local/shadowsocksRR/user-config.json"
kcptun_config="/usr/local/kcptun/config.json"
export def_port=$(shuf -i 10000-65534 -n 1)
# Set text color
COLOR_RED='\E[1;31m'
COLOR_RED_DEEP='\033[0;31m'
COLOR_GREEN='\E[1;32m'
COLOR_GREEN_DEEP='\033[0;32m'
COLOR_GREEN_LIGHTNING='\033[32m \033[05m'
COLOR_YELLOW='\E[1;33m'
COLOR_BLUE='\E[1;34m'
COLOR_PINK='\E[1;35m'
COLOR_PINKBACK_WHITEFONT='\033[45;37m'
COLOR_END='\E[0m'
# Check if user is root
if [ $(id -u) != "0" ]; then
echo "${COLOR_RED}Error: You must be root to run this script, please use root to install SS/SSR/SSRR/kcptun/BBR!${COLOR_END}"
exit 1
fi
if [[ ! `grep -a CST-8 /etc/localtime` ]]; then
echo -e "${COLOR_YELLOW}Setting timezone...${COLOR_END}"
rm -rf /etc/localtime
ln -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
echo "done."
fi
shell_update(){
clear
echo "Check updates for shell..."
echo
remote_shell_version=`wget --no-check-certificate -qO- ${shell_download_link} | sed -n '/'^version'/p' | cut -d\" -f2`
echo -e "Shell remote version :${COLOR_GREEN}${remote_shell_version}${COLOR_END}"
echo -e "Shell local version :${COLOR_GREEN}${shell_version}${COLOR_END}"
if [ ! -z ${remote_shell_version} ]; then
if [[ "${shell_version}" != "${remote_shell_version}" ]];then
echo -e "${COLOR_GREEN}Found a new version of shell(ver:${remote_shell_version})!${COLOR_END}"
echo
def_shell_update_Select=1
echo -e "${COLOR_YELLOW}You have 2 options for your shell update.${COLOR_END}"
echo "1: Continue with currently shell (default)"
echo "2: Exit to update shell"
echo
read -p "Enter your choice (1, 2 or exit. default [${def_shell_update_Select}]): " shell_update_Select
case "${shell_update_Select}" in
1)
echo
echo -e "${COLOR_PINK}You will continue with currently shell${COLOR_END}"
;;
2)
echo
echo -e "${COLOR_PINK}You will exit to update shell${COLOR_END}"
exit 1
;;
[eE][xX][iI][tT])
echo -e "${COLOR_PINK}You select <Exit>, shell exit now!${COLOR_END}"
exit 1
;;
*)
echo
echo -e "${COLOR_PINK}No input or input error,You will continue with currently shell ${COLOR_END}"
esac
else
echo -e "${COLOR_PINK}Shell is up-to-date!${COLOR_END}"
fi
fi
}
# Check OS
version_ge(){
test "$(echo "$@" | tr " " "\n" | sort -rV | head -n 1)" == "$1"
}
version_gt(){
test "$(echo "$@" | tr " " "\n" | sort -V | head -n 1)" != "$1"
}
version_lt() {
test "$(echo "$@" | tr " " "\n" | sort -rV | head -n 1)" != "$1"
}
Get_Dist_Name(){
release=''
systemPackage=''
DISTRO=''
if grep -Eqi "CentOS" /etc/issue || grep -Eq "CentOS" /etc/*-release; then
DISTRO='CentOS'
release="centos"
systemPackage='yum'
elif grep -Eqi "centos|red hat|redhat" /etc/issue || grep -Eqi "centos|red hat|redhat" /etc/*-release; then
DISTRO='RHEL'
release="centos"
systemPackage='yum'
elif grep -Eqi "Aliyun" /etc/issue || grep -Eq "Aliyun" /etc/*-release; then
DISTRO='Aliyun'
release="centos"
systemPackage='yum'
elif grep -Eqi "Fedora" /etc/issue || grep -Eq "Fedora" /etc/*-release; then
DISTRO='Fedora'
release="centos"
systemPackage='yum'
elif grep -Eqi "Debian" /etc/issue || grep -Eq "Debian" /etc/*-release; then
DISTRO='Debian'
release="debian"
systemPackage='apt'
elif grep -Eqi "Ubuntu" /etc/issue || grep -Eq "Ubuntu" /etc/*-release; then
DISTRO='Ubuntu'
release="ubuntu"
systemPackage='apt'
elif grep -Eqi "Raspbian" /etc/issue || grep -Eq "Raspbian" /etc/*-release; then
DISTRO='Raspbian'
release="debian"
systemPackage='apt'
elif grep -Eqi "Deepin" /etc/issue || grep -Eq "Deepin" /etc/*-release; then
DISTRO='Deepin'
release="debian"
systemPackage='apt'
else
release='unknow'
fi
Get_OS_Bit
}
# Check OS bit
Get_OS_Bit(){
ARCHS=""
if [[ `getconf WORD_BIT` = '32' && `getconf LONG_BIT` = '64' ]] ; then
Is_64bit='y'
ARCHS="amd64"
else
Is_64bit='n'
ARCHS="386"
fi
}
# Check system
check_sys(){
local checkType=$1
local value=$2
if [[ ${checkType} == "sysRelease" ]]; then
if [ "$value" == "$release" ]; then
return 0
else
return 1
fi
elif [[ ${checkType} == "packageManager" ]]; then
if [ "$value" == "$systemPackage" ]; then
return 0
else
return 1
fi
fi
}
# Get version
getversion(){
if [[ -s /etc/redhat-release ]]; then
grep -oE "[0-9.]+" /etc/redhat-release
else
grep -oE "[0-9.]+" /etc/issue
fi
}
# CentOS version
centosversion(){
if check_sys sysRelease centos; then
local code=$1
local version="$(getversion)"
local main_ver=${version%%.*}
if [ "$main_ver" == "$code" ]; then
return 0
else
return 1
fi
else
return 1
fi
}
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
}
debianversion(){
if check_sys sysRelease debian;then
local version=$( get_opsy )
local code=${1}
local main_ver=$( echo ${version} | sed 's/[^0-9]//g')
if [ "${main_ver}" == "${code}" ];then
return 0
else
return 1
fi
else
return 1
fi
}
# Check OS system
Check_OS_support(){
if [ "${release}" == "unknow" ]; then
echo
echo -e "${COLOR_RED}Error: Unable to get Linux distribution name, or do NOT support the current distribution.${COLOR_END}"
echo
exit 1
elif [ "${DISTRO}" == "CentOS" ]; then
if centosversion 5; then
echo
echo -e "${COLOR_RED}Not support CentOS 5, please change to CentOS 6 or 7 and try again.${COLOR_END}"
echo
exit 1
fi
fi
}
Press_Install(){
echo ""
echo -e "${COLOR_GREEN}Press any key to install...or Press Ctrl+C to cancel${COLOR_END}"
OLDCONFIG=`stty -g`
stty -icanon -echo min 1 time 0
dd count=1 2>/dev/null
stty ${OLDCONFIG}
}
Press_Start(){
echo ""
echo -e "${COLOR_GREEN}Press any key to continue...or Press Ctrl+C to cancel${COLOR_END}"
OLDCONFIG=`stty -g`
stty -icanon -echo min 1 time 0
dd count=1 2>/dev/null
stty ${OLDCONFIG}
}
Press_Exit(){
echo ""
echo -e "${COLOR_GREEN}Press any key to Exit...or Press Ctrl+C to cancel${COLOR_END}"
OLDCONFIG=`stty -g`
stty -icanon -echo min 1 time 0
dd count=1 2>/dev/null
stty ${OLDCONFIG}
}
Print_Sys_Info(){
cat /etc/issue
cat /etc/*-release
uname -a
MemTotal=`free -m | grep Mem | awk '{print $2}'`
echo "Memory is: ${MemTotal} MB "
df -h
}
Disable_Selinux(){
if [ -s /etc/selinux/config ]; then
sed -i 's/^SELINUX=.*/SELINUX=disabled/g' /etc/selinux/config
fi
}
error_detect_depends(){
local command=$1
local depend=`echo "${command}" | awk '{print $4}'`
${command}
if [ $? != 0 ]; then
echo -e "${COLOR_RED}Error,Failed to install ${depend}${COLOR_END}"
exit 1
fi
}
install_dependencies_packs(){
if check_sys packageManager yum; then
echo -e "[${COLOR_GREEN}Info${COLOR_END}] Checking the EPEL repository..."
if [ ! -f /etc/yum.repos.d/epel.repo ]; then
yum install -y epel-release > /dev/null 2>&1
fi
[ ! -f /etc/yum.repos.d/epel.repo ] && echo -e "[${COLOR_RED}Error:install EPEL repository failed, please check it.${COLOR_END}" && exit 1
[ ! "$(command -v yum-config-manager)" ] && yum install -y yum-utils > /dev/null 2>&1
[ x"$(yum-config-manager epel | grep -w enabled | awk '{print $3}')" != x"True" ] && yum-config-manager --enable epel > /dev/null 2>&1
echo -e "[${COLOR_GREEN}Info${COLOR_END}] Checking the EPEL repository complete..."
yum_depends=(
unzip gzip openssl openssl-devel gcc python python-devel python-setuptools pcre pcre-devel libtool libevent
autoconf automake make curl curl-devel zlib-devel perl perl-devel cpio expat-devel gettext-devel
libev-devel c-ares-devel git qrencode nss
)
for depend in ${yum_depends[@]}; do
error_detect_depends "yum -y install ${depend}"
done
#yum update -y
elif check_sys packageManager apt; then
apt_depends=(
gettext build-essential unzip gzip python python-dev python-setuptools curl openssl libssl-dev
autoconf automake libtool gcc make perl cpio libpcre3 libpcre3-dev zlib1g-dev libev-dev libc-ares-dev git qrencode
)
apt-get -y update
for depend in ${apt_depends[@]}; do
error_detect_depends "apt-get -y install ${depend}"
done
#apt-get upgrade -y
fi
}
#update glibc to ver 2.15
update_glibc(){
echo -e "update glibc...."
yum install kernel-headers -y
wget -c http://ftp.redsleeve.org/pub/steam/glibc-2.15-60.el6.x86_64.rpm \
http://ftp.redsleeve.org/pub/steam/glibc-common-2.15-60.el6.x86_64.rpm \
http://ftp.redsleeve.org/pub/steam/glibc-devel-2.15-60.el6.x86_64.rpm \
http://ftp.redsleeve.org/pub/steam/glibc-headers-2.15-60.el6.x86_64.rpm \
http://ftp.redsleeve.org/pub/steam/nscd-2.15-60.el6.x86_64.rpm
rpm -Uvh glibc-2.15-60.el6.x86_64.rpm \
glibc-common-2.15-60.el6.x86_64.rpm \
glibc-devel-2.15-60.el6.x86_64.rpm \
glibc-headers-2.15-60.el6.x86_64.rpm \
nscd-2.15-60.el6.x86_64.rpm
}
#update autoconf to ver 2.69
update_autoconf(){
echo -e "update autoconf...."
cd ${cur_dir}
rpm -e --nodeps autoconf-*
wget ftp://ftp.gnu.org/gnu/autoconf/autoconf-2.69.tar.gz
tar zxvf autoconf-2.69.tar.gz
cd autoconf-2.69
./configure --prefix=/usr/
make && make install
}
# Random password
randstr(){
index=0
special[0]="#"
special[1]="$"
special[2]="&"
special[3]="^"
special[4]="!"
special[5]="%"
special[6]="@"
special[7]="+"
special[8]="-"
str=""
for i in {a..z}; do arr[index]=$i; index=`expr ${index} + 1`; done
for i in {A..Z}; do arr[index]=$i; index=`expr ${index} + 1`; done
for i in {0..9}; do arr[index]=$i; index=`expr ${index} + 1`; done
for i in ${special[@]}; do arr[index]=$i; index=`expr ${index} + 1`; done
for i in {1..9}; do str="$str${arr[$RANDOM%$index]}"; done
echo $str
}
get_ip(){
local IP=$(ip addr | egrep -o '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}' | egrep -v "^192\.168|^172\.1[6-9]\.|^172\.2[0-9]\.|^172\.3[0-2]\.|^10\.|^127\.|^255\.|^0\." | head -n 1)
[ -z ${IP} ] && IP=$(wget -qO- -t1 -T2 ip.clang.cn | sed -r 's/\r//')
[ -z ${IP} ] && IP=$(wget -qO- -t1 -T2 ipv4.icanhazip.com | sed -r 's/\r//')
[ ! -z ${IP} ] && echo ${IP} || echo
}
Dispaly_Selection(){
def_Install_Select="1"
echo -e "${COLOR_YELLOW}You have 7 options for your ss/ssr/ssrr/kcptun install.${COLOR_END}"
echo "1: Install Shadowsocks-libev (default)"
echo "2: Install ShadowsocksR(python)"
echo "3: Install kcptun"
echo "4: Install Shadowsocks-libev + kcptun"
echo "5: Install ShadowsocksR(python) + kcptun"
echo "6: Install ShadowsocksRR(python)"
echo "7: Install ShadowsocksRR(python) + kcptun"
read -p "Enter your choice (1, 2, 3, 4, 5, 6, 7 or exit. default [${def_Install_Select}]): " Install_Select
case "${Install_Select}" in
1)
echo
echo -e "${COLOR_PINK}You will install Shadowsocks-libev ${SS_LIBEV_VER}${COLOR_END}"
;;
2)
echo
echo -e "${COLOR_PINK}You will install ShadowsocksR(python) ${SSR_VER}${COLOR_END}"
;;
3)
echo
echo -e "${COLOR_PINK}You will install KCPTUN ${KCPTUN_VER}${COLOR_END}"
;;
4)
echo
echo -e "${COLOR_PINK}You will Install Shadowsocks-libev ${SS_LIBEV_VER} + kcptun ${KCPTUN_VER}${COLOR_END}"
;;
5)
echo
echo -e "${COLOR_PINK}You will install ShadowsocksR(python) ${SSR_VER} + kcptun ${KCPTUN_VER}${COLOR_END}"
;;
6)
echo
echo -e "${COLOR_PINK}You will install ShadowsocksRR(python) ${SSRR_VER}${COLOR_END}"
;;
7)
echo
echo -e "${COLOR_PINK}You will install ShadowsocksRR(python) ${SSRR_VER} + kcptun ${KCPTUN_VER}${COLOR_END}"
;;
[eE][xX][iI][tT])
echo -e "${COLOR_PINK}You select <Exit>, shell exit now!${COLOR_END}"
exit 1
;;
*)
echo
echo -e "${COLOR_PINK}No input or input error,You will install Shadowsocks-libev${COLOR_END}"
Install_Select="${def_Install_Select}"
esac
if [ "${Install_Select}" == "1" ] || [ "${Install_Select}" == "4" ]; then
def_Install_obfs="Y"
echo
echo -e "${COLOR_YELLOW}Do you want to install simple-obfs for Shadowsocks-libev?[Y/N]${COLOR_END}"
read -p "Enter your choice for simple-obf installation. default: ${def_Install_obfs}:" Install_obfs
case "${Install_obfs}" in
[yY])
echo
echo -e "${COLOR_PINK}You will install Simple-obfs for Shadowsocks-libev${COLOR_END}"
;;
[nN])
echo
echo -e "${COLOR_PINK}You will not install Simple-obfs${COLOR_END}"
;;
*)
echo -e "${COLOR_PINK}No input or input error,You will install Simple-obfs for Shadowsocks-libev${COLOR_END}"
Install_obfs="${def_Install_obfs}"
esac
fi
}
Simple_obfs_option(){
if [ "${Install_obfs}" == "y" ] || [ "${Install_obfs}" == "Y" ]; then
echo
def_ofbs_option="1"
echo -e "${COLOR_YELLOW}Please select your Simple-obfs setting:${COLOR_END}"
echo "1: http (default)"
echo "2: tls"
#read -p "Enter your choice (1, 2. default ${def_ofbs_option}): " ofbs_option
case "${ofbs_option}" in
1|[hH][tT][tT][pP])
ofbs_option="http"
;;
2|[tT][lL][sS])
ofbs_option="tls"
;;
*)
echo -e "${COLOR_PINK}No input or input error,Simple-obfs will be set to:http${COLOR_END}"
ofbs_option="http"
esac
fi
}
BBR_Selection(){
if [ -d "/proc/vz" ] && [[ "$(cat /dev/net/tun 2>&1)" == "cat: /dev/net/tun: File descriptor in bad state" ]]; then
echo
echo -e "${COLOR_GREEN}System is based on OpenVZ and Tap/tun enabled${COLOR_END}"
def_bbr_install="Y"
echo -e "${COLOR_YELLOW}Do you want to install BBR?[Y/N]${COLOR_END} "
read -p "Enter your choice for BBR installation. default [${def_bbr_install}]: " bbr_install
case "${bbr_install}" in
[yY])
echo
echo -e "${COLOR_PINK}You will install BBR${COLOR_END}"
;;
[nN])
echo
echo -e "${COLOR_PINK}You will not install BBR${COLOR_END}"
;;
*)
echo
echo -e "${COLOR_PINK}No input or input error,You will install BBR${COLOR_END}"
bbr_install="${def_bbr_install}"
esac
if [ ${bbr_install} == "y" ] || [ ${bbr_install} == "Y" ];then
def_bbr_port=${def_port}
while true
do
echo
echo -e "Please input port for BBR [1-65535]"
read -p "(Default port: ${def_bbr_port}):" bbr_port
[ -z "$bbr_port" ] && bbr_port="${def_bbr_port}"
expr ${bbr_port} + 0 &>/dev/null
if [ $? -eq 0 ]; then
if [ ${bbr_port} -ge 1 ] && [ ${bbr_port} -le 65535 ]; then
echo
echo "---------------------------------------"
echo "BBR port = ${bbr_port}"
echo "---------------------------------------"
echo
break
else
echo -e "${COLOR_RED}Input error, please input correct number"${COLOR_END}
fi
else
echo -e "${COLOR_RED}Input error, please input correct number"${COLOR_END}
fi
done
export bbr_port
fi
fi
}
# Install cleanup
install_cleanup(){
cd ${cur_dir}
rm -rf .version.sh shadowsocks-libev-* manyuser.zip shadowsocksr-manyuser shadowsocks-manyuser kcptun-linux-* libsodium-* mbedtls-* shadowsocksr-akkariiin-master ssrr.zip ovz-bbr-installer.sh glibc-2.15-60.el6.x86_64.rpm glibc-common-2.15-60.el6.x86_64.rpm glibc-devel-2.15-60.el6.x86_64.rpm glibc-headers-2.15-60.el6.x86_64.rpm nscd-2.15-60.el6.x86_64.rpm simple-obfs simple-obfs.tar.gz autoconf-2.69.tar.gz autoconf-2.69
}
check_ss_ssr_ssrr_kcptun_installed(){
ss_libev_installed_flag=""
ssr_installed_flag=""
ssrr_installed_flag=""
kcptun_installed_flag=""
kcptun_install_flag=""
ss_libev_install_flag=""
ssr_install_flag=""
ssrr_install_flag=""
if [ "${Install_Select}" == "1" ] || [ "${Install_Select}" == "4" ] || [ "${Update_Select}" == "1" ] || [ "${Update_Select}" == "5" ] || [ "${Uninstall_Select}" == "1" ] || [ "${Uninstall_Select}" == "5" ]; then
if [[ "$(command -v "ss-server")" ]] || [[ "$(command -v "/usr/local/bin/ss-server")" ]]; then
ss_libev_installed_flag="true"
else
ss_libev_installed_flag="false"
fi
fi
if [ "${Install_Select}" == "2" ] || [ "${Install_Select}" == "5" ] || [ "${Update_Select}" == "2" ] || [ "${Update_Select}" == "5" ] || [ "${Uninstall_Select}" == "2" ] || [ "${Uninstall_Select}" == "5" ]; then
if [[ -x /usr/local/shadowsocksR/shadowsocks/server.py ]] && [[ -s /usr/local/shadowsocksR/shadowsocks/__init__.py ]]; then
ssr_installed_flag="true"
else
ssr_installed_flag="false"
fi
fi
if [ "${Install_Select}" == "6" ] || [ "${Install_Select}" == "7" ] || [ "${Update_Select}" == "4" ] || [ "${Update_Select}" == "5" ] || [ "${Uninstall_Select}" == "4" ] || [ "${Uninstall_Select}" == "5" ]; then
if [[ -x /usr/local/shadowsocksRR/shadowsocks/server.py ]] && [[ -s /usr/local/shadowsocksRR/shadowsocks/__init__.py ]]; then
ssrr_installed_flag="true"
else
ssrr_installed_flag="false"
fi
fi
if [ "${Install_Select}" == "3" ] || [ "${Install_Select}" == "4" ] || [ "${Install_Select}" == "5" ] || [ "${Install_Select}" == "7" ] || [ "${Update_Select}" == "3" ] || [ "${Update_Select}" == "5" ] || [ "${Uninstall_Select}" == "3" ] || [ "${Uninstall_Select}" == "5" ]; then
if [[ "$(command -v "/usr/local/kcptun/kcptun")" ]] || [[ "$(command -v "kcptun")" ]]; then
kcptun_installed_flag="true"
else
kcptun_installed_flag="false"
fi
fi
}
get_install_version(){
rm -f ${cur_dir}/.version.sh
if ! wget --no-check-certificate -qO ${cur_dir}/.version.sh ${program_version_link}; then
echo -e "${COLOR_RED}Failed to download version.sh${COLOR_END}"
fi
if [ -s ${cur_dir}/.version.sh ]; then
[ -x ${cur_dir}/.version.sh ] && chmod +x ${cur_dir}/.version.sh
. ${cur_dir}/.version.sh
fi
if [ -z ${LIBSODIUM_VER} ] || [ -z ${MBEDTLS_VER} ] || [ -z ${SS_LIBEV_VER} ] || [ -z ${SSR_VER} ] || [ -z ${SSRR_VER} ] || [ -z ${KCPTUN_VER} ]; then
echo -e "${COLOR_RED}Error: Get Program version failed!${COLOR_END}"
exit 1
fi
}
get_latest_version(){
rm -f ${cur_dir}/.api_*.txt
if [[ "${ss_libev_installed_flag}" == "false" && "${shell_action}" =~ ^[Ii]|[Ii][Nn]|[Ii][Nn][Ss][Tt][Aa][Ll][Ll]|-[Ii]|--[Ii]$ ]] || [[ "${ss_libev_installed_flag}" == "true" && "${shell_action}" =~ ^[Uu]|[Uu][Pp][Dd][Aa][Tt][Ee]|-[Uu]|--[Uu]|[Uu][Pp]|-[Uu][Pp]|--[Uu][Pp]$ ]]; then
echo -e "Loading Shadowsocks-libev version, please wait..."
if check_sys packageManager yum; then
ss_libev_init_link="${SS_LIBEV_YUM_INIT}"
elif check_sys packageManager apt; then
ss_libev_init_link="${SS_LIBEV_APT_INIT}"
fi
shadowsocks_libev_ver="shadowsocks-libev-${SS_LIBEV_VER}"
if [[ "${ss_libev_installed_flag}" == "false" && "${shell_action}" =~ ^[Ii]|[Ii][Nn]|[Ii][Nn][Ss][Tt][Aa][Ll][Ll]|-[Ii]|--[Ii]$ ]]; then
echo -e "Get the Shadowsocks-libev version:${COLOR_GREEN} ${SS_LIBEV_VER}${COLOR_END}"
fi
fi
if [ ! -f /usr/lib/libsodium.a ] && [ ! -L /usr/local/lib/libsodium.so ]; then
echo -e "Loading libsodium version, please wait..."
libsodium_laster_ver="libsodium-${LIBSODIUM_VER}"
if [ "${libsodium_laster_ver}" == "" ] || [ "${LIBSODIUM_LINK}" == "" ]; then
echo -e "${COLOR_RED}Error: Get libsodium version failed${COLOR_END}"
exit 1
fi
echo -e "Get the libsodium version:${COLOR_GREEN} ${LIBSODIUM_VER}${COLOR_END}"
fi
if [ ! -f /usr/lib/libmbedtls.a ] && [ ! -f /usr/include/mbedtls/version.h ]; then
echo -e "Loading mbedtls version, please wait..."
mbedtls_laster_ver="mbedtls-${MBEDTLS_VER}"
if [ "${mbedtls_laster_ver}" == "" ] || [ "${MBEDTLS_LINK}" == "" ]; then
echo -e "${COLOR_RED}Error: Get mbedtls version failed${COLOR_END}"
exit 1
fi
echo -e "Get the mbedtls version:${COLOR_GREEN} ${MBEDTLS_VER}${COLOR_END}"
fi
if [[ "${ssr_installed_flag}" == "false" && "${shell_action}" =~ ^[Ii]|[Ii][Nn]|[Ii][Nn][Ss][Tt][Aa][Ll][Ll]|-[Ii]|--[Ii]$ ]] || [[ "${ssr_installed_flag}" == "true" && "${shell_action}" =~ ^[Uu]|[Uu][Pp][Dd][Aa][Tt][Ee]|-[Uu]|--[Uu]|[Uu][Pp]|-[Uu][Pp]|--[Uu][Pp]$ ]]; then
echo -e "Loading ShadowsocksR version, please wait..."
ssr_download_link="${SSR_LINK}"
ssr_latest_ver="${SSR_VER}"
if check_sys packageManager yum; then
ssr_init_link="${SSR_YUM_INIT}"
elif check_sys packageManager apt; then
ssr_init_link="${SSR_APT_INIT}"
fi
if [[ "${ssr_installed_flag}" == "false" && "${shell_action}" =~ ^[Ii]|[Ii][Nn]|[Ii][Nn][Ss][Tt][Aa][Ll][Ll]|-[Ii]|--[Ii]$ ]]; then
echo -e "Get the ShadowsocksR version:${COLOR_GREEN} ${SSR_VER}${COLOR_END}"
fi
fi
if [[ "${ssrr_installed_flag}" == "false" && "${shell_action}" =~ ^[Ii]|[Ii][Nn]|[Ii][Nn][Ss][Tt][Aa][Ll][Ll]|-[Ii]|--[Ii]$ ]] || [[ "${ssrr_installed_flag}" == "true" && "${shell_action}" =~ ^[Uu]|[Uu][Pp][Dd][Aa][Tt][Ee]|-[Uu]|--[Uu]|[Uu][Pp]|-[Uu][Pp]|--[Uu][Pp]$ ]]; then
echo -e "Loading ShadowsocksRR version, please wait..."
ssrr_download_link="${SSRR_LINK}"
ssrr_latest_ver="${SSRR_VER}"
if check_sys packageManager yum; then
ssrr_init_link="${SSRR_YUM_INIT}"
elif check_sys packageManager apt; then
ssrr_init_link="${SSRR_APT_INIT}"
fi
if [[ "${ssrr_installed_flag}" == "false" && "${shell_action}" =~ ^[Ii]|[Ii][Nn]|[Ii][Nn][Ss][Tt][Aa][Ll][Ll]|-[Ii]|--[Ii]$ ]]; then
echo -e "Get the ShadowsocksRR version:${COLOR_GREEN} ${SSRR_VER}${COLOR_END}"
fi
fi
if [[ "${kcptun_installed_flag}" == "false" && "${shell_action}" =~ ^[Ii]|[Ii][Nn]|[Ii][Nn][Ss][Tt][Aa][Ll][Ll]|-[Ii]|--[Ii]$ ]] || [[ "${kcptun_installed_flag}" == "true" && "${shell_action}" =~ ^[Uu]|[Uu][Pp][Dd][Aa][Tt][Ee]|-[Uu]|--[Uu]|[Uu][Pp]|-[Uu][Pp]|--[Uu][Pp]$ ]]; then
echo -e "Loading kcptun version, please wait..."
kcptun_init_link="${KCPTUN_INIT}"
kcptun_latest_file="kcptun-linux-${ARCHS}-${KCPTUN_VER}.tar.gz"
if [[ `getconf WORD_BIT` = '32' && `getconf LONG_BIT` = '64' ]] ; then
kcptun_download_link="${KCPTUN_AMD64_LINK}"
else
kcptun_download_link="${KCPTUN_386_LINK}"
fi
if [[ "${kcptun_init_link}" == "" || "${kcptun_download_link}" == "" ]]; then
echo -e "${COLOR_RED}Error: Get kcptun version failed${COLOR_END}"
exit 1
fi
if [[ "${kcptun_installed_flag}" == "false" && "${shell_action}" =~ ^[Ii]|[Ii][Nn]|[Ii][Nn][Ss][Tt][Aa][Ll][Ll]|-[Ii]|--[Ii]$ ]]; then
echo -e "Get the kcptun version:${COLOR_GREEN} ${kcptun_latest_file}${COLOR_END}"
fi
fi
}
# Download latest
down_ss_ssr_ssrr_kcptun(){
if [ ! -f /usr/lib/libsodium.a ] && [ ! -L /usr/local/lib/libsodium.so ]; then
if [ -f ${libsodium_laster_ver}.tar.gz ]; then
echo "${libsodium_laster_ver}.tar.gz [found]"
else
if ! wget --no-check-certificate -O ${libsodium_laster_ver}.tar.gz ${LIBSODIUM_LINK}; then
echo -e "${COLOR_RED}Failed to download ${libsodium_laster_ver}.tar.gz${COLOR_END}"
exit 1
fi
fi
fi
if [[ "${ss_libev_installed_flag}" == "false" && "${shell_action}" =~ ^[Ii]|[Ii][Nn]|[Ii][Nn][Ss][Tt][Aa][Ll][Ll]|-[Ii]|--[Ii]$ ]] || [[ "${ss_libev_installed_flag}" == "true" && "${ss_libev_update_flag}" == "true" && "${shell_action}" =~ ^[Uu]|[Uu][Pp][Dd][Aa][Tt][Ee]|-[Uu]|--[Uu]|[Uu][Pp]|-[Uu][Pp]|--[Uu][Pp]$ ]]; then
if [ -f ${shadowsocks_libev_ver}.tar.gz ]; then
echo "${shadowsocks_libev_ver}.tar.gz [found]"
else
if ! wget --no-check-certificate -O ${shadowsocks_libev_ver}.tar.gz ${SS_LIBEV_LINK}; then
echo -e "${COLOR_RED}Failed to download ${shadowsocks_libev_ver}.tar.gz${COLOR_END}"
exit 1
fi
fi
# Download init script
if ! wget --no-check-certificate -O /etc/init.d/shadowsocks ${ss_libev_init_link}; then
echo -e "${COLOR_RED}Failed to download Shadowsocks-libev init script!${COLOR_END}"
exit 1
fi
if [ ! -f /usr/lib/libmbedtls.a ] && [ ! -f /usr/include/mbedtls/version.h ]; then
if [ -f ${mbedtls_laster_ver}-gpl.tgz ]; then
echo "${mbedtls_laster_ver}-gpl.tgz [found]"
else
if ! wget --no-check-certificate -O ${mbedtls_laster_ver}-gpl.tgz ${MBEDTLS_LINK}; then
echo -e "${COLOR_RED}Failed to download ${mbedtls_laster_ver}-gpl.tgz${COLOR_END}"
exit 1
fi
fi
fi
fi
if [[ "${ssr_installed_flag}" == "false" && "${shell_action}" =~ ^[Ii]|[Ii][Nn]|[Ii][Nn][Ss][Tt][Aa][Ll][Ll]|-[Ii]|--[Ii]$ ]] || [[ "${ssr_installed_flag}" == "true" && "${ssr_update_flag}" == "true" && "${shell_action}" =~ ^[Uu]|[Uu][Pp][Dd][Aa][Tt][Ee]|-[Uu]|--[Uu]|[Uu][Pp]|-[Uu][Pp]|--[Uu][Pp]$ ]]; then
if [ -f manyuser.zip ]; then
echo "manyuser.zip [found]"
else
if ! wget --no-check-certificate -O manyuser.zip ${ssr_download_link}; then
echo -e "${COLOR_RED}Failed to download ShadowsocksR file!${COLOR_END}"
exit 1
fi
fi
if ! wget --no-check-certificate -O /etc/init.d/ssr ${ssr_init_link}; then
echo -e "${COLOR_RED}Failed to download ShadowsocksR init script!${COLOR_END}"
exit 1
fi
fi
if [[ "${ssrr_installed_flag}" == "false" && "${shell_action}" =~ ^[Ii]|[Ii][Nn]|[Ii][Nn][Ss][Tt][Aa][Ll][Ll]|-[Ii]|--[Ii]$ ]] || [[ "${ssrr_installed_flag}" == "true" && "${ssrr_update_flag}" == "true" && "${shell_action}" =~ ^[Uu]|[Uu][Pp][Dd][Aa][Tt][Ee]|-[Uu]|--[Uu]|[Uu][Pp]|-[Uu][Pp]|--[Uu][Pp]$ ]]; then
if [ -f ssrr.zip ]; then
echo "ssrr.zip [found]"
else
if ! wget --no-check-certificate -O ssrr.zip ${ssrr_download_link}; then
echo -e "${COLOR_RED}Failed to download ShadowsocksRR file!${COLOR_END}"
exit 1
fi
fi
if ! wget --no-check-certificate -O /etc/init.d/ssrr ${ssrr_init_link}; then
echo -e "${COLOR_RED}Failed to download ShadowsocksRR init script!${COLOR_END}"
exit 1
fi
fi
if [[ "${kcptun_installed_flag}" == "false" && "${shell_action}" =~ ^[Ii]|[Ii][Nn]|[Ii][Nn][Ss][Tt][Aa][Ll][Ll]|-[Ii]|--[Ii]$ ]] || [[ "${kcptun_installed_flag}" == "true" && "${kcptun_update_flag}" == "true" && "${shell_action}" =~ ^[Uu]|[Uu][Pp][Dd][Aa][Tt][Ee]|-[Uu]|--[Uu]|[Uu][Pp]|-[Uu][Pp]|--[Uu][Pp]$ ]]; then
if [ -f ${kcptun_latest_file} ]; then
echo "${kcptun_latest_file} [found]"
else
if ! wget --no-check-certificate -O ${kcptun_latest_file} ${kcptun_download_link}; then
echo -e "${COLOR_RED}Failed to download ${kcptun_latest_file}${COLOR_END}"
exit 1
fi
fi
if ! wget --no-check-certificate -O /etc/init.d/kcptun ${kcptun_init_link}; then
echo -e "${COLOR_RED}Failed to download kcptun init script!${COLOR_END}"
exit 1
fi
fi
}
config_ss_ssr_ssrr_kcptun(){
fast_open="false"
if version_ge $(uname -r | cut -d- -f1) 3.7.0; then
fast_open="true"
fi
if [[ "${ss_libev_installed_flag}" == "false" && "${shell_action}" =~ ^[Ii]|[Ii][Nn]|[Ii][Nn][Ss][Tt][Aa][Ll][Ll]|-[Ii]|--[Ii]$ ]]; then
[ ! -d /etc/shadowsocks-libev ] && mkdir -p /etc/shadowsocks-libev
if [ "${Install_obfs}" == "y" ] || [ "${Install_obfs}" == "Y" ]; then
cat > ${ss_libev_config}<<-EOF
{
"server":"0.0.0.0",
"server_port":${set_ss_libev_port},
"password":"${set_ss_libev_pwd}",
"user":"nobody",
"timeout":300,
"method":"${set_ss_libev_method}",
"mode":"tcp_and_udp",
"fast_open":${fast_open},
"plugin":"obfs-server",
"plugin_opts":"obfs=${ofbs_option}"
}
EOF
else
cat > ${ss_libev_config}<<-EOF
{
"server":"0.0.0.0",
"server_port":${set_ss_libev_port},
"password":"${set_ss_libev_pwd}",
"user":"nobody",
"timeout":300,
"method":"${set_ss_libev_method}",
"mode":"tcp_and_udp",
"fast_open":${fast_open}
}
EOF
fi
fi
if [[ "${ssr_installed_flag}" == "false" && "${shell_action}" =~ ^[Ii]|[Ii][Nn]|[Ii][Nn][Ss][Tt][Aa][Ll][Ll]|-[Ii]|--[Ii]$ ]]; then
[ ! -d /usr/local/shadowsocksR ] && mkdir -p /usr/local/shadowsocksR
cat > ${ssr_config}<<-EOF
{
"server":"0.0.0.0",
"local_address":"127.0.0.1",
"local_port":${ssr_local_port},
"port_password":{
"${set_ssr_port}":"${set_ssr_pwd}"
},
"timeout":300,
"method":"${set_ssr_method}",
"protocol":"${set_ssr_protocol}",
"protocol_param":"www.cloudflare.com",
"obfs":"${set_ssr_obfs}",
"obfs_param":"www.cloudflare.com",
"redirect":"www.cloudflare.com",
"dns_ipv6":false,
"fast_open":${fast_open},
"workers":1
}
EOF
fi
if [[ "${ssrr_installed_flag}" == "false" && "${shell_action}" =~ ^[Ii]|[Ii][Nn]|[Ii][Nn][Ss][Tt][Aa][Ll][Ll]|-[Ii]|--[Ii]$ ]]; then
[ ! -d /usr/local/shadowsocksRR ] && mkdir -p /usr/local/shadowsocksRR
cat > ${ssrr_config}<<-EOF
{
"server":"0.0.0.0",
"server_ipv6":"::",
"local_address":"127.0.0.1",
"local_port":${ssrr_local_port},
"port_password":{
"${set_ssrr_port}":{"protocol":"${set_ssrr_protocol}", "protocol_param":"www.cloudflare.com", "password":"${set_ssrr_pwd}", "obfs":"${set_ssrr_obfs}", "obfs_param":"www.cloudflare.com"}
},
"timeout":300,
"method":"${set_ssrr_method}",
"redirect": "www.cloudflare.com",
"dns_ipv6": false,
"fast_open":${fast_open},
"workers": 1
}
EOF
fi
if [[ "${kcptun_installed_flag}" == "false" && "${shell_action}" =~ ^[Ii]|[Ii][Nn]|[Ii][Nn][Ss][Tt][Aa][Ll][Ll]|-[Ii]|--[Ii]$ ]]; then
[ ! -d /usr/local/kcptun ] && mkdir -p /usr/local/kcptun
# Config file
cat > ${kcptun_config}<<-EOF
{
"listen": ":${set_kcptun_port}",
"target": "127.0.0.1:${kcptun_target_port}",
"key": "${set_kcptun_pwd}",
"crypt": "${set_kcptun_method}",
"mode": "${set_kcptun_mode}",
"mtu": ${set_kcptun_mtu},
"sndwnd": 256,
"rcvwnd": 1024,
"nocomp": ${set_kcptun_nocomp},
"datashard": 10,
"parityshard": 3,
"autoexpire": 300,
"dscp": 46,
"pprof": true
}
EOF
fi
}
install_ss_ssr_ssrr_kcptun(){
if [ ! -f /usr/lib/libsodium.a ] && [ ! -L /usr/local/lib/libsodium.so ]; then
cd ${cur_dir}
echo
echo "+ Install libsodium for SS-Libev/SSR/SSRR/kcptun"
tar xzf ${libsodium_laster_ver}.tar.gz
cd ${libsodium_laster_ver}
./configure --prefix=/usr && make && make install
if [ $? -ne 0 ]; then
install_cleanup
echo -e "${COLOR_RED}libsodium install failed!${COLOR_END}"
exit 1
fi
ldconfig
else
echo -e "[${COLOR_GREED}libsodium already installed.${COLOR_END}"
fi
if [[ "${ss_libev_installed_flag}" == "false" && "${shell_action}" =~ ^[Ii]|[Ii][Nn]|[Ii][Nn][Ss][Tt][Aa][Ll][Ll]|-[Ii]|--[Ii]$ ]] || [[ "${ss_libev_installed_flag}" == "true" && "${ss_libev_update_flag}" == "true" && "${shell_action}" =~ ^[Uu]|[Uu][Pp][Dd][Aa][Tt][Ee]|-[Uu]|--[Uu]|[Uu][Pp]|-[Uu][Pp]|--[Uu][Pp]$ ]]; then
if [ ! -f /usr/lib/libmbedtls.a ]; then
cd ${cur_dir}
echo
echo "+ Install mbedtls for Shadowsocks-libev..."
tar xzf ${mbedtls_laster_ver}-gpl.tgz
cd ${mbedtls_laster_ver}
make SHARED=1 CFLAGS=-fPIC
make DESTDIR=/usr install
if [ $? -ne 0 ]; then
install_cleanup
echo -e "${COLOR_RED}mbedtls install failed!${COLOR_END}"
exit 1
fi
ldconfig
else
echo -e "[${COLOR_GREED}mbedlts already installed.${COLOR_END}"
fi
cd ${cur_dir}
echo
echo "+ Shadowsocks-libev..."
tar zxf ${shadowsocks_libev_ver}.tar.gz
cd ${shadowsocks_libev_ver}
./configure --disable-documentation
make && make install
if [ $? -eq 0 ]; then
chmod +x /etc/init.d/shadowsocks
if check_sys packageManager yum; then
chkconfig --add shadowsocks
chkconfig shadowsocks on
elif check_sys packageManager apt; then
update-rc.d -f shadowsocks defaults
fi
if [ "${Install_obfs}" == "y" ] || [ "${Install_obfs}" == "Y" ]; then
install_simple_obfs
fi
# Run shadowsocks in the background
/etc/init.d/shadowsocks start
if [ $? -eq 0 ]; then
[ -x /etc/init.d/shadowsocks ] && ln -s /etc/init.d/shadowsocks /usr/bin/shadowsocks
echo -e "${COLOR_GREEN}Shadowsocks-libev start success!${COLOR_END}"
else
echo -e "${COLOR_RED}Shadowsocks-libev start failure!${COLOR_END}"
fi
ss_libev_install_flag="true"
else
install_cleanup
echo
echo -e "${COLOR_RED}Shadowsocks-libev install failed! ${COLOR_END}"
exit 1
fi
fi
if [[ "${ssr_installed_flag}" == "false" && "${shell_action}" =~ ^[Ii]|[Ii][Nn]|[Ii][Nn][Ss][Tt][Aa][Ll][Ll]|-[Ii]|--[Ii]$ ]] || [[ "${ssr_installed_flag}" == "true" && "${ssr_update_flag}" == "true" && "${shell_action}" =~ ^[Uu]|[Uu][Pp][Dd][Aa][Tt][Ee]|-[Uu]|--[Uu]|[Uu][Pp]|-[Uu][Pp]|--[Uu][Pp]$ ]]; then
cd ${cur_dir}
unzip -qo manyuser.zip
mv shadowsocksr-manyuser/shadowsocks/ /usr/local/shadowsocksR
if [ -x /usr/local/shadowsocksR/shadowsocks/server.py ] && [ -s /usr/local/shadowsocksR/shadowsocks/__init__.py ]; then
chmod +x /etc/init.d/ssr
if check_sys packageManager yum; then
chkconfig --add ssr
chkconfig ssr on
elif check_sys packageManager apt; then
update-rc.d -f ssr defaults
fi
/etc/init.d/ssr start
if [ $? -eq 0 ]; then
[ -x /etc/init.d/ssr ] && ln -s /etc/init.d/ssr /usr/bin/ssr
echo -e "${COLOR_GREEN}ShadowsocksR start success!${COLOR_END}"
else
echo -e "${COLOR_RED}ShadowsocksR start failure!${COLOR_END}"
fi
ssr_install_flag="true"
else
install_cleanup
echo
echo -e "${COLOR_RED}ShadowsocksR install failed!${COLOR_END}"
exit 1
fi
fi
if [[ "${ssrr_installed_flag}" == "false" && "${shell_action}" =~ ^[Ii]|[Ii][Nn]|[Ii][Nn][Ss][Tt][Aa][Ll][Ll]|-[Ii]|--[Ii]$ ]] || [[ "${ssrr_installed_flag}" == "true" && "${ssrr_update_flag}" == "true" && "${shell_action}" =~ ^[Uu]|[Uu][Pp][Dd][Aa][Tt][Ee]|-[Uu]|--[Uu]|[Uu][Pp]|-[Uu][Pp]|--[Uu][Pp]$ ]]; then
cd ${cur_dir}
unzip -qo ssrr.zip
mv shadowsocksr-akkariiin-master/* /usr/local/shadowsocksRR/
if [ -x /usr/local/shadowsocksRR/shadowsocks/server.py ] && [ -s /usr/local/shadowsocksRR/shadowsocks/__init__.py ]; then
chmod +x /etc/init.d/ssrr
if check_sys packageManager yum; then
chkconfig --add ssrr
chkconfig ssrr on
elif check_sys packageManager apt; then
update-rc.d -f ssrr defaults
fi
/etc/init.d/ssrr start
if [ $? -eq 0 ]; then
[ -x /etc/init.d/ssrr ] && ln -s /etc/init.d/ssrr /usr/bin/ssrr
echo -e "${COLOR_GREEN}ShadowsocksRR start success!${COLOR_END}"
else
echo -e "${COLOR_RED}ShadowsocksRR start failure!${COLOR_END}"
fi
ssrr_install_flag="true"
else
install_cleanup
echo
echo -e "${COLOR_RED}ShadowsocksRR install failed!${COLOR_END}"
exit 1
fi
fi
if [[ "${kcptun_installed_flag}" == "false" && "${shell_action}" =~ ^[Ii]|[Ii][Nn]|[Ii][Nn][Ss][Tt][Aa][Ll][Ll]|-[Ii]|--[Ii]$ ]] || [[ "${kcptun_installed_flag}" == "true" && "${kcptun_update_flag}" == "true" && "${shell_action}" =~ ^[Uu]|[Uu][Pp][Dd][Aa][Tt][Ee]|-[Uu]|--[Uu]|[Uu][Pp]|-[Uu][Pp]|--[Uu][Pp]$ ]]; then
cd ${cur_dir}
tar xzf ${kcptun_latest_file}
[ ! -d /usr/local/kcptun ] && mkdir -p /usr/local/kcptun
mv server_linux_${ARCHS} /usr/local/kcptun/kcptun
rm -f ${kcptun_latest_file} client_linux_${ARCHS}
chown root:root /usr/local/kcptun/*
[ ! -x /usr/local/kcptun/kcptun ] && chmod 755 /usr/local/kcptun/kcptun
/usr/local/kcptun/kcptun --version
if [ $? -eq 0 ]; then
chmod +x /etc/init.d/kcptun
if check_sys packageManager yum; then
chkconfig --add kcptun
chkconfig kcptun on
elif check_sys packageManager apt; then
update-rc.d -f kcptun defaults
fi
/etc/init.d/kcptun start
if [ $? -eq 0 ]; then
[ -x /etc/init.d/kcptun ] && ln -s /etc/init.d/kcptun /usr/bin/kcptun
echo -e "${COLOR_GREEN}kcptun start success!${COLOR_END}"
else
echo -e "${COLOR_RED}kcptun start failure!${COLOR_END}"
fi
kcptun_install_flag="true"
else
install_cleanup
echo
echo -e "${COLOR_RED}kcptun install failed!${COLOR_END}"
exit 1
fi
fi
install_cleanup
}
install_simple_obfs(){
local autoconf_ver=$(autoconf --version | grep autoconf | grep -oE "[0-9.]+")
if version_lt ${autoconf_ver} 2.67; then
update_autoconf
fi
cd ${cur_dir}
git clone https://github.com/shadowsocks/simple-obfs.git
cd simple-obfs
git submodule update --init --recursive
if centosversion 6; then
if [ ! "$(command -v autoconf268)" ]; then
echo -e "Starting install autoconf268..."
yum install -y autoconf268 > /dev/null 2>&1 || echo -e "${COLOR_RED}Error,Failed to install autoconf268${COLOR_END}"
fi
# replace command autoreconf to autoreconf268
sed -i 's/autoreconf/autoreconf268/' autogen.sh
# replace #include <ev.h> to #include <libev/ev.h>
sed -i 's@^#include <ev.h>@#include <libev/ev.h>@' src/local.h
sed -i 's@^#include <ev.h>@#include <libev/ev.h>@' src/server.h
fi
./autogen.sh
./configure --disable-documentation
make && make install
if [ ! "$(command -v obfs-server)" ]; then
echo -e "[${COLOR_RED}Error:simple-obfs for Shadowsocks-libev install failed${COLOR_RED}"
install_cleanup
exit 1
fi
[ -f /usr/local/bin/obfs-server ] && ln -s /usr/local/bin/obfs-server /usr/bin
}
install_bbr(){
if [ ${bbr_install} == "y" ] || [ ${bbr_install} == "Y" ];then
local ldd_version="$(ldd --version 2>/dev/null | grep 'ldd' | rev | cut -d ' ' -f1 | rev)"
if version_lt ${ldd_version} 2.14; then
update_glibc
fi
install_lkl_bbr