2008-08-04 22:56:46 +00:00
|
|
|
#!/bin/sh /etc/rc.common
|
|
|
|
# (C) 2008 openwrt.org
|
|
|
|
|
2010-01-06 02:34:20 +00:00
|
|
|
START=96
|
2008-08-04 22:56:46 +00:00
|
|
|
|
|
|
|
load_led() {
|
|
|
|
local name
|
|
|
|
local sysfs
|
|
|
|
local trigger
|
|
|
|
local dev
|
|
|
|
local mode
|
|
|
|
local default
|
2008-08-07 11:01:46 +00:00
|
|
|
local delayon
|
|
|
|
local delayoff
|
2010-12-17 17:10:14 +00:00
|
|
|
local interval
|
2008-08-04 22:56:46 +00:00
|
|
|
|
|
|
|
config_get sysfs $1 sysfs
|
2009-08-07 00:07:56 +00:00
|
|
|
config_get name $1 name "$sysfs"
|
|
|
|
config_get trigger $1 trigger "none"
|
2008-08-04 22:56:46 +00:00
|
|
|
config_get dev $1 dev
|
2009-08-07 00:07:56 +00:00
|
|
|
config_get mode $1 mode "link"
|
|
|
|
config_get_bool default $1 default "nil"
|
2008-08-07 11:01:46 +00:00
|
|
|
config_get delayon $1 delayon
|
|
|
|
config_get delayoff $1 delayoff
|
2010-12-17 17:10:14 +00:00
|
|
|
config_get interval $1 interval "50"
|
2011-01-27 21:49:46 +00:00
|
|
|
config_get port_state $1 port_state
|
2008-08-04 22:56:46 +00:00
|
|
|
|
2008-09-13 00:08:39 +00:00
|
|
|
[ -e /sys/class/leds/${sysfs}/brightness ] && {
|
2009-08-07 00:07:56 +00:00
|
|
|
echo "setting up led ${name}"
|
2010-12-17 17:10:14 +00:00
|
|
|
[ "$default" != nil ] && {
|
|
|
|
[ $default -eq 1 ] &&
|
|
|
|
echo 1 >/sys/class/leds/${sysfs}/brightness
|
2008-08-27 20:33:13 +00:00
|
|
|
[ $default -eq 1 ] ||
|
|
|
|
echo 0 >/sys/class/leds/${sysfs}/brightness
|
2008-08-04 22:56:46 +00:00
|
|
|
}
|
|
|
|
echo $trigger > /sys/class/leds/${sysfs}/trigger
|
2011-12-31 15:02:32 +00:00
|
|
|
case "$trigger" in
|
|
|
|
"netdev")
|
|
|
|
[ -n "$dev" ] && {
|
|
|
|
echo $dev > /sys/class/leds/${sysfs}/device_name
|
|
|
|
echo $mode > /sys/class/leds/${sysfs}/mode
|
|
|
|
}
|
|
|
|
;;
|
|
|
|
|
|
|
|
"timer")
|
|
|
|
[ -n "$delayon" ] && \
|
|
|
|
echo $delayon > /sys/class/leds/${sysfs}/delay_on
|
|
|
|
[ -n "$delayoff" ] && \
|
|
|
|
echo $delayoff > /sys/class/leds/${sysfs}/delay_off
|
|
|
|
;;
|
|
|
|
|
|
|
|
"usbdev")
|
|
|
|
[ -n "$dev" ] && {
|
|
|
|
echo $dev > /sys/class/leds/${sysfs}/device_name
|
|
|
|
echo $interval > /sys/class/leds/${sysfs}/activity_interval
|
|
|
|
}
|
|
|
|
;;
|
|
|
|
|
|
|
|
"port_state")
|
|
|
|
[ -n "$port_state" ] && \
|
|
|
|
echo $port_state > /sys/class/leds/${sysfs}/port_state
|
|
|
|
;;
|
|
|
|
esac
|
2008-08-04 22:56:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
start() {
|
|
|
|
[ -e /sys/class/leds/ ] && {
|
|
|
|
config_load system
|
|
|
|
config_foreach load_led led
|
|
|
|
}
|
|
|
|
}
|