#!/bin/sh

INSTALL_DIR=`pwd`
SOFTWARE=pyzor
VERSION=0.4.0

PYTHON_VERSION=2.3

function cleanupandexit {
  echo "Installation failed.  Look above for errors."
  cd $INSTALL_DIR
  rm -rf ${SOFTWARE}-${VERSION}
  exit 1
}

tar xjf ${SOFTWARE}-${VERSION}.tar.bz2 || cleanupandexit
cd $INSTALL_DIR/${SOFTWARE}-${VERSION}

python setup.py build || cleanupandexit
python setup.py install || cleanupandexit

chmod -R a+rX /usr/share/doc/pyzor \
              /usr/lib/python${PYTHON_VERSION}/site-packages/pyzor \
              /usr/bin/pyzor /usr/bin/pyzord

python -c 'import gdbm' || (echo 'ERROR!!! The gdbm python module is not installed' && exit -1)

pyzor --homedir /etc/pyzor discover || cleanupandexit

echo "Pyzor Installation Complete"


