update ubus-status.sh

This commit is contained in:
桐话
2024-06-25 00:05:14 +08:00
committed by GitHub
parent 3f2cbdba05
commit a4136fb73f
+6 -5
View File
@@ -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