- local state = false
-
- for _, host in ipairs(PINGTRG) do
- state = state or (sys.call(PINGCMD % {droute.device, host}) == 0)
- end
-
- if not state and (not STRICT or tonumber(droute.metric) == 0) then
- local count = tonumber(uci:get("olsrd", section, "noinet_count"))
- if not THRESHOLD or (count and count > THRESHOLD) then
- sys.call(ROUTECMD % droute.gateway:string())
- else
- uci:set("olsrd", section, "noinet_count", (count or 0) + 1)
- end
- else
- uci:set("olsrd", section, "noinet_count", "0")
- end
- uci:save("olsrd")
-end
\ No newline at end of file
+ local state = false
+
+ for _, host in ipairs(PINGTRG) do
+ state = state or (sys.call(PINGCMD % {droute.device, host}) == 0)
+ end
+
+ if not state and (not STRICT or tonumber(droute.metric) == 0) then
+ local count = tonumber(uci:get("olsrd", ucisec, "noinet_count"))
+ if not THRESHOLD or (count and count >= THRESHOLD) then
+ sys.call(ROUTECMD % droute.gateway:string())
+ else
+ if not count then
+ uci:set("olsrd", ucisec, "state")
+ end
+ uci:set("olsrd", ucisec, "noinet_count", (count or 0) + 1)
+ uci:save("olsrd")
+ end
+ else
+ uci:revert("olsrd", ucisec)
+ end
+end