Fix ff_olsr_test_gw

This commit is contained in:
Steven Barth 2009-01-31 16:28:34 +00:00
parent 56f5204e8f
commit ce2da9198b
2 changed files with 31 additions and 27 deletions

View file

@ -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 ] && {

View file

@ -7,6 +7,7 @@ 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)
@ -24,14 +25,17 @@ if section and droute then -- dyn_gw is enabled and we have a defaultroute,
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
uci:set("olsrd", section, "noinet_count", "0")
end end
uci:set("olsrd", ucisec, "noinet_count", (count or 0) + 1)
uci:save("olsrd") uci:save("olsrd")
end end
else
uci:revert("olsrd", ucisec)
end
end