1
0

led.sh 496 B

12345678910111213141516171819202122232425
  1. #!/bin/sh
  2. # (C) 2008 openwrt.org
  3. . /lib/functions.sh
  4. ACTION=$1
  5. NAME=$2
  6. do_led() {
  7. local name
  8. local sysfs
  9. config_get name $1 name
  10. config_get sysfs $1 sysfs
  11. [ "$name" = "$NAME" -o "$sysfs" = "$NAME" -a -e "/sys/class/leds/${sysfs}" ] && {
  12. [ "$ACTION" = "set" ] &&
  13. echo 1 >/sys/class/leds/${sysfs}/brightness \
  14. || echo 0 >/sys/class/leds/${sysfs}/brightness
  15. exit 0
  16. }
  17. }
  18. [ "$1" = "clear" -o "$1" = "set" ] &&
  19. [ -n "$2" ] &&{
  20. config_load system
  21. config_foreach do_led
  22. exit 1
  23. }