diff --git a/go.mod b/go.mod index 2ff9d23c9..23f008918 100644 --- a/go.mod +++ b/go.mod @@ -27,7 +27,6 @@ require ( golang.org/x/sync v0.8.0 golang.org/x/time v0.6.0 google.golang.org/grpc v1.65.0 - gopkg.in/yaml.v3 v3.0.1 modernc.org/sqlite v1.32.0 ) @@ -130,6 +129,7 @@ require ( google.golang.org/genproto/googleapis/rpc v0.0.0-20240528184218-531527333157 // indirect google.golang.org/protobuf v1.34.2 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect + gopkg.in/yaml.v3 v3.0.1 // indirect gvisor.dev/gvisor v0.0.0-20231202080848-1f7806d17489 // indirect howett.net/plist v1.0.1 // indirect lukechampine.com/blake3 v1.3.0 // indirect diff --git a/hack/get-ehco.sh b/hack/get-ehco.sh index c96dc058d..61c71fbc7 100755 --- a/hack/get-ehco.sh +++ b/hack/get-ehco.sh @@ -61,21 +61,46 @@ WantedBy=multi-user.target EOF } -function _check_install_required() { - if [[ -z "$API_OR_CONFIG_PATH" ]]; then - _print_error_msg "Flag for config is required. please use --config to specify the configuration file path or api endpoint." - exit 1 +function _detect_package_manager() { + if command -v apt-get &>/dev/null; then + echo "apt-get" + elif command -v yum &>/dev/null; then + echo "yum" + elif command -v dnf &>/dev/null; then + echo "dnf" + else + echo "未知" fi +} - # check jq and curl - if ! command -v jq &>/dev/null; then - _print_error_msg "jq is required to parse JSON data. please use apt/yum to install jq." +function _install_dependencies() { + local pkg_manager=$(_detect_package_manager) + + case $pkg_manager in + apt-get) + sudo apt-get update + sudo apt-get install -y jq curl + ;; + yum|dnf) + sudo $pkg_manager install -y jq curl + ;; + *) + _print_error_msg "无法检测到支持的包管理器。请手动安装 jq 和 curl。" + exit 1 + ;; + esac +} + +function _check_install_required() { + if [[ -z "$API_OR_CONFIG_PATH" ]]; then + _print_error_msg "需要配置标志。请使用 --config 指定配置文件路径或 API 端点。" exit 1 fi - if ! command -v curl &>/dev/null; then - _print_error_msg "curl is required to download files. please use apt/yum to install curl." - exit 1 + # 检查并安装 jq 和 curl + if ! command -v jq &>/dev/null || ! command -v curl &>/dev/null; then + _print_warning_msg "正在安装必要的依赖项 (jq 和 curl)..." + _install_dependencies fi } @@ -248,7 +273,7 @@ function perform_install() { _download_bin _install_systemd_service - _print_warning_msg "Ehco has been installed." + _print_warning_msg "Ehco 已安装完成。" } function perform_remove() { diff --git a/internal/web/templates/_navbar.html b/internal/web/templates/_navbar.html index 4aa2aa573..693edbfef 100644 --- a/internal/web/templates/_navbar.html +++ b/internal/web/templates/_navbar.html @@ -20,7 +20,7 @@