. /var/config/link
. /var/config/symlink
#network test
ping -c 2 www.sateliti.info 
if [ $? != 0 ] ; then
    echo "Check your network .."
echo "M:main:Check your network! " > $SYMLINK/rm_emu.cfg
echo "M:main:Check your network! " > $SYMLINK/dl_config.cfg
echo "M:main:Check your network! " > $SYMLINK/dl_emu.cfg
sync
else
        
#todo de modificat satellites xml sa se ia de la noi

#remove emu
#download emu cfg
if [ ! -s /var/config/*.emu ] ; then

echo "M:main:Download EMU first! " > $SYMLINK/rm_emu.cfg
echo "M:main:Download EMU first! " > $SYMLINK/dl_config.cfg
 else
 b=""
  ei=`ls -1 /var/config/*.emu`
   echo "S:rm_emu:Remove Emu" > $SYMLINK/rm_emu.cfg
   echo "S:dl_config:Download Emu Config" > $SYMLINK/dl_config.cfg
    
   for i in $ei
      do
        a=${i:12:$((${#i}-16))}
        echo "C:main:$a:rem_emu.sh:$a" >> $SYMLINK/rm_emu.cfg
        echo "C:main:$a:dl_config.sh:$a" >> $SYMLINK/dl_config.cfg
        b=$b" "$a
      done
        echo "M:addons:Back to installer " >> $SYMLINK/rm_emu.cfg
        echo "M:addons:Back to installer " >> $SYMLINK/dl_config.cfg
fi

#download emu
    
wget "$ADRES""srvemulist" -q -O "/tmp/srvemulist"   2>/dev/null
. /tmp/srvemulist
echo "S:dl_emu:Download  Emu" > "$SYMLINK/dl_emu.cfg"
  for j in $emulist
  do
    x=0
   for c in $b
    do
     if [ $c =  $j ] ; then x=1
     fi
   done
    if [ $x = 0 ] ; then 
    echo "C:main:$j:dl_emux.sh:$j" >> "$SYMLINK/dl_emu.cfg"
   fi
  done
   echo "M:addons:Back to Install" >> "$SYMLINK/dl_emu.cfg" 
sync   
fi        
