#!/bin/sh

# address=http://heanet.dl.sourceforge.net/kbedic/bedic-data-4.0.tar.gz
address=http://ftp1.sourceforge.net/kbedic/bedic-data-4.0.tar.gz

tmpdir=`mktemp -d`
if \
    wget --continue --tries=1 --dns-timeout=20 --connect-timeout=20 --read-timeout=60 $address -O $tmpdir/bedic.tar.gz \
    && tar zxf $tmpdir/bedic.tar.gz -C $tmpdir/ \
    && [ -f $tmpdir/bedic-data-4.0/bg_en.dat ] \
    && [ -f $tmpdir/bedic-data-4.0/en_bg.dat ]
then
    cp $tmpdir/bedic-data-4.0/bg_en.dat /usr/local/share/bedic/bg_en.dat
    cp $tmpdir/bedic-data-4.0/en_bg.dat /usr/local/share/bedic/en_bg.dat
    chown root: /usr/local/share/bedic/*
    chmod 644  /usr/local/share/bedic/*
else
    echo Download failed!
    rm -r $tmpdir
fi
