aboutsummaryrefslogtreecommitdiff
path: root/net
diff options
context:
space:
mode:
authorFlorian Eckert <fe@dev.tdt.de>2020-01-23 10:24:19 +0100
committerFlorian Eckert <fe@dev.tdt.de>2020-06-17 13:01:49 +0200
commite30f16beef36259c30223fc9986120f176f404ce (patch)
tree79fda9412125fd574bf2d3f95b0886babcccc00b /net
parenta6dc75428c1e3a47700b5c164a16385b5c640b48 (diff)
mwan3: set status to unknown in rpcd if status file not found
If the status file is not found then set then return the value unknown. Signed-off-by: Florian Eckert <fe@dev.tdt.de>
Diffstat (limited to 'net')
-rwxr-xr-xnet/mwan3/files/usr/libexec/rpcd/mwan310
1 files changed, 8 insertions, 2 deletions
diff --git a/net/mwan3/files/usr/libexec/rpcd/mwan3 b/net/mwan3/files/usr/libexec/rpcd/mwan3
index b8b55212a..33e3e0284 100755
--- a/net/mwan3/files/usr/libexec/rpcd/mwan3
+++ b/net/mwan3/files/usr/libexec/rpcd/mwan3
@@ -77,7 +77,7 @@ get_mwan3_status() {
local online=0
local offline=0
local up="0"
- local enabled pid device time_p time_n time_u time_d
+ local enabled pid device time_p time_n time_u time_d status
network_get_device device $1
@@ -111,6 +111,12 @@ get_mwan3_status() {
network_get_uptime uptime "$iface"
network_is_up "$iface" && up="1"
+ if [ -f "$MWAN3TRACK_STATUS_DIR/${iface}/STATUS" ]; then
+ status="$(cat "$MWAN3TRACK_STATUS_DIR/${iface}/STATUS")"
+ else
+ status="unknown"
+ fi
+
json_add_object "${iface}"
json_add_int age "$age"
json_add_int online "${online}"
@@ -119,7 +125,7 @@ get_mwan3_status() {
json_add_int "score" "$(cat "$MWAN3TRACK_STATUS_DIR/${iface}/SCORE")"
json_add_int "lost" "$(cat "$MWAN3TRACK_STATUS_DIR/${iface}/LOST")"
json_add_int "turn" "$(cat "$MWAN3TRACK_STATUS_DIR/${iface}/TURN")"
- json_add_string "status" "$(cat "$MWAN3TRACK_STATUS_DIR/${iface}/STATUS")"
+ json_add_string "status" "${status}"
json_add_boolean "enabled" "${enabled}"
json_add_boolean "running" "${running}"
json_add_boolean "up" "${up}"