diag.sh 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #!/bin/sh
  2. # Copyright (C) 2007-2013 OpenWrt.org
  3. # This setup gives us 4.5 distinguishable states:
  4. #
  5. # (1-LED) Solid OFF: Bootloader running, or kernel hung (timer task stalled)
  6. # (1-LED) Solid ON: Kernel hung (timer task stalled)
  7. # (2-LED) Solid RED: Bootloader running, or kernel hung (timer task stalled)
  8. # (2-LED) Solid YELLOW: Kernel hung (timer task stalled)
  9. # 5Hz blink: preinit
  10. # 10Hz blink: failsafe
  11. # (1-LED) Heartbeat: normal operation
  12. # (2-LED) Solid GREEN: normal operation
  13. . /lib/functions/leds.sh
  14. get_status_led() {
  15. [ -d "/sys/class/leds/status" ] && status_led="status"
  16. [ -d "/sys/class/leds/power:green" ] && status_led="power:green"
  17. }
  18. set_state() {
  19. get_status_led
  20. case "$1" in
  21. preinit)
  22. status_led_set_timer 100 100
  23. ;;
  24. failsafe)
  25. status_led_set_timer 50 50
  26. ;;
  27. preinit_regular)
  28. status_led_blink_preinit_regular
  29. ;;
  30. done)
  31. [ "$status_led" = "status" ] && {
  32. status_led_set_heartbeat
  33. }
  34. [ "$status_led" = "power:green" ] && {
  35. status_led_set_on
  36. led_off "power:red"
  37. }
  38. ;;
  39. esac
  40. }