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