forked from kkkyg/CFwarp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbeta21.sh
459 lines (386 loc) · 14.5 KB
/
beta21.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
#!/usr/bin/env bash
export PATH=$PATH:/usr/local/bin
red(){
echo -e "\033[31m\033[01m$1\033[0m"
}
green(){
echo -e "\033[32m\033[01m$1\033[0m"
}
yellow(){
echo -e "\033[33m\033[01m$1\033[0m"
}
blue(){
echo -e "\033[36m\033[01m$1\033[0m"
}
white(){
echo -e "\033[1;37m\033[01m$1\033[0m"
}
bblue(){
echo -e "\033[1;34m\033[01m$1\033[0m"
}
rred(){
echo -e "\033[1;35m\033[01m$1\033[0m"
}
if [[ $(id -u) != 0 ]]; then
yellow " 请以root模式运行脚本。"
exit 0
fi
if [[ -f /etc/redhat-release ]]; then
release="Centos"
elif cat /etc/issue | grep -q -E -i "debian"; then
release="Debian"
elif cat /etc/issue | grep -q -E -i "ubuntu"; then
release="Ubuntu"
elif cat /etc/issue | grep -q -E -i "centos|red hat|redhat"; then
release="Centos"
elif cat /proc/version | grep -q -E -i "debian"; then
release="Debian"
elif cat /proc/version | grep -q -E -i "ubuntu"; then
release="Ubuntu"
elif cat /proc/version | grep -q -E -i "centos|red hat|redhat"; then
release="Centos"
fi
if ! type curl >/dev/null 2>&1; then
yellow "curl 未安装,安装中 "
apt update -y && apt install curl -y && yum install curl -y >/dev/null 2>&1
else
green "curl 已安装,继续 "
fi
if ! type wget >/dev/null 2>&1; then
yellow "wget 未安装 安装中 "
apt update -y && apt install wget -y && yum install wget -y >/dev/null 2>&1
else
green "wget 已安装,继续 "
fi
bit=`uname -m`
version=`uname -r | awk -F "-" '{print $1}'`
main=`uname -r | awk -F . '{print $1 }'`
minor=`uname -r | awk -F . '{print $2}'`
rv4=`ip a | grep global | awk 'NR==1 {print $2}' | cut -d'/' -f1`
rv6=`ip a | grep inet6 | awk 'NR==2 {print $2}' | cut -d'/' -f1`
op=`hostnamectl | grep -i Operating | awk -F ':' '{print $2}'`
vi=`hostnamectl | grep -i Virtualization | awk -F ':' '{print $2}'`
gj4=`wget -T1 -t1 -qO- -4 https://ip.gs/country-iso`
gj6=`wget -T1 -t1 -qO- -6 https://ip.gs/country-iso`
v44=`wget -T1 -t1 -qO- -4 ip.gs`
if [[ -n ${v44} ]]; then
v4=`wget -qO- -4 ip.gs`
WARPIPv4Status=$(curl -s4 https://www.cloudflare.com/cdn-cgi/trace | grep warp | cut -d= -f2)
case ${WARPIPv4Status} in
on)
WARPIPv4Status=$(green "WARP已开启,当前IPV4地址:$v4 ,IP所属国简称:$gj4 ")
;;
off)
WARPIPv4Status=$(yellow "WARP未开启,当前IPV4地址:$v4 ,IP所属国简称:$gj4 ")
esac
else
WARPIPv4Status=$(red "不存在IPV4地址 ")
fi
v66=`wget -T1 -t1 -qO- -6 ip.gs`
if [[ -n ${v66} ]]; then
v6=`wget -qO- -6 ip.gs`
WARPIPv6Status=$(curl -s6 https://www.cloudflare.com/cdn-cgi/trace | grep warp | cut -d= -f2)
case ${WARPIPv6Status} in
on)
WARPIPv6Status=$(green "WARP已开启,当前IPV6地址:$v6 ,IP所属国简称:$gj6 ")
;;
off)
WARPIPv6Status=$(yellow "WARP未开启,当前IPV6地址:$v6 ,IP所属国简称:$gj6 ")
esac
else
WARPIPv6Status=$(red "不存在IPV6地址 ")
fi
ud4='sed -i "5 s/^/PostUp = ip -4 rule add from $(ip route get 162.159.192.1 | grep -oP '"'src \K\S+') lookup main\n/"'" wgcf-profile.conf && sed -i "6 s/^/PostDown = ip -4 rule delete from $(ip route get 162.159.192.1 | grep -oP '"'src \K\S+') lookup main\n/"'" wgcf-profile.conf'
ud6='sed -i "7 s/^/PostUp = ip -6 rule add from $(ip route get 2606:4700:d0::a29f:c001 | grep -oP '"'src \K\S+') lookup main\n/"'" wgcf-profile.conf && sed -i "8 s/^/PostDown = ip -6 rule delete from $(ip route get 2606:4700:d0::a29f:c001 | grep -oP '"'src \K\S+') lookup main\n/"'" wgcf-profile.conf'
ud4ud6='sed -i "5 s/^/PostUp = ip -4 rule add from $(ip route get 162.159.192.1 | grep -oP '"'src \K\S+') lookup main\n/"'" wgcf-profile.conf && sed -i "6 s/^/PostDown = ip -4 rule delete from $(ip route get 162.159.192.1 | grep -oP '"'src \K\S+') lookup main\n/"'" wgcf-profile.conf && sed -i "7 s/^/PostUp = ip -6 rule add from $(ip route get 2606:4700:d0::a29f:c001 | grep -oP '"'src \K\S+') lookup main\n/"'" wgcf-profile.conf && sed -i "8 s/^/PostDown = ip -6 rule delete from $(ip route get 2606:4700:d0::a29f:c001 | grep -oP '"'src \K\S+') lookup main\n/"'" wgcf-profile.conf'
c1="sed -i '/0\.0\.0\.0\/0/d' wgcf-profile.conf"
c2="sed -i '/\:\:\/0/d' wgcf-profile.conf"
c3="sed -i 's/engage.cloudflareclient.com/162.159.192.1/g' wgcf-profile.conf"
c4="sed -i 's/engage.cloudflareclient.com/2606:4700:d0::a29f:c001/g' wgcf-profile.conf"
c5="sed -i 's/1.1.1.1/8.8.8.8,2001:4860:4860::8888/g' wgcf-profile.conf"
c6="sed -i 's/1.1.1.1/2001:4860:4860::8888,8.8.8.8/g' wgcf-profile.conf"
Print_ALL_Status_menu() {
white "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
yellow " VPS相关信息如下:"
blue " 操作系统名称 -$op "
blue " 系统内核版本 - $version "
blue " CPU架构名称 - $bit "
blue " 虚拟架构类型 -$vi "
white "------------------------------------------"
blue " WARP状态+IPv4地址+IP国家: ${WARPIPv4Status}"
blue " WARP状态+IPv6地址+IP国家: ${WARPIPv6Status}"
white "------------------------------------------"
}
function ins(){
rm -f /usr/local/bin/wgcf /etc/wireguard/wgcf.conf /etc/wireguard/wgcf-account.toml /usr/bin/wireguard-go
if [[ ${vi} == " lxc" ]]; then true
if [ $release = "Centos" ]; then
echo -e nameserver 2a0b:f4c0:4d:53::1 > /etc/resolv.conf
fi
fi
if [ $release = "Centos" ]; then
yum -y install epel-release
yum -y install curl net-tools wireguard-tools
if [ "$main" -lt 5 ]|| [ "$minor" -lt 6 ]; then true
if [[ ${vi} == " kvm" || ${vi} == " xen" || ${vi} == " microsoft" ]]; then
curl -Lo /etc/yum.repos.d/wireguard.repo https://copr.fedorainfracloud.org/coprs/jdoss/wireguard/repo/epel-7/jdoss-wireguard-epel-7.repo
yum -y install epel-release wireguard-dkms
fi
fi
yum -y update
elif [ $release = "Debian" ]; then
apt update -y
apt -y install lsb-release
echo "deb http://deb.debian.org/debian $(lsb_release -sc)-backports main" | tee /etc/apt/sources.list.d/backports.list
apt update -y
apt -y --no-install-recommends install net-tools iproute2 openresolv dnsutils wireguard-tools
if [ "$main" -lt 5 ]|| [ "$minor" -lt 6 ]; then true
if [[ ${vi} == " kvm" || ${vi} == " xen" || ${vi} == " microsoft" ]]; then
apt -y --no-install-recommends install linux-headers-$(uname -r);apt -y --no-install-recommends install wireguard-dkms
fi
fi
apt update -y
elif [ $release = "Ubuntu" ]; then
apt update -y
apt -y --no-install-recommends install net-tools iproute2 openresolv dnsutils wireguard-tools
else
red " 不支持你当前系统,请选择Ubuntu,Debain,Centos系统 "
rm -f 1.sh
exit 1
fi
if [[ ${bit} == "x86_64" ]]; then
wget -N https://cdn.jsdelivr.net/gh/kkkyg/1/wgcf-amd -O /usr/local/bin/wgcf && chmod +x /usr/local/bin/wgcf
elif [[ ${bit} == "aarch64" ]]; then
wget -N https://cdn.jsdelivr.net/gh/kkkyg/1/wgcf-arm -O /usr/local/bin/wgcf && chmod +x /usr/local/bin/wgcf
fi
if [[ ${vi} == " lxc" || ${vi} == " OpenVZ" ]]; then
wget -N https://cdn.jsdelivr.net/gh/kkkyg/1/wireguard-go -O /usr/bin/wireguard-go && chmod +x /usr/bin/wireguard-go
fi
echo | wgcf register
until [[ -e wgcf-account.toml ]]
do
sleep 1s
echo | wgcf register
done
wgcf generate
echo $ABC1 | sh
echo $ABC2 | sh
echo $ABC3 | sh
echo $ABC4 | sh
mv -f wgcf-profile.conf /etc/wireguard/wgcf.conf
mv -f wgcf-account.toml /etc/wireguard/wgcf-account.toml
wg-quick up wgcf >/dev/null 2>&1
v4=$(wget -T1 -t1 -qO- -4 ip.gs)
v6=$(wget -T1 -t1 -qO- -6 ip.gs)
until [[ -n $v4 || -n $v6 ]]
do
wg-quick down wgcf >/dev/null 2>&1
wg-quick up wgcf >/dev/null 2>&1
v4=$(wget -T1 -t1 -qO- -4 ip.gs)
v6=$(wget -T1 -t1 -qO- -6 ip.gs)
done
systemctl enable wg-quick@wgcf >/dev/null 2>&1
[[ -e /etc/gai.conf ]] && [[ $(grep '^[ ]*precedence[ ]*::ffff:0:0/96[ ]*100' /etc/gai.conf) ]] || echo 'precedence ::ffff:0:0/96 100' >> /etc/gai.conf
v44=`wget -T1 -t1 -qO- -4 ip.gs`
if [[ -n ${v44} ]]; then
v4=`wget -qO- -4 ip.gs`
WARPIPv4Status=$(curl -s4 https://www.cloudflare.com/cdn-cgi/trace | grep warp | cut -d= -f2)
case ${WARPIPv4Status} in
on)
WARPIPv4Status=$(green "WARP已开启,当前IPV4地址:$v4 ,IP所属国简称:$gj4 ")
;;
off)
WARPIPv4Status=$(yellow "WARP未开启,当前IPV4地址:$v4 ,IP所属国简称:$gj4 ")
esac
else
WARPIPv4Status=$(red "不存在IPV4地址 ")
fi
v66=`wget -T1 -t1 -qO- -6 ip.gs`
if [[ -n ${v66} ]]; then
v6=`wget -qO- -6 ip.gs`
WARPIPv6Status=$(curl -s6 https://www.cloudflare.com/cdn-cgi/trace | grep warp | cut -d= -f2)
case ${WARPIPv6Status} in
on)
WARPIPv6Status=$(green "WARP已开启,当前IPV6地址:$v6 ,IP所属国简称:$gj6 ")
;;
off)
WARPIPv6Status=$(yellow "WARP未开启,当前IPV6地址:$v6 ,IP所属国简称:$gj6 ")
esac
else
WARPIPv6Status=$(red "不存在IPV6地址 ")
fi
green "安装结束,当前WARP及IP状态如下 "
blue " WARP状态+IPv4地址+IP国家: ${WARPIPv4Status}"
blue " WARP状态+IPv6地址+IP国家: ${WARPIPv6Status}"
}
function upcore(){
wget -N --no-check-certificate https://cdn.jsdelivr.net/gh/kkkyg/CFwarp/upcore.sh && chmod +x upcore.sh && ./upcore.sh
}
function iptables(){
sudo iptables -P INPUT ACCEPT
sudo iptables -P FORWARD ACCEPT
sudo iptables -P OUTPUT ACCEPT
sudo iptables -F
sudo apt-get purge netfilter-persistent -y
sudo reboot
}
function BBR(){
echo "net.core.default_qdisc=fq" >> /etc/sysctl.conf
echo "net.ipv4.tcp_congestion_control=bbr" >> /etc/sysctl.conf
sysctl -p
lsmod | grep bbr
}
function cwarp(){
systemctl stop wg-quick@wgcf
systemctl disable wg-quick@wgcf
sudo reboot
}
function owarp(){
systemctl enable wg-quick@wgcf
systemctl start wg-quick@wgcf
}
function macka(){
sudo iptables -P INPUT ACCEPT
sudo iptables -P FORWARD ACCEPT
sudo iptables -P OUTPUT ACCEPT
sudo iptables -F
wget -P /root -N --no-check-certificate "https://raw.githubusercontent.com/mack-a/v2ray-agent/master/install.sh" && chmod 700 /root/install.sh && /root/install.sh
}
function phlinhng(){
sudo iptables -P INPUT ACCEPT
sudo iptables -P FORWARD ACCEPT
sudo iptables -P OUTPUT ACCEPT
sudo iptables -F
curl -fsSL https://cdn.jsdelivr.net/gh/phlinhng/v2ray-tcp-tls-web@main/src/xwall.sh -o ~/xwall.sh && bash ~/xwall.sh
}
function Netflix(){
wget -O nf https://cdn.jsdelivr.net/gh/sjlleo/netflix-verify/CDNRelease/nf_2.60_linux_amd64 && chmod +x nf && clear && ./nf -method full
}
function reboot(){
sudo reboot
}
function dns(){
echo 'DNS=8.8.8.8 2001:4860:4860::8888'>> /etc/systemd/resolved.conf
systemctl restart systemd-resolved
systemctl enable systemd-resolved
mv /etc/resolv.conf /etc/resolv.conf.bak
ln -s /run/systemd/resolve/resolv.conf /etc/
sudo reboot
}
function status(){
systemctl status wg-quick@wgcf
}
function up4(){
wget -N --no-check-certificate https://raw.githubusercontent.com/kkkyg/CFwarp/main/multi.sh && chmod +x multi.sh && ./multi.sh
}
function up6(){
echo -e nameserver 2a0b:f4c0:4d:53::1 > /etc/resolv.conf
wget -6 -N --no-check-certificate https://raw.githubusercontent.com/kkkyg/CFwarp/main/multi.sh && chmod +x multi.sh && ./multi.sh
}
#主菜单
function start_menu(){
clear
yellow " 详细说明 https://github.com/kkkyg/CFwarp YouTube频道:甬哥侃侃侃"
red " 切记:进入脚本快捷方式 bash multi.sh "
white " ==================一、VPS相关调整选择(更新中)=========================================="
green " 1. 永久开启甲骨文VPS的ubuntu系统所有端口 "
green " 2. 更新系统内核 "
green " 3. 开启原生BBR加速 "
green " 4. 检测奈飞Netflix是否解锁 "
white " ==================二、WARP功能选择(更新中)======================================"
yellow " ----VPS原生IP数------------------------------------添加WARP虚拟IP的位置--------------"
green " 5. 纯IPV4的VPS。 添加WARP虚拟IPV4 "
green " 6. 纯IPV4的VPS。 添加WARP虚拟IPV6 "
green " 7. 纯IPV4的VPS。 添加WARP虚拟IPV4+虚拟IPV6 "
green " 8. 纯IPV6的VPS。 添加WARP虚拟IPV4 "
green " 9. 纯IPV6的VPS。 添加WARP虚拟IPV6 "
green " 10. 纯IPV6的VPS。 添加WARP虚拟IPV4+虚拟IPV6 "
green " 11. 双栈IPV4+IPV6的VPS。 添加WARP虚拟IPV4 "
green " 12. 双栈IPV4+IPV6的VPS。 添加WARP虚拟IPV6 "
green " 13. 双栈IPV4+IPV6的VPS。 添加WARP虚拟IPV4+虚拟IPV6 "
white " ------------------------------------------------------------------------------------------------"
green " 14. 统一DNS功能 "
green " 15. 永久关闭WARP功能 "
green " 16. 自动开启WARP功能 "
green " 17. 有IPV4:更新脚本 "
green " 18. 无IPV4:更新脚本 "
white " ==================三、代理协议脚本选择(更新中)==========================================="
green " 19.使用mack-a脚本(支持Xray, V2ray) "
green " 20.使用phlinhng脚本(支持Xray, Trojan-go, SS+v2ray-plugin) "
white " ============================================================================================="
green " 21. 重启VPS实例,请重新连接SSH "
white " ==============================================================================================="
green " 0. 退出脚本 "
Print_ALL_Status_menu
echo
read -p "请输入数字:" menuNumberInput
case "$menuNumberInput" in
1 )
iptables
;;
2 )
upcore
;;
3 )
BBR
;;
4 )
Netflix
;;
5 )
ABC1=${ud4} && ABC2=${c3} && ABC3=${c2} && ABC4=${c5}; ins
;;
6 )
ABC1=${c3} && ABC2=${c1} && ABC3=${c5}}; ins
;;
7 )
ABC1=${ud4} && ABC2=${c3} && ABC3=${c5}; ins
;;
8 )
ABC1=${c4} && ABC2=${c2} && ABC3=${c5}; ins
;;
9 )
ABC1=${ud6} && ABC2=${c1} &&ABC3=${c4} ABC4=${c6}; ins
;;
10 )
ABC1=${ud6} && ABC2=${c4} && ABC3=${c5}; ins
;;
11 )
ABC1=${ud4} && ABC2=${c2} && ABC3=${c5}; ins
;;
12 )
ABC1=${ud6} && ABC2=${c1} && ABC3=${c5}; ins
;;
13 )
ABC1=${ud4ud6} && ABC2=${c5}; ins
;;
14 )
dns
;;
15 )
cwarp
;;
16 )
owarp
;;
17 )
up4
;;
18 )
up6
;;
19 )
macka
;;
20 )
phlinhng
;;
21 )
reboot
;;
0 )
exit 1
;;
esac
}
start_menu "first"