luci-mod-admin-full: switch to nixio.fs
[project/luci.git] / modules / luci-mod-admin-full / luasrc / model / cbi / admin_system / startup.lua
index fc35f77..e5dcbbf 100644 (file)
@@ -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