ipq40xx: add get_status_led to diag.sh
[openwrt/openwrt.git] / target / linux / ipq40xx / base-files / etc / diag.sh
1 #!/bin/sh
2
3 . /lib/functions/leds.sh
4
5 boot="$(get_dt_led boot)"
6 failsafe="$(get_dt_led failsafe)"
7 running="$(get_dt_led running)"
8 upgrade="$(get_dt_led upgrade)"
9
10 get_status_led() {
11 status_led="$boot"
12 }
13
14 set_state() {
15 status_led="$boot"
16
17 case "$1" in
18 preinit)
19 status_led_blink_preinit
20 ;;
21 failsafe)
22 status_led_off
23 [ -n "$running" ] && {
24 status_led="$running"
25 status_led_off
26 }
27 status_led="$failsafe"
28 status_led_blink_failsafe
29 ;;
30 preinit_regular)
31 status_led_blink_preinit_regular
32 ;;
33 upgrade)
34 [ -n "$running" ] && {
35 status_led="$upgrade"
36 status_led_blink_preinit_regular
37 }
38 ;;
39 done)
40 status_led_off
41 [ -n "$running" ] && {
42 status_led="$running"
43 status_led_on
44 }
45 ;;
46 esac
47 }