forked from konstpic/sharx-code
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerInit.sh
More file actions
executable file
·103 lines (99 loc) · 3.77 KB
/
Copy pathDockerInit.sh
File metadata and controls
executable file
·103 lines (99 loc) · 3.77 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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#!/bin/sh
# $1: Docker BuildKit TARGETARCH (amd64, arm64, arm, 386, ...). If empty, match host/emu arch so
# the downloaded binary name matches runtime.GOOS/GOARCH (e.g. xray-linux-arm64 on linux/arm64).
set -e
download_with_retry() {
url="$1"
out="$2"
attempt=1
while [ "$attempt" -le 3 ]; do
echo "DockerInit: download attempt ${attempt}/3 — ${out}"
if curl -fSL --connect-timeout 15 --max-time 600 -o "${out}" "${url}"; then
return 0
fi
echo "DockerInit: download failed (${out}); retrying..." >&2
attempt=$((attempt + 1))
sleep 2
done
echo "DockerInit: download failed after 3 attempts: ${out} (${url})" >&2
return 1
}
RESOLVED="${1:-}"
if [ -z "$RESOLVED" ]; then
case "$(uname -m)" in
x86_64) RESOLVED=amd64 ;;
i386|i486|i686) RESOLVED=386 ;;
aarch64) RESOLVED=arm64 ;;
armv7l) RESOLVED=arm ;;
armv6l) RESOLVED=armv6 ;;
*) RESOLVED=amd64 ;;
esac
echo "DockerInit: TARGETARCH empty, using uname -> ${RESOLVED}"
fi
case $RESOLVED in
amd64)
ARCH="64"
FNAME="amd64"
;;
386|i386)
ARCH="32"
FNAME="i386"
;;
armv8|arm64|aarch64)
ARCH="arm64-v8a"
FNAME="arm64"
;;
armv7|arm|arm32)
ARCH="arm32-v7a"
FNAME="arm32"
;;
armv6)
ARCH="arm32-v6"
FNAME="armv6"
;;
*)
echo "DockerInit: unknown arch '$RESOLVED', defaulting to amd64"
ARCH="64"
FNAME="amd64"
;;
esac
echo "DockerInit: downloading Xray for ${RESOLVED} (zip ARCH=${ARCH}, output xray-linux-${FNAME})"
mkdir -p build/bin
cd build/bin
curl -sfLRO "https://github.com/XTLS/Xray-core/releases/download/v26.5.3/Xray-linux-${ARCH}.zip"
unzip "Xray-linux-${ARCH}.zip"
rm -f "Xray-linux-${ARCH}.zip" geoip.dat geosite.dat
mv xray "xray-linux-${FNAME}"
chmod +x "xray-linux-${FNAME}"
echo "DockerInit: rules 1/6 — Loyalsoldier geoip.dat (large, may take minutes)..."
download_with_retry "https://github.com/Loyalsoldier/v2ray-rules-dat/releases/latest/download/geoip.dat" "geoip.dat"
echo "DockerInit: rules 2/6 — Loyalsoldier geosite.dat..."
download_with_retry "https://github.com/Loyalsoldier/v2ray-rules-dat/releases/latest/download/geosite.dat" "geosite.dat"
echo "DockerInit: rules 3/6 — IR geoip..."
download_with_retry "https://github.com/chocolate4u/Iran-v2ray-rules/releases/latest/download/geoip.dat" "geoip_IR.dat"
echo "DockerInit: rules 4/6 — IR geosite..."
download_with_retry "https://github.com/chocolate4u/Iran-v2ray-rules/releases/latest/download/geosite.dat" "geosite_IR.dat"
echo "DockerInit: rules 5/6 — RU geoip..."
download_with_retry "https://github.com/runetfreedom/russia-v2ray-rules-dat/releases/latest/download/geoip.dat" "geoip_RU.dat"
echo "DockerInit: rules 6/6 — RU geosite..."
download_with_retry "https://github.com/runetfreedom/russia-v2ray-rules-dat/releases/latest/download/geosite.dat" "geosite_RU.dat"
echo "DockerInit: done."
cd ../../
# Telemt (MTProto) binary for panel standalone and shared layout with node builds.
TELEMT_VERSION="${TELEMT_VERSION:-3.4.10}"
case "$FNAME" in
amd64) TELEMT_ARCH_DL="x86_64-linux-musl" ;;
arm64) TELEMT_ARCH_DL="aarch64-linux-musl" ;;
*)
echo "DockerInit: skipping Telemt download (no musl build for arch $FNAME)"
TELEMT_ARCH_DL=""
;;
esac
if [ -n "$TELEMT_ARCH_DL" ]; then
echo "DockerInit: downloading Telemt ${TELEMT_VERSION} (${TELEMT_ARCH_DL})..."
download_with_retry "https://github.com/telemt/telemt/releases/download/${TELEMT_VERSION}/telemt-${TELEMT_ARCH_DL}.tar.gz" "/tmp/telemt.tgz"
tar -xzf /tmp/telemt.tgz -C build/bin
chmod +x build/bin/telemt
rm -f /tmp/telemt.tgz
echo "DockerInit: telemt -> build/bin/telemt"
fi