Sophie

Sophie

distrib > Mandriva > 9.1 > ppc > by-pkgid > 28be96a4e473fe11a9f0a7dfe1e716fa > files > 3

lirc-0.6.6-1mdk.ppc.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
#		infra-red 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

			[ ! -f ${MODULEPATH}/serial.o* ] \
			&& setserial ${COM_PORT} uart none

		    fi

		fi

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

		    true

		else

		    #[ -f ${MODULEPATH}/${HWMOD}.o* ] \
		    #&& modprobe ${HWMOD} > /dev/null
		    [ -f ${MODULEPATH}/${HWMOD}.o* ] \
		    && insmod ${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 lsmod | grep -q ${HWMOD} ; then

		    [ -f ${MODULEPATH}/${HWMOD}.o* ] && rmmod ${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}