#!/bin/bash

# Aktuelle Version
. /etc/vdr/static.conf

# URL zu den Updates
URL="http://ftp.gwdg.de/pub/linux/easyvdr/$EASYVDRBASEVERS/online-updates"

# Temporäres Arbeitsverzeichnis
TEMPDIR="/tmp/easyvdrupdateversion"
mkdir $TEMPDIR
cd $TEMPDIR
# Update MD5-File saugen
wget -np -r -nd -N -A md5 $URL >/dev/null 2>&1

VVERS=0

for i in $(ls -1) ; do

  if [ -f ${i} ] ; then

    for z in $(cat $i | awk '{print $2}' | sort) ; do

        V="${z##*-}"
        V="${V%%.*}"

        if [ $V == "basic" ] ; then
          :
        else
          if [ $V -gt $VVERS ] ; then
            VVERS=$V
          fi
        fi
 
      done
  fi

done
echo $EASYVDRBASEVERS.$VVERS
cd /
rm -R $TEMPDIR
