Sophie

Sophie

distrib > Mandriva > 2006.0 > x86_64 > by-pkgid > 886b0f491d9bdcad782716ce621ac581 > files > 5

lirc-0.7.1-5mdk.src.rpm

#!/bin/sh
#
# lircd         Linux Infrared Remote Control daemon
#
# chkconfig:    2345 65 35
# description:  LIRC is a package that allows you to decode and send
#               infrared signals of many (but not all) commonly used
#               remote controls.
#
# processname:  lircd
# pidfile:      /var/run/lircd.pid
# config:       /etc/lircd.conf
# config:       /etc/sysconfig/lircd

# Source function library
. /etc/rc.d/init.d/functions

# Get service config
[ -f /etc/sysconfig/lircd ] && . /etc/sysconfig/lircd

MODULEPATH="/lib/modules/`uname -r`/kernel/3rdparty/lirc"

# See how we were called.
case "$1" in

  start)    # Check if the service is already running?
    	    if [ ! -f /var/lock/subsys/lircd ]; then

		# Release serial port.
		if [ "${HWMOD}" = "lirc_serial" ]; then

		    if lsmod | grep -q ^serial; then

			modprobe -r serial

		    else

			setserial ${COM_PORT} uart none

		    fi

		fi

		# Load the hardwaredriver
		if [ -z "$HWMOD" ] || lsmod | grep -q ${HWMOD} ; then

		    true

		else

		    modprobe ${HWMOD} ${DRIVER_OPTS} > /dev/null

		fi

                gprintf "Starting Linux Infrared Remote Control daemon:"

		OPTIONS=""
		[ -n "${DRIVER}" ] && OPTIONS="--driver=${DRIVER}"
		[ -n "${DEVICE}" ] && OPTIONS="${OPTIONS} --device=${DEVICE}"

                daemon lircd ${OPTIONS}

		RETVAL=$?
		[ ${RETVAL} -eq 0 ] && touch /var/lock/subsys/lircd

    	    else

                gprintf "Starting Linux Infrared Remote Control daemon:"
		failure		
		
    	    fi

	    echo
	    ;;

  stop)	    # Stop daemons.
    	    if [ -f /var/lock/subsys/lircd ]; then

		gprintf "Stopping Linux Infrared Remote Control daemon:"

		killproc lircd

		rm -f /var/lock/subsys/lircd >/dev/null 2>&1

		# Unload the hardwaredriver
		if [ -z "$HWMOD" ] || lsmod | grep -q ${HWMOD} ; then

		    modprobe -r ${HWMOD} > /dev/null

		fi

		echo

	    else

		gprintf "Stopping Linux Infrared Remote Control daemon:"
		failure
		echo
                exit 1

    	    fi
	    ;;

  status)   status lircd
	    ;;

  restart)  test -f /var/lock/subsys/irexec && RESTART_IREXEC=yes
	    test -n "${RESTART_IREXEC}" && /etc/rc.d/init.d/irexec stop
    	    
	    test -f /var/lock/subsys/lircmd && RESTART_LIRCMD=yes
	    test -n "${RESTART_LIRCMD}" && /etc/rc.d/init.d/lircmd stop
    	    
	    $0 stop
    	    $0 start
	    
	    test -n "${RESTART_LIRCMD}" && /etc/rc.d/init.d/lircmd start
	    test -n "${RESTART_IREXEC}" && /etc/rc.d/init.d/irexec start
    	    ;;

  reload)   gprintf "Reloading Linux Infrared Remote Control daemon:"
	    killproc lircd -HUP
	    echo
	    ;;

  *)	    gprintf "$0 {start|stop|status|restart|reload}\n"
    	    exit 1
	    ;;

esac

exit ${RETVAL}