#!/bin/sh
### BEGIN INIT INFO
# Provides:          udpxy
# Required-Start:    $syslog
# Required-Stop:     $syslog
# Default-Start:     2 3 4 5
# Default-Stop:      
# Short-Description: udp multicast proxy
# Description:      
### END INIT INFO

set -e
bootname="udpxy"
. /lib/lsb/init-functions

UDPXY="/usr/bin/udpxy"
DEFAULTS="/etc/udpxy.conf"

IFACE_MCAST="eth0"
PORT=4810
MAX_CLIENTS="16"

[ -r "$DEFAULTS" ] && . "$DEFAULTS"
#OPTIONS="-a $IFACE_UCAST -p $PORT -m $IFACE_MCAST -c $MAX_CLIENTS"

case "$1" in
  start)
    bootlog "Starting UDPxy..."
	$UDPXY -p $PORT -m $IFACE_MCAST -c 16 
	ip route add multicast 239.0.0.0/8 dev $IFACE_MCAST >/dev/null 2>&1
	exit 0
    ;;
  stop)
    bootlog "Stopping UDPxy..."
	killall udpxy
    ;;
  restart)
    $0 stop
    sleep 1
    $0 start
    ;;
  *)
    log_success_msg "Usage: $0 {start|stop|restart}"
    exit 1
esac

exit 0

