From 060bf6e23b599857b61db5c72fc81d53c8f6cd5f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A1=90=E8=AF=9D?= <49544781+xiaomeng9597@users.noreply.github.com> Date: Wed, 3 Jul 2024 11:12:12 +0800 Subject: [PATCH] update ubus-status.sh --- configfiles/ubus-status.sh | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/configfiles/ubus-status.sh b/configfiles/ubus-status.sh index ef2b0af..1add102 100644 --- a/configfiles/ubus-status.sh +++ b/configfiles/ubus-status.sh @@ -1,25 +1,19 @@ #!/bin/sh check_ubus() { - local pidcount=$(pgrep "ubusd" | wc -l) - local pidcount2=$(pgrep "rpcd" | wc -l) - - if [ "$pidcount" -gt 1 ]; then - killall ubusd 2>/dev/null - fi - - if [ "$pidcount2" -gt 2 ] && [ "$pidcount" -eq 1 ]; then + if [ "$(pgrep rpcd | wc -l)" -gt 2 ]; then killall rpcd 2>/dev/null + sleep 1 fi if [ "$(pgrep ubusd | wc -l)" -eq 0 ]; then - sleep 1 /sbin/ubusd & + sleep 1 fi if [ "$(pgrep rpcd | wc -l)" -eq 0 ] && [ "$(pgrep ubusd | wc -l)" -eq 1 ]; then - sleep 1 /sbin/rpcd -s /var/run/ubus/ubus.sock -t 30 & + sleep 1 fi local datetime=$(date +"%Y-%m-%d %H:%M:%S") @@ -40,7 +34,7 @@ check_ubus() { killall rpcd 2>/dev/null sleep 1 /sbin/rpcd -s /var/run/ubus/ubus.sock -t 30 & - elif [ "$(pgrep ubusd | wc -l)" -eq 1 ] && echo "$rpcd_status" | grep -q "running"; then + elif echo "$rpcd_status" | grep -q "running"; then echo "$datetime / Ubus服务正在运行,一切正常。" fi }