module("luci.controller.admin.system", package.seeall)
function index()
+ local fs = require "nixio.fs"
+
entry({"admin", "system"}, alias("admin", "system", "system"), _("System"), 30).index = true
entry({"admin", "system", "system"}, cbi("admin_system/system"), _("System"), 1)
entry({"admin", "system", "clock_status"}, call("action_clock_status"))
entry({"admin", "system", "admin"}, cbi("admin_system/admin"), _("Administration"), 2)
- if nixio.fs.access("/bin/opkg") then
+ if fs.access("/bin/opkg") then
entry({"admin", "system", "packages"}, call("action_packages"), _("Software"), 10)
entry({"admin", "system", "packages", "ipkg"}, form("admin_system/ipkg"))
end
entry({"admin", "system", "startup"}, form("admin_system/startup"), _("Startup"), 45)
entry({"admin", "system", "crontab"}, form("admin_system/crontab"), _("Scheduled Tasks"), 46)
- if nixio.fs.access("/etc/config/fstab") then
+ if fs.access("/etc/config/fstab") then
entry({"admin", "system", "fstab"}, cbi("admin_system/fstab"), _("Mount Points"), 50)
entry({"admin", "system", "fstab", "mount"}, cbi("admin_system/fstab/mount"), nil).leaf = true
entry({"admin", "system", "fstab", "swap"}, cbi("admin_system/fstab/swap"), nil).leaf = true
end
- if nixio.fs.access("/sys/class/leds") then
+ if fs.access("/sys/class/leds") then
entry({"admin", "system", "leds"}, cbi("admin_system/leds"), _("<abbr title=\"Light Emitting Diode\">LED</abbr> Configuration"), 60)
end
-- List state
local no_lists = true
local old_lists = false
- local tmp = nixio.fs.dir("/var/opkg-lists/")
- if tmp then
- for tmp in tmp do
+ if fs.access("/var/opkg-lists/") then
+ local list
+ for list in fs.dir("/var/opkg-lists/") do
no_lists = false
- tmp = nixio.fs.stat("/var/opkg-lists/"..tmp)
- if tmp and tmp.mtime < (os.time() - (24 * 60 * 60)) then
+ if (fs.stat("/var/opkg-lists/"..list, "mtime") or 0) < (os.time() - (24 * 60 * 60)) then
old_lists = true
break
end
-- Remove index cache
if changes then
- nixio.fs.unlink("/tmp/luci-indexcache")
+ fs.unlink("/tmp/luci-indexcache")
end
end
function action_flashops()
local sys = require "luci.sys"
- local fs = require "luci.fs"
+ local fs = require "nixio.fs"
- local upgrade_avail = nixio.fs.access("/lib/upgrade/platform.sh")
+ local upgrade_avail = fs.access("/lib/upgrade/platform.sh")
local reset_avail = os.execute([[grep '"rootfs_data"' /proc/mtd >/dev/null 2>&1]]) == 0
local restore_cmd = "tar -xzC/ >/dev/null 2>&1"
local function storage_size()
local size = 0
- if nixio.fs.access("/proc/mtd") then
+ if 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" or n == "firmware" then
break
end
end
- elseif nixio.fs.access("/proc/partitions") then
+ elseif 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
luci.template.render("admin_system/upgrade", {
checksum = image_checksum(),
storage = storage_size(),
- size = nixio.fs.stat(image_tmp).size,
+ size = (fs.stat(image_tmp, "size") or 0),
keep = (not not luci.http.formvalue("keep"))
})
else
- nixio.fs.unlink(image_tmp)
+ fs.unlink(image_tmp)
luci.template.render("admin_system/flashops", {
reset_avail = reset_avail,
upgrade_avail = upgrade_avail,
$Id$
]]--
-require "luci.fs"
-require "luci.sys"
-require "luci.util"
+local fs = require "nixio.fs"
+local sys = require "luci.sys"
local inits = { }
-for _, name in ipairs(luci.sys.init.names()) do
- local index = luci.sys.init.index(name)
- local enabled = luci.sys.init.enabled(name)
+for _, name in ipairs(sys.init.names()) do
+ local index = sys.init.index(name)
+ local enabled = sys.init.enabled(name)
if index < 255 then
inits["%02i.%s" % { index, name }] = {
e.write = function(self, section)
if inits[section].enabled then
inits[section].enabled = false
- return luci.sys.init.disable(inits[section].name)
+ return sys.init.disable(inits[section].name)
else
inits[section].enabled = true
- return luci.sys.init.enable(inits[section].name)
+ return sys.init.enable(inits[section].name)
end
end
start = s:option(Button, "start", translate("Start"))
start.inputstyle = "apply"
start.write = function(self, section)
- luci.sys.call("/etc/init.d/%s %s >/dev/null" %{ inits[section].name, self.option })
+ sys.call("/etc/init.d/%s %s >/dev/null" %{ inits[section].name, self.option })
end
restart = s:option(Button, "restart", translate("Restart"))
t.rows = 20
function t.cfgvalue()
- return luci.fs.readfile("/etc/rc.local") or ""
+ return fs.readfile("/etc/rc.local") or ""
end
function f.handle(self, state, data)
if state == FORM_VALID then
if data.rcs then
- luci.fs.writefile("/etc/rc.local", data.rcs:gsub("\r\n", "\n"))
+ fs.writefile("/etc/rc.local", data.rcs:gsub("\r\n", "\n"))
end
end
return true
$Id$
]]--
-require("luci.sys")
-require("luci.sys.zoneinfo")
-require("luci.tools.webadmin")
-require("luci.fs")
-require("luci.config")
+local sys = require "luci.sys"
+local zones = require "luci.sys.zoneinfo"
+local fs = require "nixio.fs"
+local conf = require "luci.config"
local m, s, o
-local has_ntpd = luci.fs.access("/usr/sbin/ntpd")
+local has_ntpd = fs.access("/usr/sbin/ntpd")
m = Map("system", translate("System"), translate("Here you can configure the basic aspects of your device like its hostname or the timezone."))
m:chain("luci")
function o.write(self, section, value)
Value.write(self, section, value)
- luci.sys.hostname(value)
+ sys.hostname(value)
end
o = s:taboption("general", ListValue, "zonename", translate("Timezone"))
o:value("UTC")
-for i, zone in ipairs(luci.sys.zoneinfo.TZ) do
+for i, zone in ipairs(zones.TZ) do
o:value(zone[1])
end
function o.write(self, section, value)
local function lookup_zone(title)
- for _, zone in ipairs(luci.sys.zoneinfo.TZ) do
+ for _, zone in ipairs(zones.TZ) do
if zone[1] == title then return zone[2] end
end
end
AbstractValue.write(self, section, value)
local timezone = lookup_zone(value) or "GMT0"
self.map.uci:set("system", section, "timezone", timezone)
- luci.fs.writefile("/etc/TZ", timezone .. "\n")
+ fs.writefile("/etc/TZ", timezone .. "\n")
end
o:value("auto")
local i18ndir = luci.i18n.i18ndir .. "base."
-for k, v in luci.util.kspairs(luci.config.languages) do
+for k, v in luci.util.kspairs(conf.languages) do
local file = i18ndir .. k:gsub("_", "-")
- if k:sub(1, 1) ~= "." and luci.fs.access(file .. ".lmo") then
+ if k:sub(1, 1) ~= "." and fs.access(file .. ".lmo") then
o:value(k, v)
end
end
o = s:taboption("language", ListValue, "_mediaurlbase", translate("Design"))
-for k, v in pairs(luci.config.themes) do
+for k, v in pairs(conf.themes) do
if k:sub(1, 1) ~= "." then
o:value(v, k)
end
o.rmempty = false
function o.cfgvalue(self)
- return luci.sys.init.enabled("sysntpd")
+ return sys.init.enabled("sysntpd")
and self.enabled or self.disabled
end
function o.write(self, section, value)
if value == self.enabled then
- luci.sys.init.enable("sysntpd")
- luci.sys.call("env -i /etc/init.d/sysntpd start >/dev/null")
+ sys.init.enable("sysntpd")
+ sys.call("env -i /etc/init.d/sysntpd start >/dev/null")
else
- luci.sys.call("env -i /etc/init.d/sysntpd stop >/dev/null")
- luci.sys.init.disable("sysntpd")
+ sys.call("env -i /etc/init.d/sysntpd stop >/dev/null")
+ sys.init.disable("sysntpd")
end
end
<%-
local sys = require "luci.sys"
- local fs = require "luci.fs"
+ local fs = require "nixio.fs"
local utl = require "luci.util"
local uci = require "luci.model.uci".cursor()
local ntm = require "luci.model.network"
return translate("Hermes 802.11b Wireless Controller")
-- hostap
- elseif name == "wlan" and fs.isdirectory("/proc/net/hostap/" .. ifname) then
+ elseif name == "wlan" and fs.stat("/proc/net/hostap/" .. ifname, "type") == "dir" then
return translate("Prism2/2.5/3 802.11b Wireless Controller")
-- dunno yet
-%>
<%
- require "luci.fs"
- require "luci.tools.status"
+ local fs = require "nixio.fs"
+ local util = require "luci.util"
+ local stat = require "luci.tools.status"
- local has_ipv6 = luci.fs.access("/proc/net/ipv6_route")
- local has_dhcp = luci.fs.access("/etc/config/dhcp")
- local has_wifi = luci.fs.stat("/etc/config/wireless")
- has_wifi = has_wifi and has_wifi.size > 0
+ local has_ipv6 = fs.access("/proc/net/ipv6_route")
+ local has_dhcp = fs.access("/etc/config/dhcp")
+ local has_wifi = ((fs.stat("/etc/config/wireless", "size") or 0) > 0)
local sysinfo = luci.util.ubus("system", "info") or { }
local boardinfo = luci.util.ubus("system", "board") or { }
free = 0
}
- local has_dsl = luci.fs.stat("/etc/init.d/dsl_control")
+ local has_dsl = fs.access("/etc/init.d/dsl_control")
if luci.http.formvalue("status") == "1" then
local ntm = require "luci.model.network".init()
swap = swapinfo,
connmax = conn_max,
conncount = conn_count,
- leases = luci.tools.status.dhcp_leases(),
- leases6 = luci.tools.status.dhcp6_leases(),
- wifinets = luci.tools.status.wifi_networks()
+ leases = stat.dhcp_leases(),
+ leases6 = stat.dhcp6_leases(),
+ wifinets = stat.wifi_networks()
}
if wan then
<% end %>
<%-
- require "luci.util"
- require "nixio.fs"
-
- local plugins = nixio.fs.dir(luci.util.libpath() .. "/view/admin_status/index")
- if plugins then
+ local incdir = util.libpath() .. "/view/admin_status/index/"
+ if fs.access(incdir) then
local inc
- for inc in plugins do
+ for inc in fs.dir(incdir) do
if inc:match("%.htm$") then
include("admin_status/index/" .. inc:gsub("%.htm$", ""))
end
<%-
require "luci.sys.iptparser"
- require "luci.tools.webadmin"
- require "luci.fs"
+ local wba = require "luci.tools.webadmin"
+ local fs = require "nixio.fs"
- local has_ip6tables = luci.fs.access("/usr/sbin/ip6tables")
+ local has_ip6tables = fs.access("/usr/sbin/ip6tables")
local mode = 4
if has_ip6tables then
end
local ipt = luci.sys.iptparser.IptParser(mode)
- local wba = luci.tools.webadmin
local rowcnt = 1
function rowstyle()