#! /bin/sh


case "$1" in

    start)
    	/sbin/getcfg upnp_nas_enable
	if [ "$?" != "1" ]; then
		echo "UPNP NAS off"
		exit 0
	fi
	route add -net 239.0.0.0 netmask 255.0.0.0 eth0
	upnp_nas_device -webdir /etc/nasweb &
	
	echo "UPNP NAS on"
	;;

    stop)
	killall -9 upnp_nas_device 
	route del -net 239.0.0.0 netmask 255.0.0.0 dev eth0
	if [ "$?" = "0" ]; then 
		echo "Done"
	else    
		echo "FAILED"; 
	fi
	;;

    restart)
    	$0 stop
	sleep 1
	$0 start
	;;

    *)
	echo "Usage: $0 (start|stop|restart)"
	exit 1
	;;

esac

exit 0

