Added support for 2.6.27 kernel
[openwrt.git] / package / base-files / files / etc / init.d / led
1 #!/bin/sh /etc/rc.common
2 # (C) 2008 openwrt.org
3
4 START=60
5
6 load_led() {
7 local name
8 local sysfs
9 local trigger
10 local dev
11 local mode
12 local default
13 local delayon
14 local delayoff
15
16 config_get name $1 name
17 config_get sysfs $1 sysfs
18 config_get trigger $1 trigger
19 config_get dev $1 dev
20 config_get mode $1 mode
21 config_get default $1 default
22 config_get delayon $1 delayon
23 config_get delayoff $1 delayoff
24
25 [ -e /sys/class/leds/${sysfs}/brightness ] && {
26 logger "setting up led : ${name:-$sysfs}"
27 [ -n "$default" ] && {
28 [ $default -eq 1 ] &&
29 echo 1 >/sys/class/leds/${sysfs}/brightness
30 [ $default -eq 1 ] ||
31 echo 0 >/sys/class/leds/${sysfs}/brightness
32 }
33 [ -z "$trigger" ] && trigger=none
34 echo $trigger > /sys/class/leds/${sysfs}/trigger
35 [ "$trigger" == "netdev" -a -n "$dev" ] && {
36 [ -z "$mode" ] && mode=link
37 echo $dev > /sys/class/leds/${sysfs}/device_name
38 echo $mode > /sys/class/leds/${sysfs}/mode
39 }
40 [ "$trigger" == "timer" ] && {
41 [ -n "$delayon" ] && echo $delayon > /sys/class/leds/${sysfs}/delay_on
42 [ -n "$delayoff" ] && echo $delayoff > /sys/class/leds/${sysfs}/delay_off
43 }
44 }
45 }
46
47 start() {
48 [ -e /sys/class/leds/ ] && {
49 config_load system
50 config_foreach load_led led
51 }
52 }
This page took 0.042147 seconds and 5 git commands to generate.