sys.lua _nethints(): read location of dhcp.lease file from uci 629/head
authorChristian Schoenebeck <christian.schoenebeck@gmail.com>
Thu, 21 Jan 2016 21:17:05 +0000 (22:17 +0100)
committerChristian Schoenebeck <christian.schoenebeck@gmail.com>
Thu, 21 Jan 2016 21:17:05 +0000 (22:17 +0100)
status.lua - change default directory of dhcp.leases file
sys.lua - read location of dhcp.leases file from uci

Signed-off-by: Christian Schoenebeck <christian.schoenebeck@gmail.com>
modules/luci-base/luasrc/sys.lua
modules/luci-base/luasrc/tools/status.lua

index a1b5b8f..ae35652 100644 (file)
@@ -185,14 +185,18 @@ local function _nethints(what, callback)
                end
        end
 
                end
        end
 
-       if fs.access("/var/dhcp.leases") then
-               for e in io.lines("/var/dhcp.leases") do
-                       mac, ip, name = e:match("^%d+ (%S+) (%S+) (%S+)")
-                       if mac and ip then
-                               _add(what, mac:upper(), ip, nil, name ~= "*" and name)
+       cur:foreach("dhcp", "dnsmasq",
+               function(s)
+                       if s.leasefile and fs.access(s.leasefile) then
+                               for e in io.lines(s.leasefile) do
+                                       mac, ip, name = e:match("^%d+ (%S+) (%S+) (%S+)")
+                                       if mac and ip then
+                                               _add(what, mac:upper(), ip, nil, name ~= "*" and name)
+                                       end
+                               end
                        end
                end
                        end
                end
-       end
+       )
 
        cur:foreach("dhcp", "host",
                function(s)
 
        cur:foreach("dhcp", "host",
                function(s)
index 0dd092c..ac053ea 100644 (file)
@@ -8,7 +8,7 @@ local uci = require "luci.model.uci".cursor()
 local function dhcp_leases_common(family)
        local rv = { }
        local nfs = require "nixio.fs"
 local function dhcp_leases_common(family)
        local rv = { }
        local nfs = require "nixio.fs"
-       local leasefile = "/var/dhcp.leases"
+       local leasefile = "/tmp/dhcp.leases"
 
        uci:foreach("dhcp", "dnsmasq",
                function(s)
 
        uci:foreach("dhcp", "dnsmasq",
                function(s)