From a4136fb73f1407fdf83adc3380c500cb9f4948b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A1=90=E8=AF=9D?= <49544781+xiaomeng9597@users.noreply.github.com> Date: Tue, 25 Jun 2024 00:05:14 +0800 Subject: [PATCH] update ubus-status.sh --- configfiles/ubus-status.sh | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/configfiles/ubus-status.sh b/configfiles/ubus-status.sh index 998bc7d..e8415ad 100644 --- a/configfiles/ubus-status.sh +++ b/configfiles/ubus-status.sh @@ -13,13 +13,10 @@ check_ubus() { fi if [ "$(pgrep ubusd | wc -l)" -eq 0 ]; then + sleep 1 /sbin/ubusd & fi - if [ "$(pgrep rpcd | wc -l)" -eq 0 ] && [ "$(pgrep ubusd | wc -l)" -eq 1 ]; then - /sbin/rpcd -s /var/run/ubus/ubus.sock -t 30 & - fi - local datetime=$(date +"%Y-%m-%d %H:%M:%S") local dbus_status=$(/etc/init.d/dbus status 2>&1) local status_code=$(curl -o /dev/null -s -w "%{http_code}\n" http://127.0.0.1/cgi-bin/luci/ 2>/dev/null) @@ -27,7 +24,11 @@ check_ubus() { status_code="ERROR" fi - if [[ "$status_code" == 500 || "$status_code" == 502 ]] && echo "$dbus_status" | grep -q "running"; then + if [ "$(pgrep rpcd | wc -l)" -eq 0 ] && [ "$(pgrep ubusd | wc -l)" -eq 1 ]; then + echo "$datetime / Ubus服务异常,正在重启Ubus。" + sleep 1 + /sbin/rpcd -s /var/run/ubus/ubus.sock -t 30 & + elif [[ "$status_code" == 500 || "$status_code" == 502 ]] && echo "$dbus_status" | grep -q "running"; then echo "$datetime / Ubus服务异常,正在重启Ubus。" killall rpcd sleep 1