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