forked from dylanbai8/V2Ray_ws-tls_Website_onekey
-
Notifications
You must be signed in to change notification settings - Fork 0
/
oo0.bid3.1_install.sh
803 lines (719 loc) · 20.7 KB
/
oo0.bid3.1_install.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
#!/bin/bash
#====================================================
# System Request:Debian 7+/Ubuntu 14.04+/Centos 6+
# Author: wulabing & dylanbai8
# Dscription: V2RAY 基于 NGINX 的 VMESS+WS+TLS+Website(Use Host)+Rinetd BBR
# Blog: https://www.wulabing.com https://oo0.bid
# Official document: www.v2ray.com
#====================================================
#定义文字颜色
Green="\033[32m"
Red="\033[31m"
Yellow="\033[33m"
GreenBG="\033[42;37m"
RedBG="\033[41;37m"
Font="\033[0m"
#定义提示信息
Info="${Green}[信息]${Font}"
OK="${Green}[OK]${Font}"
Error="${Red}[错误]${Font}"
#定义配置文件路径
v2ray_conf_dir="/etc/v2ray"
nginx_conf_dir="/etc/nginx/conf.d"
v2ray_conf="${v2ray_conf_dir}/config.json"
v2ray_user="${v2ray_conf_dir}/user.json"
nginx_conf="${nginx_conf_dir}/v2ray.conf"
#生成伪装路径
camouflage=`cat /dev/urandom | head -n 10 | md5sum | head -c 8`
hostheader=`cat /dev/urandom | head -n 10 | md5sum | head -c 8`
source /etc/os-release
#脚本欢迎语
v2ray_hello(){
clear
echo ""
echo -e "${Info} ${GreenBG} 你正在执行 V2RAY 基于 NGINX 的 VMESS+WS+TLS+Website(Use Host)+Rinetd BBR 一键安装脚本 ${Font}"
echo ""
}
#检测root权限
is_root(){
if [ `id -u` == 0 ]
then echo -e "${OK} ${GreenBG} 当前用户是root用户,开始安装流程 ${Font} "
sleep 3
else
echo -e "${Error} ${RedBG} 当前用户不是root用户,请切换到root用户后重新执行脚本 ${Font}"
exit 1
fi
}
#从VERSION中提取发行版系统的英文名称,为了在debian/ubuntu下添加相对应的Nginx apt源
VERSION=`echo ${VERSION} | awk -F "[()]" '{print $2}'`
#检测系统版本并添加源
check_system(){
if [[ "${ID}" == "centos" && ${VERSION_ID} -ge 7 ]];then
echo -e "${OK} ${GreenBG} 当前系统为 Centos ${VERSION_ID} ${VERSION} ${Font} "
INS="yum"
echo -e "${OK} ${GreenBG} SElinux 设置中,请耐心等待,不要进行其他操作${Font} "
setsebool -P httpd_can_network_connect 1
echo -e "${OK} ${GreenBG} SElinux 设置完成 ${Font} "
## Centos 也可以通过添加 epel 仓库来安装,目前不做改动
## 已改为 epel 安装
yum -y install epel-release
echo -e "${OK} ${GreenBG} epel 源 安装完成 ${Font}"
elif [[ "${ID}" == "debian" && ${VERSION_ID} -ge 8 ]];then
echo -e "${OK} ${GreenBG} 当前系统为 Debian ${VERSION_ID} ${VERSION} ${Font} "
INS="apt"
## 添加 Nginx apt源
echo "deb http://nginx.org/packages/debian/ ${VERSION} nginx" >> /etc/apt/sources.list
echo "deb-src http://nginx.org/packages/debian/ ${VERSION} nginx" >> /etc/apt/sources.list
wget -nc https://nginx.org/keys/nginx_signing.key
apt-key add nginx_signing.key
elif [[ "${ID}" == "ubuntu" && `echo "${VERSION_ID}" | cut -d '.' -f1` -ge 16 ]];then
echo -e "${OK} ${GreenBG} 当前系统为 Ubuntu ${VERSION_ID} ${VERSION} ${Font} "
INS="apt"
## 添加 Nginx apt源
echo "deb http://nginx.org/packages/debian/ ${VERSION} nginx" >> /etc/apt/sources.list
echo "deb-src http://nginx.org/packages/debian/ ${VERSION} nginx" >> /etc/apt/sources.list
wget -nc https://nginx.org/keys/nginx_signing.key
apt-key add nginx_signing.key
else
echo -e "${Error} ${RedBG} 当前系统为 ${ID} ${VERSION_ID} 不在支持的系统列表内,安装中断 ${Font} "
exit 1
fi
}
#检测安装完成或失败
judge(){
if [[ $? -eq 0 ]];then
echo -e "${OK} ${GreenBG} $1 完成 ${Font}"
sleep 1
else
echo -e "${Error} ${RedBG} $1 失败${Font}"
exit 1
fi
}
#用户设定 域名 端口 alterID
port_alterid_set(){
echo -e "${Info} ${GreenBG} 【配置 1/3 】请输入你的域名信息(如:www.bing.com),请确保域名A记录已正确解析至服务器IP ${Font}"
stty erase '^H' && read -p "请输入:" domain
echo -e "${Info} ${GreenBG} 【配置 2/3 】请输入连接端口(默认:443 无特殊需求请直接按回车键) ${Font}"
stty erase '^H' && read -p "请输入:" port
[[ -z ${port} ]] && port="443"
echo -e "${Info} ${GreenBG} 【配置 3/3 】请输入alterID(默认:64 无特殊需求请直接按回车键) ${Font}"
stty erase '^H' && read -p "请输入:" alterID
[[ -z ${alterID} ]] && alterID="64"
}
#强制清除可能残余的http服务 v2ray服务 关闭防火墙 更新源
apache_uninstall(){
if [[ "${ID}" == "centos" ]];then
systemctl disable httpd
systemctl stop httpd
yum erase httpd httpd-tools apr apr-util -y
systemctl disable nginx
systemctl stop nginx
yum erase nginx -y
systemctl disable v2ray
systemctl stop v2ray
killall -9 v2ray
systemctl disable firewalld
systemctl stop firewalld
yum -y update
rm -rf /www
else
systemctl disable apache2
systemctl stop apache2
apt purge apache2 -y
systemctl disable nginx
systemctl stop nginx
apt purge nginx -y
systemctl disable v2ray
systemctl stop v2ray
killall -9 v2ray
apt -y update
rm -rf /www
fi
}
#安装各种依赖工具
dependency_install(){
${INS} install wget curl lsof -y
if [[ "${ID}" == "centos" ]];then
${INS} -y install crontabs
else
${INS} -y install cron
fi
judge "安装 crontab"
${INS} install bc -y
judge "安装 bc"
${INS} install unzip -y
judge "安装 unzip"
}
#检测域名解析是否正确
domain_check(){
domain_ip=`ping ${domain} -c 1 | sed '1{s/[^(]*(//;s/).*//;q}'`
echo -e "${OK} ${GreenBG} 正在获取 公网ip 信息,请耐心等待 ${Font}"
local_ip=`curl -4 ip.sb`
echo -e "${OK} ${GreenBG} 域名dns解析IP:${domain_ip} ${Font}"
echo -e "${OK} ${GreenBG} 本机IP: ${local_ip} ${Font}"
sleep 2
if [[ $(echo ${local_ip}|tr '.' '+'|bc) -eq $(echo ${domain_ip}|tr '.' '+'|bc) ]];then
echo -e "${OK} ${GreenBG} 域名dns解析IP 与 本机IP 匹配 域名解析正确 ${Font}"
sleep 2
else
echo -e "${Error} ${RedBG} 域名dns解析IP 与 本机IP 不匹配 是否继续安装?(y/n)${Font}" && read install
case $install in
[yY][eE][sS]|[yY])
echo -e "${GreenBG} 继续安装 ${Font}"
sleep 2
;;
*)
echo -e "${RedBG} 安装终止 ${Font}"
exit 2
;;
esac
fi
}
#检测端口是否占用
port_exist_check(){
if [[ 0 -eq `lsof -i:"$1" | wc -l` ]];then
echo -e "${OK} ${GreenBG} $1 端口未被占用 ${Font}"
sleep 1
else
echo -e "${Error} ${RedBG} 检测到 $1 端口被占用,以下为 $1 端口占用信息 ${Font}"
lsof -i:"$1"
echo -e "${OK} ${GreenBG} 5s 后将尝试自动 kill 占用进程 ${Font}"
sleep 5
lsof -i:"$1" | awk '{print $2}'| grep -v "PID" | xargs kill -9
echo -e "${OK} ${GreenBG} kill 完成 ${Font}"
sleep 1
fi
}
#同步服务器时间
time_modify(){
${INS} install ntpdate -y
judge "安装 NTPdate 时间同步服务 "
systemctl stop ntp &>/dev/null
echo -e "${Info} ${GreenBG} 正在进行时间同步 ${Font}"
ntpdate time.nist.gov
if [[ $? -eq 0 ]];then
echo -e "${OK} ${GreenBG} 时间同步成功 ${Font}"
echo -e "${OK} ${GreenBG} 当前系统时间 `date -R`(时区时间换算后误差应为三分钟以内)${Font}"
sleep 1
else
echo -e "${Error} ${RedBG} 时间同步失败,请检查ntpdate服务是否正常工作 ${Font}"
fi
}
#安装v2ray主程序
v2ray_install(){
if [[ -d /root/v2ray ]];then
rm -rf /root/v2ray
fi
mkdir -p /root/v2ray && cd /root/v2ray
wget --no-check-certificate https://install.direct/go.sh
## wget http://install.direct/go.sh
if [[ -f go.sh ]];then
bash go.sh --force
judge "安装 V2ray"
else
echo -e "${Error} ${RedBG} V2ray 安装文件下载失败,请检查下载地址是否可用 ${Font}"
exit 4
fi
}
#设置定时升级任务
modify_crontab(){
echo -e "${OK} ${GreenBG} 配置每天凌晨自动升级V2ray内核任务 ${Font}"
sleep 2
#crontab -l >> crontab.txt
echo "20 12 * * * bash /root/v2ray/go.sh | tee -a /root/v2ray/update.log" >> crontab.txt
echo "30 12 * * * /sbin/reboot" >> crontab.txt
crontab crontab.txt
sleep 2
if [[ "${ID}" == "centos" ]];then
systemctl restart crond
else
systemctl restart cron
fi
rm -f crontab.txt
}
#安装ssl依赖
ssl_install(){
if [[ "${ID}" == "centos" ]];then
${INS} install socat nc -y
else
${INS} install socat netcat -y
fi
judge "安装 SSL 证书生成脚本依赖"
curl https://get.acme.sh | sh
judge "安装 SSL 证书生成脚本"
}
#生成ssl证书
acme(){
~/.acme.sh/acme.sh --issue -d ${domain} --standalone -k ec-256 --force
if [[ $? -eq 0 ]];then
echo -e "${OK} ${GreenBG} SSL 证书生成成功 ${Font}"
sleep 2
~/.acme.sh/acme.sh --installcert -d ${domain} --fullchainpath /etc/v2ray/v2ray.crt --keypath /etc/v2ray/v2ray.key --ecc
if [[ $? -eq 0 ]];then
echo -e "${OK} ${GreenBG} 证书配置成功 ${Font}"
sleep 2
fi
else
echo -e "${Error} ${RedBG} SSL 证书生成失败 ${Font}"
exit 1
fi
}
#安装nginx主程序
nginx_install(){
${INS} install nginx -y
if [[ -d /etc/nginx ]];then
echo -e "${OK} ${GreenBG} nginx 安装完成 ${Font}"
sleep 2
else
echo -e "${Error} ${RedBG} nginx 安装失败 ${Font}"
exit 5
fi
}
#安装web伪装站点
web_install(){
echo -e "${OK} ${GreenBG} 安装Website伪装站点 ${Font}"
sleep 2
mkdir /www
wget https://github.com/dylanbai8/V2Ray_ws-tls_Website_onekey/raw/master/V2rayWebsite.tar.gz
tar -zxvf V2rayWebsite.tar.gz -C /www
rm -f V2rayWebsite.tar.gz
}
#生成v2ray配置文件
v2ray_conf_add(){
cat>${v2ray_conf_dir}/config.json<<EOF
{
"inbound": {
"port": 10000,
"listen":"127.0.0.1",
"protocol": "vmess",
"settings": {
"clients": [
{
"id": "UserUUID",
"alterId": 64
}
]
},
"streamSettings":{
"network":"ws",
"wsSettings": {
"path": "/",
"headers": {
"Host": "www.PathHeader.com"
}
}
}
},
"outbound": {
"protocol": "freedom",
"settings": {}
}
}
EOF
modify_port_UUID
judge "V2ray 配置"
}
#生成nginx配置文件
nginx_conf_add(){
touch ${nginx_conf_dir}/v2ray.conf
cat>${nginx_conf_dir}/v2ray.conf<<EOF
server {
listen 443 ssl;
ssl_certificate /etc/v2ray/v2ray.crt;
ssl_certificate_key /etc/v2ray/v2ray.key;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers HIGH:!aNULL:!MD5;
server_name serveraddr.com;
root /www;
location / {
proxy_redirect off;
proxy_http_version 1.1;
proxy_set_header Upgrade \$http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host \$http_host;
if (\$http_host = "www.PathHeader.com" ) {
proxy_pass http://127.0.0.1:10000;
}
}
}
server {
SETPORT80;
server_name serveraddr.com;
SETREWRITE;
}
EOF
modify_nginx
judge "Nginx 配置"
}
#生成客户端json文件
user_config_add(){
touch ${v2ray_conf_dir}/user.json
cat>${v2ray_conf_dir}/user.json<<EOF
{
"outbound": {
"streamSettings": {
"network": "ws",
"kcpSettings": null,
"wsSettings": {
"headers": {
"host": "SETPATH"
},
"path": "/"
},
"tcpSettings": null,
"tlsSettings": {},
"security": "tls"
},
"tag": "agentout",
"protocol": "vmess",
"mux": {
"enabled": true,
"concurrency": 8
},
"settings": {
"vnext": [{
"users": [{
"alterId": SETAID,
"security": "aes-128-gcm",
"id": "SETID"
}],
"port": SETPORT,
"address": "SETDOMAIN"
}]
}
},
"log": {
"access": "",
"loglevel": "info",
"error": ""
},
"outboundDetour": [{
"tag": "direct",
"protocol": "freedom",
"settings": {
"response": null
}
},
{
"tag": "blockout",
"protocol": "blackhole",
"settings": {
"response": {
"type": "http"
}
}
}
],
"inbound": {
"streamSettings": null,
"settings": {
"ip": "127.0.0.1",
"udp": true,
"clients": null,
"auth": "noauth"
},
"protocol": "socks",
"port": 1080,
"listen": "0.0.0.0"
},
"inboundDetour": null,
"routing": {
"settings": {
"rules": [{
"ip": [
"0.0.0.0/8",
"10.0.0.0/8",
"100.64.0.0/10",
"127.0.0.0/8",
"169.254.0.0/16",
"172.16.0.0/12",
"192.0.0.0/24",
"192.0.2.0/24",
"192.168.0.0/16",
"198.18.0.0/15",
"198.51.100.0/24",
"203.0.113.0/24",
"::1/128",
"fc00::/7",
"fe80::/10"
],
"domain": null,
"type": "field",
"port": null,
"outboundTag": "direct"
},
{
"type": "chinasites",
"outboundTag": "direct"
},
{
"type": "chinaip",
"outboundTag": "direct"
}
],
"domainStrategy": "IPIfNonMatch"
},
"strategy": "rules"
},
"dns": {
"servers": [
"8.8.8.8",
"8.8.4.4"
]
}
}
EOF
modify_userjson
rm -rf /www/s
mkdir /www/s
mkdir /www/s/${camouflage}
cp -rp ${v2ray_user} /www/s/${camouflage}/config.json
judge "客户端json配置"
}
#修正v2ray配置文件
modify_port_UUID(){
let PORT=$RANDOM+10000
UUID=$(cat /proc/sys/kernel/random/uuid)
sed -i "/\"port\"/c \ \"port\":${PORT}," ${v2ray_conf}
sed -i "/\"id\"/c \\\t \"id\":\"${UUID}\"," ${v2ray_conf}
sed -i "/\"alterId\"/c \\\t \"alterId\":${alterID}" ${v2ray_conf}
sed -i "s/PathHeader/${hostheader}/g" "${v2ray_conf}"
}
#修正nginx配置配置文件
modify_nginx(){
sed -i "1,/listen/{s/listen 443 ssl;/listen ${port} ssl;/}" ${nginx_conf}
sed -i "/server_name/c \\\tserver_name ${domain};" ${nginx_conf}
sed -i "/proxy_pass/c \\\tproxy_pass http://127.0.0.1:${PORT};" ${nginx_conf}
sed -i "s/PathHeader/${hostheader}/g" "${nginx_conf}"
sed -i "s/SETPORT80/listen 80/g" "${nginx_conf}"
sed -i "s/SETREWRITE/rewrite ^ https:\/\/${domain}:${port}\$request_uri? permanent/g" "${nginx_conf}"
}
#修正客户端json配置文件
modify_userjson(){
sed -i "s/SETDOMAIN/${domain}/g" "${v2ray_user}"
sed -i "s/SETPORT/${port}/g" "${v2ray_user}"
sed -i "s/SETID/${UUID}/g" "${v2ray_user}"
sed -i "s/SETAID/${alterID}/g" "${v2ray_user}"
sed -i "s/SETPATH/www.${hostheader}.com/g" "${v2ray_user}"
}
#安装bbr端口加速
rinetdbbr_install(){
export RINET_URL="https://drive.google.com/uc?id=0B0D0hDHteoksVzZ4MG5hRkhqYlk"
for CMD in curl iptables grep cut xargs systemctl ip awk
do
if ! type -p ${CMD}; then
echo -e "\e[1;31mtool ${CMD} 缺少依赖 Rinetd BBR 终止安装 \e[0m"
exit 1
fi
done
systemctl disable rinetd-bbr.service
killall -9 rinetd-bbr
rm -rf /usr/bin/rinetd-bbr /etc/rinetd-bbr.conf /etc/systemd/system/rinetd-bbr.service
echo -e "${OK} ${GreenBG} 下载Rinetd-BBR安装文件 ${Font}"
curl -L "${RINET_URL}" >/usr/bin/rinetd-bbr
chmod +x /usr/bin/rinetd-bbr
echo -e "${OK} ${GreenBG} 配置 ${port} 为加速端口 ${Font}"
cat <<EOF >> /etc/rinetd-bbr.conf
0.0.0.0 ${port} 0.0.0.0 ${port}
EOF
IFACE=$(ip -4 addr | awk '{if ($1 ~ /inet/ && $NF ~ /^[ve]/) {a=$NF}} END{print a}')
cat <<EOF > /etc/systemd/system/rinetd-bbr.service
[Unit]
Description=rinetd with bbr
Documentation=https://github.com/linhua55/lkl_study
[Service]
ExecStart=/usr/bin/rinetd-bbr -f -c /etc/rinetd-bbr.conf raw ${IFACE}
Restart=always
User=root
[Install]
WantedBy=multi-user.target
EOF
systemctl enable rinetd-bbr.service
systemctl start rinetd-bbr.service
if systemctl status rinetd-bbr >/dev/null; then
echo -e "${OK} ${GreenBG} Rinetd-BBR 安装成功 ${Font}"
echo -e "${OK} ${GreenBG} ${port} 端口加速成功 ${Font}"
else
echo -e "${Error} ${RedBG} Rinetd-BBR 安装失败 ${Font}"
fi
}
#重启nginx和v2ray程序 加载配置
start_process_systemd(){
systemctl restart nginx
judge "Nginx 启动"
systemctl start v2ray
judge "V2ray 启动"
}
#展示客户端配置信息
show_information(){
clear
echo ""
echo -e "${Info} ${GreenBG} V2RAY 基于 NGINX 的 VMESS+WS+TLS+Website(Use Host)+Rinetd BBR 安装成功 ${Font} "
echo -e "----------------------------------------------------------"
echo -e "${Green} 【您的 V2ray 配置信息】 ${Font} "
echo -e "${Green} 地址(address):${Font} ${domain} "
echo -e "${Green} 端口(port):${Font} ${port} "
echo -e "${Green} 用户id(UUID):${Font} ${UUID} "
echo -e "${Green} 额外id(alterId):${Font} ${alterID} "
echo -e "${Green} 加密方式(security):${Font} 自适应 或 auto "
echo -e "${Green} 传输协议(network):${Font} 选 ws 或 websocket "
echo -e "${Green} 伪装类型(type):${Font} none "
echo -e "${Green} WS 路径(Path)(WebSocket 路径):${Font} / "
echo -e "${Green} WS Host(Host):${Font} www.${hostheader}.com "
echo -e "${Green} 伪装域名(适用于 v2rayNG):${Font} /;www.${hostheader}.com "
echo -e "${Green} HTTP头(适用于 BifrostV):${Font} 字段名:host 值:www.${hostheader}.com "
echo -e "${Green} Mux 多路复用:${Font} 自适应 "
echo -e "${Green} 底层传输安全:${Font} tls "
if [ "${port}" -eq "443" ];then
echo -e "${Green} Website 伪装站点:${Font} https://${domain} "
echo -e "${Green} 客户端配置文件下载地址(URL):${Font} https://${domain}/s/${camouflage}/config.json ${Green} 【推荐】 ${Font} "
else
echo -e "${Green} Website 伪装站点:${Font} https://${domain}:${port} "
echo -e "${Green} 客户端配置文件下载地址(URL):${Font} https://${domain}:${port}/s/${camouflage}/config.json ${Green} 【推荐】 ${Font} "
fi
echo -e "----------------------------------------------------------"
}
#命令块执行列表
main_sslon(){
is_root
check_system
v2ray_hello
port_alterid_set
apache_uninstall
dependency_install
domain_check
port_exist_check 80
port_exist_check ${port}
time_modify
v2ray_install
modify_crontab
ssl_install
acme
nginx_install
web_install
v2ray_conf_add
nginx_conf_add
user_config_add
rinetdbbr_install
show_information
start_process_systemd
}
main_ssloff(){
is_root
check_system
v2ray_hello
port_alterid_set
apache_uninstall
dependency_install
domain_check
port_exist_check 80
port_exist_check ${port}
time_modify
v2ray_install
modify_crontab
ssl_install
nginx_install
web_install
v2ray_conf_add
nginx_conf_add
user_config_add
rinetdbbr_install
show_information
start_process_systemd
}
main(){
if [[ -e /etc/v2ray/v2ray.key ]]; then
echo -e "${Info} ${GreenBG} 提示:检测到你的服务器已经存在ssl证书 为避免重复申请 脚本将自动跳过该步骤 ${Font}"
echo -e "${Info} ${GreenBG} 如果你已更换新的域名 请按 ctrl+c 退出 然后执行 bash v.sh -q 强制重装 ${Font}"
read -p "按 回车键 继续 ……"
main_ssloff
else
main_sslon
fi
}
#删除website客户端配置文件 防止被抓取
rm_userjson(){
clear
echo ""
rm -rf /www/s
echo -e "${OK} ${GreenBG} 客户端配置文件 config.json 已从 Website 中删除 ${Font} "
echo -e "${OK} ${GreenBG} 提示:如果忘记配置信息 可执行 bash v.sh -n 重新生成 ${Font} "
}
#生成新的UUID并重启服务
new_uuid(){
clear
echo ""
if [[ -e /www/index.bak ]]; then
echo -e "${Info} ${GreenBG} 您已开启账号分享功能,无法手动更换 UUID 和生成 config.json 配置文件 ${Font}"
echo -e "${Info} ${GreenBG} 提示:紧急更换共享 UUID 请执行 bash v.sh -m ${Font}"
else
NEWUUID=$(cat /proc/sys/kernel/random/uuid)
newcamouflage=`cat /dev/urandom | head -n 10 | md5sum | head -c 8`
sed -i "/\"id\"/c \\\t \"id\":\"${NEWUUID}\"," ${v2ray_conf}
sed -i "/\"id\"/c \\\t \"id\":\"${NEWUUID}\"" ${v2ray_user}
rm -rf /www/s
mkdir /www/s
mkdir /www/s/${newcamouflage}
cp -rp ${v2ray_user} /www/s/${newcamouflage}/config.json
systemctl restart v2ray
judge "重启 V2ray 进程 重新载入配置文件"
echo -e "${Info} ${GreenBG} 新的 用户id(UUID): ${NEWUUID} ${Font} "
echo -e "${Info} ${GreenBG} 新的 客户端配置文件下载地址(URL):https://你的域名:端口/s/${newcamouflage}/config.json ${Font} "
fi
}
#开启账号共享功能 增加每周一定时更换UUID任务
add_share(){
clear
echo ""
if [[ -e /www/index.bak ]]; then
echo -e "${Info} ${GreenBG} 账号分享功能已开启,请勿重复操作 ${Font}"
else
cp -rp /www/index.html /www/index.bak
crontab -l >> crontab.txt
echo "10 12 * * 1 bash /root/v.sh -m" >> crontab.txt
crontab crontab.txt
if [[ "${ID}" == "centos" ]];then
systemctl restart crond
else
systemctl restart cron
fi
rm -f crontab.txt
echo -e "${OK} ${GreenBG} 账号分享功能已开启 UUID 将在每周一12点10分更换(服务器时区)并推送至 Website 首页 ${Font}"
echo -e "${OK} ${GreenBG} 提示:为避免被恶意抓取 该模式下不生成客户端 config.json 文件 ${Font}"
echo -e "${OK} ${GreenBG} 正在执行首次 UUID 更换任务成功 ${Font}"
bash /root/v.sh -m
fi
}
#每周一定时更换UUID并推送至website首页
share_uuid(){
SHAREUUID=$(cat /proc/sys/kernel/random/uuid)
rm -f /www/index.html
cp -rp /www/index.bak /www/index.html
sed -i "/\"id\"/c \\\t \"id\":\"${NEWUUID}\"," ${v2ray_conf}
sed -i "s/<\/body>/<\/body><div style=\"color:#666666;\"><br\/><br\/><p align=\"center\">UUID:${SHAREUUID}<\/p>/g" "/www/index.html"
systemctl restart v2ray
echo -e "${OK} ${GreenBG} 执行 UUID 更换任务成功,请访问 Website 首页查看新的 UUID ${Font}"
}
#Bash执行选项
if [[ $# > 0 ]];then
key="$1"
case $key in
-r|--rm_userjson)
rm_userjson
;;
-n|--new_uuid)
new_uuid
;;
-s|--add_share)
add_share
;;
-m|--share_uuid)
share_uuid
;;
-q|--main_sslon)
main_sslon
;;
esac
else
main
fi