mirror of
https://github.com/oneclickvirt/ecs.git
synced 2025-09-28 04:02:12 +08:00
Compare commits
13 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
fb6f9da14c | ||
![]() |
7b1773c5f0 | ||
![]() |
7b15a74448 | ||
![]() |
956f65941e | ||
![]() |
6d1f806e94 | ||
![]() |
d727d6b778 | ||
![]() |
ea891861b3 | ||
![]() |
e0826a80c8 | ||
![]() |
74868a918e | ||
![]() |
889ecee3f3 | ||
![]() |
f6dd0bbb56 | ||
![]() |
01686f3e9d | ||
![]() |
5a6cd7d671 |
@@ -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
|
||||
```
|
4
go.mod
4
go.mod
@@ -7,7 +7,7 @@ require (
|
||||
github.com/oneclickvirt/CommonMediaTests v0.0.2-20240630023003
|
||||
github.com/oneclickvirt/UnlockTests v0.0.10-20240630044930
|
||||
github.com/oneclickvirt/backtrace v0.0.4-20240624090335
|
||||
github.com/oneclickvirt/basics v0.0.3-20240625075226
|
||||
github.com/oneclickvirt/basics v0.0.3-20240701085439
|
||||
github.com/oneclickvirt/cputest v0.0.7-20240701020012
|
||||
github.com/oneclickvirt/defaultset v0.0.2-20240624082446
|
||||
github.com/oneclickvirt/disktest v0.0.3-20240629152513
|
||||
@@ -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
|
||||
)
|
||||
|
||||
|
8
go.sum
8
go.sum
@@ -81,8 +81,8 @@ github.com/oneclickvirt/UnlockTests v0.0.10-20240630044930 h1:/Sc4Eas1Pso18ak93w
|
||||
github.com/oneclickvirt/UnlockTests v0.0.10-20240630044930/go.mod h1:HP3CvAS+AJWxxY+BVbxIOlvaQ87YOSge89vAMG52b5o=
|
||||
github.com/oneclickvirt/backtrace v0.0.4-20240624090335 h1:0LP5KyA6GLlqQAtOF0uyBSAykHJrzOA96Eb87qUhGQw=
|
||||
github.com/oneclickvirt/backtrace v0.0.4-20240624090335/go.mod h1:zvsC7xY/WZqs5KL2JB967OVnuqjNbxu9bW6wXRLo5h8=
|
||||
github.com/oneclickvirt/basics v0.0.3-20240625075226 h1:K9VriCHIYnXPZXBSn9PRQX+jBS6AIFH8tBVb/i8VGAw=
|
||||
github.com/oneclickvirt/basics v0.0.3-20240625075226/go.mod h1:dTB+/oyFQYfTYX55rFJVWatum5F9g62zjfmHCM6Vj1s=
|
||||
github.com/oneclickvirt/basics v0.0.3-20240701085439 h1:1PE7Womqy4AW2c9PlyFdHsBocZXSo02V5uJDSzQLzgs=
|
||||
github.com/oneclickvirt/basics v0.0.3-20240701085439/go.mod h1:dTB+/oyFQYfTYX55rFJVWatum5F9g62zjfmHCM6Vj1s=
|
||||
github.com/oneclickvirt/cputest v0.0.7-20240701020012 h1:U5cCI+6ZU3pudoAlmb1b3yB9IQNm5AnDXi1TQAZJCIA=
|
||||
github.com/oneclickvirt/cputest v0.0.7-20240701020012/go.mod h1:MmaHN9+XMntI3rLycwj8Ne31fG18IfNoa8N2utDK1CY=
|
||||
github.com/oneclickvirt/defaultset v0.0.2-20240624082446 h1:5Pg3mK/u/vQvSz7anu0nxzrNdELi/AcDAU1mMsmPzyc=
|
||||
@@ -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=
|
||||
|
54
goecs.go
54
goecs.go
@@ -1,7 +1,7 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"flag"
|
||||
ecsFlag "flag"
|
||||
"fmt"
|
||||
"github.com/oneclickvirt/CommonMediaTests/commediatests"
|
||||
backtraceori "github.com/oneclickvirt/backtrace/bk"
|
||||
@@ -29,7 +29,7 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
ecsVersion = "v0.0.19"
|
||||
ecsVersion = "v0.0.21"
|
||||
menuMode bool
|
||||
input, choice string
|
||||
showVersion bool
|
||||
@@ -50,31 +50,31 @@ var (
|
||||
)
|
||||
|
||||
func main() {
|
||||
flag.BoolVar(&showVersion, "v", false, "Display version information")
|
||||
flag.BoolVar(&menuMode, "menu", true, "Enable/Disable menu mode, disable example: -menu=false") // true 默认启用菜单栏模式
|
||||
flag.StringVar(&language, "l", "zh", "Set language (supported: en, zh)")
|
||||
flag.BoolVar(&basicStatus, "basic", true, "Enable/Disable basic test")
|
||||
flag.BoolVar(&cpuTestStatus, "cpu", true, "Enable/Disable CPU test")
|
||||
flag.BoolVar(&memoryTestStatus, "memory", true, "Enable/Disable memory test")
|
||||
flag.BoolVar(&diskTestStatus, "disk", true, "Enable/Disable disk test")
|
||||
flag.BoolVar(&commTestStatus, "comm", true, "Enable/Disable common media test")
|
||||
flag.BoolVar(&utTestStatus, "ut", true, "Enable/Disable unlock media test")
|
||||
flag.BoolVar(&securityTestStatus, "security", true, "Enable/Disable security test")
|
||||
flag.BoolVar(&emailTestStatus, "email", true, "Enable/Disable email port test")
|
||||
flag.BoolVar(&backtraceStatus, "backtrace", true, "Enable/Disable backtrace test (in 'en' language or on `windows` it always false)")
|
||||
flag.BoolVar(&nt3Status, "nt3", true, "Enable/Disable NT3 test (in 'en' language or on `windows` it always false)")
|
||||
flag.BoolVar(&speedTestStatus, "speed", true, "Enable/Disable speed test")
|
||||
flag.StringVar(&cpuTestMethod, "cpum", "sysbench", "Set CPU test method (supported: sysbench, geekbench, winsat)")
|
||||
flag.StringVar(&cpuTestThreadMode, "cput", "multi", "Set CPU test thread mode (supported: single, multi)")
|
||||
flag.StringVar(&memoryTestMethod, "memorym", "dd", "Set memory test method (supported: sysbench, dd, winsat)")
|
||||
flag.StringVar(&diskTestMethod, "diskm", "fio", "Set disk test method (supported: fio, dd, winsat)")
|
||||
flag.StringVar(&diskTestPath, "diskp", "", "Set disk test path, e.g., -diskp /root")
|
||||
flag.BoolVar(&diskMultiCheck, "diskmc", false, "Enable/Disable multiple disk checks, e.g., -diskmc=false")
|
||||
flag.StringVar(&nt3Location, "nt3loc", "GZ", "Specify NT3 test location (supported: GZ, SH, BJ, CD for Guangzhou, Shanghai, Beijing, Chengdu)")
|
||||
flag.StringVar(&nt3CheckType, "nt3t", "ipv4", "Set NT3 test type (supported: both, ipv4, ipv6)")
|
||||
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()
|
||||
ecsFlag.BoolVar(&showVersion, "v", false, "Display version information")
|
||||
ecsFlag.BoolVar(&menuMode, "menu", true, "Enable/Disable menu mode, disable example: -menu=false") // true 默认启用菜单栏模式
|
||||
ecsFlag.StringVar(&language, "l", "zh", "Set language (supported: en, zh)")
|
||||
ecsFlag.BoolVar(&basicStatus, "basic", true, "Enable/Disable basic test")
|
||||
ecsFlag.BoolVar(&cpuTestStatus, "cpu", true, "Enable/Disable CPU test")
|
||||
ecsFlag.BoolVar(&memoryTestStatus, "memory", true, "Enable/Disable memory test")
|
||||
ecsFlag.BoolVar(&diskTestStatus, "disk", true, "Enable/Disable disk test")
|
||||
ecsFlag.BoolVar(&commTestStatus, "comm", true, "Enable/Disable common media test")
|
||||
ecsFlag.BoolVar(&utTestStatus, "ut", true, "Enable/Disable unlock media test")
|
||||
ecsFlag.BoolVar(&securityTestStatus, "security", true, "Enable/Disable security test")
|
||||
ecsFlag.BoolVar(&emailTestStatus, "email", true, "Enable/Disable email port test")
|
||||
ecsFlag.BoolVar(&backtraceStatus, "backtrace", true, "Enable/Disable backtrace test (in 'en' language or on `windows` it always false)")
|
||||
ecsFlag.BoolVar(&nt3Status, "nt3", true, "Enable/Disable NT3 test (in 'en' language or on `windows` it always false)")
|
||||
ecsFlag.BoolVar(&speedTestStatus, "speed", true, "Enable/Disable speed test")
|
||||
ecsFlag.StringVar(&cpuTestMethod, "cpum", "sysbench", "Set CPU test method (supported: sysbench, geekbench, winsat)")
|
||||
ecsFlag.StringVar(&cpuTestThreadMode, "cput", "multi", "Set CPU test thread mode (supported: single, multi)")
|
||||
ecsFlag.StringVar(&memoryTestMethod, "memorym", "dd", "Set memory test method (supported: sysbench, dd, winsat)")
|
||||
ecsFlag.StringVar(&diskTestMethod, "diskm", "fio", "Set disk test method (supported: fio, dd, winsat)")
|
||||
ecsFlag.StringVar(&diskTestPath, "diskp", "", "Set disk test path, e.g., -diskp /root")
|
||||
ecsFlag.BoolVar(&diskMultiCheck, "diskmc", false, "Enable/Disable multiple disk checks, e.g., -diskmc=false")
|
||||
ecsFlag.StringVar(&nt3Location, "nt3loc", "GZ", "Specify NT3 test location (supported: GZ, SH, BJ, CD for Guangzhou, Shanghai, Beijing, Chengdu)")
|
||||
ecsFlag.StringVar(&nt3CheckType, "nt3t", "ipv4", "Set NT3 test type (supported: both, ipv4, ipv6)")
|
||||
ecsFlag.IntVar(&spNum, "spnum", 2, "Set the number of servers per operator for speed test")
|
||||
ecsFlag.BoolVar(&enableLogger, "log", false, "Enable/Disable logging in the current path")
|
||||
ecsFlag.Parse()
|
||||
sig := make(chan os.Signal, 1)
|
||||
signal.Notify(sig, os.Interrupt, syscall.SIGINT, syscall.SIGTERM)
|
||||
if showVersion {
|
||||
|
49
goecs.sh
49
goecs.sh
@@ -59,17 +59,16 @@ goecs_check() {
|
||||
ECS_VERSION=$(curl -m 6 -sSL "https://githubapi.spiritlhl.top/repos/oneclickvirt/ecs/releases/latest" | awk -F \" '/tag_name/{gsub(/^v/,"",$4); print $4}')
|
||||
fi
|
||||
# 检测原始goecs命令是否存在,若存在则升级,不存在则安装
|
||||
version_output=$(goecs -v || ./goecs -v)
|
||||
version_output=$(goecs -v command 2>/dev/null || ./goecs -v command 2>/dev/null)
|
||||
if [ $? -eq 0 ]; then
|
||||
extracted_version=$(echo "${version_output//v/}")
|
||||
if [ -n "$extracted_version" ]; then
|
||||
current_version=$(echo "$extracted_version" | cut -c 2-)
|
||||
ecs_version=$ECS_VERSION
|
||||
if [[ "$(echo -e "$current_version\n$ecs_version" | sort -V | tail -n 1)" == "$current_version" ]]; then
|
||||
echo "goecs version ($current_version) is latest, no need to upgrade."
|
||||
if [[ "$(echo -e "$extracted_version\n$ecs_version" | sort -V | tail -n 1)" == "$extracted_version" ]]; then
|
||||
echo "goecs version ($extracted_version) is latest, no need to upgrade."
|
||||
return
|
||||
else
|
||||
echo "goecs version ($current_version) < $ecs_version, need to upgrade, 5 seconds later will start to upgrade"
|
||||
echo "goecs version ($extracted_version) < $ecs_version, need to upgrade, 5 seconds later will start to upgrade"
|
||||
rm -rf /usr/bin/goecs
|
||||
rm -rf goecs
|
||||
fi
|
||||
@@ -163,7 +162,7 @@ InstallSysbench() {
|
||||
arch) pacman -S --needed --noconfirm sysbench && pacman -S --needed --noconfirm libaio && ldconfig ;;
|
||||
freebsd) pkg install -y sysbench ;;
|
||||
alpinelinux) echo -e "${Msg_Warning}Sysbench Module not found, installing ..." && echo -e "${Msg_Warning}SysBench Current not support Alpine Linux, Skipping..." && Var_Skip_SysBench="1" ;;
|
||||
*) echo "Error: Unknown OS release: $os_release" && exit 1 ;;
|
||||
*) echo "Error: Unknown OS release: $os_release" ;;
|
||||
esac
|
||||
}
|
||||
|
||||
@@ -230,7 +229,7 @@ prepare_compile_env() {
|
||||
env_check() {
|
||||
REGEX=("debian|astra" "ubuntu" "centos|red hat|kernel|oracle linux|alma|rocky" "'amazon linux'" "fedora" "arch" "freebsd" "alpine" "openbsd")
|
||||
RELEASE=("Debian" "Ubuntu" "CentOS" "CentOS" "Fedora" "Arch" "FreeBSD" "Alpine" "OpenBSD")
|
||||
PACKAGE_UPDATE=("! apt-get update && apt-get --fix-broken install -y && apt-get update" "apt-get update" "yum -y update" "yum -y update" "yum -y update" "pacman -Sy" "pkg update" "apk update" "pkg_add -u")
|
||||
PACKAGE_UPDATE=("apt-get update" "apt-get update" "yum -y update" "yum -y update" "yum -y update" "pacman -Sy" "pkg update" "apk update" "pkg_add -u")
|
||||
PACKAGE_INSTALL=("apt-get -y install" "apt-get -y install" "yum -y install" "yum -y install" "yum -y install" "pacman -Sy --noconfirm --needed" "pkg install -y" "apk add")
|
||||
PACKAGE_REMOVE=("apt-get -y remove" "apt-get -y remove" "yum -y remove" "yum -y remove" "yum -y remove" "pacman -Rsc --noconfirm" "pkg delete" "apk del")
|
||||
PACKAGE_UNINSTALL=("apt-get -y autoremove" "apt-get -y autoremove" "yum -y autoremove" "yum -y autoremove" "yum -y autoremove" "" "pkg autoremove" "apk autoremove")
|
||||
@@ -245,6 +244,16 @@ env_check() {
|
||||
done
|
||||
cdn_urls=("https://cdn0.spiritlhl.top/" "http://cdn3.spiritlhl.net/" "http://cdn1.spiritlhl.net/" "http://cdn2.spiritlhl.net/")
|
||||
check_cdn_file
|
||||
_green "Update system manager."
|
||||
$PACKAGE_UPDATE command 2>/dev/null
|
||||
if ! command -v tar >/dev/null 2>&1; then
|
||||
_green "Installing tar"
|
||||
$PACKAGE_INSTALL tar
|
||||
fi
|
||||
if ! command -v unzip >/dev/null 2>&1; then
|
||||
_green "Installing unzip"
|
||||
$PACKAGE_INSTALL unzip
|
||||
fi
|
||||
if ! command -v dd >/dev/null 2>&1; then
|
||||
_green "Installing dd"
|
||||
$PACKAGE_INSTALL dd
|
||||
@@ -291,16 +300,31 @@ env_check() {
|
||||
echo "rm -rf /usr/bin/speedtest-go"
|
||||
_blue "to uninstall speedtest and speedtest-go"
|
||||
fi
|
||||
_green "The environment is ready."
|
||||
}
|
||||
|
||||
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:
|
||||
tar (Almost all unix-like systems have it.)
|
||||
unzip (Almost all unix-like systems have it.)
|
||||
dd (Almost all unix-like systems have it.)
|
||||
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.)
|
||||
geekbench (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 +339,9 @@ case "$1" in
|
||||
"install" | "upgrade")
|
||||
goecs_check
|
||||
;;
|
||||
"delete")
|
||||
delete_goecs
|
||||
;;
|
||||
*)
|
||||
echo "No command found."
|
||||
echo
|
||||
|
@@ -215,16 +215,16 @@ func ProcessAndUpload(output string, filePath string, enableUplaod bool) {
|
||||
}
|
||||
if enableUplaod {
|
||||
// 获取文件的绝对路径
|
||||
absPath, err := filepath.Abs(filePath)
|
||||
if err != nil {
|
||||
fmt.Println("Failed to get absolute file path:", err)
|
||||
absPath, err2 := filepath.Abs(filePath)
|
||||
if err2 != nil {
|
||||
fmt.Println("Failed to get absolute file path:", err2)
|
||||
return
|
||||
}
|
||||
// 上传文件并生成短链接
|
||||
shorturl, err := UploadText(absPath)
|
||||
if err != nil {
|
||||
shorturl, err3 := UploadText(absPath)
|
||||
if err3 != nil {
|
||||
fmt.Println("Upload failed, cannot generate short URL.")
|
||||
fmt.Println(err.Error())
|
||||
fmt.Println(err3.Error())
|
||||
return
|
||||
}
|
||||
fmt.Println("Upload successful, short URL:", shorturl)
|
||||
|
Reference in New Issue
Block a user