brcm47xx: fix led indication
[openwrt.git] / target / linux / brcm47xx / base-files / etc / diag.sh
1 #!/bin/sh
2 # Copyright (C) 2006 OpenWrt.org
3
4 . /lib/functions/leds.sh
5
6 get_status_led() {
7         status_led_file=$(find /sys/class/leds/ -name "*power*" |head -n1)
8         if [ ! -f $status_led_file ]; then
9                 status_led=$(basename $status_led_file)
10                 return
11         fi;
12         status_led_file=$(find /sys/class/leds/ -name "*diag*" |head -n1)
13         if [ ! -f $status_led_file ]; then
14                 status_led=$(basename $status_led_file)
15                 return
16         fi;
17         status_led_file=$(find /sys/class/leds/ -name "*wps*" |head -n1)
18         if [ ! -f $status_led_file ]; then
19                 status_led=$(basename $status_led_file)
20                 return
21         fi;
22 }
23
24 set_state() {
25         get_status_led
26
27         case "$1" in
28         preinit)
29                 status_led_blink_preinit
30                 ;;
31         failsafe)
32                 status_led_blink_failsafe
33                 ;;
34         done)
35                 status_led_on
36                 ;;
37         esac
38 }