#!/bin/sh
#
# Startup script for the Linux Infrared Remote Control.
#
# Written by Dag Wieers <dag@wieers.com>.
#
# chkconfig: - 90 10
# description: Enables infrared controls through LIRC.
#
# processname: lircd
# config: /etc/lircd.conf
# pidfile: /var/run/lircd

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

[ -x /usr/sbin/lircd ] || exit 1
[ -r /etc/lircd.conf ]  || exit 1

RETVAL=0
prog="lircd"
desc="IR Remote Control"

start() {
	echo -n $"Starting $desc ($prog): "
	daemon $prog
	RETVAL=$?
	echo
	[ $RETVAL -eq 0 ] && touch /var/lock/subsys/$prog
	return $RETVAL
}

stop() {
        echo -n $"Shutting down $desc ($prog): "
        killproc $prog
        RETVAL=$?
        echo
        [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/$prog
        return $RETVAL
}

restart() {
	stop
	start
}

case "$1" in
  start)
	start
	;;
  stop)
	stop
	;;
  restart)
	restart
	;;
  condrestart)
	[ -e /var/lock/subsys/$prog ] && restart
	RETVAL=$?
	;;
  status)
	status $prog
	RETVAL=$?
	;;
  *)
	echo $"Usage: $0 {start|stop|restart|condrestart|status}"
	RETVAL=1
esac

exit $RETVAL
