#!/bin/bash
#
#   Script to retrieve the name of latest firmware file
#
#   Copyright (C) 2005 Daniel Eiband <eiband@online.de>
#
#   This program is free software; you can redistribute it and/or modify
#   it under the terms of the GNU General Public License as published by
#   the Free Software Foundation; either version 2 of the License, or
#   (at your option) any later version.
#
#   This program is distributed in the hope that it will be useful,
#   but WITHOUT ANY WARRANTY; without even the implied warranty of
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#   GNU General Public License for more details.
#
#   You should have received a copy of the GNU General Public License
#   along with this program; if not, write to the Free Software
#   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
#


usage()
{
	echo "Usage: fwmod_list <site>" 1>&2
}


if [ $# -ne 1 ]
then
	usage
	exit 1
fi

IFS='/'
set -- $1

if [ -z "$2" ]
then
	proto="${1%:}"
	host="$3"
	shift; shift; shift
	dir="/$*/"

	case "$proto" in
		ftp)
			ftp -n "$host" <<EOT | egrep -e 'fritz.box.*image' -o
user anonymous dsmod@example.com
cd $dir
dir
quit
EOT
			;;
		*)
			echo "ERROR: cannot retrieve list of available firmware versions" 1>&2
			exit 1
			;;
	esac
fi