Overall CBI-UVL ineraction fixes
[project/luci.git] / contrib / package / olsrd-luci / files / lib / config / olsr.lua
index d444e4d..1afd9a0 100644 (file)
@@ -15,10 +15,12 @@ $Id$
 
 ]]--
 
+require("luci.fs")
 require("luci.util")
 require("luci.model.uci")
 
-local conf = luci.model.uci.get_all("olsr")
+local uci  = luci.model.uci.cursor()
+local conf = uci:get_all("olsr")
 
 local function _value(val)
        if val:match("^[0-9%. \t]+$") or val == "yes" or val == "no" then
@@ -33,7 +35,11 @@ local function _section(sect,sval,parstr)
        local pad = ""
 
        if sval then
-               rv  = string.format( '%s "%s"\n{\n', conf[sect][".type"], conf[sect][sval] )
+               if sval == "Interface" then
+                       rv = string.format( 'Interface "%s"\n{\n', uci:get("network",conf[sect][sval],"ifname") )
+               else
+                       rv  = string.format( '%s "%s"\n{\n', conf[sect][".type"], conf[sect][sval] )
+               end
                pad = "\t"
        end
 
@@ -57,7 +63,7 @@ local function _section(sect,sval,parstr)
 
        if sval then
                rv = rv .. "}\n"
-       end     
+       end
 
        return rv
 end
@@ -118,7 +124,9 @@ print( _section("general") )
 -- plugin config sections
 for k, v in luci.util.spairs(conf) do
        if conf[k][".type"] == "LoadPlugin" then
-               print( _section( k, "Library", "PlParam" ) )
+               if v.Library and luci.fs.access("/usr/lib/"..v.Library) then
+                       print( _section( k, "Library", "PlParam" ) )
+               end
        end
 end