Fix ff_olsr_test_gw
This commit is contained in:
parent
56f5204e8f
commit
ce2da9198b
2 changed files with 31 additions and 27 deletions
|
@ -9,9 +9,9 @@ boot() {
|
||||||
echo "*/5 * * * * killall -HUP dnsmasq" >> /etc/crontabs/root
|
echo "*/5 * * * * killall -HUP dnsmasq" >> /etc/crontabs/root
|
||||||
}
|
}
|
||||||
|
|
||||||
# grep -q '/usr/sbin/ff_olsr_test_gw' /etc/crontabs/root || {
|
grep -q '/usr/sbin/ff_olsr_test_gw' /etc/crontabs/root || {
|
||||||
# echo "* * * * * /usr/sbin/ff_olsr_test_gw" >> /etc/crontabs/root
|
echo "* * * * * /usr/sbin/ff_olsr_test_gw" >> /etc/crontabs/root
|
||||||
# }
|
}
|
||||||
|
|
||||||
[ -f /etc/rc.local ] && . /etc/rc.local
|
[ -f /etc/rc.local ] && . /etc/rc.local
|
||||||
[ -d /etc/rc.local.d ] && {
|
[ -d /etc/rc.local.d ] && {
|
||||||
|
|
|
@ -7,31 +7,35 @@ local THRESHOLD = 3 -- Maximum number of failed tests before dropping the route
|
||||||
|
|
||||||
local sys = require "luci.sys"
|
local sys = require "luci.sys"
|
||||||
local uci = require "luci.model.uci".cursor_state()
|
local uci = require "luci.model.uci".cursor_state()
|
||||||
|
local ucisec = "ff_olsr_test_gw"
|
||||||
local section = nil
|
local section = nil
|
||||||
|
|
||||||
uci:foreach("olsrd", "LoadPlugin", function(s)
|
uci:foreach("olsrd", "LoadPlugin", function(s)
|
||||||
if s.library == "olsrd_dyn_gw_plain.so.0.4" and s.ignore ~= "1" then
|
if s.library == "olsrd_dyn_gw_plain.so.0.4" and s.ignore ~= "1" then
|
||||||
section = s[".name"]
|
section = s[".name"]
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
local droute = sys.net.defaultroute()
|
local droute = sys.net.defaultroute()
|
||||||
if section and droute then -- dyn_gw is enabled and we have a defaultroute, test it
|
if section and droute then -- dyn_gw is enabled and we have a defaultroute, test it
|
||||||
local state = false
|
local state = false
|
||||||
|
|
||||||
for _, host in ipairs(PINGTRG) do
|
for _, host in ipairs(PINGTRG) do
|
||||||
state = state or (sys.call(PINGCMD % {droute.device, host}) == 0)
|
state = state or (sys.call(PINGCMD % {droute.device, host}) == 0)
|
||||||
end
|
end
|
||||||
|
|
||||||
if not state and (not STRICT or tonumber(droute.metric) == 0) then
|
if not state and (not STRICT or tonumber(droute.metric) == 0) then
|
||||||
local count = tonumber(uci:get("olsrd", section, "noinet_count"))
|
local count = tonumber(uci:get("olsrd", ucisec, "noinet_count"))
|
||||||
if not THRESHOLD or (count and count > THRESHOLD) then
|
if not THRESHOLD or (count and count >= THRESHOLD) then
|
||||||
sys.call(ROUTECMD % droute.gateway:string())
|
sys.call(ROUTECMD % droute.gateway:string())
|
||||||
else
|
else
|
||||||
uci:set("olsrd", section, "noinet_count", (count or 0) + 1)
|
if not count then
|
||||||
end
|
uci:set("olsrd", ucisec, "state")
|
||||||
else
|
end
|
||||||
uci:set("olsrd", section, "noinet_count", "0")
|
uci:set("olsrd", ucisec, "noinet_count", (count or 0) + 1)
|
||||||
end
|
uci:save("olsrd")
|
||||||
uci:save("olsrd")
|
end
|
||||||
|
else
|
||||||
|
uci:revert("olsrd", ucisec)
|
||||||
|
end
|
||||||
end
|
end
|
Loading…
Reference in a new issue