#!/bin/sh
# Laffer CVS installer
#
# Copyright (C) 2004 Laffer Project [http://laffer.sf.net]
# Written by: Slavej Karadjov
# Licensed under GPL
# See main LICENSE file for more information
#
TMP_DIR=`tempfile`; # creates temporary file
rm $TMP_DIR # but we need temporary directory
CVS_CLIENT="cvs"
DEL_CVS=""

HAVE_CVS=`$CVS_CLIENT 1>/dev/null 2>/dev/null`

if [ $? -gt 1 ]; then
        echo "Please make sure that you have CVS client installed."
        exit
fi

C_DIR=`pwd`
if ! [ -d $TMP_DIR ]; then 
	mkdir -p $TMP_DIR
fi
cd $TMP_DIR
echo "Getting Laffer code from CVS..."
echo "Hit ENTER when asked for password"
cvs -d:pserver:anonymous@cvs.sourceforge.net:/cvsroot/laffer login
echo "Fetching files..."
cvs -z3 -d:pserver:anonymous@cvs.sourceforge.net:/cvsroot/laffer co laffer 1>/dev/null
cd $TMP_DIR/laffer
export LAFFER_DIR="$TMP_DIR/laffer"
echo "Waiting for the installation script..."
bash $TMP_DIR/laffer/install.sh
cd $C_DIR

echo -n "Do you want to delete the CVS files stored in \"$TMP_DIR/laffer\"(yes/no)[yes]:"
read DEL_CVS
if [ -z $DEL_CVS ]; then
	DEL_CVS="yes"
fi
if [ "yes" == "$DEL_CVS" ]; then
	echo "Deleting CVS files from \"$TMP_DIR/laffer\""
	rm -rf "$TMP_DIR/laffer/"
fi

exit