mxs: add basic board runtime detection support
[openwrt.git] / target / linux / mxs / base-files / etc / diag.sh
1 #!/bin/sh
2 # Copyright (C) 2013 OpenWrt.org
3
4 . /lib/functions/leds.sh
5 . /lib/mxs.sh
6
7 get_status_led() {
8         case $(mxs_board_name) in
9         duckbill)
10                 status_led="duckbill:green:status"
11                 ;;
12         olinuxino)
13                 status_led="green"
14                 ;;
15         *)
16                 status_led=$(cd /sys/class/leds && ls -1 *:status 2> /dev/null | head -n 1)
17                 ;;
18         esac
19 }
20
21 set_state() {
22         get_status_led
23
24         case "$1" in
25         preinit)
26                 status_led_blink_preinit
27                 ;;
28         failsafe)
29                 status_led_blink_failsafe
30                 ;;
31         done)
32                 status_led_on
33                 ;;
34         esac
35 }