diag.sh 948 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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. [ "$status_led" != "$running" ] && \
  37. status_led_restore_trigger "boot"
  38. [ -n "$running" ] && {
  39. status_led="$running"
  40. status_led_on
  41. }
  42. ;;
  43. esac
  44. }
  45. set_state() {
  46. [ -n "$boot" -o -n "$failsafe" -o -n "$running" -o -n "$upgrade" ] && set_led_state "$1"
  47. }