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