[ar7] use the second available LED to encore mode boot states
[openwrt/svn-archive/archive.git] / target / linux / ar7 / base-files / etc / diag.sh
1 #!/bin/sh
2 # Copyright (C) 2007-2012 OpenWrt.org
3
4 # This setup gives us 4.5 distinguishable states:
5 #
6 # (1-LED) Solid OFF: Bootloader running, or kernel hung (timer task stalled)
7 # (1-LED) Solid ON: Kernel hung (timer task stalled)
8 # (2-LED) Solid RED: Bootloader running, or kernel hung (timer task stalled)
9 # (2-LED) Solid YELLOW: Kernel hung (timer task stalled)
10 # 5Hz blink: preinit
11 # 10Hz blink: failsafe
12 # (1-LED) Heartbeat: normal operation
13 # (2-LED) Solid GREEN: normal operation
14
15 set_state() {
16 case "$1" in
17 preinit)
18 [ -d /sys/class/leds/status ] && {
19 echo timer >/sys/class/leds/status/trigger
20 echo 100 >/sys/class/leds/status/delay_on
21 echo 100 >/sys/class/leds/status/delay_off
22 :; } || [ -d /sys/class/leds/power\:green ] && {
23 echo timer >/sys/class/leds/power\:green/trigger
24 echo 100 >/sys/class/leds/power\:green/delay_on
25 echo 100 >/sys/class/leds/power\:green/delay_off
26 }
27 ;;
28 failsafe)
29 [ -d /sys/class/leds/status ] && {
30 echo timer >/sys/class/leds/status/trigger
31 echo 50 >/sys/class/leds/status/delay_on
32 echo 50 >/sys/class/leds/status/delay_off
33 :; } || [ -d /sys/class/leds/power\:green ] && {
34 echo timer >/sys/class/leds/power\:green/trigger
35 echo 50 >/sys/class/leds/power\:green/delay_on
36 echo 50 >/sys/class/leds/power\:green/delay_off
37 }
38 ;;
39 done)
40 [ -d /sys/class/leds/status ] && {
41 echo heartbeat >/sys/class/leds/status/trigger
42 :; } || [ -d /sys/class/leds/power\:green ] && {
43 echo default-on >/sys/class/leds/power\:green/trigger
44 echo none >/sys/class/leds/power\:red/trigger
45 }
46 ;;
47 esac
48 }