From 49b8d73b8a717ff0a1a9a6003bcc648b40fa1e22 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, 15 Jun 2024 14:32:13 +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 3052eea..c7df20f 100644 --- a/configfiles/ubus-status.sh +++ b/configfiles/ubus-status.sh @@ -4,19 +4,21 @@ while true do dbus_status=$(/etc/init.d/dbus status) status_code=$(curl -o /dev/null -s -w "%{http_code}\n" http://127.0.0.1/cgi-bin/luci/ 2>/dev/null) - page_content=$(curl -s http://127.0.0.1/cgi-bin/luci/ 2>/dev/null) - datetime=$(date +"%Y-%m-%d %H:%M:%S") - pidv=$(pgrep "ubusd" | head -n 1) - pidv2=$(pgrep "rpcd" | head -n 1) - if [ -z "$status_code" ]; then status_code="ERROR" fi + if [[ "$status_code" == 500 || "$status_code" == 502 ]]; then + page_content=$(curl -s http://127.0.0.1/cgi-bin/luci/ 2>/dev/null) + fi if [ -z "$page_content" ]; then page_content="ERROR" fi + datetime=$(date +"%Y-%m-%d %H:%M:%S") + pidv=$(pgrep "ubusd" | head -n 1) + pidv2=$(pgrep "rpcd" | head -n 1) + if [ -z "$pidv" ]; then echo "$datetime / Ubus服务异常,正在重启Ubus。" /sbin/ubusd &