#!/bin/sh

. /var/config/link
cale=/usr/local/share/enigma2    

wget -P /tmp $ADRES/lista_RSP1.tar.gz 2>/dev/null   

if [ -e /tmp/lista_RSP1.tar.gz ] ; then      

    echo "Removing the list of channels"
    echo ""
    rm $cale/enigma2/userbouquet* 2>/dev/null
    rm $cale/enigma2/bouquets* 2>/dev/null
    rm $cale/enigma2/lamedb 2>/dev/null
    rm $cale/enigma2/satellites.xml 2>/dev/null
    rm $cale/enigma2/whitelist 2>/dev/null
    rm $cale/enigma2/blacklist 2>/dev/null
    rm /etc/tuxbox/satellites.xml 2>/dev/null
    
    sleep 3

    echo "Updating the list"
    echo ""
    cd /
    tar -xvzf /tmp/lista_RSP1.tar.gz -C $cale  >/dev/null
    
    sleep 2
    
    cp $cale/satellites.xml /etc/tuxbox/satellites.xml
    rm /tmp/lista_RSP1.tar.gz

    sleep 3
    
    echo "Update completed successfully"
    echo ""
    echo " In 5 sec E2 is restarted"
    sleep 5
    killall -9 enigma2

else     
    echo "No conection to server or file error !"
fi

exit 0