05e58c312aed363f25da803d6a7d1c2f5d6d184c
[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 ap81)
34 status_led="ap81:green:status"
35 ;;
36 ap83)
37 status_led="ap83:green:power"
38 ;;
39 aw-nr580)
40 status_led="aw-nr580:green:ready"
41 ;;
42 ls-sr71)
43 status_led="ubnt:green:d22"
44 ;;
45 mzk-w04nu)
46 status_led="mzk-w04nu:green:status"
47 ;;
48 mzk-w300nh)
49 status_led="mzk-w300nh:green:status"
50 ;;
51 pb44)
52 status_led="pb44:amber:jump1"
53 ;;
54 routerstation)
55 status_led="ubnt:green:rf"
56 ;;
57 tew-632brp)
58 status_led="tew-632brp:green:status"
59 ;;
60 tl-wr741nd)
61 status_led="tl-wr741nd:green:system"
62 ;;
63 tl-wr941nd)
64 status_led="tl-wr941nd:green:system"
65 ;;
66 wnr2000)
67 status_led="wnr2000:green:power"
68 ;;
69 wp543)
70 status_led="wp543:green:diag"
71 ;;
72 wrt400n)
73 status_led="wrt400n:blue:status"
74 ;;
75 wrt160nl)
76 status_led="wrt160nl:blue:status"
77 ;;
78 esac;
79 }
80
81 set_state() {
82 get_status_led
83
84 case "$1" in
85 preinit)
86 insmod leds-gpio
87 status_led_set_timer 200 200
88 ;;
89 failsafe)
90 status_led_set_timer 50 50
91 ;;
92 done)
93 status_led_on
94 ;;
95 esac
96 }
This page took 0.047329 seconds and 3 git commands to generate.