#!/bin/bash
# Install script for contest
# Author: Enrique Gaona Jr.
#		   IBM LTC Infrastructure
# Date:		   08/19/2003
#
. /etc/autobench.conf || . functions

#
#
# You may want to specify a web location as well as sourcing the server repo:
WEB_LOCATION="http://members.optusnet.com.au/ckolivas/contest/contest-0.61.tar.gz"
. $AUTODIR/var/server-repository
#
# Get it from the server repo first, if it's there
wget -q -O $AUTODIR/sources/contest-latest.tar.gz $SERVER_REPO/sources/contest-latest.tar.gz
if [ $? -ne 0 ]; then 
  # Didn't find it on the repo, try the web location
  echo "Fetching from the network"
  wget -q -O $AUTODIR/sources/contest-latest.tar.gz $WEB_LOCATION
  if [ $? -ne 0 ]; then
    # Couldn't get the source -- complain
    echo "WARNING: could not download the source for contest."
    exit 1
  fi
fi


pushd $AUTODIR/sources > /dev/null
rm -rf contest 2> /dev/null
DST_DIR=`tar ztf contest-latest.tar.gz | head -n 1`
tar -zxf contest-latest.tar.gz
ln -sf $DST_DIR contest 

# build it...
pushd contest > /dev/null
make
if [ $? -ne 0 ]; then
  echo "WARNING: unable to make contest"
fi

popd > /dev/null
popd > /dev/null
