X-Git-Url: https://git.archive.openwrt.org/?p=project%2Fluci.git;a=blobdiff_plain;f=modules%2Ffreifunk%2Fluasrc%2Fcontroller%2Ffreifunk%2Ffreifunk.lua;h=2ea00672771c960868532558fc714094f27078fc;hp=1d0175ff1e8dfa7c4bc6be542e4b1ebd2fcb3f5b;hb=e2b8e5efa75adeb7a4141ae1b4697a14b642bf13;hpb=61778a32394378c6b120a290739984f3c9c812ce diff --git a/modules/freifunk/luasrc/controller/freifunk/freifunk.lua b/modules/freifunk/luasrc/controller/freifunk/freifunk.lua index 1d0175ff1..2ea006727 100644 --- a/modules/freifunk/luasrc/controller/freifunk/freifunk.lua +++ b/modules/freifunk/luasrc/controller/freifunk/freifunk.lua @@ -55,7 +55,10 @@ function index() entry({"freifunk", "status.json"}, call("jsonstatus")) entry({"freifunk", "status", "zeroes"}, call("zeroes"), "Testdownload") - entry({"freifunk", "status", "public_status_json"}, call("public_status_json")).leaf = true + + if nixio.fs.access("/usr/sbin/luci-splash") then + assign({"freifunk", "status", "splash"}, {"splash", "publicstatus"}, _("Splash"), 40) + end assign({"freifunk", "olsr"}, {"admin", "status", "olsr"}, _("OLSR"), 30) @@ -215,7 +218,6 @@ function jsonstatus() root.network = {} root.wireless = {devices = {}, interfaces = {}, status = {}} local wifs = root.wireless.interfaces - local wifidata = luci.sys.wifi.getiwconfig() or {} local netdata = luci.sys.net.deviceinfo() or {} for _, vif in ipairs(ffwifs) do @@ -225,7 +227,18 @@ function jsonstatus() if s.device == vif and s.network == vif then wifs[#wifs+1] = s if s.ifname then - root.wireless.status[s.ifname] = wifidata[s.ifname] + local iwinfo = luci.sys.wifi.getiwinfo(s.ifname) + if iwinfo then + root.wireless.status[s.ifname] = { } + + local _, f + for _, f in ipairs({ + "channel", "txpower", "bitrate", "signal", "noise", + "quality", "quality_max", "mode", "ssid", "bssid", "encryption", "ifname" + }) do + root.wireless.status[s.ifname][f] = iwinfo[f] + end + end end end end) @@ -236,85 +249,3 @@ function jsonstatus() http.prepare_content("application/json") ltn12.pump.all(json.Encoder(root):source(), http.write) end - -function public_status_json() - local twa = require "luci.tools.webadmin" - local sys = require "luci.sys" - local i18n = require "luci.i18n" - local path = luci.dispatcher.context.requestpath - local rv = { } - - local dev - for dev in path[#path]:gmatch("[%w%.%-]+") do - local j = { id = dev } - local iw = luci.sys.wifi.getiwinfo(dev) - if iw then - local f - for _, f in ipairs({ - "channel", "txpower", "bitrate", "signal", "noise", - "quality", "quality_max", "mode", "ssid", "bssid", "encryption", "ifname" - }) do - j[f] = iw[f] - end - end - rv[#rv+1] = j - end - - local load1, load5, load15 = sys.loadavg() - - local _, _, memtotal, memcached, membuffers, memfree = sys.sysinfo() - local mem = string.format("%.2f MB (%.2f %s, %.2f %s, %.2f %s, %.2f %s)", - tonumber(memtotal) / 1024, - tonumber(memtotal - memfree) / 1024, - tostring(i18n.translate("used")), - memfree / 1024, - tostring(i18n.translate("free")), - memcached / 1024, - tostring(i18n.translate("cached")), - membuffers / 1024, - tostring(i18n.translate("buffered")) - ) - - local dr4 = sys.net.defaultroute() - local dr6 = sys.net.defaultroute6() - - if dr6 then - def6 = { - gateway = dr6.nexthop:string(), - dest = dr6.dest:string(), - dev = dr6.device, - metr = dr6.metric } - end - - if dr4 then - def4 = { - gateway = dr4.gateway:string(), - dest = dr4.dest:string(), - dev = dr4.device, - metr = dr4.metric } - else - local dr = sys.exec("ip r s t olsr-default") - if dr then - local dest, gateway, dev, metr = dr:match("^(%w+) via (%d+.%d+.%d+.%d+) dev (%w+) +metric (%d+)") - def4 = { - dest = dest, - gateway = gateway, - dev = dev, - metr = metr - } - end - end - - rv[#rv+1] = { - time = os.date("%a, %d %b %Y, %H:%M:%S"), - uptime = twa.date_format(tonumber(sys.uptime())), - load = string.format("%.2f, %.2f, %.2f", load1, load5, load15), - mem = mem, - defroutev4 = def4, - defroutev6 = def6 - } - - luci.http.prepare_content("application/json") - luci.http.write_json(rv) - return -end