From dbc4463c0ef10d21f1bbadb2c99e7e6ac60ce645 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A1=90=E8=AF=9D?= <49544781+xiaomeng9597@users.noreply.github.com> Date: Sat, 29 Jun 2024 16:11:12 +0800 Subject: [PATCH] update ubus-status.sh --- configfiles/ubus-status.sh | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/configfiles/ubus-status.sh b/configfiles/ubus-status.sh index e8861c8..a7ac916 100644 --- a/configfiles/ubus-status.sh +++ b/configfiles/ubus-status.sh @@ -1,12 +1,14 @@ #!/bin/sh rpcd_start() { - rpcdstr=$(/sbin/rpcd -s /var/run/ubus/ubus.sock -t 30 &) + rpcdstr=$(/etc/init.d/dbus status 2>&1) if echo "$rpcdstr" | grep -q "Failed" || echo "$rpcdstr" | grep -q "Failed to connect to ubus"; then killall ubusd 2>/dev/null sleep 1 /sbin/ubusd & /sbin/rpcd -s /var/run/ubus/ubus.sock -t 30 & + else + /sbin/rpcd -s /var/run/ubus/ubus.sock -t 30 & fi } @@ -15,11 +17,11 @@ check_ubus() { local pidcount2=$(pgrep "rpcd" | wc -l) if [ "$pidcount" -gt 1 ]; then - killall ubusd + killall ubusd 2>/dev/null fi if [ "$pidcount2" -gt 2 ] && [ "$pidcount" -eq 1 ]; then - killall rpcd + killall rpcd 2>/dev/null fi if [ "$(pgrep ubusd | wc -l)" -eq 0 ]; then @@ -40,14 +42,14 @@ check_ubus() { rpcd_start elif [[ "$status_code" == 500 || "$status_code" == 502 ]] && echo "$dbus_status" | grep -q "running"; then echo "$datetime / Ubus服务异常,正在重启Ubus。" - killall rpcd + killall rpcd 2>/dev/null sleep 1 rpcd_start elif echo "$dbus_status" | grep -q "running"; then echo "$datetime / Ubus服务正在运行,一切正常。" else echo "$datetime / Ubus服务异常,正在重启Ubus。" - killall rpcd + killall rpcd 2>/dev/null sleep 1 rpcd_start fi