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