diff --git a/install_nfdump.sh b/install_nfdump.sh index e2190a3..cf730c3 100755 --- a/install_nfdump.sh +++ b/install_nfdump.sh @@ -1,16 +1,32 @@ #!/bin/bash +dir=$1 +install_path=${dir:-/opt/spot} +bin=${install_path}/bin dependencies=(tar make gcc m4 automake autoconf flex byacc) +log_cmd () { + + printf "\n****SPOT.NFDUMP.install_nfdump.sh****\n" + date +"%y-%m-%d %H:%M:%S" + printf "$1\n\n" + +} + +if [ ! -d ${install_path} ]; then + log_cmd "${install_path} not created, override with 'install_nfdump.sh [optional path]'" + exit 1 +fi + # detect distribution # to add other distribution simply create a test case with installation commands if [ -f /etc/redhat-release ]; then install_cmd="yum -y install" - echo "installation command: $install_cmd" + log_cmd "installation command: $install_cmd" elif [ -f /etc/debian_version ]; then install_cmd="apt-get install -y" - echo "installation command: $install_cmd" + log_cmd "installation command: $install_cmd" apt-get update fi @@ -21,9 +37,9 @@ fi for dep in ${dependencies[@]}; do if type ${dep} >/dev/null 2>&1; then - echo "${dep} found" + log_cmd "${dep} found" else - echo "installing ${dep}" + log_cmd "installing ${dep}" ${install_cmd} ${dep} fi done @@ -33,18 +49,18 @@ done ######################################################### cd nfdump -./configure --enable-sflow +./configure --prefix=${install_path} --enable-sflow make make install -if type nfdump >/dev/null 2>&1; then - echo "nfdump found" +if type ${bin}/nfdump >/dev/null 2>&1; then + log_cmd "nfdump found" else - echo "ERROR: there was a problem with the nfdump installation" + log_cmd "ERROR: there was a problem with the nfdump installation" exit 1 fi cd .. -echo "Done !!!!!!!!!!!!!!!!!!!!!!!!" -nfdump -V +log_cmd "Done !!!!!!!!!!!!!!!!!!!!!!!!" +${bin}/nfdump -V