#! /bin/sh
# chkconfig: 234 99 00
# description: A boot script for the Freevo dependencies
#
# script with commands to be executed from init on system startup to 
# init the stuff that Freevo depends on.
#
# lirc = Linux Infrared Remote Control, www.lirc.org
#
# $Id: freevo_dep 3741 2003-09-18 06:50:27Z tcwan $

# Get startup config file
test -f /etc/freevo/boot_config || exit 0
. /etc/freevo/boot_config

PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin
DAEMON=$FREEVO_HOME/freevo
NAME=freevo
DESC=freevo

test -f $DAEMON || exit 0

case "$1" in
    start)

        #
        # Load the lirc serial driver module
        #
        # XXX This has to be copied here manually
        echo -n "Inserting the lirc_serial.o module... "
        insmod /usr/local/lib/lirc_serial.o
        echo Done

        #
        # Start the lirc daemon
        #
        # XXX You almost certainly want to change the remote control config file
        # XXX that is passed to lircd so that it matches the remote you're using!
        echo -n "Starting the lircd daemon... "
        /usr/local/sbin/lircd /usr/local/freevo/boot/URC-7201B00
        echo Done

        # Done
        ;;

    stop)
        killall lircd > /dev/null 2>&1
        rmmod lirc_serial > /dev/null 2>&1
        
        # Done
        ;;

    restart|force-reload)
        # XXX this could probably be done a lot better...
        $0 stop
        sleep 1
        $0 start

        # Done
        ;;

    *)
        N=/etc/init.d/$NAME
        echo "Usage: $N {start|stop|restart|force-reload}" >&2
        exit 1
        ;;

esac
