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