base-files: unify get_dt_led helper function
[openwrt/openwrt.git] / target / linux / lantiq / base-files / etc / diag.sh
1 #!/bin/sh
2 # Copyright (C) 2010-2015 OpenWrt.org
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
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 done)
30 status_led_off
31 [ -n "$running" ] && {
32 status_led="$running"
33 status_led_on
34 }
35 ;;
36 esac
37 }