#!/bin/sh

# Start/stop/restart the irda daemon:
#
# This script is based on irda-utils' sysv-init script and 
# only covers SIR mode. For detailed instructionis on how
# to enable FIR mode see 'man 8 irattach' and README.irattach 
# in the doc directory. 

# You probably have to choose a different serial port (/dev/ttyS?). 
DEVICE=/dev/ttyS1
DISCOVERY=yes
#DONGLE=actisys+

[ -f /usr/sbin/irattach ] || exit 0

ARGS=
if [ $DONGLE ]; then
	ARGS="$ARGS -d $DONGLE"
fi
if [ "$DISCOVERY" = "yes" ];then
	ARGS="$ARGS -s"
fi

# See how we were called.
case "$1" in
  start)
        # Attach irda device 
        echo "Starting IrDA: /usr/sbin/irattach"
        /usr/sbin/irattach ${DEVICE} ${ARGS}
        ;;
  stop)
        # Stop service.
        echo "Stopping IrDA... "
	killall irattach
        ;;
  restart)
	$0 stop
	$0 start
	;;
  *)
        echo "Usage: irda {start|stop|restart}"
        exit 1
esac

exit 0