applications/luci-initmgr: add start/stop/reload actions, move to services menu

This commit is contained in:
Jo-Philipp Wich 2010-03-08 19:05:34 +00:00
parent 7b276a5f48
commit de585fe484
2 changed files with 37 additions and 12 deletions

View file

@ -23,7 +23,7 @@ function index()
luci.i18n.loadc("initmgr") luci.i18n.loadc("initmgr")
entry( entry(
{"admin", "system", "init"}, form("init/init"), {"admin", "services", "init"}, form("init/init"),
luci.i18n.translate("Initscripts") luci.i18n.translate("Initscripts"), 0
).i18n = "initmgr" ).i18n = "initmgr"
end end

View file

@ -32,28 +32,53 @@ end
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>")) 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>"))
m.reset = false m.reset = false
m.submit = false
s = m:section(Table, inits) s = m:section(Table, inits)
i = s:option(DummyValue, "index", translate("Start priority")) i = s:option(DummyValue, "index", translate("Start priority"))
n = s:option(DummyValue, "name", translate("Initscript")) n = s:option(DummyValue, "name", translate("Initscript"))
e = s:option(Flag, "enabled", translate("initmgr_enabled"))
e.rmempty = false
e.cfgvalue = function(self, section) e = s:option(Button, "endisable", translate("Enable/Disable"))
return inits[section].enabled and "1" or "0"
e.render = function(self, section, scope)
if inits[section].enabled then
self.title = translate("Enabled")
self.inputstyle = "save"
else
self.title = translate("Disabled")
self.inputstyle = "reset"
end end
e.write = function(self, section, value) Button.render(self, section, scope)
if value == "1" and not inits[section].enabled then end
inits[section].enabled = true
return luci.sys.init.enable(inits[section].name) e.write = function(self, section)
elseif value == "0" and inits[section].enabled then if inits[section].enabled then
inits[section].enabled = false inits[section].enabled = false
return luci.sys.init.disable(inits[section].name) return luci.sys.init.disable(inits[section].name)
else
inits[section].enabled = true
return luci.sys.init.enable(inits[section].name)
end end
return true
end end
start = s:option(Button, "start", translate("Start"))
start.inputstyle = "apply"
start.write = function(self, section)
luci.sys.call("/etc/init.d/%s %s" %{ inits[section].name, self.option })
end
restart = s:option(Button, "restart", translate("Restart"))
restart.inputstyle = "reload"
restart.write = start.write
stop = s:option(Button, "stop", translate("Stop"))
stop.inputstyle = "remove"
stop.write = start.write
return m return m