83a0e501978dc9d0f5528f02d1c0bfe01ada5078
[openwrt/openwrt.git] / target / linux / ar71xx / base-files / etc / diag.sh
1 #!/bin/sh
2 # Copyright (C) 2009-2013 OpenWrt.org
3
4 . /lib/functions/leds.sh
5 . /lib/ar71xx.sh
6
7 get_status_led() {
8 local board=$(ar71xx_board_name)
9
10 case $board in
11 alfa-nx)
12 status_led="alfa:green:led_8"
13 ;;
14 all0305)
15 status_led="eap7660d:green:ds4"
16 ;;
17 antminer-s1|\
18 antminer-s3|\
19 antminer-r1|\
20 minibox-v1|\
21 som9331|\
22 sr3200|\
23 xd3200)
24 status_led="$board:green:system"
25 ;;
26 ap132|\
27 db120|\
28 dr344|\
29 tew-632brp|\
30 wpj344|\
31 zbt-we1526)
32 status_led="$board:green:status"
33 ;;
34 ap136-010|\
35 ap136-020)
36 status_led="ap136:green:status"
37 ;;
38 ap147-010)
39 status_led="ap147:green:status"
40 ;;
41 ap135-020)
42 status_led="ap135:green:status"
43 ;;
44 mr12|\
45 mr16|\
46 nbg6616|\
47 sc450|\
48 tl-wpa8630)
49 status_led="$board:green:power"
50 ;;
51 ap90q|\
52 cpe830|\
53 cpe870|\
54 gl-inet)
55 status_led="$board:green:lan"
56 ;;
57 ap96)
58 status_led="$board:green:led2"
59 ;;
60 aw-nr580)
61 status_led="$board:green:ready"
62 ;;
63 bhr-4grv2|\
64 wzr-hp-ag300h|\
65 wzr-hp-g300nh2)
66 status_led="buffalo:red:diag"
67 ;;
68 bsb)
69 status_led="$board:red:sys"
70 ;;
71 bullet-m|\
72 rocket-m|\
73 rocket-m-xw|\
74 nano-m|\
75 nanostation-m|\
76 nanostation-m-xw|\
77 loco-m-xw)
78 status_led="ubnt:green:link4"
79 ;;
80 rocket-m-ti)
81 status_led="ubnt:green:link6"
82 ;;
83 bxu2000n-2-a1)
84 status_led="bhu:green:status"
85 ;;
86 cap324)
87 status_led="pcs:green:power"
88 ;;
89 c-55|\
90 c-60)
91 status_led="$board:green:pwr"
92 ;;
93 cap4200ag)
94 status_led="senao:green:pwr"
95 ;;
96 cf-e316n-v2|\
97 cf-e520n|\
98 cf-e530n)
99 status_led="$board:blue:wan"
100 ;;
101 cf-e320n-v2)
102 status_led="$board:blue:wlan"
103 ;;
104 cf-e380ac-v1|\
105 cf-e380ac-v2)
106 status_led="$board:blue:wlan2g"
107 ;;
108 cpe510)
109 status_led="tp-link:green:link4"
110 ;;
111 cr3000)
112 status_led="pcs:amber:power"
113 ;;
114 cr5000)
115 status_led="pcs:amber:power"
116 ;;
117 dgl-5500-a1|\
118 dhp-1565-a1|\
119 dir-505-a1|\
120 dir-600-a1|\
121 dir-615-e1|\
122 dir-615-i1|\
123 dir-615-e4)
124 status_led="d-link:green:power"
125 ;;
126 dir-615-c1)
127 status_led="d-link:green:status"
128 ;;
129 dir-825-b1)
130 status_led="d-link:orange:power"
131 ;;
132 dir-825-c1|\
133 dir-835-a1)
134 status_led="d-link:amber:power"
135 ;;
136 dir-869-a1)
137 status_led="d-link:white:status"
138 ;;
139 dlan-hotspot)
140 status_led="devolo:green:wifi"
141 ;;
142 dlan-pro-500-wp)
143 status_led="devolo:green:wlan-2g"
144 ;;
145 dlan-pro-1200-ac)
146 status_led="devolo:status:wlan"
147 ;;
148 dr531)
149 status_led="$board:green:sig4"
150 ;;
151 dragino2|\
152 oolite)
153 status_led="$board:red:system"
154 ;;
155 dw33d)
156 status_led="$board:blue:status"
157 ;;
158 eap120)
159 status_led="$(ar71xx_board_name):green:system"
160 ;;
161 eap300v2)
162 status_led="engenius:blue:power"
163 ;;
164 eap7660d)
165 status_led="$board:green:ds4"
166 ;;
167 el-mini|\
168 el-m150)
169 status_led="easylink:green:system"
170 ;;
171 ew-dorin|\
172 ew-dorin-router)
173 status_led="dorin:green:status"
174 ;;
175 f9k1115v2)
176 status_led="belkin:blue:status"
177 ;;
178 epg5000|\
179 esr1750)
180 status_led="$board:amber:power"
181 ;;
182 esr900)
183 status_led="engenius:amber:power"
184 ;;
185 hiwifi-hc6361)
186 status_led="hiwifi:blue:system"
187 ;;
188 hornet-ub|\
189 hornet-ub-x2)
190 status_led="alfa:blue:wps"
191 ;;
192 ja76pf|\
193 ja76pf2)
194 status_led="jjplus:green:led1"
195 ;;
196 jwap230)
197 status_led="$board:green:led1"
198 ;;
199 ls-sr71)
200 status_led="ubnt:green:d22"
201 ;;
202 mc-mac1200r)
203 status_led="mercury:green:system"
204 ;;
205 mr18|\
206 z1)
207 status_led="$board:green:tricolor0"
208 ;;
209 mr600)
210 status_led="$board:orange:power"
211 ;;
212 mr600v2)
213 status_led="mr600:blue:power"
214 ;;
215 mr1750|\
216 mr1750v2)
217 status_led="mr1750:blue:power"
218 ;;
219 mr900|\
220 mr900v2)
221 status_led="mr900:blue:power"
222 ;;
223 mynet-n600|\
224 mynet-n750)
225 status_led="wd:blue:power"
226 ;;
227 mynet-rext)
228 status_led="wd:blue:power"
229 ;;
230 mzk-w04nu|\
231 mzk-w300nh)
232 status_led="planex:green:status"
233 ;;
234 nbg460n_550n_550nh)
235 status_led="nbg460n:green:power"
236 ;;
237 nbg6716)
238 status_led="$board:white:power"
239 ;;
240 om2p|\
241 om2pv2|\
242 om2p-hs|\
243 om2p-hsv2|\
244 om2p-hsv3|\
245 om2p-lc)
246 status_led="om2p:blue:power"
247 ;;
248 om5p|\
249 om5p-an)
250 status_led="om5p:blue:power"
251 ;;
252 om5p-ac|\
253 om5p-acv2)
254 status_led="om5pac:blue:power"
255 ;;
256 omy-g1)
257 status_led="omy:green:wlan"
258 ;;
259 omy-x1)
260 status_led="omy:green:power"
261 ;;
262 onion-omega)
263 status_led="onion:amber:system"
264 ;;
265 pb44)
266 status_led="$board:amber:jump1"
267 ;;
268 rb-2011l|\
269 rb-2011uas|\
270 rb-2011uas-2hnd)
271 status_led="rb:green:usr"
272 ;;
273 rb-411|\
274 rb-411u|\
275 rb-433|\
276 rb-433u|\
277 rb-450|\
278 rb-450g|\
279 rb-493)
280 status_led="rb4xx:yellow:user"
281 ;;
282 rb-750)
283 status_led="rb750:green:act"
284 ;;
285 rb-911g-2hpnd|\
286 rb-911g-5hpacd|\
287 rb-911g-5hpnd|\
288 rb-912uag-2hpnd|\
289 rb-912uag-5hpnd)
290 status_led="rb:green:user"
291 ;;
292 rb-951ui-2hnd | rb-941-2nd)
293 status_led="rb:green:act"
294 ;;
295 rb-sxt2n|\
296 rb-sxt5n)
297 status_led="rb:green:power"
298 ;;
299 re450|\
300 sc300m)
301 status_led="$board:blue:power"
302 ;;
303 routerstation|\
304 routerstation-pro)
305 status_led="ubnt:green:rf"
306 ;;
307 rw2458n)
308 status_led="$board:green:d3"
309 ;;
310 smart-300)
311 status_led="nc-link:green:system"
312 ;;
313 qihoo-c301)
314 status_led="qihoo:green:status"
315 ;;
316 tellstick-znet-lite)
317 status_led="tellstick:white:system"
318 ;;
319 tew-673gru)
320 status_led="trendnet:blue:wps"
321 ;;
322 tew-712br|\
323 tew-732br|\
324 tew-823dru)
325 status_led="trendnet:green:power"
326 ;;
327 tl-mr3020)
328 status_led="tp-link:green:wps"
329 ;;
330 tl-wa750re)
331 status_led="tp-link:orange:re"
332 ;;
333 tl-wa850re)
334 status_led="tp-link:blue:re"
335 ;;
336 tl-wa860re)
337 status_led="tp-link:green:power"
338 ;;
339 tl-mr3220|\
340 tl-mr3220-v2|\
341 tl-mr3420|\
342 tl-mr3420-v2|\
343 tl-wa701nd-v2|\
344 tl-wa801nd-v2|\
345 tl-wa901nd|\
346 tl-wa901nd-v2|\
347 tl-wa901nd-v3|\
348 tl-wa901nd-v4|\
349 tl-wdr3320-v2|\
350 tl-wdr3500|\
351 tl-wr1041n-v2|\
352 tl-wr1043nd|\
353 tl-wr1043nd-v2|\
354 tl-wr1043nd-v4|\
355 tl-wr741nd|\
356 tl-wr741nd-v4|\
357 tl-wa801nd-v3|\
358 tl-wr841n-v1|\
359 tl-wr841n-v7|\
360 tl-wr841n-v8|\
361 tl-wr841n-v11|\
362 tl-wa830re-v2|\
363 tl-wr842n-v2|\
364 tl-wr842n-v3|\
365 tl-wr941nd|\
366 tl-wr941nd-v5)
367 status_led="tp-link:green:system"
368 ;;
369 archer-c5|\
370 archer-c7|\
371 tl-wdr4900-v2|\
372 tl-mr10u|\
373 tl-mr12u|\
374 tl-mr13u|\
375 tl-wdr4300|\
376 tl-wr703n|\
377 tl-wr710n|\
378 tl-wr720n-v3|\
379 tl-wr802n-v1|\
380 tl-wr810n|\
381 tl-wr940n-v4|\
382 tl-wr941nd-v6)
383 status_led="tp-link:blue:system"
384 ;;
385 tl-wr841n-v9)
386 status_led="tp-link:green:qss"
387 ;;
388 tl-wr2543n)
389 status_led="tp-link:green:wps"
390 ;;
391 tl-wdr6500-v2)
392 status_led="tp-link:white:system"
393 ;;
394 tube2h)
395 status_led="alfa:green:signal4"
396 ;;
397 unifi)
398 status_led="ubnt:green:dome"
399 ;;
400 uap-pro|\
401 unifiac-lite|\
402 unifiac-pro)
403 status_led="ubnt:white:dome"
404 ;;
405 unifi-outdoor-plus)
406 status_led="ubnt:white:front"
407 ;;
408 airgateway|\
409 airgatewaypro)
410 status_led="ubnt:white:status"
411 ;;
412 whr-g301n|\
413 whr-hp-g300n|\
414 whr-hp-gn|\
415 wzr-hp-g300nh)
416 status_led="buffalo:green:router"
417 ;;
418 wlae-ag300n)
419 status_led="buffalo:green:status"
420 ;;
421 r6100|\
422 wndap360|\
423 wndr3700|\
424 wndr3700v4|\
425 wndr4300|\
426 wnr2000|\
427 wnr2000-v3|\
428 wnr2200|\
429 wnr612-v2|\
430 wnr1000-v2|\
431 wpn824n)
432 status_led="netgear:green:power"
433 ;;
434 wp543)
435 status_led="$board:green:diag"
436 ;;
437 wpj342|\
438 wpj531|\
439 wpj558)
440 status_led="$board:green:sig3"
441 ;;
442 wrt400n|\
443 wrt160nl)
444 status_led="$board:blue:wps"
445 ;;
446 zcn-1523h-2|\
447 zcn-1523h-5)
448 status_led="zcn-1523h:amber:init"
449 ;;
450 wlr8100)
451 status_led="sitecom:amber:status"
452 ;;
453 esac
454 }
455
456 set_state() {
457 get_status_led
458
459 case "$1" in
460 preinit)
461 status_led_blink_preinit
462 ;;
463 failsafe)
464 status_led_blink_failsafe
465 ;;
466 preinit_regular)
467 status_led_blink_preinit_regular
468 ;;
469 done)
470 status_led_on
471 case $(ar71xx_board_name) in
472 gl-ar300m)
473 fw_printenv lc >/dev/null 2>&1 && fw_setenv "bootcount" 0
474 ;;
475 qihoo-c301)
476 local n=$(fw_printenv activeregion | cut -d = -f 2)
477 fw_setenv "image${n}trynum" 0
478 ;;
479 esac
480 ;;
481 esac
482 }