From 791d615a167ebd746f2baab2bc752f396c76395a Mon Sep 17 00:00:00 2001 From: mack-a <57424792+mack-a@users.noreply.github.com> Date: Thu, 14 Jan 2021 17:43:24 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E8=84=9A=E6=9C=AC):=20=E4=BF=AE=E6=94=B9ha?= =?UTF-8?q?ndle=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- install.sh | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/install.sh b/install.sh index c5dd6f7..70a9b7f 100644 --- a/install.sh +++ b/install.sh @@ -307,7 +307,6 @@ installTools() { elif [[ "${centosVersion}" == "8" ]]; then nginxEpel="http://nginx.org/packages/centos/8/x86_64/RPMS/nginx-1.18.0-1.el8.ngx.x86_64.rpm" policyCoreUtils="policycoreutils-python-utils-2.9-9.el8.noarch" - # rpm -ivh ${nginxEpel} > /etc/v2ray-agent/error.log 2>&1 fi # yum-utils @@ -325,8 +324,8 @@ installTools() { dpkg --configure -a fi - if ps -ef | grep -q apt; then - ps -ef | grep -v grep | grep apt | awk '{print $2}' | xargs kill -9 + if pgrep -f apt; then + pgrep -f apt | xargs kill -9 fi echoContent green " ---> 检查、安装更新【新机器会很慢,耐心等待】" @@ -1246,7 +1245,7 @@ EOF # 操作V2Ray handleV2Ray() { # shellcheck disable=SC2010 - if find /bin /usr/bin | grep -q systemctl && ls /etc/systemd/system/*v2ray* | grep -q v2ray.service; then + if find /bin /usr/bin | grep -q systemctl && ls /etc/systemd/system/ | grep -q v2ray.service; then if [[ -z "$(pgrep -f v2ray/v2ray)" ]] && [[ "$1" == "start" ]]; then systemctl start v2ray.service elif [[ -z "$(pgrep -f v2ray/v2ray)" ]] && [[ "$1" == "stop" ]]; then @@ -1264,7 +1263,7 @@ handleV2Ray() { exit 0 fi elif [[ "$1" == "stop" ]]; then - if ! ps -ef | grep -q "v2ray/v2ray"; then + if ! pgrep -f "v2ray/v2ray"; then echoContent green " ---> V2Ray关闭成功" else echoContent red "V2Ray关闭失败" @@ -1286,7 +1285,7 @@ handleXray() { sleep 0.5 if [[ "$1" == "start" ]]; then - if ps -ef | grep -q "xray/xray"; then + if pgrep -f "xray/xray"; then echoContent green " ---> Xray启动成功" else echoContent red "xray启动失败" @@ -1294,7 +1293,7 @@ handleXray() { exit 0 fi elif [[ "$1" == "stop" ]]; then - if ps -ef | !grep -q "xray/xray"; then + if ! pgrep -f "xray/xray"; then echoContent green " ---> Xray关闭成功" else echoContent red "xray关闭失败"