#!/bin/sh
#######################################################
# BiffSocko <- shameless self promotion
# open_ldap_install.sh
#
# download & install openldap
#######################################################
# url for latest version of open_ldap
URL="ftp://ftp.openldap.org/pub/OpenLDAP/openldap-release/openldap-2.4.34.tgz"
#######################################################
# you shouldn't need to edit anything below this line
#######################################################
FILE=`basename $URL`
OLDIR=`echo $FILE | awk -F ".tgz" '{print $1}'`
DIR="/var/tmp/openldap"
#######################################################
# function for checking command return codes
#######################################################
function chkerr_exit {
$@
if [ $? -ne 0 ]
then
# epic fail.
echo "failed executing: $@ "
exit 1
fi
}
#######################################################
# main ()
#######################################################
# get rid of old stuff
if [ -d $DIR ]
then
chkerr_exit "rm -rf $DIR"
fi
# start new
chkerr_exit "mkdir -p $DIR"
chkerr_exit "cd $DIR"
# download and install
chkerr_exit "wget $URL"
chkerr_exit "tar -xvzf $FILE"
chkerr_exit "cd $OLDIR"
chkerr_exit "./configure"
chkerr_exit "make depend"
chkerr_exit "make"
chkerr_exit "make install"
exit 0