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