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