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"
|
2011-01-27 23:49:46 +02:00
|
|
|
config_get port_state $1 port_state
|
2008-08-05 01:56:46 +03:00
|
|
|
|
2012-10-11 09:45:02 +03:00
|
|
|
if [ "$trigger" = "rssi" ]; then
|
|
|
|
# handled by rssileds userspace process
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
|
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
|
2011-12-31 17:02:32 +02: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
|
|
|
|
;;
|
2011-12-31 17:02:35 +02:00
|
|
|
|
|
|
|
switch[0-9]*)
|
|
|
|
local port_mask
|
|
|
|
|
|
|
|
config_get port_mask $1 port_mask
|
|
|
|
[ -n "$port_mask" ] && \
|
|
|
|
echo $port_mask > /sys/class/leds/${sysfs}/port_mask
|
|
|
|
;;
|
2011-12-31 17:02:32 +02:00
|
|
|
esac
|
2008-08-05 01:56:46 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
start() {
|
|
|
|
[ -e /sys/class/leds/ ] && {
|
|
|
|
config_load system
|
|
|
|
config_foreach load_led led
|
|
|
|
}
|
|
|
|
}
|