ramips: add feature to blink led on sysupgrade
[openwrt/openwrt.git] / target / linux / ramips / base-files / etc / diag.sh
1 #!/bin/sh
2 # Copyright (C) 2010-2013 OpenWrt.org
3
4 . /lib/functions/leds.sh
5 . /lib/ramips.sh
6
7 get_status_led() {
8 board=$(ramips_board_name)
9
10 case $board in
11 3g150b|\
12 3g300m|\
13 w150m)
14 status_led="$board:blue:ap"
15 ;;
16 3g-6200n|\
17 ar670w|\
18 ar725w|\
19 asl26555|\
20 br-6425|\
21 br-6475nd|\
22 e1700|\
23 fonera20n|\
24 mzk-dp150n|\
25 mzk-w300nh2|\
26 nbg-419n|\
27 pwh2004|\
28 wnce2001|\
29 x5|\
30 x8|\
31 xdxrn502j)
32 status_led="$board:green:power"
33 ;;
34 a5-v11|\
35 d105|\
36 dcs-930l-b1|\
37 hlk-rm04|\
38 mpr-a1|\
39 mpr-a2)
40 status_led="$board:red:power"
41 ;;
42 ai-br100|\
43 ht-tm02)
44 status_led="$board:blue:wlan"
45 ;;
46 all0239-3g|\
47 dcs-930|\
48 dir-300-b1|\
49 dir-300-b7|\
50 dir-320-b1|\
51 dir-600-b1|\
52 dir-600-b2|\
53 dir-610-a1|\
54 dir-615-d|\
55 dir-615-h1|\
56 dir-620-a1|\
57 dir-620-d1|\
58 hpm|\
59 hw550-3g|\
60 miniembwifi|\
61 mofi3500-3gn|\
62 rut5xx|\
63 v11st-fe|\
64 vocore|\
65 wmr-300|\
66 zbt-wg2626)
67 status_led="$board:green:status"
68 ;;
69 atp-52b|\
70 ip2202)
71 status_led="$board:green:run"
72 ;;
73 awapn2403|\
74 dir-645)
75 status_led="$board:green:wps"
76 ;;
77 cf-wr800n)
78 status_led="$board:white:wps"
79 ;;
80 cy-swr1100|\
81 w502u)
82 status_led="$board:blue:wps"
83 ;;
84 dap-1350|\
85 na930|\
86 rt-n13u|\
87 rt-n14u|\
88 rt-n15|\
89 rt-n56u|\
90 wl-330n|\
91 wl-330n3g|\
92 wli-tx4-ag300n|\
93 wt3020|\
94 y1|\
95 y1s)
96 status_led="$board:blue:power"
97 ;;
98 db-wrt01|\
99 esr-9753)
100 status_led="$board:orange:power"
101 ;;
102 f5d8235-v2)
103 status_led="$board:blue:router"
104 ;;
105 f7c027)
106 status_led="$board:orange:status"
107 ;;
108 hc5*61|\
109 mlw221|\
110 mlwg2)
111 status_led="$board:blue:system"
112 ;;
113 linkits7688| \
114 linkits7688d)
115 [ "$1" = "upgrade" ] && status_led="mediatek:orange:wifi"
116 ;;
117 m2m)
118 status_led="$board:blue:wifi"
119 ;;
120 m3|\
121 m4)
122 status_led="$board:blue:status"
123 ;;
124 miwifi-mini|\
125 zte-q7)
126 status_led="$board:red:status"
127 ;;
128 mr-102n)
129 status_led="$board:amber:status"
130 ;;
131 nw718)
132 status_led="$board:amber:cpu"
133 ;;
134 oy-0001|\
135 sl-r7205)
136 status_led="$board:green:wifi"
137 ;;
138 pbr-m1|\
139 w306r-v20|\
140 zbt-wr8305rt)
141 status_led="$board:green:sys"
142 ;;
143 psr-680w)
144 status_led="$board:red:wan"
145 ;;
146 px-4885|\
147 re6500|\
148 whr-1166d|\
149 whr-300hp2|\
150 whr-600d)
151 status_led="$board:orange:wifi"
152 ;;
153 rt-n10-plus|\
154 tew-691gr|\
155 tew-692gr|\
156 ur-326n4g|\
157 ur-336un|\
158 wr512-3gn)
159 status_led="$board:green:wps"
160 ;;
161 sap-g3200u3)
162 status_led="$board:green:usb"
163 ;;
164 v22rw-2x2)
165 status_led="$board:green:security"
166 ;;
167 wcr-150gn|\
168 wl-351)
169 status_led="$board:amber:power"
170 ;;
171 whr-g300n|\
172 wzr-agl300nh)
173 status_led="$board:green:router"
174 ;;
175 wizfi630a)
176 status_led="$board::run"
177 ;;
178 wsr-1166|\
179 wsr-600)
180 status_led="$board:orange:diag"
181 ;;
182 esac
183 }
184
185 set_state() {
186 get_status_led $1
187
188 case "$1" in
189 preinit)
190 status_led_blink_preinit
191 ;;
192 failsafe)
193 status_led_blink_failsafe
194 ;;
195 upgrade | \
196 preinit_regular)
197 status_led_blink_preinit_regular
198 ;;
199 done)
200 status_led_on
201 ;;
202 esac
203 }