diag.sh 847 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #!/bin/sh
  2. # Copyright (C) 2014 OpenWrt.org
  3. . /lib/functions/leds.sh
  4. get_status_led() {
  5. local status_led_file
  6. # There may be more than one color of power LED, try to avoid amber/red
  7. status_led_file=$(find /sys/class/leds/ -name "*:power" -a ! -name "*:amber:*" -a ! -name "*:red:*" | head -n1)
  8. if [ -d "$status_led_file" ]; then
  9. status_led=$(basename $status_led_file)
  10. return
  11. fi;
  12. # Now just pick any power LED
  13. status_led_file=$(find /sys/class/leds/ -name "*:power:*" | head -n1)
  14. if [ -d "$status_led_file" ]; then
  15. status_led=$(basename $status_led_file)
  16. return
  17. fi;
  18. }
  19. set_state() {
  20. get_status_led
  21. [ -z "$status_led" ] && return
  22. case "$1" in
  23. preinit)
  24. status_led_blink_preinit
  25. ;;
  26. failsafe)
  27. status_led_blink_failsafe
  28. ;;
  29. preinit_regular)
  30. status_led_blink_preinit_regular
  31. ;;
  32. done)
  33. status_led_on
  34. ;;
  35. esac
  36. }