#!/bin/sh

# http://www.din.or.jp/~ushijima/qmail-conf/install.html

INSTALL_DIR=`pwd`

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

if [[ ! -d $INSTALL_DIR/../djbdns/djbdns-1.05 ]]; then
  echo "You must install djbdns before installing qmail-conf"
  exit 1
fi

tar zxf qmail-conf-0.60.tar.gz || cleanupandexit
cd $INSTALL_DIR/qmail-conf-0.60 || cleanupandexit

make -f Makefile.ini djbdns=$INSTALL_DIR/../djbdns/djbdns-1.05 || cleanupandexit
make || cleanupandexit
make setup check || cleanupandexit
ln -s /var/qmail/bin/qmail-*-conf /usr/sbin || cleanupandexit

echo "QMail-Conf Installation Complete."


