convert luci.fs users to nixio.fs api
[project/luci.git] / applications / luci-olsr / luasrc / controller / olsr.lua
index c80a75cc1ec18a4fd48233f9bcfb41510a12ab53..837873adfb04a93c4b5a928fa1311bcf66a7bb96 100644 (file)
@@ -1,7 +1,7 @@
 module("luci.controller.olsr", package.seeall)
 
 function index()
-       if not luci.fs.isfile("/etc/config/olsrd") then
+       if not nixio.fs.access("/etc/config/olsrd") then
                return
        end
 
@@ -12,6 +12,7 @@ function index()
        page.target = call("action_index")
        page.title  = "OLSR"
        page.i18n   = "olsr"
+       page.subindex = true
 
        local page  = node("admin", "status", "olsr", "routes")
        page.target = call("action_routes")
@@ -33,15 +34,17 @@ function index()
        page.title  = "MID"
        page.order  = 50
 
-       entry(
+       local ol = entry(
                {"admin", "services", "olsrd"},
                cbi("olsr/olsrd"), "OLSR"
-       ).i18n = "olsr"
+       )
+       ol.i18n = "olsr"
+       ol.subindex = true
 
        entry(
                {"admin", "services", "olsrd", "hna"},
                cbi("olsr/olsrdhna"), "HNA Announcements"
-       ).i18n = "olsr"
+       )
 
        oplg = entry(
                {"admin", "services", "olsrd", "plugins"},
@@ -49,6 +52,7 @@ function index()
        )
        oplg.i18n = "olsr"
        oplg.leaf = true
+       oplg.subindex = true
 
        local uci = require("luci.model.uci").cursor()
        uci:foreach("olsrd", "LoadPlugin",
@@ -178,7 +182,14 @@ function fetch_txtinfo(otable)
        local rawdata = luci.sys.httpget("http://127.0.0.1:2006/"..otable)
 
        if #rawdata == 0 then
-               return nil
+               if nixio.fs.access("/proc/net/ipv6_route", "r") then
+                       rawdata = luci.sys.httpget("http://[::1]:2006/"..otable)
+                       if #rawdata == 0 then
+                               return nil
+                       end
+               else
+                       return nil
+               end
        end
 
        local data = {}