forked from v2fly/docker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
v2ray.sh
65 lines (57 loc) · 1.62 KB
/
v2ray.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
#!/bin/sh
# Set ARG
PLATFORM=$1
TAG=$2
if [ -z "$PLATFORM" ]; then
ARCH="64"
else
case "$PLATFORM" in
linux/386)
ARCH="32"
;;
linux/amd64)
ARCH="64"
;;
linux/arm/v6)
ARCH="arm32-v6"
;;
linux/arm/v7)
ARCH="arm32-v7a"
;;
linux/arm64|linux/arm64/v8)
ARCH="arm64-v8a"
;;
*)
ARCH=""
;;
esac
fi
[ -z "${ARCH}" ] && echo "Error: Not supported OS Architecture" && exit 1
# Download files
V2RAY_FILE="v2ray-linux-${ARCH}.zip"
DGST_FILE="v2ray-linux-${ARCH}.zip.dgst"
echo "Downloading binary file: ${V2RAY_FILE}"
echo "Downloading binary file: ${DGST_FILE}"
wget -O ${PWD}/v2ray.zip https://github.com/v2fly/v2ray-core/releases/download/${TAG}/${V2RAY_FILE} > /dev/null 2>&1
wget -O ${PWD}/v2ray.zip.dgst https://github.com/v2fly/v2ray-core/releases/download/${TAG}/${DGST_FILE} > /dev/null 2>&1
if [ $? -ne 0 ]; then
echo "Error: Failed to download binary file: ${V2RAY_FILE} ${DGST_FILE}" && exit 1
fi
echo "Download binary file: ${V2RAY_FILE} ${DGST_FILE} completed"
# Check SHA512
LOCAL=$(openssl dgst -sha512 v2ray.zip | sed 's/([^)]*)//g')
STR=$(cat v2ray.zip.dgst | grep 'SHA512' | head -n1)
if [ "${LOCAL}" = "${STR}" ]; then
echo " Check passed" && rm -fv v2ray.zip.dgst
else
echo " Check have not passed yet " && exit 1
fi
# Prepare
echo "Prepare to use"
unzip v2ray.zip && chmod +x v2ray
mv v2ray /usr/bin/
mv geosite.dat geoip.dat /usr/local/share/v2ray/
mv config.json /etc/v2ray/config.json
# Clean
rm -rf ${PWD}/*
echo "Done"