[scripts] env: colorize git output
[openwrt.git] / target / linux / ar71xx / base-files / etc / diag.sh
1 #!/bin/sh
2 #
3 # Copyright (C) 2009 OpenWrt.org
4 #
5 #
6
7 . /lib/ar71xx.sh
8
9 status_led=""
10
11 led_set_attr() {
12 [ -f "/sys/class/leds/$1/$2" ] && echo "$3" > "/sys/class/leds/$1/$2"
13 }
14
15 status_led_set_timer() {
16 led_set_attr $status_led "trigger" "timer"
17 led_set_attr $status_led "delay_on" "$1"
18 led_set_attr $status_led "delay_off" "$2"
19 }
20
21 status_led_on() {
22 led_set_attr $status_led "trigger" "none"
23 led_set_attr $status_led "brightness" 255
24 }
25
26 status_led_off() {
27 led_set_attr $status_led "trigger" "none"
28 led_set_attr $status_led "brightness" 0
29 }
30
31 get_status_led() {
32 case $(ar71xx_board_name) in
33 alfa-nx)
34 status_led="alfa:green:led_8"
35 ;;
36 ap81)
37 status_led="ap81:green:status"
38 ;;
39 ap83)
40 status_led="ap83:green:power"
41 ;;
42 ap96)
43 status_led="ap96:green:led2"
44 ;;
45 aw-nr580)
46 status_led="aw-nr580:green:ready"
47 ;;
48 bullet-m | rocket-m | nano-m | nanostation-m)
49 status_led="ubnt:green:link4"
50 ;;
51 db120)
52 status_led="db120:green:status"
53 ;;
54 dir-600-a1 |\
55 dir-615-e4)
56 status_led="d-link:green:power"
57 ;;
58 dir-615-c1)
59 status_led="d-link:green:status"
60 ;;
61 dir-825-b1)
62 status_led="d-link:orange:power"
63 ;;
64 eap7660d)
65 status_led="eap7660d:green:ds4"
66 ;;
67 hornet-ub)
68 status_led="alfa:blue:wps"
69 ;;
70 ja76pf)
71 status_led="ja76pf:green:led1"
72 ;;
73 ls-sr71)
74 status_led="ubnt:green:d22"
75 ;;
76 mzk-w04nu | \
77 mzk-w300nh)
78 status_led="planex:green:status"
79 ;;
80 nbg460n_550n_550nh)
81 status_led="nbg460n:green:power"
82 ;;
83 om2p)
84 status_led="om2p:blue:power"
85 ;;
86 pb44)
87 status_led="pb44:amber:jump1"
88 ;;
89 rb-411 | rb-411u | rb-433 | rb-433u | rb-450 | rb-450g | rb-493)
90 status_led="rb4xx:yellow:user"
91 ;;
92 routerstation | routerstation-pro)
93 status_led="ubnt:green:rf"
94 ;;
95 rw2458n)
96 status_led="rw2458n:green:d3"
97 ;;
98 tew-632brp)
99 status_led="tew-632brp:green:status"
100 ;;
101 tew-673gru)
102 status_led="trendnet:blue:wps"
103 ;;
104 tl-mr3020)
105 status_led="tp-link:green:wps"
106 ;;
107 tl-mr3220 | \
108 tl-mr3420 | \
109 tl-wa901nd | \
110 tl-wa901nd-v2 | \
111 tl-wr1043nd | \
112 tl-wr741nd | \
113 tl-wr741nd-v4 | \
114 tl-wr841n-v1 | \
115 tl-wr841n-v7 | \
116 tl-wr941nd)
117 status_led="tp-link:green:system"
118 ;;
119 tl-wr703n)
120 status_led="tp-link:blue:system"
121 ;;
122 tl-wr2543n)
123 status_led="tp-link:green:wps"
124 ;;
125 unifi)
126 status_led="ubnt:green:dome"
127 ;;
128 whr-g301n | \
129 whr-hp-g300n | \
130 whr-hp-gn | \
131 wzr-hp-g300nh)
132 status_led="buffalo:green:router"
133 ;;
134 wzr-hp-g300nh2)
135 status_led="buffalo:red:diag"
136 ;;
137 wndr3700)
138 status_led="wndr3700:green:power"
139 ;;
140 wnr2000)
141 status_led="wnr2000:green:power"
142 ;;
143 wp543)
144 status_led="wp543:green:diag"
145 ;;
146 wrt400n)
147 status_led="wrt400n:blue:wps"
148 ;;
149 wrt160nl)
150 status_led="wrt160nl:blue:wps"
151 ;;
152 zcn-1523h-2 | zcn-1523h-5)
153 status_led="zcn-1523h:amber:init"
154 ;;
155 esac;
156 }
157
158 set_state() {
159 get_status_led
160
161 case "$1" in
162 preinit)
163 insmod leds-gpio
164 status_led_set_timer 200 200
165 ;;
166 failsafe)
167 status_led_set_timer 50 50
168 ;;
169 done)
170 status_led_on
171 ;;
172 esac
173 }
This page took 0.056962 seconds and 5 git commands to generate.