diag.sh 794 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #!/bin/sh
  2. # Copyright (C) 2006 OpenWrt.org
  3. . /lib/functions/leds.sh
  4. get_status_led() {
  5. status_led_file=$(find /sys/class/leds/ -name "*power*" |head -n1)
  6. if [ ! -f $status_led_file ]; then
  7. status_led=$(basename $status_led_file)
  8. return
  9. fi;
  10. status_led_file=$(find /sys/class/leds/ -name "*diag*" |head -n1)
  11. if [ ! -f $status_led_file ]; then
  12. status_led=$(basename $status_led_file)
  13. return
  14. fi;
  15. status_led_file=$(find /sys/class/leds/ -name "*wps*" |head -n1)
  16. if [ ! -f $status_led_file ]; then
  17. status_led=$(basename $status_led_file)
  18. return
  19. fi;
  20. }
  21. set_state() {
  22. get_status_led
  23. case "$1" in
  24. preinit)
  25. status_led_blink_preinit
  26. ;;
  27. failsafe)
  28. status_led_blink_failsafe
  29. ;;
  30. preinit_regular)
  31. status_led_blink_preinit_regular
  32. ;;
  33. done)
  34. status_led_on
  35. ;;
  36. esac
  37. }