-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdgb.sh
More file actions
203 lines (193 loc) · 6.85 KB
/
dgb.sh
File metadata and controls
203 lines (193 loc) · 6.85 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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
#!/bin/bash
#From https://github.com/oneclickvirt/cputest
#2025.08.26
rm -rf /usr/bin/geekbench*
arch=$(uname -m)
GB4_VER="4.4.4"
GB5_VER="5.5.1"
GB6_VER="6.7.1"
RELEASE_TAG="20240525"
GB_BASE="https://github.com/oneclickvirt/cputest/releases/download/${RELEASE_TAG}"
mypwd=$(pwd)
if [ ! -d "/usr/bin/" ]; then
mkdir /usr/bin/
fi
if ! command -v wget >/dev/null 2>&1; then
echo "The wget command is not detected, please download it before executing this script."
fi
if ! command -v tar >/dev/null 2>&1; then
echo "The tar command is not detected, please download it before executing this script."
fi
if [ "$1" != "-v" ]; then
echo "Error: the -v option must be used"
exit 1
fi
if [ -z "$2" ]; then
echo "Error: a value must be provided (gb4, gb5 or gb6)"
exit 1
fi
case "$2" in
gb4|gb5|gb6)
gbv="$2"
;;
*)
echo "Error: Invalid value. Must be gb4, gb5 or gb6"
exit 1
;;
esac
check_ipv4_available() {
if ! curl -s 'https://browser.geekbench.com' --connect-timeout 5 >/dev/null; then
echo "No IPV4 network, can't test with geekbench, browser.geekbench.com only has IPv4, does not support IPv6, forcing to test with no result."
exit 1
fi
}
check_ipv4_available
check_memory() {
if command -v free >/dev/null 2>&1; then
mem=$(free -m | awk '/Mem/{print $2}')
swap=$(free -m | awk '/Swap/{print $2}')
elif [ -f "/proc/meminfo" ]; then
mem=$(awk '/MemTotal/{print $2/1024}' /proc/meminfo | cut -d. -f1)
swap=$(awk '/SwapTotal/{print $2/1024}' /proc/meminfo | cut -d. -f1)
else
echo "Unable to determine system memory. Defaulting to GB4 for testing."
gbv="gb4"
return 1
fi
ms=$((mem + swap))
if [ "$mem" -ge "1024" ]; then
echo "After judgment, the memory of this machine is greater than 1G, which meets the GB5/GB6 test conditions"
elif [ "$ms" -ge "1280" ]; then
echo "After judgment, the total amount of RAM plus Swap of this machine is more than 1.25G, which meets the GB5/GB6 test conditions."
else
echo "After judgment, the total memory plus Swap of this machine is less than 1.25G, switch to GB4 for testing."
gbv="gb4"
fi
}
check_memory
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
cdn_success_url="$cdn_url"
return
fi
sleep 0.5
done
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
download_file() {
local url="$1"
local output="$2"
if ! wget -O "$output" "$url"; then
echo "wget failed, trying curl..."
if ! curl -L -o "$output" "$url"; then
echo "Both wget and curl failed. Unable to download the file."
return 1
fi
fi
return 0
}
case $gbv in
gb4)
case $arch in
"x86_64" | "x86" | "amd64" | "x64")
download_file "${cdn_success_url}${GB_BASE}/Geekbench-${GB4_VER}-Linux.tar.gz" "/usr/bin/geekbench.tar.gz"
cd /usr/bin >/dev/null 2>&1
chmod 777 geekbench.tar.gz
tar -xvf geekbench.tar.gz
mv "Geekbench-${GB4_VER}-Linux/geekbench4" geekbench
mv "Geekbench-${GB4_VER}-Linux/geekbench_x86_64" geekbench_x86_64
mv "Geekbench-${GB4_VER}-Linux/geekbench.plar" geekbench.plar
rm -rf "Geekbench-${GB4_VER}-Linux"
cd $mypwd >/dev/null 2>&1
;;
*)
echo "Unsupported architecture: $arch"
exit 1
;;
esac
;;
gb5)
case $arch in
"x86_64" | "x86" | "amd64" | "x64")
download_file "${cdn_success_url}${GB_BASE}/Geekbench-${GB5_VER}-Linux.tar.gz" "/usr/bin/geekbench.tar.gz"
cd /usr/bin >/dev/null 2>&1
chmod 777 geekbench.tar.gz
tar -xvf geekbench.tar.gz
mv "Geekbench-${GB5_VER}-Linux/geekbench5" geekbench
mv "Geekbench-${GB5_VER}-Linux/geekbench_x86_64" geekbench_x86_64
mv "Geekbench-${GB5_VER}-Linux/geekbench.plar" geekbench.plar
rm -rf "Geekbench-${GB5_VER}-Linux"
cd $mypwd >/dev/null 2>&1
;;
"armv7l" | "armv8" | "armv8l" | "aarch64" | "arm64")
download_file "${cdn_success_url}${GB_BASE}/Geekbench-${GB5_VER}-LinuxARMPreview.tar.gz" "/usr/bin/geekbench.tar.gz"
cd /usr/bin >/dev/null 2>&1
chmod 777 geekbench.tar.gz
tar -xvf geekbench.tar.gz
mv "Geekbench-${GB5_VER}-LinuxARMPreview/geekbench5" geekbench
mv "Geekbench-${GB5_VER}-LinuxARMPreview/geekbench_aarch64" geekbench_aarch64
mv "Geekbench-${GB5_VER}-LinuxARMPreview/geekbench_armv7" geekbench_armv7
mv "Geekbench-${GB5_VER}-LinuxARMPreview/geekbench.plar" geekbench.plar
rm -rf "Geekbench-${GB5_VER}-LinuxARMPreview"
cd $mypwd >/dev/null 2>&1
;;
*)
echo "Unsupported architecture: $arch"
exit 1
;;
esac
;;
gb6)
case $arch in
"x86_64" | "x86" | "amd64" | "x64")
download_file "${cdn_success_url}${GB_BASE}/Geekbench-${GB6_VER}-Linux.tar.gz" "/usr/bin/geekbench.tar.gz"
cd /usr/bin >/dev/null 2>&1
chmod 777 geekbench.tar.gz
tar -xvf geekbench.tar.gz
mv "Geekbench-${GB6_VER}-Linux/geekbench6" geekbench
mv "Geekbench-${GB6_VER}-Linux/geekbench_x86_64" geekbench_x86_64
mv "Geekbench-${GB6_VER}-Linux/geekbench.plar" geekbench.plar
rm -rf "Geekbench-${GB6_VER}-Linux"
cd $mypwd >/dev/null 2>&1
;;
"armv7l" | "armv8" | "armv8l" | "aarch64" | "arm64")
download_file "${cdn_success_url}${GB_BASE}/Geekbench-${GB6_VER}-LinuxARMPreview.tar.gz" "/usr/bin/geekbench.tar.gz"
cd /usr/bin >/dev/null 2>&1
chmod 777 geekbench.tar.gz
tar -xvf geekbench.tar.gz
mv "Geekbench-${GB6_VER}-LinuxARMPreview/geekbench6" geekbench
mv "Geekbench-${GB6_VER}-LinuxARMPreview/geekbench_aarch64" geekbench_aarch64
mv "Geekbench-${GB6_VER}-LinuxARMPreview/geekbench_armv7" geekbench_armv7
mv "Geekbench-${GB6_VER}-LinuxARMPreview/geekbench.plar" geekbench.plar
rm -rf "Geekbench-${GB6_VER}-LinuxARMPreview"
cd $mypwd >/dev/null 2>&1
;;
*)
echo "Unsupported architecture: $arch"
exit 1
;;
esac
;;
esac
if [ -f /usr/bin/geekbench ]; then
chmod 777 /usr/bin/geekbench
/usr/bin/geekbench --version
if [ $? -ne 0 ]; then
echo "Geekbench failed to check the version, please leave an error message in the repository's issues."
fi
rm -rf /usr/bin/geekbench.tar.gz
else
echo "Geekbench failed to download, please leave an error message in the repository's issues."
fi