ramips: add support for indicating the boot state using multiple leds
[openwrt/openwrt.git] / target / linux / ramips / 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 set_state() {
11 status_led="$boot"
12
13 case "$1" in
14 preinit)
15 status_led_blink_preinit
16 ;;
17 failsafe)
18 status_led_off
19 [ -n "$running" ] && {
20 status_led="$running"
21 status_led_off
22 }
23 status_led="$failsafe"
24 status_led_blink_failsafe
25 ;;
26 preinit_regular)
27 status_led_blink_preinit_regular
28 ;;
29 upgrade)
30 [ -n "$running" ] && {
31 status_led="$running"
32 status_led_off
33 }
34 status_led="$upgrade"
35 status_led_blink_preinit_regular
36 ;;
37 done)
38 status_led_off
39 [ -n "$running" ] && {
40 status_led="$running"
41 status_led_on
42 }
43 ;;
44 esac
45 }