mirror of
https://github.com/oneclickvirt/ecs.git
synced 2025-09-28 04:02:12 +08:00
Compare commits
1 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
35e183b640 |
19
goecs.go
19
goecs.go
@@ -18,15 +18,18 @@ import (
|
|||||||
gostunmodel "github.com/oneclickvirt/gostun/model"
|
gostunmodel "github.com/oneclickvirt/gostun/model"
|
||||||
"github.com/oneclickvirt/portchecker/email"
|
"github.com/oneclickvirt/portchecker/email"
|
||||||
speedtestmodel "github.com/oneclickvirt/speedtest/model"
|
speedtestmodel "github.com/oneclickvirt/speedtest/model"
|
||||||
|
"os"
|
||||||
|
"os/signal"
|
||||||
"regexp"
|
"regexp"
|
||||||
"runtime"
|
"runtime"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
|
"syscall"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
ecsVersion = "2024.07.01.1"
|
ecsVersion = "v0.0.19"
|
||||||
menuMode bool
|
menuMode bool
|
||||||
input, choice string
|
input, choice string
|
||||||
showVersion bool
|
showVersion bool
|
||||||
@@ -42,6 +45,8 @@ var (
|
|||||||
basicStatus, cpuTestStatus, memoryTestStatus, diskTestStatus bool
|
basicStatus, cpuTestStatus, memoryTestStatus, diskTestStatus bool
|
||||||
commTestStatus, utTestStatus, securityTestStatus, emailTestStatus bool
|
commTestStatus, utTestStatus, securityTestStatus, emailTestStatus bool
|
||||||
backtraceStatus, nt3Status, speedTestStatus bool
|
backtraceStatus, nt3Status, speedTestStatus bool
|
||||||
|
filePath = "goecs.txt"
|
||||||
|
enabelUpload = true
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
@@ -70,6 +75,8 @@ func main() {
|
|||||||
flag.IntVar(&spNum, "spnum", 2, "Set the number of servers per operator for speed test")
|
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.BoolVar(&enableLogger, "log", false, "Enable/Disable logging in the current path")
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
sig := make(chan os.Signal, 1)
|
||||||
|
signal.Notify(sig, os.Interrupt, syscall.SIGINT, syscall.SIGTERM)
|
||||||
if showVersion {
|
if showVersion {
|
||||||
fmt.Println(ecsVersion)
|
fmt.Println(ecsVersion)
|
||||||
return
|
return
|
||||||
@@ -216,6 +223,13 @@ func main() {
|
|||||||
basicInfo, securityInfo, emailInfo, mediaInfo string
|
basicInfo, securityInfo, emailInfo, mediaInfo string
|
||||||
output, tempOutput string
|
output, tempOutput string
|
||||||
)
|
)
|
||||||
|
// 启动一个goroutine来等待信号
|
||||||
|
go func() {
|
||||||
|
// 等待信号
|
||||||
|
<-sig
|
||||||
|
utils.ProcessAndUpload(output, filePath, enabelUpload)
|
||||||
|
os.Exit(1) // 使用非零状态码退出,表示意外退出
|
||||||
|
}()
|
||||||
output = utils.PrintAndCapture(func() {
|
output = utils.PrintAndCapture(func() {
|
||||||
switch language {
|
switch language {
|
||||||
case "zh":
|
case "zh":
|
||||||
@@ -372,6 +386,5 @@ func main() {
|
|||||||
fmt.Println("Unsupported language")
|
fmt.Println("Unsupported language")
|
||||||
}
|
}
|
||||||
}, tempOutput, output)
|
}, tempOutput, output)
|
||||||
filePath := "goecs.txt"
|
utils.ProcessAndUpload(output, filePath, enabelUpload)
|
||||||
utils.ProcessAndUpload(output, filePath, true)
|
|
||||||
}
|
}
|
||||||
|
2
goecs.sh
2
goecs.sh
@@ -61,7 +61,7 @@ goecs_check() {
|
|||||||
# 检测原始goecs命令是否存在,若存在则升级,不存在则安装
|
# 检测原始goecs命令是否存在,若存在则升级,不存在则安装
|
||||||
version_output=$(goecs -v || ./goecs -v)
|
version_output=$(goecs -v || ./goecs -v)
|
||||||
if [ $? -eq 0 ]; then
|
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
|
if [ -n "$extracted_version" ]; then
|
||||||
current_version=$(echo "$extracted_version" | cut -c 2-)
|
current_version=$(echo "$extracted_version" | cut -c 2-)
|
||||||
ecs_version=$ECS_VERSION
|
ecs_version=$ECS_VERSION
|
||||||
|
Reference in New Issue
Block a user