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