diff options
author | Jo-Philipp Wich <jow@openwrt.org> | 2015-01-15 15:37:46 +0100 |
---|---|---|
committer | Jo-Philipp Wich <jow@openwrt.org> | 2015-01-15 15:37:46 +0100 |
commit | b7f80a98d8b78e259648d820912b7c2338529e0a (patch) | |
tree | c399b203a293f5351d0135f96259a54f6314adb3 /modules/luci-mod-admin-full/luasrc/model/cbi | |
parent | 9780ee382e72f8a5fb69e337a3fcc51fc0914883 (diff) |
luci-mod-admin-full: switch to nixio.fs
Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
Diffstat (limited to 'modules/luci-mod-admin-full/luasrc/model/cbi')
-rw-r--r-- | modules/luci-mod-admin-full/luasrc/model/cbi/admin_system/startup.lua | 21 | ||||
-rw-r--r-- | modules/luci-mod-admin-full/luasrc/model/cbi/admin_system/system.lua | 35 |
2 files changed, 27 insertions, 29 deletions
diff --git a/modules/luci-mod-admin-full/luasrc/model/cbi/admin_system/startup.lua b/modules/luci-mod-admin-full/luasrc/model/cbi/admin_system/startup.lua index fc35f774a9..e5dcbbf233 100644 --- a/modules/luci-mod-admin-full/luasrc/model/cbi/admin_system/startup.lua +++ b/modules/luci-mod-admin-full/luasrc/model/cbi/admin_system/startup.lua @@ -14,15 +14,14 @@ You may obtain a copy of the License at $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 }] = { @@ -62,10 +61,10 @@ end 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 @@ -73,7 +72,7 @@ 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")) @@ -94,13 +93,13 @@ t.rmempty = true 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 diff --git a/modules/luci-mod-admin-full/luasrc/model/cbi/admin_system/system.lua b/modules/luci-mod-admin-full/luasrc/model/cbi/admin_system/system.lua index 5e82289bd8..21bdea3436 100644 --- a/modules/luci-mod-admin-full/luasrc/model/cbi/admin_system/system.lua +++ b/modules/luci-mod-admin-full/luasrc/model/cbi/admin_system/system.lua @@ -13,14 +13,13 @@ You may obtain a copy of the License at $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") @@ -48,20 +47,20 @@ o.datatype = "hostname" 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 @@ -69,7 +68,7 @@ function o.write(self, section, value) 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 @@ -117,9 +116,9 @@ o = s:taboption("language", ListValue, "_lang", translate("Language")) 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 @@ -134,7 +133,7 @@ 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 @@ -196,17 +195,17 @@ if has_ntpd then 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 |