tools/firmware-utils: allow to create buffalo tags w/o hw version
[openwrt.git] / package / base-files / files / etc / init.d / led
1 #!/bin/sh /etc/rc.common
2 # (C) 2008 openwrt.org
3
4 START=96
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 local interval
16
17 config_get sysfs $1 sysfs
18 config_get name $1 name "$sysfs"
19 config_get trigger $1 trigger "none"
20 config_get dev $1 dev
21 config_get mode $1 mode "link"
22 config_get_bool default $1 default "nil"
23 config_get delayon $1 delayon
24 config_get delayoff $1 delayoff
25 config_get interval $1 interval "50"
26 config_get port_state $1 port_state
27
28 [ -e /sys/class/leds/${sysfs}/brightness ] && {
29 echo "setting up led ${name}"
30 [ "$default" != nil ] && {
31 [ $default -eq 1 ] &&
32 echo 1 >/sys/class/leds/${sysfs}/brightness
33 [ $default -eq 1 ] ||
34 echo 0 >/sys/class/leds/${sysfs}/brightness
35 }
36 echo $trigger > /sys/class/leds/${sysfs}/trigger
37 [ "$trigger" == "netdev" -a -n "$dev" ] && {
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 [ "$trigger" == "usbdev" -a -n "$dev" ] && {
46 echo $dev > /sys/class/leds/${sysfs}/device_name
47 echo $interval > /sys/class/leds/${sysfs}/activity_interval
48 }
49 [ "$trigger" == "port_state" -a -n "$port_state" ] && {
50 echo $port_state > /sys/class/leds/${sysfs}/port_state
51 }
52 }
53 }
54
55 start() {
56 [ -e /sys/class/leds/ ] && {
57 config_load system
58 config_foreach load_led led
59 }
60 }
This page took 0.046989 seconds and 5 git commands to generate.