Merge pull request #1735 from sumpfralle/olsr-jsoninfo-parser-handle-empty-result
[oweals/luci.git] / modules / luci-base / luasrc / sys.lua
index 4c6574368da45c3cef017916f568cd7c07fa5268..5aede84848edbe875079d3fabe3e908329a58278 100644 (file)
@@ -190,6 +190,24 @@ local function _nethints(what, callback)
                end
        )
 
+       cur:foreach("dhcp", "odhcpd",
+               function(s)
+                       if type(s.leasefile) == "string" and fs.access(s.leasefile) then
+                               for e in io.lines(s.leasefile) do
+                                       duid, iaid, name, _, ip = e:match("^# %S+ (%S+) (%S+) (%S+) (-?%d+) %S+ %S+ ([0-9a-f:.]+)/[0-9]+")
+                                       mac = net.duid_to_mac(duid)
+                                       if mac then
+                                               if ip and iaid == "ipv4" then
+                                                       _add(what, mac, ip, nil, name ~= "*" and name)
+                                               elseif ip then
+                                                       _add(what, mac, nil, ip, name ~= "*" and name)
+                                               end
+                                       end
+                               end
+                       end
+               end
+       )
+
        cur:foreach("dhcp", "host",
                function(s)
                        for mac in luci.util.imatch(s.mac) do
@@ -425,11 +443,11 @@ function process.list()
 
        for line in ps do
                local pid, ppid, user, stat, vsz, mem, cpu, cmd = line:match(
-                       "^ *(%d+) +(%d+) +(%S.-%S) +([RSDZTW][W ][<N ]) +(%d+) +(%d+%%) +(%d+%%) +(.+)"
+                       "^ *(%d+) +(%d+) +(%S.-%S) +([RSDZTW][<NW ][<N ]) +(%d+) +(%d+%%) +(%d+%%) +(.+)"
                )
 
                local idx = tonumber(pid)
-               if idx then
+               if idx and not cmd:match("top %-bn1") then
                        data[idx] = {
                                ['PID']     = pid,
                                ['PPID']    = ppid,
@@ -627,7 +645,7 @@ function init.enabled(name)
 end
 
 function init.enable(name)
-       return (init_action("enable", name) == 1)
+       return (init_action("enable", name) == 0)
 end
 
 function init.disable(name)
@@ -641,3 +659,11 @@ end
 function init.stop(name)
        return (init_action("stop", name) == 0)
 end
+
+function init.restart(name)
+       return (init_action("restart", name) == 0)
+end
+
+function init.reload(name)
+       return (init_action("reload", name) == 0)
+end