6 local fs = require "nixio.fs"
8 if fs.access("/var/run/olsrd.pid") or fs.access("/var/run/olsrd4.pid") then
10 local x = uci.cursor()
12 x:foreach("olsrd", "LoadPlugin",
14 if s.library == "olsrd_watchdog" then
15 intv = tonumber(s.interval)
20 if intv and fs.access(stamp) then
21 local systime = os.time()
22 local wdgtime = tonumber(io.lines(stamp)())
24 if not wdgtime or ( systime - wdgtime ) > ( intv * 2 ) then
25 os.execute("logger -t 'OLSR watchdog' 'Process died - restarting!'")
26 local tnls = io.popen("ip tunnel show | cut -d : -f 1")
28 tnl = tnls:read("*line")
29 if tnl == nil then break end
30 if string.find(tnl, "tnl_") == 1 then
31 os.execute(string.format("logger -t 'OLSR watchdog' 'Deleting stale tunnel %s'", tnl))
32 os.execute(string.format("ip link del %s", tnl))
35 os.execute("/etc/init.d/olsrd restart")