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