Some fixes on the alix led script.
[people/pmueller/ipfire-2.x.git] / src / initscripts / init.d / leds
1 #!/bin/sh
2 ########################################################################
3 # Begin $rc_base/init.d/leds
4 #
5 # Description : Script to setup leds at boot.
6 #
7 ########################################################################
8
9 . /etc/sysconfig/rc
10 . ${rc_functions}
11
12 # Load ethernet settings
13 eval $(/usr/local/bin/readhash /var/ipfire/ethernet/settings)
14
15 setup_red_modem() {
16 local led1=${1}
17 local led2=${2}
18
19 modprobe ledtrig-netdev
20
21 local i
22 for i in ${led1} ${led2}; do
23 echo "netdev" > ${i}/trigger
24 echo "${RED_DEV}" > ${i}/device_name
25 done
26
27 echo "rx" > ${led1}/mode
28 echo "tx" > ${led2}/mode
29 }
30
31 reset_trigger() {
32 [ -d "${1}" ] || return 0
33 echo "none" > ${1}/trigger
34 }
35
36 start_alix2() {
37 modprobe -q leds-alix2 &>/dev/null
38
39 local i
40 for i in 1 2 3; do
41 if [ ! -d "/sys/class/leds/alix:${i}" ]; then
42 return 1
43 fi
44 done
45
46 setup_red_modem /sys/class/leds/alix:2 /sys/class/leds/alix:3
47 }
48
49 stop_alix2() {
50 local i
51 for i in 1 2 3; do
52 reset_trigger /sys/class/leds/alix:${i}
53 done
54 }
55
56 case "${1}" in
57 start|stop)
58 for i in alix2; do
59 ${1}_${i}
60 done
61 exit 0
62 ;;
63
64 *)
65 echo "Usage: ${0} {start|stop}"
66 exit 1
67 ;;
68 esac
69
70 # End $rc_base/init.d/leds