2 LuCI - Lua Configuration Interface
4 Copyright 2008 Steven Barth <steven@midlink.org>
5 Copyright 2008 Jo-Philipp Wich <xm@leipzig.freifunk.net>
7 Licensed under the Apache License, Version 2.0 (the "License");
8 you may not use this file except in compliance with the License.
9 You may obtain a copy of the License at
11 http://www.apache.org/licenses/LICENSE-2.0
21 for _, name in ipairs(luci.sys.init.names()) do
22 local index = luci.sys.init.index(name)
23 local enabled = luci.sys.init.enabled(name)
25 inits["%02i.%s" % { index, name }] = {
27 index = tostring(index),
33 m = SimpleForm("initmgr", translate("initmgr"), translate("initmgr_desc"))
36 s = m:section(Table, inits)
38 i = s:option(DummyValue, "index", translate("initmgr_index"))
39 n = s:option(DummyValue, "name", translate("initmgr_name"))
41 e = s:option(Flag, "enabled", translate("initmgr_enabled"))
43 e.cfgvalue = function(self, section)
44 return inits[section].enabled and "1" or "0"
47 e.write = function(self, section, value)
48 if value == "1" and not inits[section].enabled then
49 inits[section].enabled = true
50 return luci.sys.init.enable(inits[section].name)
51 elseif value == "0" and inits[section].enabled then
52 inits[section].enabled = false
53 return luci.sys.init.disable(inits[section].name)