#!/bin/sh

#    jpilot-syncmal-prc-install: fetch and install AvantGo .prc on the Palm
#    Copyright (C) 2002, Ludovic Rousseau <ludovic.rousseau@free.fr>
#
#    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

set -e

FILE=AvantGo40.tgz
URL=http://www.tomw.org/malsync/$FILE
TMP=/tmp/jpilot-syncmal-prc-install.$$

bad=0
if [ ! -x /usr/bin/wget ]
then
	echo "Error: You must install wget (wget package) to use this script!"
	bad=1
fi

if [ ! -x /usr/bin/pilot-xfer ]
then
	echo "Error: You must install pilot-xfer (pilot-link package) to use this script!"
	bad=1
fi

if [ $bad -ne 0 ]
then
	exit
fi

# remove temporary files in case of premature exit (Ctrl-C)
clean_exit()
{
	echo
	rm -rf $TMP
}

trap clean_exit SIGINT

case "$1" in
	"-v"|"--version")
		echo "jpilot-syncmal-prc-install: fetch and install AvantGo .prc on the Palm"
		echo "Version 1.0, April 2002"
		echo "Copyright (C) 2002, Ludovic Rousseau <ludovic.rousseau@free.fr>"
		echo "This program is protected by the GNU GPL version 2 of later"
		exit
	;;

	?*)
		echo "Usage: $0 [-h] [--help] [-v] [--version]"
		exit
		exit
	;;
esac

mkdir $TMP
cd $TMP

wget $URL
tar xzvf $FILE

pilot-xfer -i *.prc

rm -rf $TMP

