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