Skip to content

Commit

Permalink
v0.0.9 - 增加CDN
Browse files Browse the repository at this point in the history
  • Loading branch information
spiritLHLS committed Jun 30, 2024
1 parent cfde2aa commit ecb115a
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 16 deletions.
12 changes: 8 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,16 @@

## 使用

更新时间:2024.06.24

安装
下载、安装、升级

```shell
curl https://raw.githubusercontent.com/oneclickvirt/UnlockTests/main/ut_install.sh -sSf | sh
curl https://raw.githubusercontent.com/oneclickvirt/UnlockTests/main/ut_install.sh -sSf | bash
```


```
curl https://cdn.spiritlhl.net/https://raw.githubusercontent.com/oneclickvirt/UnlockTests/main/ut_install.sh -sSf | bash
```

以后需要使用时使用
Expand Down
48 changes: 36 additions & 12 deletions ut_install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,41 @@ rm -rf ut
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 ut https://github.com/oneclickvirt/UnlockTests/releases/download/output/ut-linux-amd64
wget -O ut "${cdn_success_url}https://github.com/oneclickvirt/UnlockTests/releases/download/output/ut-linux-amd64"
;;
"i386" | "i686")
wget -O ut https://github.com/oneclickvirt/UnlockTests/releases/download/output/ut-linux-386
wget -O ut "${cdn_success_url}https://github.com/oneclickvirt/UnlockTests/releases/download/output/ut-linux-386"
;;
"armv7l" | "armv8" | "armv8l" | "aarch64" | "arm64")
wget -O ut https://github.com/oneclickvirt/UnlockTests/releases/download/output/ut-linux-arm64
wget -O ut "${cdn_success_url}https://github.com/oneclickvirt/UnlockTests/releases/download/output/ut-linux-arm64"
;;
*)
echo "Unsupported architecture: $arch"
Expand All @@ -28,13 +52,13 @@ case $os in
Darwin)
case $arch in
"x86_64" | "x86" | "amd64" | "x64")
wget -O ut https://github.com/oneclickvirt/UnlockTests/releases/download/output/ut-darwin-amd64
wget -O ut "${cdn_success_url}https://github.com/oneclickvirt/UnlockTests/releases/download/output/ut-darwin-amd64"
;;
"i386" | "i686")
wget -O ut https://github.com/oneclickvirt/UnlockTests/releases/download/output/ut-darwin-386
wget -O ut "${cdn_success_url}https://github.com/oneclickvirt/UnlockTests/releases/download/output/ut-darwin-386"
;;
"armv7l" | "armv8" | "armv8l" | "aarch64" | "arm64")
wget -O ut https://github.com/oneclickvirt/UnlockTests/releases/download/output/ut-darwin-arm64
wget -O ut "${cdn_success_url}https://github.com/oneclickvirt/UnlockTests/releases/download/output/ut-darwin-arm64"
;;
*)
echo "Unsupported architecture: $arch"
Expand All @@ -45,13 +69,13 @@ case $os in
FreeBSD)
case $arch in
amd64)
wget -O ut https://github.com/oneclickvirt/UnlockTests/releases/download/output/ut-freebsd-amd64
wget -O ut "${cdn_success_url}https://github.com/oneclickvirt/UnlockTests/releases/download/output/ut-freebsd-amd64"
;;
"i386" | "i686")
wget -O ut https://github.com/oneclickvirt/UnlockTests/releases/download/output/ut-freebsd-386
wget -O ut "${cdn_success_url}https://github.com/oneclickvirt/UnlockTests/releases/download/output/ut-freebsd-386"
;;
"armv7l" | "armv8" | "armv8l" | "aarch64" | "arm64")
wget -O ut https://github.com/oneclickvirt/UnlockTests/releases/download/output/ut-freebsd-arm64
wget -O ut "${cdn_success_url}https://github.com/oneclickvirt/UnlockTests/releases/download/output/ut-freebsd-arm64"
;;
*)
echo "Unsupported architecture: $arch"
Expand All @@ -62,13 +86,13 @@ case $os in
OpenBSD)
case $arch in
amd64)
wget -O ut https://github.com/oneclickvirt/UnlockTests/releases/download/output/ut-openbsd-amd64
wget -O ut "${cdn_success_url}https://github.com/oneclickvirt/UnlockTests/releases/download/output/ut-openbsd-amd64"
;;
"i386" | "i686")
wget -O ut https://github.com/oneclickvirt/UnlockTests/releases/download/output/ut-openbsd-386
wget -O ut "${cdn_success_url}https://github.com/oneclickvirt/UnlockTests/releases/download/output/ut-openbsd-386"
;;
"armv7l" | "armv8" | "armv8l" | "aarch64" | "arm64")
wget -O ut https://github.com/oneclickvirt/UnlockTests/releases/download/output/ut-openbsd-arm64
wget -O ut "${cdn_success_url}https://github.com/oneclickvirt/UnlockTests/releases/download/output/ut-openbsd-arm64"
;;
*)
echo "Unsupported architecture: $arch"
Expand Down

0 comments on commit ecb115a

Please sign in to comment.