diag.sh 872 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. #!/bin/sh
  2. # Copyright (C) 2006-2019 OpenWrt.org
  3. . /lib/functions/leds.sh
  4. boot="$(get_dt_led boot)"
  5. failsafe="$(get_dt_led failsafe)"
  6. running="$(get_dt_led running)"
  7. upgrade="$(get_dt_led upgrade)"
  8. set_led_state() {
  9. status_led="$boot"
  10. case "$1" in
  11. preinit)
  12. status_led_blink_preinit
  13. ;;
  14. failsafe)
  15. status_led_off
  16. [ -n "$running" ] && {
  17. status_led="$running"
  18. status_led_off
  19. }
  20. status_led="$failsafe"
  21. status_led_blink_failsafe
  22. ;;
  23. preinit_regular)
  24. status_led_blink_preinit_regular
  25. ;;
  26. upgrade)
  27. [ -n "$running" ] && {
  28. status_led="$running"
  29. status_led_off
  30. }
  31. status_led="$upgrade"
  32. status_led_blink_preinit_regular
  33. ;;
  34. done)
  35. status_led_off
  36. [ -n "$running" ] && {
  37. status_led="$running"
  38. status_led_on
  39. }
  40. ;;
  41. esac
  42. }
  43. set_state() {
  44. [ -n "$boot" -o -n "$failsafe" -o -n "$running" -o -n "$upgrade" ] && set_led_state "$1"
  45. }