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("Initscripts"), translate("You can enable or disable installed init scripts here. Changes will applied after a device reboot.<br /><strong>Warning: If you disable essential init scripts like \"network\", your device might become inaccesable!</strong>"))
38 s = m:section(Table, inits)
40 i = s:option(DummyValue, "index", translate("Start priority"))
41 n = s:option(DummyValue, "name", translate("Initscript"))
44 e = s:option(Button, "endisable", translate("Enable/Disable"))
46 e.render = function(self, section, scope)
47 if inits[section].enabled then
48 self.title = translate("Enabled")
49 self.inputstyle = "save"
51 self.title = translate("Disabled")
52 self.inputstyle = "reset"
55 Button.render(self, section, scope)
58 e.write = function(self, section)
59 if inits[section].enabled then
60 inits[section].enabled = false
61 return luci.sys.init.disable(inits[section].name)
63 inits[section].enabled = true
64 return luci.sys.init.enable(inits[section].name)
69 start = s:option(Button, "start", translate("Start"))
70 start.inputstyle = "apply"
71 start.write = function(self, section)
72 luci.sys.call("/etc/init.d/%s %s" %{ inits[section].name, self.option })
75 restart = s:option(Button, "restart", translate("Restart"))
76 restart.inputstyle = "reload"
77 restart.write = start.write
79 stop = s:option(Button, "stop", translate("Stop"))
80 stop.inputstyle = "remove"
81 stop.write = start.write