From 9995fe80984ccab5cb2159a166e0a4fb83711d44 Mon Sep 17 00:00:00 2001 From: natedogs911 Date: Wed, 8 Feb 2017 11:09:55 -0800 Subject: [PATCH 1/5] add validation of install path --- install_nfdump.sh | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/install_nfdump.sh b/install_nfdump.sh index e2190a3..dd49809 100755 --- a/install_nfdump.sh +++ b/install_nfdump.sh @@ -1,7 +1,22 @@ #!/bin/bash +dir=$1 +install_path=${dir:-/opt/spot/bin} dependencies=(tar make gcc m4 automake autoconf flex byacc) +log_cmd () { + + printf "\n****SPOT.NFDUMP.Install.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 @@ -33,7 +48,7 @@ done ######################################################### cd nfdump -./configure --enable-sflow +./configure --prefix=${install_path} --enable-sflow make make install From 9acf3b5e7c585a4c36727870aa4438b79a70ea5c Mon Sep 17 00:00:00 2001 From: natedogs911 Date: Wed, 8 Feb 2017 11:13:36 -0800 Subject: [PATCH 2/5] switch to default log_cmd --- install_nfdump.sh | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/install_nfdump.sh b/install_nfdump.sh index dd49809..7d446c0 100755 --- a/install_nfdump.sh +++ b/install_nfdump.sh @@ -22,10 +22,10 @@ fi 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 @@ -36,9 +36,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 @@ -53,13 +53,13 @@ make make install if type nfdump >/dev/null 2>&1; then - echo "nfdump found" + 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 !!!!!!!!!!!!!!!!!!!!!!!!" +log_cmd "Done !!!!!!!!!!!!!!!!!!!!!!!!" nfdump -V From aa039f986cbdaa91891a3ae6e6141107a6a47906 Mon Sep 17 00:00:00 2001 From: natedogs911 Date: Wed, 8 Feb 2017 11:52:33 -0800 Subject: [PATCH 3/5] fixed bin path --- install_nfdump.sh | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/install_nfdump.sh b/install_nfdump.sh index 7d446c0..16c489c 100755 --- a/install_nfdump.sh +++ b/install_nfdump.sh @@ -1,7 +1,8 @@ #!/bin/bash dir=$1 -install_path=${dir:-/opt/spot/bin} +install_path=${dir:-/opt/spot} +bin=${install_path}/bin dependencies=(tar make gcc m4 automake autoconf flex byacc) log_cmd () { @@ -48,11 +49,11 @@ done ######################################################### cd nfdump -./configure --prefix=${install_path} --enable-sflow +./configure --without-man --prefix=${install_path} --enable-sflow make make install -if type nfdump >/dev/null 2>&1; then +if type ${bin}/nfdump >/dev/null 2>&1; then log_cmd "nfdump found" else log_cmd "ERROR: there was a problem with the nfdump installation" @@ -62,4 +63,4 @@ fi cd .. log_cmd "Done !!!!!!!!!!!!!!!!!!!!!!!!" -nfdump -V +${bin}/nfdump -V From b9019d24594aff02174af85b7fed61829213c1a0 Mon Sep 17 00:00:00 2001 From: natedogs911 Date: Wed, 8 Feb 2017 11:55:25 -0800 Subject: [PATCH 4/5] fixed log message --- install_nfdump.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install_nfdump.sh b/install_nfdump.sh index 16c489c..75443b9 100755 --- a/install_nfdump.sh +++ b/install_nfdump.sh @@ -7,7 +7,7 @@ dependencies=(tar make gcc m4 automake autoconf flex byacc) log_cmd () { - printf "\n****SPOT.NFDUMP.Install.sh****\n" + printf "\n****SPOT.NFDUMP.install_nfdump.sh****\n" date +"%y-%m-%d %H:%M:%S" printf "$1\n\n" From e808527f66234ef87f822c46e5b1da70002fc9da Mon Sep 17 00:00:00 2001 From: natedogs911 Date: Wed, 8 Feb 2017 11:59:37 -0800 Subject: [PATCH 5/5] fixed configure --- install_nfdump.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install_nfdump.sh b/install_nfdump.sh index 75443b9..cf730c3 100755 --- a/install_nfdump.sh +++ b/install_nfdump.sh @@ -49,7 +49,7 @@ done ######################################################### cd nfdump -./configure --without-man --prefix=${install_path} --enable-sflow +./configure --prefix=${install_path} --enable-sflow make make install