#!/bin/bash
# install
# THUM software installation script
# $Revision: 1.4 $
# $Name: release-1_0_7 $
# $Date: 2006/09/17 21:40:53 $

soname="libTHUM.so.1"
libname="libTHUM.so"
libdir="/usr/lib"
ldconfig="/sbin/ldconfig"
bindir="/usr/local/bin"
confdir="/etc"

installLib(){
	echo
	echo "Installing shared library into $libdir"
	cp $soname $libdir
	chmod 644 $libdir/$soname
	ln -sf $libdir/$soname $libdir/$libname
	$ldconfig
}

installApps(){
	echo
	echo "Installing sample applications into $bindir"
	cp thumctl $bindir
	cp thumchk.pl $bindir
	echo
	echo "Installing sample thumchk.conf configuration file into $confdir"
	cp thumchk.conf $confdir
}

finish(){
	echo
	echo "THUM software installation completed."
	exit
}

runcpan(){
	cpan -i Net::SMTP_auth
}

prompt(){
	echo
	echo -n "Would you like to attempt to install Net::SMTP_auth via cpan? [y/n] "
	read response
	case $response in
	N|n|No|no) 
	finish
	;;
	Y|y|Yes|yes)
	runcpan
	finish
	;;
	*)
	echo
	echo "Enter yes or no"
	prompt
	;;
	esac
}

installLib
installApps
echo
echo "The provided thumchk.pl script requires the Net::SMTP_auth Perl module to send mail.  This install script can attempt to install the Net::SMTP_auth Perl module using the cpan command.  NOTE: If this is your first time using the cpan command on this machine, you may be asked several configuration questions.  In nearly all cases accepting the provided default values will work fine."
prompt
