mirror of https://git.openwrt.org/project/luci.git
convert luci.fs users to nixio.fs api
This commit is contained in:
parent
6abba61632
commit
8fcd841aa9
|
@ -17,7 +17,7 @@ module("luci.controller.ddns", package.seeall)
|
|||
function index()
|
||||
require("luci.i18n")
|
||||
luci.i18n.loadc("ddns")
|
||||
if not luci.fs.access("/etc/config/ddns") then
|
||||
if not nixio.fs.access("/etc/config/ddns") then
|
||||
return
|
||||
end
|
||||
|
||||
|
@ -29,4 +29,4 @@ function index()
|
|||
local page = entry({"mini", "network", "ddns"}, cbi("ddns/ddnsmini", {autoapply=true}), luci.i18n.translate("ddns"), 60)
|
||||
page.i18n = "ddns"
|
||||
page.dependent = true
|
||||
end
|
||||
end
|
||||
|
|
|
@ -18,7 +18,7 @@ module("luci.controller.hd_idle", package.seeall)
|
|||
function index()
|
||||
require("luci.i18n")
|
||||
luci.i18n.loadc("hd_idle")
|
||||
if not luci.fs.access("/etc/config/hd-idle") then
|
||||
if not nixio.fs.access("/etc/config/hd-idle") then
|
||||
return
|
||||
end
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ $Id$
|
|||
|
||||
]]--
|
||||
|
||||
require("luci.fs")
|
||||
require("nixio.fs")
|
||||
|
||||
m = Map("hd-idle", translate("hd_idle"), translate("hd_idle_desc"))
|
||||
|
||||
|
@ -24,8 +24,8 @@ s:option(Flag, "enabled", translate("enable", "Enable"))
|
|||
|
||||
disk = s:option(Value, "disk", translate("disk"))
|
||||
disk.rmempty = true
|
||||
for _, dev in ipairs(luci.fs.glob("/dev/[sh]d[a-z]")) do
|
||||
disk:value(luci.fs.basename(dev))
|
||||
for _, dev in nixio.fs.glob("/dev/[sh]d[a-z]") do
|
||||
disk:value(nixio.fs.basename(dev))
|
||||
end
|
||||
|
||||
s:option(Value, "idle_time_interval", translate("idle_time_interval")).default = 10
|
||||
|
|
|
@ -15,7 +15,7 @@ $Id$
|
|||
module("luci.controller.init", package.seeall)
|
||||
|
||||
function index()
|
||||
if not luci.fs.access("/etc/rc.common") then
|
||||
if not nixio.fs.access("/etc/rc.common") then
|
||||
return
|
||||
end
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@ module("luci.controller.mmc_over_gpio", package.seeall)
|
|||
function index()
|
||||
require("luci.i18n")
|
||||
luci.i18n.loadc("mmc_over_gpio")
|
||||
if not luci.fs.access("/etc/config/mmc_over_gpio") then
|
||||
if not nixio.fs.access("/etc/config/mmc_over_gpio") then
|
||||
return
|
||||
end
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ module("luci.controller.ntpc", package.seeall)
|
|||
function index()
|
||||
require("luci.i18n")
|
||||
luci.i18n.loadc("ntpc")
|
||||
if not luci.fs.access("/etc/config/ntpclient") then
|
||||
if not nixio.fs.access("/etc/config/ntpclient") then
|
||||
return
|
||||
end
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
module("luci.controller.olsr", package.seeall)
|
||||
|
||||
function index()
|
||||
if not luci.fs.access("/etc/config/olsrd") then
|
||||
if not nixio.fs.access("/etc/config/olsrd") then
|
||||
return
|
||||
end
|
||||
|
||||
|
@ -182,7 +182,7 @@ function fetch_txtinfo(otable)
|
|||
local rawdata = luci.sys.httpget("http://127.0.0.1:2006/"..otable)
|
||||
|
||||
if #rawdata == 0 then
|
||||
if luci.fs.access("/proc/net/ipv6_route", "r") then
|
||||
if nixio.fs.access("/proc/net/ipv6_route", "r") then
|
||||
rawdata = luci.sys.httpget("http://[::1]:2006/"..otable)
|
||||
if #rawdata == 0 then
|
||||
return nil
|
||||
|
|
|
@ -13,9 +13,8 @@ You may obtain a copy of the License at
|
|||
$Id$
|
||||
]]--
|
||||
|
||||
require("luci.fs")
|
||||
require("luci.ip")
|
||||
|
||||
local ip = require "luci.ip"
|
||||
local fs = require "nixio.fs"
|
||||
|
||||
if arg[1] then
|
||||
mp = Map("olsrd", translate("olsrd_plugins", "OLSR - Plugins"))
|
||||
|
@ -44,7 +43,7 @@ if arg[1] then
|
|||
local function Cidr2IpMask(val)
|
||||
if val then
|
||||
for i = 1, #val do
|
||||
local cidr = luci.ip.IPv4(val[i]) or luci.ip.IPv6(val[i])
|
||||
local cidr = ip.IPv4(val[i]) or ip.IPv6(val[i])
|
||||
if cidr then
|
||||
val[i] = cidr:network():string() .. " " .. cidr:mask():string()
|
||||
end
|
||||
|
@ -59,9 +58,9 @@ if arg[1] then
|
|||
local ip, mask = val[i]:gmatch("([^%s]+)%s+([^%s]+)")()
|
||||
local cidr
|
||||
if ip and mask and ip:match(":") then
|
||||
cidr = luci.ip.IPv6(ip, mask)
|
||||
cidr = ip.IPv6(ip, mask)
|
||||
elseif ip and mask then
|
||||
cidr = luci.ip.IPv4(ip, mask)
|
||||
cidr = ip.IPv4(ip, mask)
|
||||
end
|
||||
|
||||
if cidr then
|
||||
|
@ -220,7 +219,7 @@ else
|
|||
)
|
||||
|
||||
-- create a loadplugin section for each found plugin
|
||||
for k, v in pairs(luci.fs.dir("/usr/lib")) do
|
||||
for v in fs.dir("/usr/lib") do
|
||||
if v:sub(1, 6) == "olsrd_" then
|
||||
if not plugins[v] then
|
||||
mpi.uci:section(
|
||||
|
|
|
@ -12,7 +12,6 @@ You may obtain a copy of the License at
|
|||
$Id$
|
||||
]]--
|
||||
|
||||
require("luci.fs")
|
||||
require("luci.ip")
|
||||
|
||||
|
||||
|
|
|
@ -12,7 +12,6 @@ You may obtain a copy of the License at
|
|||
$Id$
|
||||
]]--
|
||||
|
||||
require("luci.fs")
|
||||
require("luci.ip")
|
||||
require("luci.model.uci")
|
||||
|
||||
|
|
|
@ -12,13 +12,9 @@ You may obtain a copy of the License at
|
|||
$Id$
|
||||
]]--
|
||||
|
||||
require("luci.fs")
|
||||
require("luci.ip")
|
||||
require("luci.sys")
|
||||
require("luci.model.uci")
|
||||
|
||||
|
||||
local uci = luci.model.uci.cursor()
|
||||
local fs = require "nixio.fs"
|
||||
local sys = require "luci.sys"
|
||||
local uci = require "luci.model.uci".cursor()
|
||||
|
||||
local m = Map("openvpn", translate("openvpn"))
|
||||
local s = m:section( TypedSection, "openvpn", translate("openvpn_overview"), translate("openvpn_overview_desc") )
|
||||
|
@ -74,13 +70,11 @@ s:option( Flag, "enable", translate("openvpn_enable") )
|
|||
|
||||
local active = s:option( DummyValue, "_active", translate("openvpn_active") )
|
||||
function active.cfgvalue(self, section)
|
||||
if luci.fs.isfile("/var/run/openvpn_%s.pid" % section) then
|
||||
local pid = io.lines("/var/run/openvpn_%s.pid" % section)()
|
||||
if pid and #pid > 0 and tonumber(pid) ~= nil then
|
||||
return (luci.sys.process.signal(pid, 0))
|
||||
and translatef("openvpn_active_yes", pid)
|
||||
or translate("openvpn_active_no")
|
||||
end
|
||||
local pid = fs.readfile("/var/run/openvpn_%s.pid" % section)
|
||||
if pid and #pid > 0 and tonumber(pid) ~= nil then
|
||||
return (sys.process.signal(pid, 0))
|
||||
and translatef("openvpn_active_yes", pid)
|
||||
or translate("openvpn_active_no")
|
||||
end
|
||||
return translate("openvpn_active_no")
|
||||
end
|
||||
|
|
|
@ -18,7 +18,7 @@ module("luci.controller.p910nd", package.seeall)
|
|||
function index()
|
||||
require("luci.i18n")
|
||||
luci.i18n.loadc("p910nd")
|
||||
if not luci.fs.access("/etc/config/p910nd") then
|
||||
if not nixio.fs.access("/etc/config/p910nd") then
|
||||
return
|
||||
end
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ $Id$
|
|||
module("luci.controller.polipo", package.seeall)
|
||||
|
||||
function index()
|
||||
if not luci.fs.access("/etc/config/polipo") then
|
||||
if not nixio.fs.access("/etc/config/polipo") then
|
||||
return
|
||||
end
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ $Id$
|
|||
module("luci.controller.qos", package.seeall)
|
||||
|
||||
function index()
|
||||
if not luci.fs.access("/etc/config/qos") then
|
||||
if not nixio.fs.access("/etc/config/qos") then
|
||||
return
|
||||
end
|
||||
|
||||
|
@ -26,4 +26,4 @@ function index()
|
|||
local page = entry({"mini", "network", "qos"}, cbi("qos/qosmini", {autoapply=true}), "QoS")
|
||||
page.i18n = "qos"
|
||||
page.dependent = true
|
||||
end
|
||||
end
|
||||
|
|
|
@ -11,7 +11,10 @@ You may obtain a copy of the License at
|
|||
|
||||
$Id$
|
||||
]]--
|
||||
require("luci.tools.webadmin")
|
||||
|
||||
local wa = require "luci.tools.webadmin"
|
||||
local fs = require "nixio.fs"
|
||||
|
||||
m = Map("qos")
|
||||
|
||||
s = m:section(TypedSection, "interface", translate("interfaces"))
|
||||
|
@ -46,19 +49,19 @@ t.default = "Normal"
|
|||
srch = s:option(Value, "srchost")
|
||||
srch.rmempty = true
|
||||
srch:value("", translate("all"))
|
||||
luci.tools.webadmin.cbi_add_knownips(srch)
|
||||
wa.cbi_add_knownips(srch)
|
||||
|
||||
dsth = s:option(Value, "dsthost")
|
||||
dsth.rmempty = true
|
||||
dsth:value("", translate("all"))
|
||||
luci.tools.webadmin.cbi_add_knownips(dsth)
|
||||
wa.cbi_add_knownips(dsth)
|
||||
|
||||
l7 = s:option(ListValue, "layer7", translate("service"))
|
||||
l7.rmempty = true
|
||||
l7:value("", translate("all"))
|
||||
local pats = luci.fs.dir("/etc/l7-protocols")
|
||||
local pats = fs.dir("/etc/l7-protocols")
|
||||
if pats then
|
||||
for i,f in ipairs(pats) do
|
||||
for f in pats do
|
||||
if f:sub(-4) == ".pat" then
|
||||
l7:value(f:sub(1, #f-4))
|
||||
end
|
||||
|
|
|
@ -12,7 +12,10 @@ You may obtain a copy of the License at
|
|||
|
||||
$Id$
|
||||
]]--
|
||||
require("luci.tools.webadmin")
|
||||
|
||||
local wa = require "luci.tools.webadmin"
|
||||
local fs = require "nixio.fs"
|
||||
|
||||
m = Map("qos")
|
||||
|
||||
s = m:section(NamedSection, "wan", "interface", translate("m_n_inet"))
|
||||
|
@ -37,19 +40,19 @@ t.default = "Normal"
|
|||
srch = s:option(Value, "srchost")
|
||||
srch.rmempty = true
|
||||
srch:value("", translate("all"))
|
||||
luci.tools.webadmin.cbi_add_knownips(srch)
|
||||
wa.cbi_add_knownips(srch)
|
||||
|
||||
dsth = s:option(Value, "dsthost")
|
||||
dsth.rmempty = true
|
||||
dsth:value("", translate("all"))
|
||||
luci.tools.webadmin.cbi_add_knownips(dsth)
|
||||
wa.cbi_add_knownips(dsth)
|
||||
|
||||
l7 = s:option(ListValue, "layer7", translate("service"))
|
||||
l7.rmempty = true
|
||||
l7:value("", translate("all"))
|
||||
local pats = luci.fs.dir("/etc/l7-protocols")
|
||||
local pats = fs.dir("/etc/l7-protocols")
|
||||
if pats then
|
||||
for i,f in ipairs(pats) do
|
||||
for f in pats do
|
||||
if f:sub(-4) == ".pat" then
|
||||
l7:value(f:sub(1, #f-4))
|
||||
end
|
||||
|
|
|
@ -15,7 +15,7 @@ $Id$
|
|||
module("luci.controller.samba", package.seeall)
|
||||
|
||||
function index()
|
||||
if not luci.fs.access("/etc/config/samba") then
|
||||
if not nixio.fs.access("/etc/config/samba") then
|
||||
return
|
||||
end
|
||||
require("luci.i18n")
|
||||
|
|
|
@ -18,6 +18,8 @@ local utl = require "luci.util"
|
|||
local ipt = require "luci.sys.iptparser".IptParser()
|
||||
local uci = require "luci.model.uci".cursor_state()
|
||||
local wat = require "luci.tools.webadmin"
|
||||
local fs = require "nixio.fs"
|
||||
|
||||
local clients = { }
|
||||
local leasetime = tonumber(uci:get("luci_splash", "general", "leasetime") or 1) * 60 * 60
|
||||
local leasefile = "/tmp/dhcp.leases"
|
||||
|
@ -94,7 +96,7 @@ uci:foreach("luci_splash", "blacklist",
|
|||
end
|
||||
end)
|
||||
|
||||
if luci.fs.access(leasefile) then
|
||||
if fs.access(leasefile) then
|
||||
for l in io.lines(leasefile) do
|
||||
local time, mac, ip, name = l:match("^(%d+) (%S+) (%S+) (%S+)")
|
||||
if time and mac and ip then
|
||||
|
|
|
@ -22,7 +22,8 @@ require("luci.statistics.i18n")
|
|||
require("luci.model.uci")
|
||||
require("luci.util")
|
||||
require("luci.sys")
|
||||
require("luci.fs")
|
||||
|
||||
local fs = require "nixio.fs"
|
||||
|
||||
|
||||
Graph = luci.util.class()
|
||||
|
@ -96,7 +97,7 @@ function Graph._rrdtool( self, def, rrd )
|
|||
|
||||
-- prepare directory
|
||||
local dir = def[1]:gsub("/[^/]+$","")
|
||||
luci.fs.mkdir( dir, true )
|
||||
fs.mkdirr( dir )
|
||||
|
||||
-- construct commandline
|
||||
local cmdline = "rrdtool graph"
|
||||
|
@ -500,7 +501,7 @@ function Graph.render( self, plugin, plugin_instance )
|
|||
|
||||
-- check for a whole graph handler
|
||||
local plugin_def = "luci.statistics.rrdtool.definitions." .. plugin
|
||||
local stat, def = luci.util.copcall( require, plugin_def )
|
||||
local stat, def = pcall( require, plugin_def )
|
||||
|
||||
if stat and def and type(def.rrdargs) == "function" then
|
||||
|
||||
|
@ -539,7 +540,7 @@ function Graph.render( self, plugin, plugin_instance )
|
|||
|
||||
-- check for data type handler
|
||||
local dtype_def = plugin_def .. "." .. dtype
|
||||
local stat, def = luci.util.copcall( require, dtype_def )
|
||||
local stat, def = pcall( require, dtype_def )
|
||||
|
||||
if stat and def and type(def.rrdargs) == "function" then
|
||||
|
||||
|
|
|
@ -16,7 +16,6 @@ $Id$
|
|||
module("luci.statistics.rrdtool.definitions", package.seeall)
|
||||
|
||||
require("luci.util")
|
||||
require("luci.fs")
|
||||
|
||||
|
||||
Instance = luci.util.class()
|
||||
|
|
|
@ -22,7 +22,7 @@ about open tcp connections, interface traffic, iptables rules etc.%></p>
|
|||
<p><%:stat_networkplugins_installed Installed network plugins:%>
|
||||
<ul>
|
||||
<% for plugin, desc in pairs(plugins) do %>
|
||||
<% if luci.fs.access("/usr/lib/collectd/" .. plugin .. ".so") then %>
|
||||
<% if nixio.fs.access("/usr/lib/collectd/" .. plugin .. ".so") then %>
|
||||
<li><a href="<%=controller%>/admin/statistics/collectd/network/<%=plugin%>"><%=desc%></a></li>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
|
|
@ -23,7 +23,7 @@ and to transmit the data over the network to other collectd instances.%></p>
|
|||
<p><%:stat_outputplugins_installed Installed output plugins:%>
|
||||
<ul>
|
||||
<% for plugin, desc in pairs(plugins) do %>
|
||||
<% if luci.fs.access("/usr/lib/collectd/" .. plugin .. ".so") then %>
|
||||
<% if nixio.fs.access("/usr/lib/collectd/" .. plugin .. ".so") then %>
|
||||
<li><a href="<%=controller%>/admin/statistics/collectd/output/<%=plugin%>"><%=desc%></a></li>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
|
|
@ -19,7 +19,7 @@ $Id$
|
|||
<p><%:stat_systemplugins_desc System plugins collecting values about system state and ressource usage on the device.:%>
|
||||
<ul>
|
||||
<% for plugin, desc in pairs(plugins) do %>
|
||||
<% if luci.fs.access("/usr/lib/collectd/" .. plugin .. ".so") then %>
|
||||
<% if nixio.fs.access("/usr/lib/collectd/" .. plugin .. ".so") then %>
|
||||
<li><a href="<%=controller%>/admin/statistics/collectd/system/<%=plugin%>"><%=desc%></a></li>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
|
|
@ -15,11 +15,11 @@ $Id$
|
|||
module("luci.controller.tinyproxy", package.seeall)
|
||||
|
||||
function index()
|
||||
if not luci.fs.access("/etc/config/tinyproxy") then
|
||||
if not nixio.fs.access("/etc/config/tinyproxy") then
|
||||
return
|
||||
end
|
||||
|
||||
local page = entry({"admin", "services", "tinyproxy"}, cbi("tinyproxy"), "Tinyproxy")
|
||||
page.dependent = true
|
||||
page.i18n = "tinyproxy"
|
||||
end
|
||||
end
|
||||
|
|
|
@ -15,7 +15,7 @@ $Id$
|
|||
module("luci.controller.upnp", package.seeall)
|
||||
|
||||
function index()
|
||||
if not luci.fs.access("/etc/config/upnpd") then
|
||||
if not nixio.fs.access("/etc/config/upnpd") then
|
||||
return
|
||||
end
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@ module("luci.controller.ushare", package.seeall)
|
|||
function index()
|
||||
require("luci.i18n")
|
||||
luci.i18n.loadc("ushare")
|
||||
if not luci.fs.access("/etc/config/ushare") then
|
||||
if not nixio.fs.access("/etc/config/ushare") then
|
||||
return
|
||||
end
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@ module("luci.controller.uvc_streamer", package.seeall)
|
|||
function index()
|
||||
require("luci.i18n")
|
||||
luci.i18n.loadc("uvc_streamer")
|
||||
if not luci.fs.access("/etc/config/uvc-streamer") then
|
||||
if not nixio.fs.access("/etc/config/uvc-streamer") then
|
||||
return
|
||||
end
|
||||
|
||||
|
|
|
@ -30,9 +30,10 @@ require("luci.template")
|
|||
local util = require("luci.util")
|
||||
require("luci.http")
|
||||
require("luci.uvl")
|
||||
require("luci.fs")
|
||||
|
||||
|
||||
--local event = require "luci.sys.event"
|
||||
local fs = require("nixio.fs")
|
||||
local uci = require("luci.model.uci")
|
||||
local class = util.class
|
||||
local instanceof = util.instanceof
|
||||
|
@ -52,7 +53,7 @@ REMOVE_PREFIX = "cbi.rts."
|
|||
|
||||
-- Loads a CBI map from given file, creating an environment and returns it
|
||||
function load(cbimap, ...)
|
||||
require("luci.fs")
|
||||
local fs = require "nixio.fs"
|
||||
local i18n = require "luci.i18n"
|
||||
require("luci.config")
|
||||
require("luci.util")
|
||||
|
@ -60,9 +61,9 @@ function load(cbimap, ...)
|
|||
local upldir = "/lib/uci/upload/"
|
||||
local cbidir = luci.util.libpath() .. "/model/cbi/"
|
||||
|
||||
assert(luci.fs.stat(cbimap) or
|
||||
luci.fs.stat(cbidir..cbimap..".lua") or
|
||||
luci.fs.stat(cbidir..cbimap..".lua.gz"),
|
||||
assert(fs.stat(cbimap) or
|
||||
fs.stat(cbidir..cbimap..".lua") or
|
||||
fs.stat(cbidir..cbimap..".lua.gz"),
|
||||
"Model not found!")
|
||||
|
||||
local func, err = loadfile(cbimap)
|
||||
|
@ -1703,7 +1704,7 @@ end
|
|||
|
||||
function FileUpload.cfgvalue(self, section)
|
||||
local val = AbstractValue.cfgvalue(self, section)
|
||||
if val and luci.fs.access(val) then
|
||||
if val and fs.access(val) then
|
||||
return val
|
||||
end
|
||||
return nil
|
||||
|
@ -1717,7 +1718,7 @@ function FileUpload.formvalue(self, section)
|
|||
then
|
||||
return val
|
||||
end
|
||||
luci.fs.unlink(val)
|
||||
fs.unlink(val)
|
||||
self.value = nil
|
||||
end
|
||||
return nil
|
||||
|
@ -1725,7 +1726,7 @@ end
|
|||
|
||||
function FileUpload.remove(self, section)
|
||||
local val = AbstractValue.formvalue(self, section)
|
||||
if val and luci.fs.access(val) then luci.fs.unlink(val) end
|
||||
if val and fs.access(val) then fs.unlink(val) end
|
||||
return AbstractValue.remove(self, section)
|
||||
end
|
||||
|
||||
|
|
|
@ -48,7 +48,8 @@ $Id$
|
|||
</head>
|
||||
<body>
|
||||
<%
|
||||
require("luci.fs")
|
||||
require("nixio.fs")
|
||||
require("nixio.util")
|
||||
require("luci.http")
|
||||
require("luci.dispatcher")
|
||||
|
||||
|
@ -63,7 +64,7 @@ $Id$
|
|||
end
|
||||
|
||||
local filepath = table.concat( path, '/' )
|
||||
local filestat = luci.fs.stat( filepath )
|
||||
local filestat = nixio.fs.stat( filepath )
|
||||
local baseurl = luci.dispatcher.build_url('admin', 'filebrowser')
|
||||
|
||||
if filestat and filestat.type == "reg" then
|
||||
|
@ -76,7 +77,7 @@ $Id$
|
|||
filepath = filepath .. '/'
|
||||
end
|
||||
|
||||
local entries = luci.fs.dir(filepath)
|
||||
local entries = nixio.util.consume((nixio.fs.dir(filepath)))
|
||||
-%>
|
||||
<div id="path">
|
||||
Location:
|
||||
|
@ -98,8 +99,8 @@ $Id$
|
|||
<div id="listing">
|
||||
<ul>
|
||||
<% for _, e in luci.util.vspairs(entries) do
|
||||
local stat = luci.fs.stat(filepath..e)
|
||||
if e ~= '.' and e ~= '..' and stat and stat.type == 'dir' then
|
||||
local stat = nixio.fs.stat(filepath..e)
|
||||
if stat and stat.type == 'dir' then
|
||||
-%>
|
||||
<li class="dir">
|
||||
<img src="/luci-static/resources/cbi/folder.png" alt="Directory" />
|
||||
|
@ -108,7 +109,7 @@ $Id$
|
|||
<% end end -%>
|
||||
|
||||
<% for _, e in luci.util.vspairs(entries) do
|
||||
local stat = luci.fs.stat(filepath..e)
|
||||
local stat = nixio.fs.stat(filepath..e)
|
||||
if stat and stat.type ~= 'dir' then
|
||||
-%>
|
||||
<li class="file">
|
||||
|
|
|
@ -16,10 +16,11 @@ $Id$
|
|||
<%
|
||||
local t = require("luci.tools.webadmin")
|
||||
local v = self:cfgvalue(section)
|
||||
v = v and nixio.fs.stat(v)
|
||||
-%>
|
||||
<%+cbi/valueheader%>
|
||||
<% if v then %>
|
||||
<%:cbi_upload Uploaded File%> (<%=t.byte_format(luci.fs.stat(v, "size") or 0)%>)
|
||||
<%:cbi_upload Uploaded File%> (<%=t.byte_format(v.size)%>)
|
||||
<input type="hidden"<%= attr("value", v) .. attr("name", cbid) .. attr("id", cbid) %> />
|
||||
<input class="cbi-input-image" type="image" value="<%:cbi_replace%>" name="cbi.rlf.<%=section .. "." .. self.option%>" alt="<%:cbi_replace%>" title="<%:cbi_replace%>" src="<%=resource%>/cbi/reload.gif" />
|
||||
<% else %>
|
||||
|
|
|
@ -705,7 +705,7 @@ end
|
|||
--- Returns the absolute path to LuCI base directory.
|
||||
-- @return String containing the directory path
|
||||
function libpath()
|
||||
return require "luci.fs".dirname(ldebug.__file__)
|
||||
return require "nixio.fs".dirname(ldebug.__file__)
|
||||
end
|
||||
|
||||
|
||||
|
|
|
@ -331,4 +331,4 @@ function daemonize()
|
|||
nixio.dup(devnull, nixio.stderr)
|
||||
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
|
|
@ -27,12 +27,12 @@ limitations under the License.
|
|||
|
||||
local io = require "io"
|
||||
local os = require "os"
|
||||
local nixio = require "nixio"
|
||||
local table = require "table"
|
||||
local nixio = require "nixio"
|
||||
local fs = require "nixio.fs"
|
||||
|
||||
local luci = {}
|
||||
luci.util = require "luci.util"
|
||||
luci.fs = require "luci.fs"
|
||||
luci.ip = require "luci.ip"
|
||||
|
||||
local tonumber, ipairs, pairs, pcall, type, next =
|
||||
|
@ -135,7 +135,7 @@ getenv = nixio.getenv
|
|||
-- @return String containing the system hostname
|
||||
function hostname(newname)
|
||||
if type(newname) == "string" and #newname > 0 then
|
||||
luci.fs.writefile( "/proc/sys/kernel/hostname", newname .. "\n" )
|
||||
fs.writefile( "/proc/sys/kernel/hostname", newname )
|
||||
return newname
|
||||
else
|
||||
return nixio.uname().nodename
|
||||
|
@ -180,8 +180,8 @@ end
|
|||
-- @return String containing the memory used for buffering in kB
|
||||
-- @return String containing the free memory amount in kB
|
||||
function sysinfo()
|
||||
local cpuinfo = luci.fs.readfile("/proc/cpuinfo")
|
||||
local meminfo = luci.fs.readfile("/proc/meminfo")
|
||||
local cpuinfo = fs.readfile("/proc/cpuinfo")
|
||||
local meminfo = fs.readfile("/proc/meminfo")
|
||||
|
||||
local system = cpuinfo:match("system typ.-:%s*([^\n]+)")
|
||||
local model = ""
|
||||
|
@ -219,7 +219,7 @@ end
|
|||
-- @param bytes Number of bytes for the unique id
|
||||
-- @return String containing hex encoded id
|
||||
function uniqueid(bytes)
|
||||
local rand = luci.fs.readfile("/dev/urandom", bytes)
|
||||
local rand = fs.readfile("/dev/urandom", bytes)
|
||||
return rand and nixio.bin.hexlify(rand)
|
||||
end
|
||||
|
||||
|
@ -247,7 +247,7 @@ end
|
|||
-- @return Table with the currently tracked IP connections
|
||||
function net.conntrack(callback)
|
||||
local connt = {}
|
||||
if luci.fs.access("/proc/net/nf_conntrack", "r") then
|
||||
if fs.access("/proc/net/nf_conntrack", "r") then
|
||||
for line in io.lines("/proc/net/nf_conntrack") do
|
||||
line = line:match "^(.-( [^ =]+=).-)%2"
|
||||
local entry, flags = _parse_mixed_record(line, " +")
|
||||
|
@ -263,7 +263,7 @@ function net.conntrack(callback)
|
|||
connt[#connt+1] = entry
|
||||
end
|
||||
end
|
||||
elseif luci.fs.access("/proc/net/ip_conntrack", "r") then
|
||||
elseif fs.access("/proc/net/ip_conntrack", "r") then
|
||||
for line in io.lines("/proc/net/ip_conntrack") do
|
||||
line = line:match "^(.-( [^ =]+=).-)%2"
|
||||
local entry, flags = _parse_mixed_record(line, " +")
|
||||
|
@ -369,13 +369,11 @@ end
|
|||
-- @return String containing the MAC address or nil if it cannot be found
|
||||
function net.ip4mac(ip)
|
||||
local mac = nil
|
||||
|
||||
for i, l in ipairs(net.arptable()) do
|
||||
if l["IP address"] == ip then
|
||||
mac = l["HW address"]
|
||||
net.arptable(function(e)
|
||||
if e["IP address"] == ip then
|
||||
mac = e["HW address"]
|
||||
end
|
||||
end
|
||||
|
||||
end)
|
||||
return mac
|
||||
end
|
||||
|
||||
|
@ -432,7 +430,7 @@ end
|
|||
-- { "source", "dest", "nexthop", "metric", "refcount", "usecount",
|
||||
-- "flags", "device" }
|
||||
function net.routes6(callback)
|
||||
if luci.fs.access("/proc/net/ipv6_route", "r") then
|
||||
if fs.access("/proc/net/ipv6_route", "r") then
|
||||
local routes = { }
|
||||
|
||||
for line in io.lines("/proc/net/ipv6_route") do
|
||||
|
@ -711,8 +709,8 @@ init.dir = "/etc/init.d/"
|
|||
-- @return Table containing the names of all inistalled init scripts
|
||||
function init.names()
|
||||
local names = { }
|
||||
for _, name in ipairs(luci.fs.glob(init.dir.."*")) do
|
||||
names[#names+1] = luci.fs.basename(name)
|
||||
for name in fs.glob(init.dir.."*") do
|
||||
names[#names+1] = fs.basename(name)
|
||||
end
|
||||
return names
|
||||
end
|
||||
|
@ -721,7 +719,7 @@ end
|
|||
-- @param name Name of the init script
|
||||
-- @return Boolean indicating whether init is enabled
|
||||
function init.enabled(name)
|
||||
if luci.fs.access(init.dir..name) then
|
||||
if fs.access(init.dir..name) then
|
||||
return ( call(init.dir..name.." enabled") == 0 )
|
||||
end
|
||||
return false
|
||||
|
@ -731,7 +729,7 @@ end
|
|||
-- @param name Name of the init script
|
||||
-- @return Numeric index value
|
||||
function init.index(name)
|
||||
if luci.fs.access(init.dir..name) then
|
||||
if fs.access(init.dir..name) then
|
||||
return call("source "..init.dir..name.."; exit $START")
|
||||
end
|
||||
end
|
||||
|
@ -740,7 +738,7 @@ end
|
|||
-- @param name Name of the init script
|
||||
-- @return Boolean indicating success
|
||||
function init.enable(name)
|
||||
if luci.fs.access(init.dir..name) then
|
||||
if fs.access(init.dir..name) then
|
||||
return ( call(init.dir..name.." enable") == 1 )
|
||||
end
|
||||
end
|
||||
|
@ -749,7 +747,7 @@ end
|
|||
-- @param name Name of the init script
|
||||
-- @return Boolean indicating success
|
||||
function init.disable(name)
|
||||
if luci.fs.access(init.dir..name) then
|
||||
if fs.access(init.dir..name) then
|
||||
return ( call(init.dir..name.." disable") == 0 )
|
||||
end
|
||||
end
|
||||
|
|
|
@ -19,7 +19,9 @@ $Id$
|
|||
-- @class module
|
||||
-- @cstyle instance
|
||||
|
||||
local fs = require "luci.fs"
|
||||
require "nixio.util"
|
||||
|
||||
local fs = require "nixio.fs"
|
||||
local uci = require "luci.model.uci"
|
||||
local util = require "luci.util"
|
||||
local table = require "table"
|
||||
|
@ -403,11 +405,11 @@ function UVL.read_scheme( self, shm, alias )
|
|||
local bc = "%s/bytecode/%s.lua" %{ self.schemedir, shm }
|
||||
|
||||
if not fs.access(bc) then
|
||||
local files = fs.glob(self.schemedir .. '/*/' .. shm)
|
||||
local files = nixio.util.consume(fs.glob(self.schemedir .. '/*/' .. shm))
|
||||
|
||||
if files then
|
||||
if #files > 0 then
|
||||
local ok, err
|
||||
for i, file in ipairs( files ) do
|
||||
for file in files do
|
||||
if not fs.access(file) then
|
||||
return false, so:error(ERR.SME_READ(so,file))
|
||||
end
|
||||
|
|
|
@ -14,7 +14,7 @@ $Id$
|
|||
|
||||
]]--
|
||||
|
||||
local fs = require "luci.fs"
|
||||
local fs = require "nixio.fs"
|
||||
local ip = require "luci.ip"
|
||||
local math = require "math"
|
||||
local util = require "luci.util"
|
||||
|
|
|
@ -15,7 +15,7 @@ $Id$
|
|||
]]--
|
||||
|
||||
local os = require "os"
|
||||
local fs = require "luci.fs"
|
||||
local fs = require "nixio.fs"
|
||||
local sys = require "luci.sys"
|
||||
local ERR = require "luci.uvl.errors"
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ $Id$
|
|||
]]--
|
||||
|
||||
local io = require "io"
|
||||
local fs = require "luci.fs"
|
||||
local fs = require "nixio.fs"
|
||||
local uvl = require "luci.uvl"
|
||||
local util = require "luci.util"
|
||||
local ltn12 = require "luci.ltn12"
|
||||
|
@ -48,7 +48,7 @@ function Generator.make(self)
|
|||
fs.mkdir(self.output)
|
||||
|
||||
for i, file in ipairs(self.additionals) do
|
||||
fs.copy(self.sourcedir .. file, self.output .. "/" .. file)
|
||||
fs.datacopy(self.sourcedir .. file, self.output .. "/" .. file)
|
||||
end
|
||||
|
||||
template.compiler_mode = "memory"
|
||||
|
|
|
@ -25,7 +25,7 @@ limitations under the License.
|
|||
]]--
|
||||
|
||||
--- LuCI web dispatcher.
|
||||
local fs = require "luci.fs"
|
||||
local fs = require "nixio.fs"
|
||||
local sys = require "luci.sys"
|
||||
local init = require "luci.init"
|
||||
local util = require "luci.util"
|
||||
|
@ -394,19 +394,16 @@ end
|
|||
function createindex_plain(path, suffixes)
|
||||
local controllers = { }
|
||||
for _, suffix in ipairs(suffixes) do
|
||||
controllers = util.combine(
|
||||
controllers,
|
||||
luci.fs.glob(path .. "*" .. suffix) or {},
|
||||
luci.fs.glob(path .. "*/*" .. suffix) or {}
|
||||
)
|
||||
nixio.util.consume((fs.glob(path .. "*" .. suffix)), controllers)
|
||||
nixio.util.consume((fs.glob(path .. "*/*" .. suffix)), controllers)
|
||||
end
|
||||
|
||||
if indexcache then
|
||||
local cachedate = fs.mtime(indexcache)
|
||||
local cachedate = fs.stat(indexcache, "mtime")
|
||||
if cachedate then
|
||||
local realdate = 0
|
||||
for _, obj in ipairs(controllers) do
|
||||
local omtime = fs.mtime(path .. "/" .. obj)
|
||||
local omtime = fs.stat(path .. "/" .. obj, "mtime")
|
||||
realdate = (omtime and omtime > realdate) and omtime or realdate
|
||||
end
|
||||
|
||||
|
|
|
@ -15,7 +15,6 @@ $Id$
|
|||
|
||||
--- LuCI session library.
|
||||
module("luci.sauth", package.seeall)
|
||||
require("luci.fs")
|
||||
require("luci.util")
|
||||
require("luci.sys")
|
||||
require("luci.config")
|
||||
|
@ -30,17 +29,17 @@ sessiontime = tonumber(luci.config.sauth.sessiontime) or 15 * 60
|
|||
--- Manually clean up expired sessions.
|
||||
function clean()
|
||||
local now = os.time()
|
||||
local files = luci.fs.dir(sessionpath)
|
||||
local files = fs.dir(sessionpath)
|
||||
|
||||
if not files then
|
||||
return nil
|
||||
end
|
||||
|
||||
for i, file in pairs(files) do
|
||||
for file in files do
|
||||
local fname = sessionpath .. "/" .. file
|
||||
local stat = luci.fs.stat(fname)
|
||||
local stat = fs.stat(fname)
|
||||
if stat and stat.type == "reg" and stat.mtime + sessiontime < now then
|
||||
luci.fs.unlink(fname)
|
||||
fs.unlink(fname)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -68,8 +67,8 @@ function read(id)
|
|||
if not sane(sessionpath .. "/" .. id) then
|
||||
return
|
||||
end
|
||||
luci.fs.utime(sessionpath .. "/" .. id)
|
||||
return luci.fs.readfile(sessionpath .. "/" .. id)
|
||||
fs.utimes(sessionpath .. "/" .. id)
|
||||
return fs.readfile(sessionpath .. "/" .. id)
|
||||
end
|
||||
|
||||
|
||||
|
@ -77,8 +76,8 @@ end
|
|||
-- @return Boolean status
|
||||
function sane(file)
|
||||
return luci.sys.process.info("uid")
|
||||
== luci.fs.stat(file or sessionpath, "uid")
|
||||
and luci.fs.stat(file or sessionpath, "modestr")
|
||||
== fs.stat(file or sessionpath, "uid")
|
||||
and fs.stat(file or sessionpath, "modestr")
|
||||
== (file and "rw-------" or "rwx------")
|
||||
end
|
||||
|
||||
|
@ -106,5 +105,5 @@ function kill(id)
|
|||
if not id:match("^%w+$") then
|
||||
error("Session ID is not sane!")
|
||||
end
|
||||
luci.fs.unlink(sessionpath .. "/" .. id)
|
||||
end
|
||||
fs.unlink(sessionpath .. "/" .. id)
|
||||
end
|
||||
|
|
|
@ -24,7 +24,7 @@ limitations under the License.
|
|||
|
||||
]]--
|
||||
|
||||
local fs = require "luci.fs"
|
||||
local fs = require "nixio.fs"
|
||||
local sys = require "luci.sys"
|
||||
local util = require "luci.util"
|
||||
local table = require "table"
|
||||
|
@ -173,18 +173,18 @@ function Template.__init__(self, name)
|
|||
local err
|
||||
|
||||
if compiler_mode == "file" then
|
||||
local tplmt = fs.mtime(sourcefile) or fs.mtime(sourcefile .. ".htm")
|
||||
local commt = fs.mtime(compiledfile)
|
||||
local tplmt = fs.stat(sourcefile, "mtime") or fs.stat(sourcefile .. ".htm", "mtime")
|
||||
local commt = fs.stat(compiledfile, "mtime")
|
||||
|
||||
if not fs.mtime(cdir) then
|
||||
fs.mkdir(cdir, true)
|
||||
fs.mkdirr(cdir)
|
||||
fs.chmod(fs.dirname(cdir), 777)
|
||||
end
|
||||
|
||||
assert(tplmt or commt, "No such template: " .. name)
|
||||
|
||||
-- Build if there is no compiled file or if compiled file is outdated
|
||||
if not commt or (commt and tplmt and commt < tplmt) then
|
||||
if not commt or (commt and tplmt and commt < tplmt) then
|
||||
local source
|
||||
source, err = fs.readfile(sourcefile) or fs.readfile(sourcefile .. ".htm")
|
||||
|
||||
|
|
|
@ -28,14 +28,14 @@ function index()
|
|||
page.order = 40
|
||||
page.index = true
|
||||
|
||||
if luci.fs.access("/etc/config/lucittpd") then
|
||||
if nixio.fs.access("/etc/config/lucittpd") then
|
||||
local page = node("admin", "services", "lucittpd")
|
||||
page.target = cbi("admin_services/lucittpd")
|
||||
page.title = "LuCIttpd"
|
||||
page.order = 10
|
||||
end
|
||||
|
||||
if luci.fs.access("/etc/config/httpd") then
|
||||
if nixio.fs.access("/etc/config/httpd") then
|
||||
local page = node("admin", "services", "httpd")
|
||||
page.target = cbi("admin_services/httpd")
|
||||
page.title = "Busybox HTTPd"
|
||||
|
@ -51,4 +51,4 @@ function index()
|
|||
page.target = cbi("admin_services/dnsmasq")
|
||||
page.title = "Dnsmasq"
|
||||
page.order = 30
|
||||
end
|
||||
end
|
||||
|
|
|
@ -27,7 +27,7 @@ function index()
|
|||
entry({"admin", "system", "processes"}, form("admin_system/processes"), i18n("process_head"), 45)
|
||||
entry({"admin", "system", "fstab"}, cbi("admin_system/fstab"), i18n("a_s_fstab"), 50)
|
||||
|
||||
if luci.fs.isdirectory("/sys/class/leds") then
|
||||
if nixio.fs.access("/sys/class/leds") then
|
||||
entry({"admin", "system", "leds"}, cbi("admin_system/leds"), i18n("leds", "LEDs"), 60)
|
||||
end
|
||||
|
||||
|
@ -124,7 +124,7 @@ function action_packages()
|
|||
|
||||
-- Remove index cache
|
||||
if changes then
|
||||
luci.fs.unlink("/tmp/luci-indexcache")
|
||||
nixio.fs.unlink("/tmp/luci-indexcache")
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -214,7 +214,7 @@ function action_upgrade()
|
|||
|
||||
local function storage_size()
|
||||
local size = 0
|
||||
if luci.fs.access("/proc/mtd") then
|
||||
if nixio.fs.access("/proc/mtd") then
|
||||
for l in io.lines("/proc/mtd") do
|
||||
local d, s, e, n = l:match('^([^%s]+)%s+([^%s]+)%s+([^%s]+)%s+"([^%s]+)"')
|
||||
if n == "linux" then
|
||||
|
@ -222,7 +222,7 @@ function action_upgrade()
|
|||
break
|
||||
end
|
||||
end
|
||||
elseif luci.fs.access("/proc/partitions") then
|
||||
elseif nixio.fs.access("/proc/partitions") then
|
||||
for l in io.lines("/proc/partitions") do
|
||||
local x, y, b, n = l:match('^%s*(%d+)%s+(%d+)%s+([^%s]+)%s+([^%s]+)')
|
||||
if b and n and not n:match('[0-9]') then
|
||||
|
@ -239,7 +239,7 @@ function action_upgrade()
|
|||
local file
|
||||
luci.http.setfilehandler(
|
||||
function(meta, chunk, eof)
|
||||
if not luci.fs.access(tmpfile) and not file and chunk and #chunk > 0 then
|
||||
if not nixio.fs.access(tmpfile) and not file and chunk and #chunk > 0 then
|
||||
file = io.open(tmpfile, "w")
|
||||
end
|
||||
if file and chunk then
|
||||
|
@ -255,9 +255,9 @@ function action_upgrade()
|
|||
-- Determine state
|
||||
local keep_avail = true
|
||||
local step = tonumber(luci.http.formvalue("step") or 1)
|
||||
local has_image = luci.fs.access(tmpfile)
|
||||
local has_image = nixio.fs.access(tmpfile)
|
||||
local has_support = image_supported()
|
||||
local has_platform = luci.fs.access("/lib/upgrade/platform.sh")
|
||||
local has_platform = nixio.fs.access("/lib/upgrade/platform.sh")
|
||||
local has_upload = luci.http.formvalue("image")
|
||||
|
||||
-- This does the actual flashing which is invoked inside an iframe
|
||||
|
@ -298,7 +298,7 @@ function action_upgrade()
|
|||
-- If there is an image but user has requested step 1
|
||||
-- or type is not supported, then remove it.
|
||||
if has_image then
|
||||
luci.fs.unlink(tmpfile)
|
||||
nixio.fs.unlink(tmpfile)
|
||||
end
|
||||
|
||||
luci.template.render("admin_system/upgrade", {
|
||||
|
@ -313,7 +313,7 @@ function action_upgrade()
|
|||
luci.template.render("admin_system/upgrade", {
|
||||
step=2,
|
||||
checksum=image_checksum(),
|
||||
filesize=luci.fs.stat(tmpfile).size,
|
||||
filesize=nixio.fs.stat(tmpfile).size,
|
||||
flashsize=storage_size(),
|
||||
keepconfig=(keep_avail and luci.http.formvalue("keepcfg") == "1")
|
||||
} )
|
||||
|
@ -333,7 +333,7 @@ function _keep_pattern()
|
|||
if files then
|
||||
kpattern = ""
|
||||
for k, v in pairs(files) do
|
||||
if k:sub(1,1) ~= "." and luci.fs.glob(v) then
|
||||
if k:sub(1,1) ~= "." and nixio.fs.glob(v)() then
|
||||
kpattern = kpattern .. " " .. v
|
||||
end
|
||||
end
|
||||
|
|
|
@ -15,6 +15,8 @@ require("luci.config")
|
|||
m = Map("luci", translate("webui"), translate("a_i_luci1",
|
||||
"Hier können Eigenschaften und die Funktionalität der Oberfläche angepasst werden."))
|
||||
|
||||
local fs = require "nixio.fs"
|
||||
|
||||
-- force reload of global luci config namespace to reflect the changes
|
||||
function m.commit_handler(self)
|
||||
package.loaded["luci.config"] = nil
|
||||
|
@ -31,8 +33,8 @@ local i18ndir = luci.i18n.i18ndir .. "default."
|
|||
for k, v in luci.util.kspairs(luci.config.languages) do
|
||||
local file = i18ndir .. k:gsub("_", "-")
|
||||
if k:sub(1, 1) ~= "." and (
|
||||
luci.fs.access(file .. ".lua") or
|
||||
luci.fs.access(file .. ".lua.gz")
|
||||
fs.access(file .. ".lua") or
|
||||
fs.access(file .. ".lua.gz")
|
||||
) then
|
||||
l:value(k, v)
|
||||
end
|
||||
|
|
|
@ -11,17 +11,21 @@ You may obtain a copy of the License at
|
|||
|
||||
$Id$
|
||||
]]--
|
||||
require("luci.sys")
|
||||
require("luci.tools.webadmin")
|
||||
|
||||
local uci = require "luci.model.uci".cursor()
|
||||
local sys = require "luci.sys"
|
||||
local wa = require "luci.tools.webadmin"
|
||||
local fs = require "nixio.fs"
|
||||
|
||||
m2 = Map("luci_ethers", translate("dhcp_leases"))
|
||||
|
||||
local leasefn, leasefp, leases
|
||||
luci.model.uci.cursor():foreach("dhcp", "dnsmasq",
|
||||
uci:foreach("dhcp", "dnsmasq",
|
||||
function(section)
|
||||
leasefn = section.leasefile
|
||||
end
|
||||
)
|
||||
local leasefp = leasefn and luci.fs.access(leasefn) and io.lines(leasefn)
|
||||
local leasefp = leasefn and fs.access(leasefn) and io.lines(leasefn)
|
||||
if leasefp then
|
||||
leases = {}
|
||||
for lease in leasefp do
|
||||
|
@ -38,9 +42,7 @@ if leases then
|
|||
ltime = v:option(DummyValue, 1, translate("dhcp_timeremain"))
|
||||
function ltime.cfgvalue(self, ...)
|
||||
local value = DummyValue.cfgvalue(self, ...)
|
||||
return luci.tools.webadmin.date_format(
|
||||
os.difftime(tonumber(value), os.time())
|
||||
)
|
||||
return wa.date_format(os.difftime(tonumber(value), os.time()))
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -51,11 +53,13 @@ s.template = "cbi/tblsection"
|
|||
|
||||
mac = s:option(Value, "macaddr", translate("macaddress"))
|
||||
ip = s:option(Value, "ipaddr", translate("ipaddress"))
|
||||
for i, dataset in ipairs(luci.sys.net.arptable()) do
|
||||
ip:value(dataset["IP address"])
|
||||
mac:value(dataset["HW address"],
|
||||
dataset["HW address"] .. " (" .. dataset["IP address"] .. ")")
|
||||
end
|
||||
sys.net.arptable(function(entry)
|
||||
ip:value(entry["IP address"])
|
||||
mac:value(
|
||||
entry["HW address"],
|
||||
entry["HW address"] .. " (" .. entry["IP address"] .. ")"
|
||||
)
|
||||
end)
|
||||
|
||||
|
||||
return m2
|
||||
|
|
|
@ -13,14 +13,16 @@ You may obtain a copy of the License at
|
|||
$Id$
|
||||
]]--
|
||||
|
||||
require("luci.tools.webadmin")
|
||||
local wa = require "luci.tools.webadmin"
|
||||
local fs = require "nixio.fs"
|
||||
|
||||
arg[1] = arg[1] or ""
|
||||
|
||||
local has_3g = luci.fs.mtime("/usr/bin/gcom")
|
||||
local has_pptp = luci.fs.mtime("/usr/sbin/pptp")
|
||||
local has_pppd = luci.fs.mtime("/usr/sbin/pppd")
|
||||
local has_pppoe = luci.fs.glob("/usr/lib/pppd/*/rp-pppoe.so")
|
||||
local has_pppoa = luci.fs.glob("/usr/lib/pppd/*/pppoatm.so")
|
||||
local has_3g = fs.access("/usr/bin/gcom")
|
||||
local has_pptp = fs.access("/usr/sbin/pptp")
|
||||
local has_pppd = fs.access("/usr/sbin/pppd")
|
||||
local has_pppoe = fs.glob("/usr/lib/pppd/*/rp-pppoe.so")()
|
||||
local has_pppoa = fs.glob("/usr/lib/pppd/*/pppoatm.so")()
|
||||
|
||||
m = Map("network", translate("interfaces"), translate("a_n_ifaces1"))
|
||||
|
||||
|
@ -64,7 +66,7 @@ for i,d in ipairs(luci.sys.net.devices()) do
|
|||
end
|
||||
end
|
||||
|
||||
local zones = luci.tools.webadmin.network_get_zones(arg[1])
|
||||
local zones = wa.network_get_zones(arg[1])
|
||||
if zones then
|
||||
if #zones == 0 then
|
||||
m:chain("firewall")
|
||||
|
@ -83,7 +85,7 @@ if zones then
|
|||
)
|
||||
|
||||
function fwzone.write(self, section, value)
|
||||
local zone = luci.tools.webadmin.firewall_find_zone(value)
|
||||
local zone = wa.firewall_find_zone(value)
|
||||
local stat
|
||||
|
||||
if not zone then
|
||||
|
|
|
@ -12,14 +12,16 @@ You may obtain a copy of the License at
|
|||
|
||||
$Id$
|
||||
]]--
|
||||
require("luci.sys")
|
||||
require("luci.tools.webadmin")
|
||||
|
||||
local sys = require "luci.sys"
|
||||
local wa = require "luci.tools.webadmin"
|
||||
local fs = require "nixio.fs"
|
||||
|
||||
local netstate = luci.model.uci.cursor_state():get_all("network")
|
||||
m = Map("network", translate("interfaces"))
|
||||
|
||||
local created
|
||||
local netstat = luci.sys.net.deviceinfo()
|
||||
local netstat = sys.net.deviceinfo()
|
||||
|
||||
s = m:section(TypedSection, "interface", "")
|
||||
s.addremove = true
|
||||
|
@ -76,25 +78,22 @@ if luci.model.uci.cursor():load("firewall") then
|
|||
zone.titleref = luci.dispatcher.build_url("admin", "network", "firewall", "zones")
|
||||
|
||||
function zone.cfgvalue(self, section)
|
||||
local zones = luci.tools.webadmin.network_get_zones(section)
|
||||
return zones and table.concat(zones, ", ") or "-"
|
||||
return table.concat(wa.network_get_zones(section) or { "-" }, ", ")
|
||||
end
|
||||
end
|
||||
|
||||
hwaddr = s:option(DummyValue, "_hwaddr")
|
||||
function hwaddr.cfgvalue(self, section)
|
||||
local ix = self.map:get(section, "ifname") or ""
|
||||
return luci.fs.readfile("/sys/class/net/" .. ix .. "/address")
|
||||
return fs.readfile("/sys/class/net/" .. ix .. "/address")
|
||||
or luci.util.exec("ifconfig " .. ix):match(" ([A-F0-9:]+)%s*\n")
|
||||
or "n/a"
|
||||
|
||||
end
|
||||
|
||||
|
||||
ipaddr = s:option(DummyValue, "ipaddr", translate("addresses"))
|
||||
function ipaddr.cfgvalue(self, section)
|
||||
local addr = luci.tools.webadmin.network_get_addresses(section)
|
||||
return table.concat(addr, ", ")
|
||||
return table.concat(wa.network_get_addresses(section), ", ")
|
||||
end
|
||||
|
||||
txrx = s:option(DummyValue, "_txrx")
|
||||
|
@ -103,10 +102,10 @@ function txrx.cfgvalue(self, section)
|
|||
local ix = self.map:get(section, "ifname")
|
||||
|
||||
local rx = netstat and netstat[ix] and netstat[ix][1]
|
||||
rx = rx and luci.tools.webadmin.byte_format(tonumber(rx)) or "-"
|
||||
rx = rx and wa.byte_format(tonumber(rx)) or "-"
|
||||
|
||||
local tx = netstat and netstat[ix] and netstat[ix][9]
|
||||
tx = tx and luci.tools.webadmin.byte_format(tonumber(tx)) or "-"
|
||||
tx = tx and wa.byte_format(tonumber(tx)) or "-"
|
||||
|
||||
return string.format("%s / %s", tx, rx)
|
||||
end
|
||||
|
|
|
@ -11,7 +11,10 @@ You may obtain a copy of the License at
|
|||
|
||||
$Id$
|
||||
]]--
|
||||
require("luci.tools.webadmin")
|
||||
|
||||
local wa = require "luci.tools.webadmin"
|
||||
local fs = require "nixio.fs"
|
||||
|
||||
arg[1] = arg[1] or ""
|
||||
|
||||
m = Map("wireless", translate("networks"), translate("a_w_networks1"))
|
||||
|
@ -143,7 +146,7 @@ network = s:option(Value, "network", translate("network"), translate("a_w_networ
|
|||
network.rmempty = true
|
||||
network:value("")
|
||||
network.combobox_manual = translate("a_w_netmanual")
|
||||
luci.tools.webadmin.cbi_add_networks(network)
|
||||
wa.cbi_add_networks(network)
|
||||
|
||||
function network.write(self, section, value)
|
||||
if not m.uci:get("network", value) then
|
||||
|
@ -173,7 +176,7 @@ bssid = s:option(Value, "bssid", translate("wifi_bssid"))
|
|||
-------------------- MAC80211 Interface ----------------------
|
||||
|
||||
if hwtype == "mac80211" then
|
||||
if luci.fs.mtime("/usr/sbin/iw") then
|
||||
if fs.access("/usr/sbin/iw") then
|
||||
mode:value("mesh", "802.11s")
|
||||
end
|
||||
|
||||
|
@ -322,8 +325,8 @@ encr:value("none", "No Encryption")
|
|||
encr:value("wep", "WEP")
|
||||
|
||||
if hwtype == "atheros" or hwtype == "mac80211" or hwtype == "prism2" then
|
||||
local supplicant = luci.fs.mtime("/usr/sbin/wpa_supplicant")
|
||||
local hostapd = luci.fs.mtime("/usr/sbin/hostapd")
|
||||
local supplicant = fs.access("/usr/sbin/wpa_supplicant")
|
||||
local hostapd = fs.access("/usr/sbin/hostapd")
|
||||
|
||||
if hostapd and supplicant then
|
||||
encr:value("psk", "WPA-PSK")
|
||||
|
|
|
@ -12,6 +12,8 @@ You may obtain a copy of the License at
|
|||
|
||||
$Id$
|
||||
]]--
|
||||
|
||||
local fs = require "nixio.fs"
|
||||
local cronfile = "/etc/crontabs/root"
|
||||
|
||||
f = SimpleForm("crontab", translate("a_s_crontab"), translate("a_s_crontab1"))
|
||||
|
@ -20,13 +22,13 @@ t = f:field(TextValue, "crons")
|
|||
t.rmempty = true
|
||||
t.rows = 10
|
||||
function t.cfgvalue()
|
||||
return luci.fs.readfile(cronfile) or ""
|
||||
return fs.readfile(cronfile) or ""
|
||||
end
|
||||
|
||||
function f.handle(self, state, data)
|
||||
if state == FORM_VALID then
|
||||
if data.crons then
|
||||
luci.fs.writefile(cronfile, data.crons:gsub("\r\n", "\n"))
|
||||
fs.writefile(cronfile, data.crons:gsub("\r\n", "\n"))
|
||||
end
|
||||
end
|
||||
return true
|
||||
|
|
|
@ -13,16 +13,18 @@ $Id$
|
|||
]]--
|
||||
require("luci.tools.webadmin")
|
||||
|
||||
local fs = require "luci.fs"
|
||||
local fs = require "nixio.fs"
|
||||
local util = require "nixio.util"
|
||||
|
||||
local devices = {}
|
||||
luci.util.update(devices, fs.glob("/dev/sd*") or {})
|
||||
luci.util.update(devices, fs.glob("/dev/hd*") or {})
|
||||
luci.util.update(devices, fs.glob("/dev/scd*") or {})
|
||||
luci.util.update(devices, fs.glob("/dev/mmc*") or {})
|
||||
util.consume((fs.glob("/dev/sd*")), devices)
|
||||
util.consume((fs.glob("/dev/hd*")), devices)
|
||||
util.consume((fs.glob("/dev/scd*")), devices)
|
||||
util.consume((fs.glob("/dev/mmc*")), devices)
|
||||
|
||||
local size = {}
|
||||
for i, dev in ipairs(devices) do
|
||||
local s = tonumber((luci.fs.readfile("/sys/class/block/%s/size" % dev:sub(6))))
|
||||
local s = tonumber((fs.readfile("/sys/class/block/%s/size" % dev:sub(6))))
|
||||
size[dev] = s and math.floor(s / 2048)
|
||||
end
|
||||
|
||||
|
|
|
@ -19,11 +19,11 @@ f = SimpleForm("ipkgconf", translate("a_s_p_ipkg"))
|
|||
t = f:field(TextValue, "lines")
|
||||
t.rows = 10
|
||||
function t.cfgvalue()
|
||||
return luci.fs.readfile(ipkgfile) or ""
|
||||
return nixio.fs.readfile(ipkgfile) or ""
|
||||
end
|
||||
|
||||
function t.write(self, section, data)
|
||||
return luci.fs.writefile(ipkgfile, data:gsub("\r\n", "\n"))
|
||||
return nixio.fs.writefile(ipkgfile, data:gsub("\r\n", "\n"))
|
||||
end
|
||||
|
||||
f:append(Template("admin_system/ipkg"))
|
||||
|
|
|
@ -16,12 +16,11 @@ m = Map("system", translate("leds"), translate("leds_desc"))
|
|||
local sysfs_path = "/sys/class/leds/"
|
||||
local leds = {}
|
||||
|
||||
if luci.fs.access(sysfs_path) then
|
||||
for k, v in pairs(luci.fs.dir(sysfs_path)) do
|
||||
if v ~= "." and v ~= ".." then
|
||||
table.insert(leds, v)
|
||||
end
|
||||
end
|
||||
local fs = require "nixio.fs"
|
||||
local util = require "nixio.util"
|
||||
|
||||
if fs.access(sysfs_path) then
|
||||
leds = util.consume((fs.dir(sysfs_path)))
|
||||
end
|
||||
|
||||
if #leds == 0 then
|
||||
|
@ -52,7 +51,7 @@ s:option(Flag, "default").rmempty = true
|
|||
|
||||
trigger = s:option(ListValue, "trigger")
|
||||
|
||||
local triggers = luci.fs.readfile(sysfs_path .. leds[1] .. "/trigger")
|
||||
local triggers = fs.readfile(sysfs_path .. leds[1] .. "/trigger")
|
||||
for t in triggers:gmatch("[%w-]+") do
|
||||
trigger:value(t, translate("system_led_trigger_" .. t:gsub("-", "")))
|
||||
end
|
||||
|
@ -83,4 +82,4 @@ mode:value("link", translate("system_led_mode_link"))
|
|||
mode:value("tx", translate("system_led_mode_tx"))
|
||||
mode:value("rx", translate("system_led_mode_rx"))
|
||||
|
||||
return m
|
||||
return m
|
||||
|
|
|
@ -20,13 +20,13 @@ t = f:field(TextValue, "keys")
|
|||
t.rmempty = true
|
||||
t.rows = 10
|
||||
function t.cfgvalue()
|
||||
return luci.fs.readfile(keyfile) or ""
|
||||
return nixio.fs.readfile(keyfile) or ""
|
||||
end
|
||||
|
||||
function f.handle(self, state, data)
|
||||
if state == FORM_VALID then
|
||||
if data.keys then
|
||||
luci.fs.writefile(keyfile, data.keys:gsub("\r\n", "\n"))
|
||||
nixio.fs.writefile(keyfile, data.keys:gsub("\r\n", "\n"))
|
||||
end
|
||||
end
|
||||
return true
|
||||
|
|
|
@ -15,15 +15,15 @@ $Id$
|
|||
|
||||
<%-
|
||||
|
||||
require "luci.tools.webadmin"
|
||||
|
||||
local wba = luci.tools.webadmin
|
||||
local uci = luci.model.uci.cursor_state()
|
||||
local sys = require "luci.sys"
|
||||
local wba = require "luci.tools.webadmin"
|
||||
local uci = require "luci.model.uci".cursor_state()
|
||||
local fs = require "nixio.fs"
|
||||
|
||||
local bridge_ifs = { }
|
||||
local single_ifs = { }
|
||||
local wifi_ifs = { }
|
||||
local devinfo = luci.sys.net.deviceinfo()
|
||||
local devinfo = sys.net.deviceinfo()
|
||||
|
||||
uci:foreach("network", "interface",
|
||||
function(s)
|
||||
|
@ -86,8 +86,8 @@ $Id$
|
|||
|
||||
function get_switch_driver(i)
|
||||
local n, d = i:match("([a-z]+)(%d+)%.%d+$")
|
||||
local hw = luci.fs.readfile("/proc/switch/%s%s/driver" %{ n, d })
|
||||
or luci.fs.readfile("/proc/switch/%s/driver" % d )
|
||||
local hw = fs.readfile("/proc/switch/%s%s/driver" %{ n, d })
|
||||
or fs.readfile("/proc/switch/%s/driver" % d )
|
||||
|
||||
return hw and hw:match("%S+")
|
||||
end
|
||||
|
|
|
@ -15,9 +15,9 @@ $Id$
|
|||
|
||||
<%-
|
||||
require "bit"
|
||||
require "luci.fs"
|
||||
require "luci.sys"
|
||||
require "luci.tools.webadmin"
|
||||
require "nixio.fs"
|
||||
|
||||
local style = true
|
||||
-%>
|
||||
|
@ -54,7 +54,7 @@ $Id$
|
|||
</fieldset>
|
||||
<br />
|
||||
|
||||
<% if luci.fs.access("/proc/net/ipv6_route") then style = true %>
|
||||
<% if fs.access("/proc/net/ipv6_route") then style = true %>
|
||||
<fieldset class="cbi-section" id="cbi-table-table">
|
||||
<legend><%:a_n_routes_kernel6%></legend>
|
||||
|
||||
|
|
|
@ -98,7 +98,7 @@ function action_upgrade()
|
|||
|
||||
local function storage_size()
|
||||
local size = 0
|
||||
if luci.fs.access("/proc/mtd") then
|
||||
if nixio.fs.access("/proc/mtd") then
|
||||
for l in io.lines("/proc/mtd") do
|
||||
local d, s, e, n = l:match('^([^%s]+)%s+([^%s]+)%s+([^%s]+)%s+"([^%s]+)"')
|
||||
if n == "linux" then
|
||||
|
@ -106,7 +106,7 @@ function action_upgrade()
|
|||
break
|
||||
end
|
||||
end
|
||||
elseif luci.fs.access("/proc/partitions") then
|
||||
elseif nixio.fs.access("/proc/partitions") then
|
||||
for l in io.lines("/proc/partitions") do
|
||||
local x, y, b, n = l:match('^%s*(%d+)%s+(%d+)%s+([^%s]+)%s+([^%s]+)')
|
||||
if b and n and not n:match('[0-9]') then
|
||||
|
@ -123,7 +123,7 @@ function action_upgrade()
|
|||
local file
|
||||
luci.http.setfilehandler(
|
||||
function(meta, chunk, eof)
|
||||
if not luci.fs.access(tmpfile) and not file and chunk and #chunk > 0 then
|
||||
if not nixio.fs.access(tmpfile) and not file and chunk and #chunk > 0 then
|
||||
file = io.open(tmpfile, "w")
|
||||
end
|
||||
if file and chunk then
|
||||
|
@ -139,9 +139,9 @@ function action_upgrade()
|
|||
-- Determine state
|
||||
local keep_avail = true
|
||||
local step = tonumber(luci.http.formvalue("step") or 1)
|
||||
local has_image = luci.fs.access(tmpfile)
|
||||
local has_image = nixio.fs.access(tmpfile)
|
||||
local has_support = image_supported()
|
||||
local has_platform = luci.fs.access("/lib/upgrade/platform.sh")
|
||||
local has_platform = nixio.fs.access("/lib/upgrade/platform.sh")
|
||||
local has_upload = luci.http.formvalue("image")
|
||||
|
||||
-- This does the actual flashing which is invoked inside an iframe
|
||||
|
@ -182,7 +182,7 @@ function action_upgrade()
|
|||
-- If there is an image but user has requested step 1
|
||||
-- or type is not supported, then remove it.
|
||||
if has_image then
|
||||
luci.fs.unlink(tmpfile)
|
||||
nixio.fs.unlink(tmpfile)
|
||||
end
|
||||
|
||||
luci.template.render("admin_system/upgrade", {
|
||||
|
@ -197,7 +197,7 @@ function action_upgrade()
|
|||
luci.template.render("admin_system/upgrade", {
|
||||
step=2,
|
||||
checksum=image_checksum(),
|
||||
filesize=luci.fs.stat(tmpfile).size,
|
||||
filesize=nixio.fs.stat(tmpfile).size,
|
||||
flashsize=storage_size(),
|
||||
keepconfig=(keep_avail and luci.http.formvalue("keepcfg") == "1")
|
||||
} )
|
||||
|
@ -217,7 +217,7 @@ function _keep_pattern()
|
|||
if files then
|
||||
kpattern = ""
|
||||
for k, v in pairs(files) do
|
||||
if k:sub(1,1) ~= "." and luci.fs.glob(v) then
|
||||
if k:sub(1,1) ~= "." and nixio.fs.glob(v)() then
|
||||
kpattern = kpattern .. " " .. v
|
||||
end
|
||||
end
|
||||
|
|
|
@ -12,9 +12,11 @@ You may obtain a copy of the License at
|
|||
|
||||
$Id$
|
||||
]]--
|
||||
require("luci.model.uci")
|
||||
require("luci.sys")
|
||||
require("luci.tools.webadmin")
|
||||
|
||||
local uci = require "luci.model.uci".cursor()
|
||||
local sys = require "luci.sys"
|
||||
local wa = require "luci.tools.webadmin"
|
||||
local fs = require "nixio.fs"
|
||||
|
||||
m = Map("dhcp", "DHCP")
|
||||
|
||||
|
@ -61,12 +63,12 @@ time.rmempty = true
|
|||
m2 = Map("luci_ethers", translate("dhcp_leases"))
|
||||
|
||||
local leasefn, leasefp, leases
|
||||
luci.model.uci.cursor():foreach("dhcp", "dnsmasq",
|
||||
uci:foreach("dhcp", "dnsmasq",
|
||||
function(section)
|
||||
leasefn = section.leasefile
|
||||
end
|
||||
)
|
||||
local leasefp = leasefn and luci.fs.access(leasefn) and io.lines(leasefn)
|
||||
local leasefp = leasefn and fs.access(leasefn) and io.lines(leasefn)
|
||||
if leasefp then
|
||||
leases = {}
|
||||
for lease in leasefp do
|
||||
|
@ -83,9 +85,7 @@ if leases then
|
|||
ltime = v:option(DummyValue, 1, translate("dhcp_timeremain"))
|
||||
function ltime.cfgvalue(self, ...)
|
||||
local value = DummyValue.cfgvalue(self, ...)
|
||||
return luci.tools.webadmin.date_format(
|
||||
os.difftime(tonumber(value), os.time())
|
||||
)
|
||||
return wa.date_format(os.difftime(tonumber(value), os.time()))
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -96,10 +96,12 @@ s.template = "cbi/tblsection"
|
|||
|
||||
mac = s:option(Value, "macaddr", translate("macaddress"))
|
||||
ip = s:option(Value, "ipaddr", translate("ipaddress"))
|
||||
for i, dataset in ipairs(luci.sys.net.arptable()) do
|
||||
ip:value(dataset["IP address"])
|
||||
mac:value(dataset["HW address"],
|
||||
dataset["HW address"] .. " (" .. dataset["IP address"] .. ")")
|
||||
end
|
||||
sys.net.arptable(function(entry)
|
||||
ip:value(entry["IP address"])
|
||||
mac:value(
|
||||
entry["HW address"],
|
||||
entry["HW address"] .. " (" .. entry["IP address"] .. ")"
|
||||
)
|
||||
end)
|
||||
|
||||
return m, m2
|
||||
return m, m2
|
||||
|
|
|
@ -12,13 +12,16 @@ You may obtain a copy of the License at
|
|||
|
||||
$Id$
|
||||
]]--
|
||||
require("luci.config")
|
||||
|
||||
require "luci.config"
|
||||
local fs = require "nixio.fs"
|
||||
|
||||
m = Map("luci", translate("webui"), translate("a_i_luci1"))
|
||||
|
||||
-- force reload of global luci config namespace to reflect the changes
|
||||
function m.commit_handler(self)
|
||||
package.loaded["luci.config"] = nil
|
||||
require("luci.config")
|
||||
require "luci.config"
|
||||
end
|
||||
|
||||
|
||||
|
@ -31,8 +34,8 @@ local i18ndir = luci.i18n.i18ndir .. "default."
|
|||
for k, v in luci.util.kspairs(luci.config.languages) do
|
||||
local file = i18ndir .. k:gsub("_", "-")
|
||||
if k:sub(1, 1) ~= "." and (
|
||||
luci.fs.access(file .. ".lua") or
|
||||
luci.fs.access(file .. ".lua.gz")
|
||||
fs.access(file .. ".lua") or
|
||||
fs.access(file .. ".lua.gz")
|
||||
) then
|
||||
l:value(k, v)
|
||||
end
|
||||
|
|
|
@ -13,16 +13,16 @@ You may obtain a copy of the License at
|
|||
$Id$
|
||||
]]--
|
||||
|
||||
require("luci.tools.webadmin")
|
||||
require("luci.sys")
|
||||
require("luci.fs")
|
||||
local wa = require "luci.tools.webadmin"
|
||||
local sys = require "luci.sys"
|
||||
local fs = require "nixio.fs"
|
||||
|
||||
local has_pptp = luci.fs.mtime("/usr/sbin/pptp")
|
||||
local has_pppoe = luci.fs.glob("/usr/lib/pppd/*/rp-pppoe.so")
|
||||
local has_pptp = fs.access("/usr/sbin/pptp")
|
||||
local has_pppoe = fs.glob("/usr/lib/pppd/*/rp-pppoe.so")()
|
||||
|
||||
local network = luci.model.uci.cursor_state():get_all("network")
|
||||
|
||||
local netstat = luci.sys.net.deviceinfo()
|
||||
local netstat = sys.net.deviceinfo()
|
||||
local ifaces = {}
|
||||
|
||||
for k, v in pairs(network) do
|
||||
|
@ -41,7 +41,7 @@ hwaddr = s:option(DummyValue, "_hwaddr",
|
|||
translate("network_interface_hwaddr"), translate("network_interface_hwaddr_desc"))
|
||||
function hwaddr.cfgvalue(self, section)
|
||||
local ix = self.map:get(section, "ifname") or ""
|
||||
return luci.fs.readfile("/sys/class/net/" .. ix .. "/address")
|
||||
return fs.readfile("/sys/class/net/" .. ix .. "/address")
|
||||
or luci.util.exec("ifconfig " .. ix):match(" ([A-F0-9:]+)%s*\n")
|
||||
or "n/a"
|
||||
end
|
||||
|
@ -59,10 +59,10 @@ function txrx.cfgvalue(self, section)
|
|||
local ix = self.map:get(section, "ifname")
|
||||
|
||||
local rx = netstat and netstat[ix] and netstat[ix][1]
|
||||
rx = rx and luci.tools.webadmin.byte_format(tonumber(rx)) or "-"
|
||||
rx = rx and wa.byte_format(tonumber(rx)) or "-"
|
||||
|
||||
local tx = netstat and netstat[ix] and netstat[ix][9]
|
||||
tx = tx and luci.tools.webadmin.byte_format(tonumber(tx)) or "-"
|
||||
tx = tx and wa.byte_format(tonumber(tx)) or "-"
|
||||
|
||||
return string.format("%s / %s", tx, rx)
|
||||
end
|
||||
|
@ -150,7 +150,7 @@ pwd:depends("proto", "pptp")
|
|||
|
||||
-- Allow user to set MSS correction here if the UCI firewall is installed
|
||||
-- This cures some cancer for providers with pre-war routers
|
||||
if luci.fs.access("/etc/config/firewall") then
|
||||
if fs.access("/etc/config/firewall") then
|
||||
mssfix = s:option(Flag, "_mssfix",
|
||||
translate("m_n_mssfix"), translate("m_n_mssfix_desc"))
|
||||
mssfix.rmempty = false
|
||||
|
|
|
@ -15,7 +15,10 @@ $Id$
|
|||
|
||||
-- Data init --
|
||||
|
||||
local uci = luci.model.uci.cursor()
|
||||
local fs = require "nixio.fs"
|
||||
local sys = require "luci.sys"
|
||||
local uci = require "luci.model.uci".cursor()
|
||||
|
||||
if not uci:get("network", "wan") then
|
||||
uci:section("network", "interface", "wan", {proto="none", ifname=" "})
|
||||
uci:save("network")
|
||||
|
@ -24,7 +27,7 @@ end
|
|||
|
||||
local wlcursor = luci.model.uci.cursor_state()
|
||||
local wireless = wlcursor:get_all("wireless")
|
||||
local wifidata = luci.sys.wifi.getiwconfig()
|
||||
local wifidata = sys.wifi.getiwconfig()
|
||||
local wifidevs = {}
|
||||
local ifaces = {}
|
||||
|
||||
|
@ -99,7 +102,7 @@ function scan.write(self, section)
|
|||
m.autoapply = false
|
||||
t2.render = t2._render
|
||||
local ifname = self.map:get(section, "ifname")
|
||||
luci.util.update(t2.data, luci.sys.wifi.iwscan(ifname))
|
||||
luci.util.update(t2.data, sys.wifi.iwscan(ifname))
|
||||
end
|
||||
|
||||
t2._render = t2.render
|
||||
|
@ -218,8 +221,8 @@ encr:value("none", "No Encryption")
|
|||
encr:value("wep", "WEP")
|
||||
|
||||
if hwtype == "atheros" or hwtype == "mac80211" then
|
||||
local supplicant = luci.fs.mtime("/usr/sbin/wpa_supplicant")
|
||||
local hostapd = luci.fs.mtime("/usr/sbin/hostapd")
|
||||
local supplicant = fs.access("/usr/sbin/wpa_supplicant")
|
||||
local hostapd = fs.access("/usr/sbin/hostapd")
|
||||
|
||||
if hostapd and supplicant then
|
||||
encr:value("psk", "WPA-PSK")
|
||||
|
|
|
@ -56,7 +56,7 @@ function index()
|
|||
|
||||
assign({"freifunk", "olsr"}, {"admin", "status", "olsr"}, "OLSR", 30)
|
||||
|
||||
if luci.fs.access("/etc/config/luci_statistics") then
|
||||
if nixio.fs.access("/etc/config/luci_statistics") then
|
||||
assign({"freifunk", "graph"}, {"admin", "statistics", "graph"}, i18n("stat_statistics", "Statistiken"), 40)
|
||||
end
|
||||
|
||||
|
@ -83,7 +83,7 @@ local function fetch_olsrd()
|
|||
local rawdata = sys.httpget("http://127.0.0.1:2006/")
|
||||
|
||||
if #rawdata == 0 then
|
||||
if luci.fs.access("/proc/net/ipv6_route", "r") then
|
||||
if nixio.fs.access("/proc/net/ipv6_route", "r") then
|
||||
rawdata = sys.httpget("http://[::1]:2006/")
|
||||
if #rawdata == 0 then
|
||||
return nil
|
||||
|
|
|
@ -117,7 +117,7 @@ end
|
|||
function rpc_fs()
|
||||
local util = require "luci.util"
|
||||
local io = require "io"
|
||||
local fs2 = util.clone(require "luci.fs")
|
||||
local fs2 = util.clone(require "nixio.fs")
|
||||
local jsonrpc = require "luci.jsonrpc"
|
||||
local http = require "luci.http"
|
||||
local ltn12 = require "luci.ltn12"
|
||||
|
|
Loading…
Reference in New Issue