Compare commits

..

4 Commits

Author SHA1 Message Date
spiritysdx
f6dd0bbb56 update 2024-07-01 15:03:54 +08:00
spiritysdx
01686f3e9d update 2024-07-01 13:44:03 +08:00
spiritysdx
5a6cd7d671 update 2024-07-01 13:31:44 +08:00
spiritysdx
35e183b640 update 2024-07-01 13:14:49 +08:00
6 changed files with 45 additions and 12 deletions

View File

@@ -27,4 +27,8 @@ Shell版本 https://github.com/spiritLHLS/ecs
## 说明
开发中,勿要使用
开发中,勿要使用
```
curl -L https://raw.githubusercontent.com/oneclickvirt/ecs/master/goecs.sh -o goecs.sh && chmod +x goecs.sh
```

2
go.mod
View File

@@ -15,7 +15,7 @@ require (
github.com/oneclickvirt/memorytest v0.0.1-20240624151629
github.com/oneclickvirt/nt3 v0.0.2-20240630152642
github.com/oneclickvirt/portchecker v0.0.1-20240624155429
github.com/oneclickvirt/security v0.0.2-20240630142358
github.com/oneclickvirt/security v0.0.3-20240701065755
github.com/oneclickvirt/speedtest v0.0.6-20240630114816
)

4
go.sum
View File

@@ -97,8 +97,8 @@ github.com/oneclickvirt/nt3 v0.0.2-20240630152642 h1:BkpR1j9JaDxMzx7iIwtsnFDxSld
github.com/oneclickvirt/nt3 v0.0.2-20240630152642/go.mod h1:UojPmtangn17TiQaDccVrZbn6sZwJOtzBgg3idp68cA=
github.com/oneclickvirt/portchecker v0.0.1-20240624155429 h1:+wapaOcFrg1iWJDhBKThDzppyIMY7hWxK7F5RBkZg4o=
github.com/oneclickvirt/portchecker v0.0.1-20240624155429/go.mod h1:HQxSTrqM8/QFqHMTBZ7S8H9eEO5FkUXU1eb7ZX5Mk+k=
github.com/oneclickvirt/security v0.0.2-20240630142358 h1:yioMtHuW9wbJ7payL8GCPnj1ScEqNoqbNHt3+4Z4VAg=
github.com/oneclickvirt/security v0.0.2-20240630142358/go.mod h1:cUNNOldoVQuovyc0EtAVAZlAT4y2xA1e0uA80aj1ly8=
github.com/oneclickvirt/security v0.0.3-20240701065755 h1:eHZDuyvzufOu2yDUIMggK2iRtMWJaFlCzG4+leQn5+0=
github.com/oneclickvirt/security v0.0.3-20240701065755/go.mod h1:cUNNOldoVQuovyc0EtAVAZlAT4y2xA1e0uA80aj1ly8=
github.com/oneclickvirt/speedtest v0.0.6-20240630114816 h1:gI2hqV0IwcvGqYzLhlt4w2oZvYhCL+73jftUuJYBsuI=
github.com/oneclickvirt/speedtest v0.0.6-20240630114816/go.mod h1:zd5ZgIGslmtQLQehEfRjyumlvgDHTpCSMchKfKXoASI=
github.com/onsi/ginkgo/v2 v2.19.0 h1:9Cnnf7UHo57Hy3k6/m5k3dRfGTMXGvxhHFvkDTCTpvA=

View File

@@ -18,15 +18,18 @@ import (
gostunmodel "github.com/oneclickvirt/gostun/model"
"github.com/oneclickvirt/portchecker/email"
speedtestmodel "github.com/oneclickvirt/speedtest/model"
"os"
"os/signal"
"regexp"
"runtime"
"strings"
"sync"
"syscall"
"time"
)
var (
ecsVersion = "2024.07.01.1"
ecsVersion = "v0.0.19"
menuMode bool
input, choice string
showVersion bool
@@ -42,6 +45,8 @@ var (
basicStatus, cpuTestStatus, memoryTestStatus, diskTestStatus bool
commTestStatus, utTestStatus, securityTestStatus, emailTestStatus bool
backtraceStatus, nt3Status, speedTestStatus bool
filePath = "goecs.txt"
enabelUpload = true
)
func main() {
@@ -70,6 +75,8 @@ func main() {
flag.IntVar(&spNum, "spnum", 2, "Set the number of servers per operator for speed test")
flag.BoolVar(&enableLogger, "log", false, "Enable/Disable logging in the current path")
flag.Parse()
sig := make(chan os.Signal, 1)
signal.Notify(sig, os.Interrupt, syscall.SIGINT, syscall.SIGTERM)
if showVersion {
fmt.Println(ecsVersion)
return
@@ -216,6 +223,13 @@ func main() {
basicInfo, securityInfo, emailInfo, mediaInfo string
output, tempOutput string
)
// 启动一个goroutine来等待信号
go func() {
// 等待信号
<-sig
utils.ProcessAndUpload(output, filePath, enabelUpload)
os.Exit(1) // 使用非零状态码退出,表示意外退出
}()
output = utils.PrintAndCapture(func() {
switch language {
case "zh":
@@ -372,6 +386,5 @@ func main() {
fmt.Println("Unsupported language")
}
}, tempOutput, output)
filePath := "goecs.txt"
utils.ProcessAndUpload(output, filePath, true)
utils.ProcessAndUpload(output, filePath, enabelUpload)
}

View File

@@ -61,7 +61,7 @@ goecs_check() {
# 检测原始goecs命令是否存在若存在则升级不存在则安装
version_output=$(goecs -v || ./goecs -v)
if [ $? -eq 0 ]; then
extracted_version=$(echo "$version_output" | grep -oP '^v\d+(\.\d+)+')
extracted_version=$(echo "${version_output//v/}")
if [ -n "$extracted_version" ]; then
current_version=$(echo "$extracted_version" | cut -c 2-)
ecs_version=$ECS_VERSION
@@ -293,14 +293,26 @@ env_check() {
fi
}
delete_goecs() {
rm -rf /root/goecs
rm -rf /usr/bin/goecs
}
show_help() {
cat <<"EOF"
Available commands:
env Check and Install package: dd fio sysbench geekbench5 speedtest
install Install goecs command
upgrade Upgrade goecs command
help Show this message
./goecs.sh env Check and Install package:
dd (Almost all unix-like systems have it, it's only for testing on most systems.)
fio (Almost all unix-like systems can be installed through the system's package manager.)
sysbench (Almost all unix-like systems can be installed through the system's package manager.)
geekbench5 (Only support IPV4 environment, and memory greater than 1GB network detection, only support amd64 and arm64 architecture.)
speedtest (Use the officially provided binaries for more accurate test results.)
In fact, sysbench/geekbench is the only one of the above dependencies that must be installed, without which the CPU score cannot be tested.
./goecs.sh install Install goecs command
./goecs.sh upgrade Upgrade goecs command
./goecs.sh delete Uninstall goecs command
./goecs.sh help Show this message
EOF
}
@@ -315,6 +327,9 @@ case "$1" in
"install" | "upgrade")
goecs_check
;;
"delete")
delete_goecs
;;
*)
echo "No command found."
echo

View File

@@ -24,6 +24,7 @@ REM 提示用户输入版本号
set /p version="Enter the version number (e.g., v1.0.0): "
REM 创建并推送标签
:push_tag
git tag %version%
git push origin %version%
if errorlevel 1 (