This commit is contained in:
spiritlhl 2024-07-02 14:02:45 +00:00
parent 9a43a89d39
commit 9488f3cec7
3 changed files with 61 additions and 22 deletions

View File

@ -25,12 +25,16 @@
## 使用 ## 使用
更新时间2024.06.24 下载、安装、更新
下载及安装
```shell ```shell
curl https://raw.githubusercontent.com/oneclickvirt/backtrace/main/backtrace_install.sh -sSf | sh curl https://raw.githubusercontent.com/oneclickvirt/backtrace/main/backtrace_install.sh -sSf | bash
```
```
curl https://cdn.spiritlhl.net/https://raw.githubusercontent.com/oneclickvirt/backtrace/main/backtrace_install.sh -sSf | bash
``` ```
使用 使用
@ -49,6 +53,9 @@ backtrace
无环境依赖,理论上适配所有系统和主流架构,更多架构请查看 https://github.com/oneclickvirt/backtrace/releases/tag/output 无环境依赖,理论上适配所有系统和主流架构,更多架构请查看 https://github.com/oneclickvirt/backtrace/releases/tag/output
```
```
## 卸载 ## 卸载

View File

@ -1,22 +1,46 @@
#!/bin/bash #!/bin/bash
#From https://github.com/oneclickvirt/backtrace #From https://github.com/oneclickvirt/backtrace
#2024.06.28 #2024.07.02
rm -rf /usr/bin/backtrace rm -rf /usr/bin/backtrace
os=$(uname -s) os=$(uname -s)
arch=$(uname -m) 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 case $os in
Linux) Linux)
case $arch in case $arch in
"x86_64" | "x86" | "amd64" | "x64") "x86_64" | "x86" | "amd64" | "x64")
wget -O backtrace https://github.com/oneclickvirt/backtrace/releases/download/output/backtrace-linux-amd64 wget -O backtrace "${cdn_success_url}https://github.com/oneclickvirt/backtrace/releases/download/output/backtrace-linux-amd64"
;; ;;
"i386" | "i686") "i386" | "i686")
wget -O backtrace https://github.com/oneclickvirt/backtrace/releases/download/output/backtrace-linux-386 wget -O backtrace "${cdn_success_url}https://github.com/oneclickvirt/backtrace/releases/download/output/backtrace-linux-386"
;; ;;
"armv7l" | "armv8" | "armv8l" | "aarch64" | "arm64") "armv7l" | "armv8" | "armv8l" | "aarch64" | "arm64")
wget -O backtrace https://github.com/oneclickvirt/backtrace/releases/download/output/backtrace-linux-arm64 wget -O backtrace "${cdn_success_url}https://github.com/oneclickvirt/backtrace/releases/download/output/backtrace-linux-arm64"
;; ;;
*) *)
echo "Unsupported architecture: $arch" echo "Unsupported architecture: $arch"
@ -27,13 +51,13 @@ case $os in
Darwin) Darwin)
case $arch in case $arch in
"x86_64" | "x86" | "amd64" | "x64") "x86_64" | "x86" | "amd64" | "x64")
wget -O backtrace https://github.com/oneclickvirt/backtrace/releases/download/output/backtrace-darwin-amd64 wget -O backtrace "${cdn_success_url}https://github.com/oneclickvirt/backtrace/releases/download/output/backtrace-darwin-amd64"
;; ;;
"i386" | "i686") "i386" | "i686")
wget -O backtrace https://github.com/oneclickvirt/backtrace/releases/download/output/backtrace-darwin-386 wget -O backtrace "${cdn_success_url}https://github.com/oneclickvirt/backtrace/releases/download/output/backtrace-darwin-386"
;; ;;
"armv7l" | "armv8" | "armv8l" | "aarch64" | "arm64") "armv7l" | "armv8" | "armv8l" | "aarch64" | "arm64")
wget -O backtrace https://github.com/oneclickvirt/backtrace/releases/download/output/backtrace-darwin-arm64 wget -O backtrace "${cdn_success_url}https://github.com/oneclickvirt/backtrace/releases/download/output/backtrace-darwin-arm64"
;; ;;
*) *)
echo "Unsupported architecture: $arch" echo "Unsupported architecture: $arch"
@ -44,13 +68,13 @@ case $os in
FreeBSD) FreeBSD)
case $arch in case $arch in
amd64) amd64)
wget -O backtrace https://github.com/oneclickvirt/backtrace/releases/download/output/backtrace-freebsd-amd64 wget -O backtrace "${cdn_success_url}https://github.com/oneclickvirt/backtrace/releases/download/output/backtrace-freebsd-amd64"
;; ;;
"i386" | "i686") "i386" | "i686")
wget -O backtrace https://github.com/oneclickvirt/backtrace/releases/download/output/backtrace-freebsd-386 wget -O backtrace "${cdn_success_url}https://github.com/oneclickvirt/backtrace/releases/download/output/backtrace-freebsd-386"
;; ;;
"armv7l" | "armv8" | "armv8l" | "aarch64" | "arm64") "armv7l" | "armv8" | "armv8l" | "aarch64" | "arm64")
wget -O backtrace https://github.com/oneclickvirt/backtrace/releases/download/output/backtrace-freebsd-arm64 wget -O backtrace "${cdn_success_url}https://github.com/oneclickvirt/backtrace/releases/download/output/backtrace-freebsd-arm64"
;; ;;
*) *)
echo "Unsupported architecture: $arch" echo "Unsupported architecture: $arch"
@ -61,13 +85,13 @@ case $os in
OpenBSD) OpenBSD)
case $arch in case $arch in
amd64) amd64)
wget -O backtrace https://github.com/oneclickvirt/backtrace/releases/download/output/backtrace-openbsd-amd64 wget -O backtrace "${cdn_success_url}https://github.com/oneclickvirt/backtrace/releases/download/output/backtrace-openbsd-amd64"
;; ;;
"i386" | "i686") "i386" | "i686")
wget -O backtrace https://github.com/oneclickvirt/backtrace/releases/download/output/backtrace-openbsd-386 wget -O backtrace "${cdn_success_url}https://github.com/oneclickvirt/backtrace/releases/download/output/backtrace-openbsd-386"
;; ;;
"armv7l" | "armv8" | "armv8l" | "aarch64" | "arm64") "armv7l" | "armv8" | "armv8l" | "aarch64" | "arm64")
wget -O backtrace https://github.com/oneclickvirt/backtrace/releases/download/output/backtrace-openbsd-arm64 wget -O backtrace "${cdn_success_url}https://github.com/oneclickvirt/backtrace/releases/download/output/backtrace-openbsd-arm64"
;; ;;
*) *)
echo "Unsupported architecture: $arch" echo "Unsupported architecture: $arch"

