-
Notifications
You must be signed in to change notification settings - Fork 25
/
xbmll.sh
3024 lines (2890 loc) · 105 KB
/
xbmll.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
# 作者 心欣&掌握节流核心技术
### ###
### sed s/$/"\\\n"/ xbml-yd-137.ovpn|tr -d '\n' ###
### ###
#iptables -A INPUT -p TCP --dport 端口 -j ACCEPT
#service iptables save >/dev/null 2>&1
#systemctl restart iptables >/dev/null 2>&1
#systemctl enable iptables >/dev/null 2>&1
#./mproxy-xb -l 8081 -d >/dev/null 2>&1
rm -rf xxx
function shellhead() {
ulimit -c 0
rm -rf $0
DmgLogo='
==========================================================================
小白免流™全新一代的流控
Powered by www.xbmll.cn 2016
All Rights Reserved
QQ群:201320977
by 心欣
==========================================================================';
errorlogo='
==========================================================================
服务验证失败,安装被终止
小白免流™全新一代的流控
Powered by www.xbmll.cn 2016 QQ群:201320977
All Rights Reserved
by 心欣
==========================================================================';
finishlogo='
==========================================================================
最好看好用的流控之一
小白免流™全新一代的流控
Powered by www.xbmll.cn 2016 QQ群:201320977
All Rights Reserved
by 心欣
==========================================================================';
keyerrorlogo='
==========================================================================
验证码输入错误,请重新运行
小白免流™-流控系统
小白免流™全新一代的流控
Powered by www.xbmll.cn 2016 QQ群:201320977
All Rights Reserved
by 心欣
==========================================================================';
http="http://";
update="web-update.zip";
sq=squid.conf;
mp=mproxy-xb;
RSA=EasyRSA-2.2.2.tar.gz;
Host='raw.githubusercontent.com/QHDS/OpenVPN-server/master';
xbml='shell/xbmll';
IP=`curl -s http://members.3322.org/dyndns/getip`;
squser=auth_user;
mysqlip='null';
KRSA=easy-rsa.zip;
webupdatefile='xb-web-update.zip';
webfile32='ioncube-32.tar.gz';
webfile64='ioncube_loaders-64.tar.gz';
phpmyadminfile='phpMyAdmin-4.0.10.15-all-languages.tar.gz';
key='xbmll.cn'
upload=transfer.sh;
jiankongfile=jiankong.zip
lnmpfile='xb-lnmp.tar.gz';
webfile='xb-web5.zip';
uploadfile=xb-openvpn.tar.gz;export uploadfile=$uploadfile
return 1
}
function authentication() {
echo -n -e "请输入验证码 [\033[32m $key \033[0m] :"
read PASSWD
readkey=$PASSWD
if [[ ${readkey%%\ *} == $key ]]
then
echo
echo -e '\033[32m验证成功!\033[0m即将开始搭建...'
echo -e "本机IP:\033[34m $IP \033[0m"
yum install curl -y >/dev/null 2>&1
else
echo
echo -e '\033[31m验证失败 ,请重新尝试! \033[0m'
sleep 3
echo "$keyerrorlogo";
exit
fi
return 1
}
function InputIPAddress() {
echo
echo "正在检测您的IP是否正确加载..."
if [[ "$IP" == '' ]]; then
echo '无法检测您的IP,可能会影响到您接下来的搭建工作';
read -p '请输入您的公网IP:' IP;
[[ "$IP" == '' ]] && InputIPAddress;
fi;
[[ "$IP" != '' ]] &&
echo -e 'IP状态: [\033[32m OK \033[0m]'
sleep 2
echo -n "正在检测网卡..."
if [ ! -e "/dev/net/tun" ];
then
echo
echo "检查到你是网易蜂巢 正在为你开启网卡"
sleep 2
echo -e " [\033[32m OK \033[0m]"
mkdir /dev/net; mknod /dev/net/tun c 10 200
echo "更新系统 接下来的所有提示都输入Y回车"
sleep 2
yum install wget
yum update -y
yum install gcc gcc-c++ make
else
echo -e " [\033[32m OK \033[0m]"
fi
return 1
}
function readytoinstall() {
echo
echo -e "\033[35m开始整理安装环境...\033[0m"
echo -e "\033[35m可能需要1分钟左右...\033[0m"
sleep 2
echo -e "\033[35m开始整理残留环境...\033[0m"
systemctl stop [email protected] >/dev/null 2>&1
yum -y remove openvpn >/dev/null 2>&1
yum -y remove java-1.7.0-openjdk* >/dev/null 2>&1
yum -y remove java >/dev/null 2>&1
systemctl stop squid.service >/dev/null 2>&1
yum -y remove squid >/dev/null 2>&1
killall mproxy-xb >/dev/null 2>&1
rm -rf /etc/openvpn/*
rm -rf /root/*
rm -rf /home/*
sleep 2
systemctl stop httpd.service >/dev/null 2>&1
systemctl stop mariadb.service >/dev/null 2>&1
systemctl stop mysqld.service >/dev/null 2>&1
/etc/init.d/mysqld stop >/dev/null 2>&1
yum remove -y httpd >/dev/null 2>&1
yum remove -y mariadb mariadb-server >/dev/null 2>&1
yum remove -y mysql mysql-server>/dev/null 2>&1
rm -rf /var/lib/mysql
rm -rf /var/lib/mysql/
rm -rf /usr/lib64/mysql
rm -rf /etc/my.cnf
rm -rf /var/log/mysql/
rm -rf
yum remove -y nginx php-fpm >/dev/null 2>&1
yum remove -y nginx php-fpm >/dev/null 2>&1
yum remove -y php php-mysql php-gd libjpeg* php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-bcmath php-mhash php-fpm >/dev/null 2>&1
sleep 2
echo -e "\033[35m正在安装主程序...\033[0m"
yum install -y openvpn telnet >/dev/null 2>&1
sleep 1
yum install -y openssl openssl-devel lzo lzo-devel pam pam-devel automake pkgconfig expect >/dev/null 2>&1
cd /etc/openvpn/ >/dev/null 2>&1
rm -rf /etc/openvpn/server.conf >/dev/null 2>&1
service sendmail stop >/dev/null 2>&1
rm -rf /etc/openvpn/xbmll.sh >/dev/null 2>&1
echo -e "\033[35m正在检查并更新源...\033[0m"
# 安装mysql
yum install -y mariadb mariadb-server
systemctl restart mariadb.service
systemctl enable mariadb.service
sleep 3
# 配置epel源
#rpm -ivh http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-8.noarch.rpm --force
rpm -ivh http://bo.mirror.garr.it/1/slc/centos/7.1.1503/extras/x86_64/Packages/epel-release-7-5.noarch.rpm --force
rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
# 配置remi源
rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm --force
rpm --import http://rpms.famillecollet.com/RPM-GPG-KEY-remi
# 安装php
yum -y --enablerepo=epel,remi,remi-php55 install php-fpm php-cli php-gd php-mbstring php-mcrypt php-mysqlnd php-opcache php-pdo php-devel php-xml
#mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
#wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
#yum clean all
#yum makecache
#yum update -y
yum install unzip curl tar expect -y
sleep 3
#yum update -y
echo
echo -e "\033[35m正在配置网络环境...\033[0m"
sleep 3
systemctl stop firewalld.service >/dev/null 2>&1
systemctl disable firewalld.service >/dev/null 2>&1
systemctl mask firewalld.service >/dev/null 2>&1
yum install -y iptables >/dev/null 2>&1
yum update iptables >/dev/null 2>&1
yum install iptables-services -y >/dev/null 2>&1
yum -y install vim vim-runtime ctags >/dev/null 2>&1
setenforce 0 >/dev/null 2>&1
service sendmail stop >/dev/null 2>&1
echo "/usr/sbin/setenforce 0" >> /etc/rc.local >/dev/null 2>&1
sleep 1
echo
echo -e "\033[35m正在配置网速优化...\033[0m"
echo '# Kernel sysctl configuration file for Red Hat Linux
# by dmkuai.com
# For binary values, 0 is disabled, 1 is enabled. See sysctl(8) and
# sysctl.conf(5) for more details.
# Controls IP packet forwarding
net.ipv4.ip_forward = 1
# Controls source route verification
net.ipv4.conf.default.rp_filter = 1
# Do not accept source routing
net.ipv4.conf.default.accept_source_route = 0
# Controls the System Request debugging functionality of the kernel
kernel.sysrq = 0
# Controls whether core dumps will append the PID to the core filename.
# Useful for debugging multi-threaded applications.
kernel.core_uses_pid = 1
# Controls the use of TCP syncookies
net.ipv4.tcp_syncookies = 1
# Disable netfilter on bridges.
net.bridge.bridge-nf-call-ip6tables = 0
net.bridge.bridge-nf-call-iptables = 0
net.bridge.bridge-nf-call-arptables = 0
# Controls the default maxmimum size of a mesage queue
kernel.msgmport = 65536
# Controls the maximum size of a message, in bytes
kernel.msgmax = 65536
# Controls the maximum shared segment size, in bytes
kernel.shmmax = 68719476736
# Controls the maximum number of shared memory segments, in pages
kernel.shmall = 4294967296' >/etc/sysctl.conf
sysctl -p >/dev/null 2>&1
echo
echo -e "\033[35m正在配置防火墙...\033[0m"
systemctl start iptables >/dev/null 2>&1
iptables -F >/dev/null 2>&1
sleep 3
iptables -t nat -A POSTROUTING -s 10.8.0.0/16 -o eth0 -j MASQUERADE
iptables -t nat -A POSTROUTING -s 10.8.0.0/16 -j SNAT --to-source $IP
iptables -t nat -A POSTROUTING -s 10.9.0.0/16 -o eth0 -j MASQUERADE
iptables -t nat -A POSTROUTING -s 10.9.0.0/16 -j SNAT --to-source $IP
iptables -t nat -A POSTROUTING -s 10.10.0.0/16 -o eth0 -j MASQUERADE
iptables -t nat -A POSTROUTING -s 10.10.0.0/16 -j SNAT --to-source $IP
iptables -t nat -A POSTROUTING -j MASQUERADE
iptables -A INPUT -p TCP --dport $mpport -j ACCEPT
iptables -A INPUT -p TCP --dport 137 -j ACCEPT
iptables -A INPUT -p TCP --dport 138 -j ACCEPT
iptables -A INPUT -p TCP --dport 139 -j ACCEPT
iptables -A INPUT -p TCP --dport 351 -j ACCEPT
iptables -A INPUT -p TCP --dport 366 -j ACCEPT
iptables -A INPUT -p TCP --dport 1026 -j ACCEPT
iptables -A INPUT -p UDP --dport 137 -j ACCEPT
iptables -A INPUT -p UDP --dport 138 -j ACCEPT
iptables -A INPUT -p TCP --dport 443 -j ACCEPT
iptables -A INPUT -p TCP --dport 3389 -j ACCEPT
iptables -A INPUT -p TCP --dport 53 -j ACCEPT
iptables -A INPUT -p TCP --dport 9101 -j ACCEPT
iptables -A INPUT -p TCP --dport 80 -j ACCEPT
iptables -A INPUT -p TCP --dport 28080 -j ACCEPT
iptables -A INPUT -p TCP --dport $sqport -j ACCEPT
iptables -A INPUT -p TCP --dport $vpnport -j ACCEPT
iptables -A INPUT -p TCP --dport 22 -j ACCEPT
iptables -A INPUT -p TCP --dport 25 -j DROP
iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
/etc/rc.d/init.d/iptables save >/dev/null 2>&1
service iptables save >/dev/null 2>&1
systemctl restart iptables >/dev/null 2>&1
systemctl enable iptables >/dev/null 2>&1
echo
sleep 1
return 1
}
function vpnportseetings() {
echo -ne "\033[31m##-------------------小白请使用默认--------------------## \033[0m"
echo
echo -ne "\033[31m##-------------------小白请使用默认--------------------## \033[0m"
echo
echo -ne "\033[31m##-------------------小白请使用默认--------------------## \033[0m"
echo
echo -ne "\033[34m 输入本地代理端口\033[0m"
echo
echo -n -e " 回车默认 [\033[31m 440 \033[0m] :"
read vpnport
[ -z "$vpnport" ] && vpnport="440"
echo
echo " ================="
echo " |端口 = $vpnport"
echo " ================="
echo
#小白免流
echo -ne "\033[36m 请输入转接端口\033[0m"
echo
echo -n -e " 回车默认 [\033[31m 8080 \033[0m] :"
read mpport
[ -z "$mpport" ] && mpport="8080"
echo
echo " ================="
echo " |端口 = $mpport"
echo " ================="
echo
#小白免流
echo -ne "\033[34m 输入常规代理端口\033[0m"
echo
echo -n -e " 回车默认 [\033[31m 80 \033[0m] :"
read sqport
[ -z "$sqport" ] && sqport="80"
echo
echo " ================="
echo " |端口 = $sqport"
echo " ================="
echo
#xbmll.cn
echo -ne "\033[35m 请输入实时监控频率(秒)\033[0m"
echo
echo -n -e " 回车默认 [\033[31m 20 \033[0m] :"
read jiankongs
[ -z "$jiankongs" ] && jiankongs="20"
echo
echo " ============="
echo " |秒数 = $jiankongs"
echo " ============="
echo
#小白免流
clear
echo -ne "\033[35m 请输入云端后台密码\033[0m"
echo
echo -n -e " 回车默认 [\033[31m 随机六位数 \033[0m] :"
read pas
[ -z "$pas" ] && pas=`cat /dev/urandom | head -n 6 | md5sum | head -c 6`
echo
echo " =================="
echo " |密码 = $pas |"
echo " =================="
echo
#小白免流
echo -ne "\033[34m 请输入你的APPkey \033[0m"
echo
echo -n -e " 回车默认 [\033[31m 随机六位数 \033[0m] :"
read ykey
[ -z "$ykey" ] && ykey=`cat /dev/urandom | head -n 6 | md5sum | head -c 6`
echo
echo " ================="
echo " |密码 = $ykey|"
echo " ================="
echo
#dnsml.top
echo -ne "\033[35m 请输入云端访问路径\033[0m"
echo
echo -n -e " 回车默认 [\033[31m 随机六位数 \033[0m] :"
read appapi
[ -z "$appapi" ] && appapi=`cat /dev/urandom | head -n 6 | md5sum | head -c 6`
echo
echo " ============="
echo " |路径 = $appapi"
echo " ============="
echo
#小白免流
echo -ne "\033[35m 请输入后台访问路径\033[0m"
echo
echo -n -e " 回车默认 [\033[31m 随机六位数 \033[0m] :"
read fh1
[ -z "$fh1" ] && fh1=`cat /dev/urandom | head -n 6 | md5sum | head -c 6`
echo
echo " ============="
echo " |路径 = $fh1"
echo " ============="
echo
#小白免流
echo -ne "\033[35m 请输入数据库访问路径\033[0m"
echo
echo -n -e " 回车默认 [\033[31m 随机六位数 \033[0m] :"
read sqlfh
[ -z "$sqlfh" ] && sqlfh=`cat /dev/urandom | head -n 6 | md5sum | head -c 6`
echo
echo " ============="
echo " |路径 = $sqlfh"
echo " ============="
echo
if [[ $fh1 == $appapi ]]
then
fh1=`cat /dev/urandom | head -n 6 | md5sum | head -c 6`
echo "检查到后台访问路径相同 随机产生路径"
echo "$fh1"
fi
if [[ $fh1 == $sqlfh ]]
then
fh1=`cat /dev/urandom | head -n 6 | md5sum | head -c 6`
echo "检查到后台访问路径相同 随机产生路径"
echo "$fh1"
fi
if [[ $appapi == $sqlfh ]]
then
appapi=`cat /dev/urandom | head -n 6 | md5sum | head -c 6`
echo "检查到后台访问路径相同 随机产生路径"
echo "$appapi"
fi
if [[ $sqlfh == $appapi ]]
then
sqlfh=`cat /dev/urandom | head -n 6 | md5sum | head -c 6`
echo "检查到后台访问路径相同 随机产生路径"
echo "$sqlfh"
fi
cd /bin/
echo $fh1 >by.txt
#小白免流
#echo
#echo -ne "\033[31m##-------------------请务必别使用默认--------------------## \033[0m"
#echo
#echo -ne "\033[31m##-------------------请务必别使用默认--------------------## \033[0m"
#echo
#echo -ne "\033[31m##-------------------请务必别使用默认--------------------## \033[0m"
clear
echo -ne "\033[33m 请输入数据库密码 \033[0m"
echo
echo -ne "\033[33m 切勿有符号或者上下左右键 \033[0m"
echo
echo -n -e " 回车默认 [\033[31m 随机八位数 \033[0m] :"
read sqlpass
[ -z "$sqlpass" ] && sqlpass=`cat /dev/urandom | head -n 8 | md5sum | head -c 8`
echo
echo " =============="
echo " |密码 = $sqlpass"
echo " =============="
echo
#小白免流
#echo -e "\033[34m设置数据库完成\033[0m"
echo -ne "\033[36m 请设置0-65535之间的数值 \033[0m"
echo
echo -ne "\033[36m 请输入流控端口\033[0m"
echo
echo -n -e " 回车默认 [\033[31m 1234 \033[0m] :"
read port
[ -z "$port" ] && port="1234"
echo
echo " ============="
echo " |端口 = $port"
echo " ============="
echo
#小白免流
iptables -A INPUT -p TCP --dport $port -j ACCEPT
service iptables save >/dev/null 2>&1
systemctl restart iptables >/dev/null 2>&1
if [[ $port == "80" ]]
then
if [[ $sqport == "80" ]]
then
echo
echo "检测到HTTP端口和流控端口有冲突,系统默认将流控端口默认为1234端口"
port=1234
fi
fi
echo -ne "\033[34m 请输入后台管理员账号\033[0m"
echo
echo -n -e " 回车默认 [\033[31m 随机六位数 \033[0m] :"
read adminuser
[ -z "$adminuser" ] && adminuser=`cat /dev/urandom | head -n 8 | md5sum | head -c 8`
echo
echo " ================="
echo " |账号 = $adminuser"
echo " ================="
echo
#小白免流
echo -ne "\033[34m 请输入后台管理员密码 \033[0m"
echo
echo -n -e " 回车默认 [\033[31m 随机六位数 \033[0m] :"
read adminpass
[ -z "$adminpass" ] && adminpass=`cat /dev/urandom | head -n 6 | md5sum | head -c 6`
echo
echo " ================="
echo " |密码 = $adminpass"
echo " ================="
echo
#小白免流
clear
echo -ne "\033[36m 请输入App名称\033[0m"
echo
echo -n -e " 回车默认 [\033[31m 小白云流量 \033[0m] :"
read appname
[ -z "$appname" ] && appname="小白云流量"
echo
echo " ======================"
echo " |名称 = $appname"
echo " ======================"
echo
#小白免流
echo -ne "\033[36m 请输入客服QQ\033[0m"
echo
echo -n -e " 回车默认 [\033[31m 100000 \033[0m] :"
read appname1
[ -z "$appname1" ] && appname1="100000"
echo
echo " ======================"
echo " |QQ = $appname1"
echo " ======================"
echo
#小白免流
echo -e "\033[35m设置完成 接下来的时间
可以打把撸 啪啪啪 看看小黄片 群主献上www.papapa88.com...\033[0m"
return 1
}
function newvpn() {
clear
echo
echo -e "\033[35m正在安装主程序...\033[0m"
yum install -y openvpn telnet >/dev/null 2>&1
sleep 1
yum install -y openssl openssl-devel lzo lzo-devel pam pam-devel automake pkgconfig expect >/dev/null 2>&1
cd /etc/openvpn/ >/dev/null 2>&1
rm -rf /etc/openvpn/server.conf >/dev/null 2>&1
service sendmail stop >/dev/null 2>&1
rm -rf /etc/openvpn/xbmll.sh >/dev/null 2>&1
#echo "> 选择安装模式"
#echo
#echo " 1 - 标准(回车默认) < 新装+流控系统"
#echo -e " \033[31m注意:\033[0m\033[35m支持阿里云、腾讯云等正规服务商 Centos7 全新系统. \033[0m"
#echo -e " 腾讯云:请默认安全组放通全部端口."
#echo
#echo " 2 - 修复模式 >> 证书问题"
#echo
#echo " 3 - 对接模式 >> 实现N台服务器共用账号"
#echo
#echo -n -e "请输入对应数字:"
#read installxuanze
if [[ $installslect == "1" ]]
then
echo "#################################################
# vpn流量控制配置文件 #
# by:小白免流™ #
# 2016-10-09 #
#################################################
port 137
#your port by:xbmll.cn
proto udp
dev tun
ca /etc/openvpn/easy-rsa/keys/ca.crt
cert /etc/openvpn/easy-rsa/keys/centos.crt
key /etc/openvpn/easy-rsa/keys/centos.key
dh /etc/openvpn/easy-rsa/keys/dh2048.pem
auth-user-pass-verify /etc/openvpn/loginudp.sh via-env
client-disconnect /etc/openvpn/disconnectudp.sh
client-connect /etc/openvpn/connect.sh
client-cert-not-required
username-as-common-name
script-security 3 system
server 10.9.0.0 255.255.0.0
push redirect-gateway def1 bypass-dhcp
push dhcp-option DNS 114.114.114.114
push dhcp-option DNS 114.114.115.115
management localhost 7506
keepalive 10 120
tls-auth /etc/openvpn/easy-rsa/ta.key 0
comp-lzo
persist-key
persist-tun
status /home/wwwroot/default/udp1/openvpn-status2.txt
log /etc/openvpn/openvpn2.log
log-append /etc/openvpn/openvpn2.log
verb 3
#xbmll.cn" >/etc/openvpn/server-udp.conf
echo "#################################################
# vpn流量控制配置文件 #
# by:小白免流™ #
# 2016-10-09 #
#################################################
port 138
#your port by:xbmll.cn
proto udp
dev tun
ca /etc/openvpn/easy-rsa/keys/ca.crt
cert /etc/openvpn/easy-rsa/keys/centos.crt
key /etc/openvpn/easy-rsa/keys/centos.key
dh /etc/openvpn/easy-rsa/keys/dh2048.pem
auth-user-pass-verify /etc/openvpn/loginudp.sh via-env
client-disconnect /etc/openvpn/disconnectudp.sh
client-connect /etc/openvpn/connect.sh
client-cert-not-required
username-as-common-name
script-security 3 system
server 10.10.0.0 255.255.0.0
push redirect-gateway def1 bypass-dhcp
push dhcp-option DNS 114.114.114.114
push dhcp-option DNS 114.114.115.115
management localhost 7507
keepalive 10 120
tls-auth /etc/openvpn/easy-rsa/ta.key 0
comp-lzo
persist-key
persist-tun
status /home/wwwroot/default/udp2/openvpn-status3.txt
log /etc/openvpn/openvpn3.log
log-append /etc/openvpn/openvpn3.log
verb 3
#xbmll.cn" >/etc/openvpn/server-udp2.conf
echo "#################################################
# vpn流量控制配置文件 #
# by:小白免流™ #
# 2016-09-22 #
#################################################
port $vpnport
#your port by:xbmll
proto tcp
dev tun
ca /etc/openvpn/easy-rsa/keys/ca.crt
cert /etc/openvpn/easy-rsa/keys/centos.crt
key /etc/openvpn/easy-rsa/keys/centos.key
dh /etc/openvpn/easy-rsa/keys/dh2048.pem
auth-user-pass-verify /etc/openvpn/login.sh via-env
client-disconnect /etc/openvpn/disconnect.sh
client-connect /etc/openvpn/connect.sh
client-cert-not-required
username-as-common-name
script-security 3 system
server 10.8.0.0 255.255.0.0
push "redirect-gateway def1 bypass-dhcp"
push "dhcp-option DNS 114.114.114.114"
push "dhcp-option DNS 114.114.115.115"
management localhost 7505
keepalive 10 120
tls-auth /etc/openvpn/easy-rsa/ta.key 0
comp-lzo
persist-key
persist-tun
status /home/wwwroot/default/res/openvpn-status.txt
log openvpn.log
log-append openvpn.log
verb 3
#xbmll.cn" >/etc/openvpn/server.conf
cd /etc/openvpn/
rm -rf /easy-rsa/
curl -O ${http}${Host}/${xbml}/${KRSA}
unzip ${KRSA} >/dev/null 2>&1
rm -rf ${KRSA}
else
echo "#################################################
# vpn流量控制配置文件 #
# by:小白免流™ #
# 2016-10-09 #
#################################################
port 137
#your port by:xbmll.cn
proto udp
dev tun
ca /etc/openvpn/easy-rsa/keys/ca.crt
cert /etc/openvpn/easy-rsa/keys/centos.crt
key /etc/openvpn/easy-rsa/keys/centos.key
dh /etc/openvpn/easy-rsa/keys/dh2048.pem
auth-user-pass-verify /etc/openvpn/loginudp.sh via-env
client-disconnect /etc/openvpn/disconnectudp.sh
client-connect /etc/openvpn/connect.sh
client-cert-not-required
username-as-common-name
script-security 3 system
server 10.9.0.0 255.255.0.0
push redirect-gateway def1 bypass-dhcp
push dhcp-option DNS 114.114.114.114
push dhcp-option DNS 114.114.115.115
management localhost 7506
keepalive 10 120
tls-auth /etc/openvpn/easy-rsa/ta.key 0
comp-lzo
persist-key
persist-tun
status /home/wwwroot/default/udp1/openvpn-status2.txt
log /etc/openvpn/openvpn2.log
log-append /etc/openvpn/openvpn2.log
verb 3
#xbmll.cn" >/etc/openvpn/server-udp.conf
echo "#################################################
# vpn流量控制配置文件 #
# by:小白免流™ #
# 2016-10-09 #
#################################################
port 138
#your port by:xbmll.cn
proto udp
dev tun
ca /etc/openvpn/easy-rsa/keys/ca.crt
cert /etc/openvpn/easy-rsa/keys/centos.crt
key /etc/openvpn/easy-rsa/keys/centos.key
dh /etc/openvpn/easy-rsa/keys/dh2048.pem
auth-user-pass-verify /etc/openvpn/loginudp.sh via-env
client-disconnect /etc/openvpn/disconnectudp.sh
client-connect /etc/openvpn/connect.sh
client-cert-not-required
username-as-common-name
script-security 3 system
server 10.10.0.0 255.255.0.0
push redirect-gateway def1 bypass-dhcp
push dhcp-option DNS 114.114.114.114
push dhcp-option DNS 114.114.115.115
management localhost 7507
keepalive 10 120
tls-auth /etc/openvpn/easy-rsa/ta.key 0
comp-lzo
persist-key
persist-tun
status /home/wwwroot/default/udp2/openvpn-status3.txt
log /etc/openvpn/openvpn3.log
log-append /etc/openvpn/openvpn3.log
verb 3
#xbmll.cn" >/etc/openvpn/server-udp2.conf
echo "#################################################
# vpn流量控制配置文件 #
# by:小白免流™ #
# 2016-09-22 #
#################################################
port $vpnport
#your port by:xbmll
proto tcp
dev tun
ca /etc/openvpn/easy-rsa/keys/ca.crt
cert /etc/openvpn/easy-rsa/keys/centos.crt
key /etc/openvpn/easy-rsa/keys/centos.key
dh /etc/openvpn/easy-rsa/keys/dh2048.pem
auth-user-pass-verify /etc/openvpn/login.sh via-env
client-disconnect /etc/openvpn/disconnect.sh
client-connect /etc/openvpn/connect.sh
client-cert-not-required
username-as-common-name
script-security 3 system
server 10.8.0.0 255.255.0.0
push "redirect-gateway def1 bypass-dhcp"
push "dhcp-option DNS 114.114.114.114"
push "dhcp-option DNS 114.114.115.115"
management localhost 7505
keepalive 10 120
tls-auth /etc/openvpn/easy-rsa/ta.key 0
comp-lzo
persist-key
persist-tun
status /home/wwwroot/default/res/openvpn-status.txt
log openvpn.log
log-append openvpn.log
verb 3
#xbmll.cn" >/etc/openvpn/server.conf
curl -O ${http}${Host}/${xbml}/${RSA}
tar -zxvf ${RSA} >/dev/null 2>&1
rm -rf /etc/openvpn/${RSA}
cd /etc/openvpn/easy-rsa/
sleep 1
source vars >/dev/null 2>&1
./clean-all
clear
echo "正在生成CA/服务端证书..."
echo
sleep 2
./ca >/dev/null 2>&1 && ./centos centos >/dev/null 2>&1
sleep 2
echo "正在生成TLS密钥..."
openvpn --genkey --secret ta.key
echo
sleep 1
clear
echo
echo "正在生成加密证书..."
./build-dh
echo
echo "生成完毕!"
fi
sleep 2
cd /etc/
chmod 777 -R openvpn
cd openvpn
systemctl enable [email protected] >/dev/null 2>&1
sleep 1
cp /etc/openvpn/easy-rsa/keys/ca.crt /home/ >/dev/null 2>&1
cp /etc/openvpn/easy-rsa/ta.key /home/ >/dev/null 2>&1
echo "创建vpn启动命令..."
echo "正在重启openvpn服务...
mkdir -p /dev/net; mknod /dev/net/tun c 10 200 >/dev/null 2>&1
killall openvpn >/dev/null 2>&1
systemctl disable firewalld.service
systemctl stop [email protected]
systemctl start [email protected]
killall mproxy-xb >/dev/null 2>&1
cd /root/
./mproxy-xb -l $mpport -d >/dev/null 2>&1
./mproxy-xb -l 137 -d >/dev/null 2>&1
./mproxy-xb -l 139 -d >/dev/null 2>&1
./mproxy-xb -l 138 -d >/dev/null 2>&1
./mproxy-xb -l 3389 -d >/dev/null 2>&1
./mproxy-xb -l 53 -d >/dev/null 2>&1
./mproxy-xb -l 28080 -d >/dev/null 2>&1
./mproxy-xb -l 351 -d >/dev/null 2>&1
./mproxy-xb -l 366 -d >/dev/null 2>&1
./mproxy-xb -l 9101 -d >/dev/null 2>&1
killall squid >/dev/null 2>&1
squid -z >/dev/null 2>&1
systemctl restart squid
lnmp
openvpn --config /etc/openvpn/server-udp.conf &
openvpn --config /etc/openvpn/server-udp2.conf &
killall jiankong >/dev/null 2>&1
rm -rf /home/jiankong.log >/dev/null 2>&1
/home/wwwroot/default/res/jiankong >>/home/jiankong.log >&1 &
/home/wwwroot/default/udp1/udpjiankong >>/home/jiankong.log >&1 &
/home/wwwroot/default/udp2/udpjiankong2 >>/home/jiankong.log >&1 &
echo -e '服务状态: [\033[32m OK \033[0m]'
exit 0" >/bin/vpn
chmod 777 /bin/vpn
cd /bin
curl -O ${http}${Host}/${xbml}/onsql >/dev/null 2>&1
curl -O ${http}${Host}/${xbml}/onyd >/dev/null 2>&1
curl -O ${http}${Host}/${xbml}/offsql >/dev/null 2>&1
curl -O ${http}${Host}/${xbml}/offyd >/dev/null 2>&1
sed -i '5s/phpmyadmin/'$sqlfh'/' /bin/offsql >/dev/null 2>&1
sed -i '3s/phpmyadmin/'$sqlfh'/' /bin/onsql >/dev/null 2>&1
sed -i '5s/dnsml/'$appapi'/' /bin/offyd >/dev/null 2>&1
sed -i '6s/dnsml/'$appapi'/' /bin/offyd >/dev/null 2>&1
sed -i '3s/dnsml/'$appapi'/' /bin/onyd >/dev/null 2>&1
sed -i '4s/dnsml/'$appapi'/' /bin/onyd >/dev/null 2>&1
chmod 777 /bin/onsql
chmod 777 /bin/onyd
chmod 777 /bin/offsql
chmod 777 /bin/offyd
echo
sleep 1
killall squid >/dev/null 2>&1
clear
echo -e "\033[35m正在安装设置HTTP代理端口...\033[0m"
sleep 2
yum -y install squid >/dev/null 2>&1
chkconfig squid on
cd /etc/squid
rm -rf ./squid.conf >/dev/null 2>&1
sleep 1
curl -O ${http}${Host}/${xbml}/${sq}
sed -i 's/http_port 80/http_port '$sqport'/g' /etc/squid/squid.conf >/dev/null 2>&1
sleep 1
chmod 0755 ./${sq} >/dev/null 2>&1
echo
echo
sleep 2
curl -O ${http}${Host}/${xbml}/${squser} >/dev/null 2>&1
chmod 0755 ./${squser} >/dev/null 2>&1
sleep 1
echo
echo
cd /etc/
chmod 777 -R squid
cd squid
squid -z >/dev/null 2>&1
systemctl restart squid >/dev/null 2>&1
systemctl enable squid >/dev/null 2>&1
#禁ping代码
#echo 1 > /proc/sys/net/ipv4/icmp_echo_ignore_all >/dev/null 2>&1
sleep 2
echo
sleep 3
clear
echo
sleep 3
cd /root/
curl -O ${http}${Host}/${xbml}/${mp} >/dev/null 2>&1
chmod 0777 ./${mp} >/dev/null 2>&1
echo
return 1
}
function installlnmp(){
#rm -rf /etc/yum.repos.d/CentOS-Base.repo >/dev/null 2>&1
#mv /etc/yum.repos.d/CentOS-Base.repo.backup /etc/yum.repos.d/CentOS-Base.repo >/dev/null 2>&1
rm -rf /etc/yum.repos.d/epel.repo >/dev/null 2>&1
rm -rf /etc/yum.repos.d/epel-testing.repo >/dev/null 2>&1
clear
echo -e "\033[35m正在安装小白免流™ LNMP系统\033[0m"
echo
echo -e "\033[33m注意:安装过程中如果有卡住或者停住请耐心等待\033[0m"
mkdir -p /home/wwwroot/default >/dev/null 2>&1
wget ${http}${Host}/${xbml}/${lnmpfile} >/dev/null 2>&1
tar -zxf ./${lnmpfile} >/dev/null 2>&1
rm -rf ${lnmpfile} >/dev/null 2>&1
#yum -y install httpd
#rm -rf /etc/httpd/conf/httpd.conf
#cd /etc/httpd/conf/
#curl -O ${http}${Host}/${xbml}/httpd.conf
#systemctl restart httpd.service
#systemctl enable httpd.service
#sleep 1
cd lnmp
chmod +x ./install_php.sh
./install_php.sh
# 安装mysql
yum -y install nginx
mv /usr/share/nginx /home/wwwroot
rm -rf /etc/nginx/conf.d/default.conf
cp -r /root/lnmp/conf/default.conf /etc/nginx/conf.d/default.conf
systemctl enable nginx.service
systemctl start nginx.service
#yum --enablerepo=remi install -y mariadb-server mariadb
#sleep 1
#systemctl restart mariadb
#systemctl enable mariadb
#sleep 1
#yum -y --enablerepo=epel,remi,remi-php54 install php php-cli php-gd php-mbstring php-mcrypt php-mysqlnd php-opcache php-pdo php-devel php-xml
##3 yum --enablerepo=remi install -y php php-mysql php-gd libjpeg* php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-bcmath php-mhash
#systemctl restart httpd.service
#sleep 1
echo
echo
cd /usr/local/
echo
curl -O ${http}${Host}/${xbml}/${webfile64}
tar zxf ${webfile64}
rm -rf ${webfile64}
CDIR='/usr/local/ioncube'
phpversion=`php -v | grep ^PHP | cut -f2 -d " "| awk -F "." '{print "zend_extension=\"/usr/local/ioncube/ioncube_loader_lin_"$1"."$2".so\""}'`
phplocation=`php -i | grep php.ini | grep ^Configuration | cut -f6 -d" "`
RED='\033[01;31m'
RESET='\033[0m'
GREEN='\033[01;32m'
echo ""
if [ -e "/usr/local/ioncube" ];then
echo -e "目录切换成功,正在整理资源!"$RESET
echo -e "Adding line $phpversion to file $phplocation/php.ini" >/dev/null 2>&1 $RESET
echo -e "$phpversion" >> $phplocation/php.ini
echo -e "安装成功"$RESET
else
echo -e "安装失败!请确认当前系统为Centos7.x 64位!"$RESET
echo -e "请不要用旧版本进行搭建!"$RESET
exit
fi
echo "#!/bin/bash
echo '正在重启lnmp...'
systemctl restart mariadb
systemctl restart nginx.service
systemctl restart php-fpm.service
systemctl restart crond.service
service sendmail stop >/dev/null 2>&1
echo -e '服务状态: [\033[32m OK \033[0m]'
exit 0;
" >/bin/lnmp
chmod 777 /bin/lnmp >/dev/null 2>&1
lnmp
echo
echo -e "\033[31m安装完成!\033[0m"
echo -e "\033[31m感谢使用小白免流™ LNMP系统 - Centos7版\033[0m"
return 1
}
function webml(){
clear
echo -e "\033[36m开始搭建小白免流™流量控制程序\033[0m"
echo -e "\033[33m请不要进行任何操作 程序自动完成...\033[0m"
cd /root/
curl -O ${http}${Host}/${xbml}/${webfile}
unzip -q ${webfile} >/dev/null 2>&1
mysqladmin -u root password "${sqlpass}"
sed -i "289s/ip/$IP/" /root/xb/web/install.sql >/dev/null 2>&1
sed -i "289s/port/$port/" /root/xb/web/install.sql >/dev/null 2>&1