ipq806x: add support for indicating the boot and upgrade state using four leds
[openwrt/staging/chunkeey.git] / target / linux / ipq806x / base-files / etc / diag.sh
1 #!/bin/sh
2 # Copyright (C) 2016 Henryk Heisig hyniu@o2.pl
3
4 . /lib/functions/leds.sh
5 . /lib/ipq806x.sh
6
7 boot="$(ipq806x_get_dt_led boot)"
8 failsafe="$(ipq806x_get_dt_led failsafe)"
9 running="$(ipq806x_get_dt_led running)"
10 upgrade="$(ipq806x_get_dt_led upgrade)"
11
12 set_state() {
13 status_led="$boot"
14
15 case "$1" in
16 preinit)
17 status_led_blink_preinit
18 ;;
19 failsafe)
20 status_led_off
21 [ -n "$running" ] && {
22 status_led="$running"
23 status_led_off
24 }
25 status_led="$failsafe"
26 status_led_blink_failsafe
27 ;;
28 preinit_regular)
29 status_led_blink_preinit_regular
30 ;;
31 upgrade)
32 [ -n "$running" ] && {
33 status_led="$upgrade"
34 status_led_blink_preinit_regular
35 }
36 ;;
37 done)
38 status_led_off
39 [ -n "$running" ] && {
40 status_led="$running"
41 status_led_on
42 }
43 ;;
44 esac
45 }