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