2010-04-12 01:47:23 +08:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
|
|
|
# Copyright (C) 2010 OpenWrt.org
|
|
|
|
#
|
|
|
|
#
|
|
|
|
|
|
|
|
. /lib/ramips.sh
|
|
|
|
|
|
|
|
status_led=""
|
|
|
|
|
|
|
|
led_set_attr() {
|
|
|
|
[ -f "/sys/class/leds/$1/$2" ] && echo "$3" > "/sys/class/leds/$1/$2"
|
|
|
|
}
|
|
|
|
|
|
|
|
status_led_set_timer() {
|
|
|
|
led_set_attr $status_led "trigger" "timer"
|
|
|
|
led_set_attr $status_led "delay_on" "$1"
|
|
|
|
led_set_attr $status_led "delay_off" "$2"
|
|
|
|
}
|
|
|
|
|
|
|
|
status_led_on() {
|
|
|
|
led_set_attr $status_led "trigger" "none"
|
|
|
|
led_set_attr $status_led "brightness" 255
|
|
|
|
}
|
|
|
|
|
|
|
|
status_led_off() {
|
|
|
|
led_set_attr $status_led "trigger" "none"
|
|
|
|
led_set_attr $status_led "brightness" 0
|
|
|
|
}
|
|
|
|
|
|
|
|
get_status_led() {
|
|
|
|
case $(ramips_board_name) in
|
2011-07-28 18:56:24 +08:00
|
|
|
dir-300-b1 | dir-600-b1 | dir-600-b2)
|
2011-07-28 18:56:21 +08:00
|
|
|
status_led="d-link:green:status"
|
2010-04-12 01:47:23 +08:00
|
|
|
;;
|
2011-12-23 22:27:10 +08:00
|
|
|
esr-9753)
|
|
|
|
status_led="esr-9753:orange:power"
|
|
|
|
;;
|
2010-04-12 01:47:23 +08:00
|
|
|
fonera20n)
|
|
|
|
status_led="fonera20n:green:power"
|
|
|
|
;;
|
2011-03-28 03:19:40 +08:00
|
|
|
hw550-3g)
|
|
|
|
status_led="hw550-3g:green:status"
|
|
|
|
;;
|
2011-04-04 16:43:07 +08:00
|
|
|
mofi3500-3gn)
|
|
|
|
status_led="mofi3500-3gn:green:status"
|
|
|
|
;;
|
2011-08-23 04:41:49 +08:00
|
|
|
nbg-419n)
|
|
|
|
status_led="nbg-419n:green:power"
|
|
|
|
;;
|
2011-07-28 18:56:32 +08:00
|
|
|
nw718)
|
|
|
|
status_led="nw718:amber:cpu"
|
|
|
|
;;
|
2011-12-15 04:51:26 +08:00
|
|
|
omni-emb)
|
|
|
|
status_led="emb:green:status"
|
|
|
|
;;
|
2011-07-06 16:05:00 +08:00
|
|
|
pwh2004)
|
|
|
|
status_led="pwh2004:green:power"
|
|
|
|
;;
|
|
|
|
rt-n15)
|
|
|
|
status_led="rt-n15:blue:power"
|
|
|
|
;;
|
|
|
|
v22rw-2x2)
|
|
|
|
status_led="v22rw-2x2:green:security"
|
|
|
|
;;
|
|
|
|
whr-g300n)
|
|
|
|
status_led="whr-g300n:green:router"
|
|
|
|
;;
|
2011-12-23 22:27:16 +08:00
|
|
|
wl-351)
|
|
|
|
status_led="wl-351:amber:power"
|
|
|
|
;;
|
2011-03-28 03:19:40 +08:00
|
|
|
esac
|
2010-04-12 01:47:23 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
set_state() {
|
|
|
|
get_status_led
|
|
|
|
|
|
|
|
case "$1" in
|
|
|
|
preinit)
|
|
|
|
insmod leds-gpio
|
|
|
|
status_led_set_timer 200 200
|
|
|
|
;;
|
|
|
|
failsafe)
|
|
|
|
status_led_set_timer 50 50
|
|
|
|
;;
|
|
|
|
done)
|
|
|
|
status_led_on
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
}
|