View File

@ -5,6 +5,7 @@ import (
"flag" "flag"
"fmt" "fmt"
"net/http" "net/http"
"os"
backtrace "github.com/oneclickvirt/backtrace/bk" backtrace "github.com/oneclickvirt/backtrace/bk"
. "github.com/oneclickvirt/defaultset" . "github.com/oneclickvirt/defaultset"
@ -23,11 +24,18 @@ func main() {
http.Get("https://hits.seeyoufarm.com/api/count/incr/badge.svg?url=https%3A%2F%2Fgithub.com%2Foneclickvirt%2Fbacktrace&count_bg=%2323E01C&title_bg=%23555555&icon=sonarcloud.svg&icon_color=%23E7E7E7&title=hits&edge_flat=false") http.Get("https://hits.seeyoufarm.com/api/count/incr/badge.svg?url=https%3A%2F%2Fgithub.com%2Foneclickvirt%2Fbacktrace&count_bg=%2323E01C&title_bg=%23555555&icon=sonarcloud.svg&icon_color=%23E7E7E7&title=hits&edge_flat=false")
}() }()
fmt.Println(Green("项目地址:"), Yellow("https://github.com/oneclickvirt/backtrace")) fmt.Println(Green("项目地址:"), Yellow("https://github.com/oneclickvirt/backtrace"))
var showVersion, showIpInfo bool var showVersion, showIpInfo, help bool
flag.BoolVar(&showVersion, "v", false, "show version") backtraceFlag := flag.NewFlagSet("backtrace", flag.ContinueOnError)
flag.BoolVar(&showIpInfo, "s", true, "diabel show ip info") backtraceFlag.BoolVar(&help, "h", false, "Show help information")
flag.BoolVar(&backtrace.EnableLoger, "e", false, "Enable logging") backtraceFlag.BoolVar(&showVersion, "v", false, "Show version")
flag.Parse() backtraceFlag.BoolVar(&showIpInfo, "s", true, "Disabe show ip info")
backtraceFlag.BoolVar(&backtrace.EnableLoger, "e", false, "Enable logging")
backtraceFlag.Parse(os.Args[1:])
if help {
fmt.Printf("Usage: %s [options]\n", os.Args[0])
backtraceFlag.PrintDefaults()
return
}
if showVersion { if showVersion {
fmt.Println(backtrace.BackTraceVersion) fmt.Println(backtrace.BackTraceVersion)
return return