-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathopenwrt-v2ray.sh
More file actions
87 lines (76 loc) · 2.05 KB
/
openwrt-v2ray.sh
File metadata and controls
87 lines (76 loc) · 2.05 KB
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
#!/bin/sh
VERSION=4.22.1
DIR=/etc/config/v2ray
# DIR=./tmp
platform="$1"
all=",386,amd64,armv5,armv6,armv7,arm64,mips,mipsle,mips64,mips64le,ppc64,ppc64le,s390x,"
result=$(echo $all | grep ",${platform},")
if [[ "$result" != "" ]]
then
echo "Your router platform: $platform"
else
echo "Unknown platform: $platform"
exit
fi
float=""
if [[ $platform == "mips" || $platform == "mipsle" ]]
then
read -r -p "Enable FPU support(soft-float)? [y/N] " input
case $input in
[yY][eE][sS]|[yY])
echo "Yes"
float="float"
;;
*)
echo "No"
float=""
;;
esac
fi
read -p "Enter the server address:" server
read -p "Enter the user id:" user
read -p "Enter the ws path:" path
path=${path//\//}
read -r -p "Enable UDP support? [y/N] " input
case $input in
[yY][eE][sS]|[yY])
echo "Yes"
config="udp"
;;
*)
echo "No"
config="tcp"
;;
esac
mkdir -p $DIR
cd $DIR
curl -L --socks5-hostname 192.168.1.122:1080 https://github.com/felix-fly/v2ray-openwrt/releases/download/$VERSION/v2ray-linux-$platform.tar.gz -o /tmp/v2ray.tar.gz
curl -L --socks5-hostname 192.168.1.122:1080 https://raw.githubusercontent.com/felix-fly/v2ray-openwrt/master/v2ray.service
curl -L --socks5-hostname 192.168.1.122:1080 https://raw.githubusercontent.com/felix-fly/v2ray-openwrt/master/client-$config.json -O config.json
curl -L --socks5-hostname 192.168.1.122:1080 https://raw.githubusercontent.com/felix-fly/v2ray-adlist/master/site.dat
tar -xzvf /tmp/v2ray.tar.gz -C /tmp
if [[ $float == "float" ]]
then
rm -f /tmp/v2ray
mv /tmp/v2ray_softfloat v2ray
else
rm -f /v2ray_softfloat
mv /tmp/v2ray v2ray
fi
rm -f /tmp/v2ray.tar.gz
chmod +x v2ray v2ray.service
ln -s $DIR/v2ray.service /etc/init.d/v2ray
/etc/init.d/v2ray enable
sed -i "s/==YOUR DOMAIN or SERVER ADDRESS==/$server/" config.json
sed -i "s/==YOUR USER ID==/$user/" config.json
sed -i "s/==YOUR ENTRY PATH==/\/$path\//" config.json
read -r -p "Start v2ray now? [y/N] " input
case $input in
[yY][eE][sS]|[yY])
echo "Yes"
/etc/init.d/v2ray start
;;
*)
echo "No"
;;
esac