2 LuCI - Lua Configuration Interface
4 Copyright 2008 Steven Barth <steven@midlink.org>
5 Copyright 2010-2011 Jo-Philipp Wich <xm@subsignal.org>
6 Copyright 2010 Manuel Munz <freifunk at somakoma dot de>
8 Licensed under the Apache License, Version 2.0 (the "License");
9 you may not use this file except in compliance with the License.
10 You may obtain a copy of the License at
12 http://www.apache.org/licenses/LICENSE-2.0
23 for _, name in ipairs(luci.sys.init.names()) do
24 local index = luci.sys.init.index(name)
25 local enabled = luci.sys.init.enabled(name)
27 inits["%02i.%s" % { index, name }] = {
29 index = tostring(index),
35 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>"))
40 s = m:section(Table, inits)
42 i = s:option(DummyValue, "index", translate("Start priority"))
43 n = s:option(DummyValue, "name", translate("Initscript"))
46 e = s:option(Button, "endisable", translate("Enable/Disable"))
48 e.render = function(self, section, scope)
49 if inits[section].enabled then
50 self.title = translate("Enabled")
51 self.inputstyle = "save"
53 self.title = translate("Disabled")
54 self.inputstyle = "reset"
57 Button.render(self, section, scope)
60 e.write = function(self, section)
61 if inits[section].enabled then
62 inits[section].enabled = false
63 return luci.sys.init.disable(inits[section].name)
65 inits[section].enabled = true
66 return luci.sys.init.enable(inits[section].name)
71 start = s:option(Button, "start", translate("Start"))
72 start.inputstyle = "apply"
73 start.write = function(self, section)
74 luci.sys.call("/etc/init.d/%s %s" %{ inits[section].name, self.option })
77 restart = s:option(Button, "restart", translate("Restart"))
78 restart.inputstyle = "reload"
79 restart.write = start.write
81 stop = s:option(Button, "stop", translate("Stop"))
82 stop.inputstyle = "remove"
83 stop.write = start.write
87 f = SimpleForm("rc", translate("Local Startup"),
88 translate("This is the content of /etc/rc.local. Insert your own commands here (in front of 'exit 0') to execute them at the end of the boot process."))
90 t = f:field(TextValue, "rcs")
95 return luci.fs.readfile("/etc/rc.local") or ""
98 function f.handle(self, state, data)
99 if state == FORM_VALID then
101 luci.fs.writefile("/etc/rc.local", data.rcs:gsub("\r\n", "\n"))