blob: 446899baa74ff49c2110fa4c0900e5b37bc72025 (
plain)
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
|
#!/bin/bash
cd "$(dirname "$0")"
V2RAY_HOME=${V2RAY_HOME:-$(pwd)}
V2RAY="$V2RAY_HOME/v2ray"
if [[ -f "$V2RAY" ]]
then
CURRENT_VERSION=$("$V2RAY" -version | grep -Po "\b\d+\.\d+\.\d+\b")
echo "Current version: v$CURRENT_VERSION"
fi
echo "Checking latest version..."
LATEST_VERSION=$(curl -H "Accept: application/vnd.github.v3+json" \
-s "https://api.github.com/repos/v2fly/v2ray-core/releases/latest" | \
grep '"tag_name":' | \
sed -E 's/.*"([^"]+)".*/\1/')
[[ -z "$LATEST_VERSION" ]] \
&& { echo "Cannot check latest version, check your network." >&2; exit 1; } \
|| echo "Lasest version found: $LATEST_VERSION"
if [[ -n "$CURRENT_VERSION" && "$LATEST_VERSION" == "v$CURRENT_VERSION" ]]
then
echo "Already up-to-date."
exit 0
fi
declare -a file_list=(
"v2ray-linux-64.zip"
"v2ray-linux-64.zip.dgst"
)
for file in "${file_list[@]}"
do
echo "Downloading $file..."
curl -LO "https://github.com/v2fly/v2ray-core/releases/download/$LATEST_VERSION/$file" \
|| { echo "Cannot download $file, check your network." >&2; exit 1; }
done
echo "Checking file integrity..."
sha512sum "${file_list[0]}" | \
cut -d ' ' -f 1 | grep -f - -q "${file_list[1]}" \
|| { echo "ERROR" >&2; exit 1; }
echo "OK"
echo "Extracting ${file_list[0]}..."
unzip -o "${file_list[0]}" -x "*.sig" "*.json" "systemd/*"
echo "Removing archive..."
rm -fv "${file_list[@]}"
echo "Upgrade complete!"
|