if ! echo abcd | grep -o bc 2>/dev/null >/dev/null
then
	echo "Error: You have obsolete grep which doesn't support -o switch."
        echo "Install GNU grep at least 2.5."
	exit 1
fi
if [ $# -eq 0 ]
then
	echo "Usage: $0 directory_to_be_created_and_filled"
	exit 1
fi
if [ ! -e $1 ]
then
mkdir $1
fi
cd $1

echo -n "Removing possible previous content..."
rm -rf ronja.twibright.com images.twibright.com urls urls.gz index.html \
index_cz.html README.txt README_CZ.txt
echo " removed."

wget http://ronja.twibright.com/urls/urls.gz --output-document=urls.gz
gunzip urls.gz
wget -nv -nc -xEHkp -i urls
rm urls
wget -nH -N http://ronja.twibright.com/utils/data/index.html \
http://ronja.twibright.com/utils/data/index_cz.html \
http://ronja.twibright.com/utils/data/README.txt \
http://ronja.twibright.com/utils/data/README_CZ.txt

cd ..

# mkisofs taken out - the image would be now over 1GB.
#
#if which mkisofs 2>/dev/null 1>&2
#then
#mkisofs -J -joliet-long -publisher "Twibright Labs, http://twibright.com" \
#-r -V "Twibright Ronja guide on CD-ROM" -o $1.iso $1
#
#echo "CD ISO image is ready in file $1.iso."
#else
#echo You don\'t have mkisofs installed. CD-ROM ISO image hasn\'t been created. >&2
#fi

echo "Downloaded data are ready in directory $1. Point your browser to \
$1/index.html"