base-files: unify get_dt_led helper function
[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
6 boot="$(get_dt_led boot)"
7 failsafe="$(get_dt_led failsafe)"
8 running="$(get_dt_led running)"
9 upgrade="$(get_dt_led upgrade)"
10
11 set_state() {
12 status_led="$boot"
13
14 case "$1" in
15 preinit)
16 status_led_blink_preinit
17 ;;
18 failsafe)
19 status_led_off
20 [ -n "$running" ] && {
21 status_led="$running"
22 status_led_off
23 }
24 status_led="$failsafe"
25 status_led_blink_failsafe
26 ;;
27 preinit_regular)
28 status_led_blink_preinit_regular
29 ;;
30 upgrade)
31 [ -n "$running" ] && {
32 status_led="$upgrade"
33 status_led_blink_preinit_regular
34 }
35 ;;
36 done)
37 status_led_off
38 [ -n "$running" ] && {
39 status_led="$running"
40 status_led_on
41 }
42 ;;
43 esac
44 }