8eb35120549900614746f0f937dbe0ccde5f9244
[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 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 nbg6616)
177 status_led="nbg6616:green:power"
178 ;;
179 nbg6716)
180 status_led="nbg6716:white:power"
181 ;;
182 om2p | \
183 om2pv2 | \
184 om2p-hs | \
185 om2p-hsv2 | \
186 om2p-lc)
187 status_led="om2p:blue:power"
188 ;;
189 om5p | \
190 om5p-an)
191 status_led="om5p:blue:power"
192 ;;
193 onion-omega)
194 status_led="onion:amber:system"
195 ;;
196 pb44)
197 status_led="pb44:amber:jump1"
198 ;;
199 rb-2011l|\
200 rb-2011uas|\
201 rb-2011uas-2hnd)
202 status_led="rb:green:usr"
203 ;;
204 rb-411 | rb-411u | rb-433 | rb-433u | rb-450 | rb-450g | rb-493)
205 status_led="rb4xx:yellow:user"
206 ;;
207 rb-750)
208 status_led="rb750:green:act"
209 ;;
210 rb-911g-2hpnd|\
211 rb-911g-5hpacd|\
212 rb-911g-5hpnd|\
213 rb-912uag-2hpnd|\
214 rb-912uag-5hpnd)
215 status_led="rb:green:user"
216 ;;
217 rb-951ui-2hnd)
218 status_led="rb:green:act"
219 ;;
220 rb-sxt2n|\
221 rb-sxt5n)
222 status_led="rb:green:power"
223 ;;
224 routerstation | routerstation-pro)
225 status_led="ubnt:green:rf"
226 ;;
227 rw2458n)
228 status_led="rw2458n:green:d3"
229 ;;
230 smart-300)
231 status_led="nc-link:green:system"
232 ;;
233 minibox-v1)
234 status_led="minibox-v1:green:system"
235 ;;
236 oolite)
237 status_led="oolite:red:system"
238 ;;
239 qihoo-c301)
240 status_led="qihoo:green:status"
241 ;;
242 tew-632brp)
243 status_led="tew-632brp:green:status"
244 ;;
245 tew-673gru)
246 status_led="trendnet:blue:wps"
247 ;;
248 tew-712br|\
249 tew-732br)
250 status_led="trendnet:green:power"
251 ;;
252 tl-mr3020)
253 status_led="tp-link:green:wps"
254 ;;
255 tl-wa750re)
256 status_led="tp-link:orange:re"
257 ;;
258 tl-wa850re)
259 status_led="tp-link:blue:re"
260 ;;
261 tl-wa860re)
262 status_led="tp-link:green:power"
263 ;;
264 tl-mr3220 | \
265 tl-mr3220-v2 | \
266 tl-mr3420 | \
267 tl-mr3420-v2 | \
268 tl-wa701nd-v2 | \
269 tl-wa801nd-v2 | \
270 tl-wa901nd | \
271 tl-wa901nd-v2 | \
272 tl-wa901nd-v3 | \
273 tl-wdr3320-v2 | \
274 tl-wdr3500 | \
275 tl-wr1041n-v2 | \
276 tl-wr1043nd | \
277 tl-wr1043nd-v2 | \
278 tl-wr741nd | \
279 tl-wr741nd-v4 | \
280 tl-wr841n-v1 | \
281 tl-wr841n-v7 | \
282 tl-wr841n-v8 | \
283 tl-wa830re-v2 | \
284 tl-wr842n-v2 | \
285 tl-wr941nd | \
286 tl-wr941nd-v5)
287 status_led="tp-link:green:system"
288 ;;
289 archer-c5 | \
290 archer-c7 | \
291 tl-wdr4900-v2 | \
292 tl-mr10u | \
293 tl-mr12u | \
294 tl-mr13u | \
295 tl-wdr4300 | \
296 tl-wr703n | \
297 tl-wr710n | \
298 tl-wr720n-v3 | \
299 tl-wr941nd-v6)
300 status_led="tp-link:blue:system"
301 ;;
302 tl-wr841n-v9)
303 status_led="tp-link:green:qss"
304 ;;
305 tl-wr2543n)
306 status_led="tp-link:green:wps"
307 ;;
308 tl-wdr6500-v2)
309 status_led="tp-link:white:system"
310 ;;
311 tube2h)
312 status_led="alfa:green:signal4"
313 ;;
314 unifi)
315 status_led="ubnt:green:dome"
316 ;;
317 uap-pro)
318 status_led="ubnt:white:dome"
319 ;;
320 unifi-outdoor-plus)
321 status_led="ubnt:white:front"
322 ;;
323 airgateway | \
324 airgatewaypro)
325 status_led="ubnt:white:status"
326 ;;
327 whr-g301n | \
328 whr-hp-g300n | \
329 whr-hp-gn | \
330 wzr-hp-g300nh)
331 status_led="buffalo:green:router"
332 ;;
333 wlae-ag300n)
334 status_led="buffalo:green:status"
335 ;;
336 wzr-hp-ag300h | \
337 wzr-hp-g300nh2)
338 status_led="buffalo:red:diag"
339 ;;
340 r6100 | \
341 wndap360 | \
342 wndr3700 | \
343 wndr3700v4 | \
344 wndr4300 | \
345 wnr2000 | \
346 wnr2200 |\
347 wnr612-v2 |\
348 wnr1000-v2)
349 status_led="netgear:green:power"
350 ;;
351 wp543)
352 status_led="wp543:green:diag"
353 ;;
354 wpj344)
355 status_led="wpj344:green:status"
356 ;;
357 wpj531)
358 status_led="wpj531:green:sig3"
359 ;;
360 wpj558)
361 status_led="wpj558:green:sig3"
362 ;;
363 wrt400n)
364 status_led="wrt400n:blue:wps"
365 ;;
366 wrt160nl)
367 status_led="wrt160nl:blue:wps"
368 ;;
369 zcn-1523h-2 | zcn-1523h-5)
370 status_led="zcn-1523h:amber:init"
371 ;;
372 wlr8100)
373 status_led="sitecom:amber:status"
374 ;;
375 esac
376 }
377
378 set_state() {
379 get_status_led
380
381 case "$1" in
382 preinit)
383 status_led_blink_preinit
384 ;;
385 failsafe)
386 status_led_blink_failsafe
387 ;;
388 preinit_regular)
389 status_led_blink_preinit_regular
390 ;;
391 done)
392 status_led_on
393 case $(ar71xx_board_name) in
394 qihoo-c301)
395 local n=$(fw_printenv activeregion | cut -d = -f 2)
396 fw_setenv "image${n}trynum" 0
397 ;;
398 esac
399 ;;
400 esac
401 }