forked from KANIKIG/steamsv.github.io
-
Notifications
You must be signed in to change notification settings - Fork 10
/
install_v2ray_ws_dnsmasq.sh
executable file
·134 lines (122 loc) · 4.04 KB
/
install_v2ray_ws_dnsmasq.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
#!/bin/bash
#fonts color
Green="\033[32m"
Red="\033[31m"
Yellow="\033[33m"
GreenBG="\033[42;37m"
RedBG="\033[41;37m"
Font="\033[0m"
if grep -Eqi "CentOS" /etc/issue || grep -Eq "CentOS" /etc/*-release; then
echo ""
else
echo "脚本目前仅支持Centos7"
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
}
install_v2ray(){
if [[ -d /usr/local/etc/v2ray ]];then
rm -rf /usr/local/etc/v2ray
fi
if [[ -d /etc/v2ray ]];then
rm -rf /usr/local/etc/v2ray
fi
mkdir -p /usr/local/etc/v2ray && cd /usr/local/etc/v2ray
yum makecache
yum install curl -y
curl -O https://raw.githubusercontent.com/v2fly/fhs-install-v2ray/master/install-release.sh
curl -O https://raw.githubusercontent.com/v2fly/fhs-install-v2ray/master/install-dat-release.sh
## wget http://install.direct/go.sh
if [[ -f install-release.sh ]];then
bash install-release.sh --remove
bash install-release.sh
bash install-dat-release.sh
judge "安装 V2ray"
else
echo -e "${Error} ${RedBG} V2ray 安装文件下载失败,请检查下载地址是否可用 ${Font}"
exit 4
fi
# 清除临时文件
rm -rf /usr/local/etc/v2ray/config.json
cd /usr/local/etc/v2ray/
wget https://dnsunlock.com/config.json
systemctl restart v2ray
}
echo_v2ray(){
echo "v2ray参数"
local_ip=`curl -4 ip.sb`
echo -e "服务器ip: ${local_ip}"
echo "端口: 8090"
echo "uuid: 179c0060-9c92-3dd4-013a-aba0dbc39054"
echo "alterid: 0"
echo "path: /v2ray/"
echo "v2rayNG一键导入:"
json=`echo "{\"add\":\"$local_ip\",\"aid\":\"0\",\"host\":\"\",\"id\":\"179c0060-9c92-3dd4-013a-aba0dbc39054\",\"net\":\"ws\",\"path\":\"/v2ray/\",\"port\":\"8090\",\"ps\":\"v2ray+dnsmasq\",\"tls\":\"\",\"type\":\"none\",\"v\":\"2\"}" | base64 | xargs`
echo "vmess://$json"
}
uninstall_v2ray(){
systemctl stop v2ray
systemctl disable v2ray
systemctl stop dnsmasq
systemctl disable dnsmasq
echo "nameserver 1.1.1.1" > /etc/resolv.conf
echo "卸载成功"
}
install_dnsmasq(){
yum install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
yum install -y dnsmasq
if [ $? -eq 0 ]; then
read -p "请输入解锁dns:" dns
systemctl enable dnsmasq
rm -f /etc/resolv.conf
echo "nameserver 127.0.0.1" > /etc/resolv.conf
touch /etc/dnsmasq.d/unlock.conf
echo "server=1.0.0.1" > /etc/dnsmasq.d/unlock.conf
echo "server=8.8.4.4" >> /etc/dnsmasq.d/unlock.conf
echo "server=8.8.4.4" >> /etc/dnsmasq.d/unlock.conf
echo "server=/fast.com/$dns" >> /etc/dnsmasq.d/unlock.conf
echo "server=/netflix.com/$dns" >> /etc/dnsmasq.d/unlock.conf
echo "server=/netflix.net/$dns" >> /etc/dnsmasq.d/unlock.conf
echo "server=/nflximg.net/$dns" >> /etc/dnsmasq.d/unlock.conf
echo "server=/nflximg.com/$dns" >> /etc/dnsmasq.d/unlock.conf
echo "server=/nflxvideo.net/$dns" >> /etc/dnsmasq.d/unlock.conf
echo "server=/nflxso.net/$dns" >> /etc/dnsmasq.d/unlock.conf
echo "server=/nflxext.com/$dns" >> /etc/dnsmasq.d/unlock.conf
systemctl restart dnsmasq
systemctl status dnsmasq
echo "dnsmasq启动成功"
else
echo "dnsmasq安装失败, 请检查仓库状况"
fi
}
menu(){
echo -e " V2ray|Trojan dnsmasq奈飞解锁安装管理脚本 ${Red}[${shell_version}]${Font}"
echo -e "${Green}1.${Font} 安装 v2ray+dnsmasq"
echo -e "${Green}2.${Font} 卸载 v2ray+dnsmasq"
echo -e "${Green}3.${Font} 退出 \n"
read -p "请输入数字:" menu_num
case $menu_num in
1)
install_v2ray
install_dnsmasq
echo_v2ray
;;
2)
uninstall_v2ray
;;
3)
exit 0
;;
*)
echo -e "${RedBG}请输入正确的数字${Font}"
;;
esac
}
menu