#!/bin/sh



DownloadNonZero()
{
wget -q $@ -O /tmp/$CO 
SIZE=`ls -l /tmp/$CO | awk '{ print $5 }'`
echo 'Size '$SIZE
echo ""
}

Tmp2Keys()
{
if [ -e /tmp/$CO ]
   then
        echo "Copies of / tmp to $@"	
		echo ""
		cd /tmp/
		cp /tmp/$CO $@/$CO
		chmod 744 $@/*key*
		rm -r /tmp/$CO
		echo "Keys taken. Restart the EMU"
		echo ""
		   /usr/lib/enigma2/python/Plugins/Extensions/Fantastic/emustarter.sh
	else
		echo "No keys"
		echo ""
fi
}

echo "Wait download keys ..."
echo ""
CO=camd3.keys
DownloadNonZero "http://www.softcam.tv/deneme6.php?file=camd3.keys"
if [ $SIZE -gt 100 ]
then
  Tmp2Keys /var/keys
  echo "Source 1 ok"
  echo ""
  exit 0
fi

exit 0