-
Notifications
You must be signed in to change notification settings - Fork 9
/
backtrace_install.sh
109 lines (103 loc) · 3.53 KB
/
backtrace_install.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
#!/bin/bash
#From https://github.com/oneclickvirt/backtrace
#2024.07.02
rm -rf /usr/bin/backtrace
os=$(uname -s)
arch=$(uname -m)
check_cdn() {
local o_url=$1
for cdn_url in "${cdn_urls[@]}"; do
if curl -sL -k "$cdn_url$o_url" --max-time 6 | grep -q "success" >/dev/null 2>&1; then
export cdn_success_url="$cdn_url"
return
fi
sleep 0.5
done
export cdn_success_url=""
}
check_cdn_file() {
check_cdn "https://raw.githubusercontent.com/spiritLHLS/ecs/main/back/test"
if [ -n "$cdn_success_url" ]; then
echo "CDN available, using CDN"
else
echo "No CDN available, no use CDN"
fi
}
cdn_urls=("https://cdn0.spiritlhl.top/" "http://cdn3.spiritlhl.net/" "http://cdn1.spiritlhl.net/" "http://cdn2.spiritlhl.net/")
check_cdn_file
case $os in
Linux)
case $arch in
"x86_64" | "x86" | "amd64" | "x64")
wget -O backtrace "${cdn_success_url}https://github.com/oneclickvirt/backtrace/releases/download/output/backtrace-linux-amd64"
;;
"i386" | "i686")
wget -O backtrace "${cdn_success_url}https://github.com/oneclickvirt/backtrace/releases/download/output/backtrace-linux-386"
;;
"armv7l" | "armv8" | "armv8l" | "aarch64" | "arm64")
wget -O backtrace "${cdn_success_url}https://github.com/oneclickvirt/backtrace/releases/download/output/backtrace-linux-arm64"
;;
*)
echo "Unsupported architecture: $arch"
exit 1
;;
esac
;;
Darwin)
case $arch in
"x86_64" | "x86" | "amd64" | "x64")
wget -O backtrace "${cdn_success_url}https://github.com/oneclickvirt/backtrace/releases/download/output/backtrace-darwin-amd64"
;;
"i386" | "i686")
wget -O backtrace "${cdn_success_url}https://github.com/oneclickvirt/backtrace/releases/download/output/backtrace-darwin-386"
;;
"armv7l" | "armv8" | "armv8l" | "aarch64" | "arm64")
wget -O backtrace "${cdn_success_url}https://github.com/oneclickvirt/backtrace/releases/download/output/backtrace-darwin-arm64"
;;
*)
echo "Unsupported architecture: $arch"
exit 1
;;
esac
;;
FreeBSD)
case $arch in
amd64)
wget -O backtrace "${cdn_success_url}https://github.com/oneclickvirt/backtrace/releases/download/output/backtrace-freebsd-amd64"
;;
"i386" | "i686")
wget -O backtrace "${cdn_success_url}https://github.com/oneclickvirt/backtrace/releases/download/output/backtrace-freebsd-386"
;;
"armv7l" | "armv8" | "armv8l" | "aarch64" | "arm64")
wget -O backtrace "${cdn_success_url}https://github.com/oneclickvirt/backtrace/releases/download/output/backtrace-freebsd-arm64"
;;
*)
echo "Unsupported architecture: $arch"
exit 1
;;
esac
;;
OpenBSD)
case $arch in
amd64)
wget -O backtrace "${cdn_success_url}https://github.com/oneclickvirt/backtrace/releases/download/output/backtrace-openbsd-amd64"
;;
"i386" | "i686")
wget -O backtrace "${cdn_success_url}https://github.com/oneclickvirt/backtrace/releases/download/output/backtrace-openbsd-386"
;;
"armv7l" | "armv8" | "armv8l" | "aarch64" | "arm64")
wget -O backtrace "${cdn_success_url}https://github.com/oneclickvirt/backtrace/releases/download/output/backtrace-openbsd-arm64"
;;
*)
echo "Unsupported architecture: $arch"
exit 1
;;
esac
;;
*)
echo "Unsupported operating system: $os"
exit 1
;;
esac
chmod 777 backtrace
cp backtrace /usr/bin/backtrace