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