From: Jo-Philipp Wich Date: Mon, 6 Oct 2008 20:09:06 +0000 (+0000) Subject: * luci-0.8: backport luci-app-initmgr X-Git-Tag: 0.8.0~12 X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=9a02c8634e9aaff78c14c5c71f7edbae917ddb05;p=project%2Fluci.git * luci-0.8: backport luci-app-initmgr --- diff --git a/applications/luci-initmgr/Makefile b/applications/luci-initmgr/Makefile new file mode 100644 index 0000000000..81a96f6a83 --- /dev/null +++ b/applications/luci-initmgr/Makefile @@ -0,0 +1,2 @@ +include ../../build/config.mk +include ../../build/module.mk \ No newline at end of file diff --git a/applications/luci-initmgr/luasrc/controller/init.lua b/applications/luci-initmgr/luasrc/controller/init.lua new file mode 100644 index 0000000000..aecf6c1863 --- /dev/null +++ b/applications/luci-initmgr/luasrc/controller/init.lua @@ -0,0 +1,29 @@ +--[[ +LuCI - Lua Configuration Interface + +Copyright 2008 Steven Barth +Copyright 2008 Jo-Philipp Wich + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +$Id$ +]]-- +module("luci.controller.init", package.seeall) + +function index() + if not luci.fs.isfile("/etc/rc.common") then + return + end + + require("luci.i18n") + luci.i18n.loadc("initmgr") + + entry( + {"admin", "system", "init"}, form("init/init"), + luci.i18n.translate("initmgr", "Init Scripts") + ).i18n = "initmgr" +end diff --git a/applications/luci-initmgr/luasrc/i18n/initmgr.de.lua b/applications/luci-initmgr/luasrc/i18n/initmgr.de.lua new file mode 100644 index 0000000000..13b6a4a8c1 --- /dev/null +++ b/applications/luci-initmgr/luasrc/i18n/initmgr.de.lua @@ -0,0 +1,5 @@ +initmgr = 'Startscripte' +initmgr_desc = 'Hier können installierte Startscripte aktiviert oder deaktiviert werden. Änderungen werden erst mit einem Geräteneustart angewendet.
Warnung: Wenn essentialle Startscripte wie "network" deaktiviert werden könnte das Gerät unerreichbar werden!' +initmgr_index = 'Startpriorität' +initmgr_name = 'Startscript' +initmgr_enabled = 'Aktivieren/Deaktivieren' diff --git a/applications/luci-initmgr/luasrc/i18n/initmgr.de.xml b/applications/luci-initmgr/luasrc/i18n/initmgr.de.xml new file mode 100644 index 0000000000..955ec11de5 --- /dev/null +++ b/applications/luci-initmgr/luasrc/i18n/initmgr.de.xml @@ -0,0 +1,11 @@ + + + + +Startscripte +Hier können installierte Startscripte aktiviert oder deaktiviert werden. Änderungen werden erst mit einem Geräteneustart angewendet.
Warnung: Wenn essentialle Startscripte wie "network" deaktiviert werden könnte das Gerät unerreichbar werden!
+Startpriorität +Startscript +Aktivieren/Deaktivieren + +
diff --git a/applications/luci-initmgr/luasrc/i18n/initmgr.en.lua b/applications/luci-initmgr/luasrc/i18n/initmgr.en.lua new file mode 100644 index 0000000000..6e6da7b814 --- /dev/null +++ b/applications/luci-initmgr/luasrc/i18n/initmgr.en.lua @@ -0,0 +1,5 @@ +initmgr = 'Initscripts' +initmgr_desc = 'You can enable or disable installed init scripts here. Changes will applied after a device reboot.
Warning: If you disable essential init scripts like "network", your device might become inaccesable!' +initmgr_index = 'Start priority' +initmgr_name = 'Initscript' +initmgr_enabled = 'Enable/Disable' diff --git a/applications/luci-initmgr/luasrc/i18n/initmgr.en.xml b/applications/luci-initmgr/luasrc/i18n/initmgr.en.xml new file mode 100644 index 0000000000..49a0d7b5a9 --- /dev/null +++ b/applications/luci-initmgr/luasrc/i18n/initmgr.en.xml @@ -0,0 +1,11 @@ + + + + +Initscripts +You can enable or disable installed init scripts here. Changes will applied after a device reboot.
Warning: If you disable essential init scripts like "network", your device might become inaccesable!
+Start priority +Initscript +Enable/Disable + +
diff --git a/applications/luci-initmgr/luasrc/i18n/initmgr.pt-br.lua b/applications/luci-initmgr/luasrc/i18n/initmgr.pt-br.lua new file mode 100644 index 0000000000..9831948b6c --- /dev/null +++ b/applications/luci-initmgr/luasrc/i18n/initmgr.pt-br.lua @@ -0,0 +1,5 @@ +initmgr = 'Scripts de Inicialização' +initmgr_desc = 'Você pode ativar ou desativar os scripts de inicialização instalados aqui. As mudanças serão aplicadas após a reinicialização do equipamento.
Aviso: Se você desativar algum script de inicialização essencial "rede/network", o dispositivo poderá tornar-se inacessível!' +initmgr_index = 'Prioridade de inicialização' +initmgr_name = 'Script de inicialização' +initmgr_enabled = 'Ativar/Desativar' diff --git a/applications/luci-initmgr/luasrc/i18n/initmgr.pt-br.xml b/applications/luci-initmgr/luasrc/i18n/initmgr.pt-br.xml new file mode 100644 index 0000000000..cf3c937b85 --- /dev/null +++ b/applications/luci-initmgr/luasrc/i18n/initmgr.pt-br.xml @@ -0,0 +1,11 @@ + + + + +Scripts de Inicialização +Você pode ativar ou desativar os scripts de inicialização instalados aqui. As mudanças serão aplicadas após a reinicialização do equipamento.
Aviso: Se você desativar algum script de inicialização essencial como por exemplo "rede/network", o dispositivo poderá tornar-se inacessível!
+Prioridade de inicialização +Script de inicialização +Ativar/Desativar + +
diff --git a/applications/luci-initmgr/luasrc/model/cbi/init/init.lua b/applications/luci-initmgr/luasrc/model/cbi/init/init.lua new file mode 100644 index 0000000000..1fdc32bcaa --- /dev/null +++ b/applications/luci-initmgr/luasrc/model/cbi/init/init.lua @@ -0,0 +1,58 @@ +--[[ +LuCI - Lua Configuration Interface + +Copyright 2008 Steven Barth +Copyright 2008 Jo-Philipp Wich + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +$Id$ +]]-- + +require("luci.sys") +require("luci.util") + +local inits = { } + +for _, name in ipairs(luci.sys.init.names()) do + local index = luci.sys.init.index(name) + local enabled = luci.sys.init.enabled(name) + + inits["%02i.%s" % { index, name }] = { + name = name, + index = tostring(index), + enabled = enabled + } +end + + +m = SimpleForm("initmgr", translate("initmgr"), translate("initmgr_desc")) +m.reset = false + +s = m:section(Table, inits) + +i = s:option(DummyValue, "index", translate("initmgr_index")) +n = s:option(DummyValue, "name", translate("initmgr_name")) + +e = s:option(Flag, "enabled", translate("initmgr_enabled")) + +e.cfgvalue = function(self, section) + return inits[section].enabled and "1" or "0" +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 + inits[section].enabled = false + return luci.sys.init.disable(inits[section].name) + end + return true +end + +return m diff --git a/contrib/package/luci/Makefile b/contrib/package/luci/Makefile index 23eefa6f05..1c8bef6091 100644 --- a/contrib/package/luci/Makefile +++ b/contrib/package/luci/Makefile @@ -418,6 +418,16 @@ define Package/luci-app-tinyproxy/install $(call Package/luci/install/template,$(1),applications/luci-tinyproxy) endef +define Package/luci-app-initmgr + $(call Package/luci/webtemplate) + DEPENDS+=+luci-admin-full + TITLE:=LuCI Initscript Management +endef + +define Package/luci-app-initmgr/install + $(call Package/luci/install/template,$(1),applications/luci-initmgr) +endef + ### Server Gateway Interfaces ### @@ -587,6 +597,9 @@ endif ifneq ($(CONFIG_PACKAGE_luci-app-tinyproxy),) PKG_SELECTED_MODULES+=applications/luci-tinyproxy endif +ifneq ($(CONFIG_PACKAGE_luci-app-initmgr),) + PKG_SELECTED_MODULES+=applications/luci-initmgr +endif ifneq ($(CONFIG_PACKAGE_luci-sgi-cgi),) @@ -655,6 +668,7 @@ $(eval $(call BuildPackage,luci-app-p910nd)) $(eval $(call BuildPackage,luci-app-ushare)) $(eval $(call BuildPackage,luci-app-hd_idle)) $(eval $(call BuildPackage,luci-app-tinyproxy)) +$(eval $(call BuildPackage,luci-app-initmgr)) $(eval $(call BuildPackage,luci-sgi-cgi)) diff --git a/libs/sys/luasrc/sys.lua b/libs/sys/luasrc/sys.lua index 230201d829..96690d2976 100644 --- a/libs/sys/luasrc/sys.lua +++ b/libs/sys/luasrc/sys.lua @@ -559,7 +559,7 @@ end -- @return Numeric index value function init.index(name) if luci.fs.access(init.dir..name) then - return call("source "..init.dir..name.." && exit $START") + return call("source "..init.dir..name.."; exit $START") end end @@ -567,7 +567,7 @@ end -- @return Boolean indicating success function init.enable(name) if luci.fs.access(init.dir..name) then - return ( call(init.dir..name.." enable") == 0 ) + return ( call(init.dir..name.." enable") == 1 ) end end