#!/bin/sh
#
# udhcpc script edited by Tim Riker <Tim@Rikers.org>
# This derivative for multicast promisc  on SP-ICE-3 by jim spriggs <j.spriggs@raylase.de>
#
CMDNAME="${0##*/}"

[ -z "$1" ] && echo "Error: should be called from udhcpc" && exit 1

function log() {
	/usr/bin/logger --id=$$ --tag "${CMDNAME}" "$*"
}


log "$@ for ${interface}"

case "$1" in
	leasefail|renew|bound)
        ip link set $interface promisc on multicast on
		;;
esac

case "$1" in
	leasefail|bound)
		# Make sure we're discoverable at our current address
		# by restarting the UPnP Device.

		# Get the parent pid (i.e. the pid of the dotnetDaemon that spawned the DeviceDiscoveryServer).
		upnppid=$(pgrep -f "dotnetDaemon upnp_app")

		# Send SIGHUP to any child(ren) of the parent.
		pkill -SIGHUP -P ${upnppid}

		;;
esac

exit 0
