summaryrefslogtreecommitdiffhomepage
path: root/applications/luci-initmgr/luasrc
diff options
context:
space:
mode:
authorJo-Philipp Wich <jow@openwrt.org>2010-03-08 19:05:34 +0000
committerJo-Philipp Wich <jow@openwrt.org>2010-03-08 19:05:34 +0000
commitde585fe48424a9d62cea08b1c27e36d706367d08 (patch)
treef22e84a7bd8aa2375a1861fc24d8cdd5df082cde /applications/luci-initmgr/luasrc
parent7b276a5f4861da8e2e6692b5afa648d6dff1c5bb (diff)
applications/luci-initmgr: add start/stop/reload actions, move to services menu
Diffstat (limited to 'applications/luci-initmgr/luasrc')
-rw-r--r--applications/luci-initmgr/luasrc/controller/init.lua4
-rw-r--r--applications/luci-initmgr/luasrc/model/cbi/init/init.lua45
2 files changed, 37 insertions, 12 deletions
diff --git a/applications/luci-initmgr/luasrc/controller/init.lua b/applications/luci-initmgr/luasrc/controller/init.lua
index 3ff9ed0c0..277e95c9d 100644
--- a/applications/luci-initmgr/luasrc/controller/init.lua
+++ b/applications/luci-initmgr/luasrc/controller/init.lua
@@ -23,7 +23,7 @@ function index()
luci.i18n.loadc("initmgr")
entry(
- {"admin", "system", "init"}, form("init/init"),
- luci.i18n.translate("Initscripts")
+ {"admin", "services", "init"}, form("init/init"),
+ luci.i18n.translate("Initscripts"), 0
).i18n = "initmgr"
end
diff --git a/applications/luci-initmgr/luasrc/model/cbi/init/init.lua b/applications/luci-initmgr/luasrc/model/cbi/init/init.lua
index 9773d9b45..d988b3a33 100644
--- a/applications/luci-initmgr/luasrc/model/cbi/init/init.lua
+++ b/applications/luci-initmgr/luasrc/model/cbi/init/init.lua
@@ -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.reset = false
+m.submit = false
+
s = m:section(Table, inits)
i = s:option(DummyValue, "index", translate("Start priority"))
n = s:option(DummyValue, "name", translate("Initscript"))
-e = s:option(Flag, "enabled", translate("initmgr_enabled"))
-e.rmempty = false
-e.cfgvalue = function(self, section)
- return inits[section].enabled and "1" or "0"
+e = s:option(Button, "endisable", translate("Enable/Disable"))
+
+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
+
+ Button.render(self, section, scope)
end
-e.write = function(self, section, value)
- if value == "1" and not inits[section].enabled then
- inits[section].enabled = true
- return luci.sys.init.enable(inits[section].name)
- elseif value == "0" and inits[section].enabled then
+e.write = function(self, section)
+ if inits[section].enabled then
inits[section].enabled = false
return luci.sys.init.disable(inits[section].name)
+ else
+ inits[section].enabled = true
+ return luci.sys.init.enable(inits[section].name)
end
- return true
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