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