updated on Thu Jan 12 04:00:44 UTC 2012
[aur-mirror.git] / ifled / ifled_init_script
blobe12f9d273ec26e102ae1c909eb942b3e01f96bdf
1 #!/bin/sh
2 # vim:ts=4:sw=4:et:
4 # Script to take care of ifled initialization on each led as defined
5 # in /etc/ifled.conf
7 # Taken from Mandriva and modified for ArchLinux by Gilles CHAUVIN <gcnweb@gmail.com>
10 . /etc/rc.conf
11 . /etc/rc.d/functions
13 CONFIG="/etc/sysconfig/ifled"
15 # Check if config file is present
16 if [ -f ${CONFIG} ]; then
17 . ${CONFIG}
18 else
19 echo "File ${CONFIG} is missing. Aborting!"
20 exit 1
23 PID=`pidof -o %PPID /usr/sbin/ifled`
25 case "$1" in
26 start)
27 if [ ! -z "$IF1" ] && /sbin/ifconfig | grep -q "$IF1" ; then
28 stat_busy "Starting InterfaceLED (\"$IF1\" on NumLock)"
29 [ -z "$PID" ] && /usr/sbin/ifled console "$IF1" -f -c ann
30 if [ $? -gt 0 ]; then
31 stat_fail
32 else
33 add_daemon ifled
34 stat_done
38 if [ ! -z "$IF2" ] && /sbin/ifconfig | grep -q "$IF2" ; then
39 stat_busy "Starting InterfaceLED (\"$IF2\" on CapsLock)"
40 [ -z "$PID" ] && /usr/sbin/ifled console "$IF2" -f -c nan
41 if [ $? -gt 0 ]; then
42 stat_fail
43 else
44 add_daemon ifled
45 stat_done
49 if [ ! -z "$IF3" ] && /sbin/ifconfig | grep -q "$IF3" ; then
50 stat_busy "Starting InterfaceLED (\"$IF3\" on ScrollLock)"
51 [ -z "$PID" ] && /usr/sbin/ifled console "$IF3" -f -c nna
52 if [ $? -gt 0 ]; then
53 stat_fail
54 else
55 add_daemon ifled
56 stat_done
62 stop)
63 stat_busy "Stopping InterfaceLED"
64 [ ! -z "$PID" ] && kill $PID &> /dev/null
65 if [ $? -gt 0 ]; then
66 stat_fail
67 else
68 rm_daemon ifled
69 stat_done
74 restart)
75 $0 stop
76 $0 start
81 echo "usage: $0 {start|stop|restart}" >&2
82 exit 1
85 esac
87 exit 0