From 22c9eb7611ab61b0899f253bc2fb7b61efe874e9 Mon Sep 17 00:00:00 2001 From: spiritlhl <103393591+spiritLHLS@users.noreply.github.com> Date: Mon, 2 Mar 2026 09:37:59 +0000 Subject: [PATCH] =?UTF-8?q?fix=EF=BC=9A=E6=9D=83=E9=99=90=E4=B8=8D?= =?UTF-8?q?=E8=B6=B3=E6=97=B6=E8=87=AA=E5=8A=A8=E9=99=8D=E7=BA=A7=E5=A4=84?= =?UTF-8?q?=E7=90=86=E6=8F=90=E7=A4=BA=E4=BD=BF=E7=94=A8=E6=96=B9=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README_EN.md | 2 +- goecs.sh | 31 ++++++++++++++++++++----------- 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/README_EN.md b/README_EN.md index 56c1084..cb2e355 100644 --- a/README_EN.md +++ b/README_EN.md @@ -45,7 +45,7 @@ Shell version: [https://github.com/spiritLHLS/ecs/blob/main/README_EN.md](https: | OS | Notes | |--------|-------------------------------------------------------------------------------------------------| -| OpenBSD/NetBSD | Some of Goalng's official libraries do not support this system (especially net-related items) | +| OpenBSD/NetBSD | Some of Golang's official libraries do not support this system (especially net-related items) | --- diff --git a/goecs.sh b/goecs.sh index 632b774..79aa267 100644 --- a/goecs.sh +++ b/goecs.sh @@ -260,29 +260,38 @@ goecs_check() { fi rm -f goecs.zip README.md LICENSE README_EN.md chmod 777 goecs + installed_to_system=false for install_path in "/usr/bin" "/usr/local/bin"; do if [ -d "$install_path" ]; then - cp -f goecs "$install_path/" - break + if cp -f goecs "$install_path/" 2>/dev/null; then + installed_to_system=true + break + fi fi done + if [ "$installed_to_system" = "false" ]; then + _yellow "权限不足,无法安装到系统路径,goecs 已保留在当前目录下" + _yellow "Insufficient permissions to install to system path, goecs is kept in the current directory" + _yellow "请使用以下命令运行: ./goecs" + _yellow "Please use the following command to run: ./goecs" + fi if [ "$os" != "Darwin" ]; then PARAM="net.ipv4.ping_group_range" NEW_VALUE="0 2147483647" if [ -f /etc/sysctl.conf ]; then - if grep -q "^$PARAM" /etc/sysctl.conf; then - sed -i "s/^$PARAM.*/$PARAM = $NEW_VALUE/" /etc/sysctl.conf + if grep -q "^$PARAM" /etc/sysctl.conf 2>/dev/null; then + sed -i "s/^$PARAM.*/$PARAM = $NEW_VALUE/" /etc/sysctl.conf 2>/dev/null || true else - echo "$PARAM = $NEW_VALUE" >> /etc/sysctl.conf + echo "$PARAM = $NEW_VALUE" >> /etc/sysctl.conf 2>/dev/null || true fi - sysctl -p >/dev/null 2>&1 + sysctl -p >/dev/null 2>&1 || true fi fi - setcap cap_net_raw=+ep goecs 2>/dev/null - setcap cap_net_raw=+ep /usr/bin/goecs 2>/dev/null - setcap cap_net_raw=+ep /usr/local/bin/goecs 2>/dev/null - _green "goecs installation complete, current version:" - goecs -v || ./goecs -v + setcap cap_net_raw=+ep goecs 2>/dev/null || true + setcap cap_net_raw=+ep /usr/bin/goecs 2>/dev/null || true + setcap cap_net_raw=+ep /usr/local/bin/goecs 2>/dev/null || true + _green "goecs 安装完成 / goecs installation complete, 当前版本 / current version:" + goecs -v 2>/dev/null || ./goecs -v } InstallSysbench() {