Sophie

Sophie

distrib > Mandriva > 2008.1 > x86_64 > media > contrib-release > by-pkgid > bc228239bd93fe7b9b1e8074fe175595 > files > 1

ifled-0.6-11mdv2008.1.x86_64.rpm

#!/bin/bash
# Script to take care of ifled initialization on each led as defined
# in /etc/sysconfig/ifled
# Taken from dutch version of ifled by Myckel Habets myckel@daxis.nl
# Modified to work on Mandrake/RedHat by Max Heijndijk <cchq@wanadoo.nl>
# Modified to keep track of different ifled processes by Bruno Santos <bluey@netcabo.pt>

# /etc/rc.d/init.d/ifled
# chkconfig: 2345 95 05
# description: Monitor network traffic with the keyboard LED's.

if [ -f /etc/rc.d/init.d/functions ]; then
    . /etc/rc.d/init.d/functions
else
    exit 0
fi

if [ -f /etc/sysconfig/ifled ]; then
    . /etc/sysconfig/ifled
else
    exit 0
fi

case "$1" in
  start) if [ ! -z "$IF1" ] && /sbin/ifconfig | grep -q "$IF1" ; then
	    gprintf "Starting InterfaceLED (\"$IF1\" on NumLock):" 
	    daemon /usr/bin/ifled console "$IF1" -f -c ann
	    touch /var/lock/subsys/ifled.numlock
	    echo
	 fi

	 if [ ! -z "$IF2" ] && /sbin/ifconfig | grep -q "$IF2" ; then
	    gprintf "Starting InterfaceLED (\"$IF2\" on CapsLock):"
	    daemon /usr/bin/ifled console "$IF2" -f -c nan
	    touch /var/lock/subsys/ifled.capslock
	    echo
	 fi

	 if [ ! -z "$IF3" ] && /sbin/ifconfig | grep -q "$IF3" ; then
	    gprintf "Starting InterfaceLED (\"$IF3\" on ScrollLock):"
	    daemon /usr/bin/ifled console "$IF3" -f -c nna
	    touch /var/lock/subsys/ifled.scrolllock
	    echo
	 fi
	 
	 pidof ifled > /var/run/ifled
	 touch /var/lock/subsys/ifled
	 ;;

  stop)
         if [ -f /var/lock/subsys/ifled ]; then
	   action "Stopping InterfaceLED: (`cat /var/run/ifled`)" \
	   kill `cat /var/run/ifled`
	   rm -f /var/lock/subsys/ifled*
	   rm -f /var/run/ifled
         else
	   gprintf "InterfaceLED is not running\n"
	 fi
         ;;
	 
  status)
         if [ -f /var/lock/subsys/ifled ]; then
           if [ -f /var/lock/subsys/ifled.numlock ]; then
	     action "Running InterfaceLED (\"$IF1\" on NumLock):" \
             true	
           fi
           if [ -f /var/lock/subsys/ifled.capslock ]; then
	     action "Running InterfaceLED (\"$IF2\" on CapsLock):" \
	     true 
           fi
	   if [ -f /var/lock/subsys/ifled.scrolllock ]; then
	     action "Running InterfaceLED (\"$IF3\" on ScrollLock):" \
	     true
           fi   
	 else 
	   gprintf "InterfaceLED is not running\n"
	 fi
	 ;;

  *)	 echo "Usage: /etc/rc.d/init.d/ifled {start|stop|status}" >&2
	 exit 1
	 ;;

esac
exit 0