base-files: remove old coldplugging hacks that are no longer necessary since the...
[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 case "$trigger" in
38 "netdev")
39 [ -n "$dev" ] && {
40 echo $dev > /sys/class/leds/${sysfs}/device_name
41 echo $mode > /sys/class/leds/${sysfs}/mode
42 }
43 ;;
44
45 "timer")
46 [ -n "$delayon" ] && \
47 echo $delayon > /sys/class/leds/${sysfs}/delay_on
48 [ -n "$delayoff" ] && \
49 echo $delayoff > /sys/class/leds/${sysfs}/delay_off
50 ;;
51
52 "usbdev")
53 [ -n "$dev" ] && {
54 echo $dev > /sys/class/leds/${sysfs}/device_name
55 echo $interval > /sys/class/leds/${sysfs}/activity_interval
56 }
57 ;;
58
59 "port_state")
60 [ -n "$port_state" ] && \
61 echo $port_state > /sys/class/leds/${sysfs}/port_state
62 ;;
63
64 switch[0-9]*)
65 local port_mask
66
67 config_get port_mask $1 port_mask
68 [ -n "$port_mask" ] && \
69 echo $port_mask > /sys/class/leds/${sysfs}/port_mask
70 ;;
71 esac
72 }
73 }
74
75 start() {
76 [ -e /sys/class/leds/ ] && {
77 config_load system
78 config_foreach load_led led
79 }
80 }
This page took 0.055695 seconds and 5 git commands to generate.