summaryrefslogtreecommitdiffhomepage
path: root/modules
diff options
context:
space:
mode:
authorSteven Barth <steven@midlink.org>2008-08-07 11:45:19 +0000
committerSteven Barth <steven@midlink.org>2008-08-07 11:45:19 +0000
commit6901e28cfc1c6e10394f27af346f5269b4918555 (patch)
treeea085b61c54c07d1760f6ab1895ab431975f8cad /modules
parent6b32f06b1a43f05fef5e0ac6d690db70b6c88092 (diff)
modules/admin-full: Completed support for LED configuration
Diffstat (limited to 'modules')
-rw-r--r--modules/admin-full/luasrc/controller/admin/system.lua21
-rw-r--r--modules/admin-full/luasrc/model/cbi/admin_system/leds.lua56
2 files changed, 58 insertions, 19 deletions
diff --git a/modules/admin-full/luasrc/controller/admin/system.lua b/modules/admin-full/luasrc/controller/admin/system.lua
index 9abdb2aba..3ebaebcee 100644
--- a/modules/admin-full/luasrc/controller/admin/system.lua
+++ b/modules/admin-full/luasrc/controller/admin/system.lua
@@ -17,16 +17,17 @@ function index()
luci.i18n.loadc("admin-core")
local i18n = luci.i18n.translate
- entry({"admin", "system"}, template("admin_system/index"), i18n("system", "System"), 30)
- entry({"admin", "system", "packages"}, call("action_packages"), i18n("a_s_packages", "Paketverwaltung"), 10)
- entry({"admin", "system", "packages", "ipkg"}, call("action_ipkg"), i18n("a_s_p_ipkg", "IPKG-Konfiguration"))
- entry({"admin", "system", "passwd"}, call("action_passwd"), i18n("a_s_changepw", "Passwort ändern"), 20)
- entry({"admin", "system", "sshkeys"}, call("action_sshkeys"), i18n("a_s_sshkeys", "SSH-Schlüssel"), 30)
- entry({"admin", "system", "system"}, cbi("admin_system/system"), i18n("system", "System"), 40)
- entry({"admin", "system", "fstab"}, cbi("admin_system/fstab"), i18n("a_s_fstab", "Einhängepunkte"), 50)
- entry({"admin", "system", "backup"}, call("action_backup"), i18n("a_s_backup"), 60)
- entry({"admin", "system", "upgrade"}, call("action_upgrade"), i18n("a_s_flash", "Firmwareupgrade"), 70)
- entry({"admin", "system", "reboot"}, call("action_reboot"), i18n("reboot", "Neu starten"), 80)
+ entry({"admin", "system"}, template("admin_system/index"), i18n("system"), 30)
+ entry({"admin", "system", "packages"}, call("action_packages"), i18n("a_s_packages"), 10)
+ entry({"admin", "system", "packages", "ipkg"}, call("action_ipkg"), i18n("a_s_p_ipkg"))
+ entry({"admin", "system", "passwd"}, call("action_passwd"), i18n("a_s_changepw"), 20)
+ entry({"admin", "system", "sshkeys"}, call("action_sshkeys"), i18n("a_s_sshkeys"), 30)
+ entry({"admin", "system", "system"}, cbi("admin_system/system"), i18n("system"), 40)
+ entry({"admin", "system", "fstab"}, cbi("admin_system/fstab"), i18n("a_s_fstab"), 50)
+ entry({"admin", "system", "leds"}, cbi("admin_system/leds"), i18n("leds", "LEDs"), 60)
+ entry({"admin", "system", "backup"}, call("action_backup"), i18n("a_s_backup"), 70)
+ entry({"admin", "system", "upgrade"}, call("action_upgrade"), i18n("a_s_flash"), 80)
+ entry({"admin", "system", "reboot"}, call("action_reboot"), i18n("reboot"), 90)
end
function action_editor()
diff --git a/modules/admin-full/luasrc/model/cbi/admin_system/leds.lua b/modules/admin-full/luasrc/model/cbi/admin_system/leds.lua
index 100f03159..0acb7479b 100644
--- a/modules/admin-full/luasrc/model/cbi/admin_system/leds.lua
+++ b/modules/admin-full/luasrc/model/cbi/admin_system/leds.lua
@@ -13,25 +13,58 @@ $Id$
]]--
m = Map("system", translate("leds"), translate("leds_desc"))
+local sysfs_path = "/sys/class/leds/"
+local leds = {}
+leds[1] = "moep"
+
+if luci.fs.access(sysfs_path) then
+ for k, v in pairs(luci.fs.dir(sysfs_path)) do
+ if v ~= "." and v ~= ".." then
+ table.insert(leds, v)
+ end
+ end
+end
+
+if #leds == 0 then
+ return m
+end
+
+
s = m:section(TypedSection, "led", "")
s.anonymous = true
s.addremove = true
+function s.parse(self, ...)
+ TypedSection.parse(self, ...)
+ os.execute("/etc/init.d/led enable")
+end
+
s:option(Value, "name")
+
sysfs = s:option(ListValue, "sysfs")
-for k, v in pairs(luci.fs.dir("/sys/class/leds/")) do
- if v ~= "." and v ~= ".." then
- sysfs:value(v)
- end
+for k, v in ipairs(leds) do
+ sysfs:value(v)
end
s:option(Flag, "default").rmempty = true
-trigger = s:option(Value, "trigger")
-trigger.rmempty = true
-trigger:value("netdev")
+
+trigger = s:option(ListValue, "trigger")
+
+--local triggers = luci.fs.readfile(sysfs_path .. leds[1] .. "/trigger")
+triggers = "[none] netdev heartbeat default-on timer"
+for t in triggers:gmatch("[%w-]+") do
+ trigger:value(t, translate("system_led_trigger_" .. t:gsub("-", "")))
+end
+
+
+delayon = s:option(Value, "delayon")
+delayon:depends("trigger", "timer")
+
+delayoff = s:option(Value, "delayoff")
+delayoff:depends("trigger", "timer")
dev = s:option(ListValue, "dev")
@@ -44,7 +77,12 @@ for k, v in pairs(luci.sys.net.devices()) do
end
end
-mode = s:option(Value, "mode")
+
+mode = s:option(MultiValue, "mode")
mode.rmempty = true
-mode:value("link")
mode:depends("trigger", "netdev")
+mode:value("link", translate("system_led_mode_link"))
+mode:value("tx", translate("system_led_mode_tx"))
+mode:value("rx", translate("system_led_mode_rx"))
+
+return m \ No newline at end of file