#!/bin/sh

### This file download EMU in tuner ####
#  creating iscan_adm for E2 ipbox900  #
#       http://ipbox900.com.ua         #
########################################

echo "WAIT" > /dev/dbox/fp0

siteurl=http://ipbox900.com.ua

fant_folder=/usr/lib/enigma2/python/Plugins/Extensions/Fantastic/
mod_folder=/setup/iscan_mod
f_folder=/tmp/Fantastic
up_file=iscan_mod.tar.gz

cd $fant_folder
wget $siteurl$mod_folder/$up_file
tar -x -f iscan_mod.tar.gz

mkdir $f_folder
cd $f_folder
rm -f $up_file

if [ -e $f_folder/$up_file ] ; then
echo "ErrorLoad" 
echo "Server is Down"
else

cd $f_folder
echo "UPDATE NEW VERSION MOD"
echo "UPDATE MOD" > /dev/dbox/fp0
wget $siteurl$mod_folder/$up_file
fi

echo "Unpack"
cd $f_folder

if [ -e $f_folder/$up_file ] ; then
echo "File is OK" 
echo "Unpack"
tar -x -f iscan_mod.tar.gz
rm -f $up_file
cp -f $f_folder/* $fant_folder
rm -f $f_folder/* 
echo "Finished" > /dev/dbox/fp0

else
echo "No File for update"
echo "Please,test you network connect"
echo "No Update" > /dev/dbox/fp0
fi
