Added ssh test, fixed tar bug, testing traf user

1. Added ssh test to make sure able to connect

2. Fixed tar bug when running installer from other directory than
/installer/

3. Testing to make sure user is not running trafodion_installer from
the trafodion user id.

4. Added message to make sure user checks their firewall settings
if they can not access Hadoop.

Edit 1: Changed error reporting. Change locatoin of Trafodion user id
check.

Edit 2: Most check outside the for loop. Changed "much" to "must".

Change-Id: I967c94ff23a0f0d55a1ca3a8ec7d51b7fb48307f
diff --git a/installer/traf_cloudera_mods98 b/installer/traf_cloudera_mods98
index 76a6f27..14b7a72 100755
--- a/installer/traf_cloudera_mods98
+++ b/installer/traf_cloudera_mods98
@@ -161,6 +161,8 @@
 if [ $? != 0 ]; then
     echo "***ERROR: Unable to modify HDFS configuration through Cloudera's REST API."
     echo "***ERROR: Check if Cloudera URL is correct, may need to enter external IP address."
+    echo "***ERROR: Check if iptables/firewall is configured correctly and ports a
+    re enabled."
     echo "***ERROR: Check that HDFS is running without error."
     exit -1
 fi
@@ -171,7 +173,9 @@
 if [ $curl_error -ne 0 ]; then
     echo "***ERROR: Unable to modify hdfs configuration through Cloudera's REST API."
     echo "***ERROR: Check if Cloudera URL is correct, may need to enter external IP address
-." 
+."
+    echo "***ERROR: Check if iptables/firewall is configured correctly and ports a
+    re enabled."  2>&1 
     echo "***ERROR: Check that HDFS is running without error."
     exit -1
 fi
diff --git a/installer/traf_config_setup b/installer/traf_config_setup
index 18acf1a..0667bfa 100755
--- a/installer/traf_config_setup
+++ b/installer/traf_config_setup
@@ -134,11 +134,6 @@
 	source $LOCAL_TRAF_CONFIG
 fi
 
-if [[ "$(whoami)" == "$TRAF_USER" ]]; then
-   echo "***ERROR: The Trafodion username cannot be the same as the install username"
-   exit -1 
-fi
-
 echo "#!/bin/bash" > $LOCAL_TRAF_CONFIG
 echo "export TRAF_USER=\"$TRAF_USER\"" >> $LOCAL_TRAF_CONFIG
 echo "export TRAF_WORKDIR=\"$TRAF_WORKDIR\"" >> $LOCAL_TRAF_CONFIG
@@ -181,6 +176,7 @@
 else
    NODES="$answer"
    NODE_LIST=""
+   ERROR_NODES=""
    for node in $NODES
    do
       newNode=$(ssh -n $node hostname)
@@ -206,15 +202,35 @@
       fi
     
       #Testing sudo access on all nodes
-      ssh -n $node sudo echo "***INFO: Testing sudo access on node $node"
+      ssh -n $newNode sudo echo "***INFO: Testing sudo access on node $newNode"
       if [ $? -ne "0" ]; then
-         echo "***ERROR: Node $node does not have sudo access."
-         echo "***ERROR: Must have sudo access on all nodes."
-         exit -1
+         error=1
+         ERROR_NODES="$ERROR_NODES $newNode"
       fi
       
       NODE_LIST="$NODE_LIST $newNode"  
    done
+
+   if [[ $error == "1" ]]; then
+      echo "***ERROR: $ERROR_NODES does not have sudo access."
+      echo "***ERROR: Must have sudo access on all nodes."
+      exit -1
+   fi
+fi
+
+for node in $NODE_LIST
+do
+   ssh -n $node echo "***INFO: Testing ssh on $node"
+   if [[ $? -ne "0" ]]; then
+      errorFound=1
+      ERROR_NODES="$ERROR_NODES $node"
+   fi
+done
+
+if [[ $errorFound == "1" ]]; then
+   echo "***ERROR: Could not ssh to $ERROR_NODES."
+   echo "***ERROR: Check permissions and known hosts files."
+   exit -1 
 fi
 
 node_count=$(echo $NODE_LIST | wc -w)
@@ -455,10 +471,10 @@
    exit -1
 fi
 
-install_features_path=$(tar -tf $TRAF_BUILD | grep "install_features")
+install_features_path=$(tar -tf $LOCAL_WORKDIR/$TRAF_BUILD | grep "install_features")
 
 if [[ ! -z $install_features_path ]]; then
-   tar -xzf $TRAF_BUILD $install_features_path
+   tar -xzf $LOCAL_WORKDIR/$TRAF_BUILD $install_features_path
    source $install_features_path
    echo "export CDH_5_3_HDP_2_2_SUPPORT=\"$CDH_5_3_HDP_2_2_SUPPORT\"" >> $LOCAL_TRAF_CONFIG
 else
diff --git a/installer/traf_hortonworks_mods98 b/installer/traf_hortonworks_mods98
index 495409f..8be5f37 100755
--- a/installer/traf_hortonworks_mods98
+++ b/installer/traf_hortonworks_mods98
@@ -150,6 +150,8 @@
 if [ $? != 0 ]; then
     echo "***ERROR: unable to modify hbase.master.distributed.log.splitting through Ambari's configs.sh script."
     echo "***ERROR: Check if Ambari URL is correct, may need to enter external IP address."
+    echo "***ERROR: Check if iptables/firewall is configured correctly and ports a
+    re enabled."
     echo "***ERROR: Check that HBase is running without error."
     exit -1
 fi
diff --git a/installer/trafodion_install b/installer/trafodion_install
index e9ae635..0847f07 100755
--- a/installer/trafodion_install
+++ b/installer/trafodion_install
@@ -113,14 +113,6 @@
 echo
 
 #==============================================
-# check that we are running from a userid with sudo access
-sudo echo "***INFO: testing sudo access"
-if [ $? -ne 0 ]; then
-    echo "***ERROR: This script must be run from a userid with sudo access."
-    exit -1
-fi
-
-#==============================================
 # Default values
 
 export timestamp=$(date +%F-%H-%M-%S)
@@ -136,6 +128,22 @@
 export TRAF_USER="trafodion"
 
 #==============================================
+#Prechecks 
+
+#Check not installing as userid Trafodion
+if [[ "$(whoami)" == "$TRAF_USER" ]]; then
+   echo "***ERROR: The Trafodion username cannot be the same as the install username"
+   exit -1
+fi
+
+# check that we are running from a userid with sudo access
+sudo echo "***INFO: testing sudo access"
+if [ $? -ne 0 ]; then
+    echo "***ERROR: This script must be run from a userid with sudo access."
+    exit -1
+fi
+
+#==============================================
 # Setup log & working directories
 
 sudo mkdir -p $TRAF_LOGDIR
@@ -691,13 +699,14 @@
       reserved_ports=$(ssh $node -n '/sbin/sysctl net.ipv4.ip_local_reserved_ports' | awk -F'=' '{print $2;}' | sed 's/^ //')
       ssh $node -n 'sudo chmod 777 /etc/sysctl.conf'
       ssh $node -n 'sudo sed -i '/net.ipv4.ip_local_reserved_ports""\=*/d' /etc/sysctl.conf'
-      if [[ -z "${reserved_ports}" ]]; then
-         ssh $node -n "sudo echo "$reservedTrafodionPorts" >> /etc/sysctl.conf"
-      else
-         ssh $node -n "sudo echo "$reservedTrafodionPorts","$reserved_ports" >> /etc/sysctl.conf"
-      fi
-      ssh $node -n 'sudo chmod 644 /etc/sysctl.conf'
-      ssh $node -n 'sudo /sbin/sysctl -p'
+
+   if [[ -z "${reserved_ports}" ]]; then
+      ssh $node -n 'sudo echo "$reservedTrafodionPorts" >> /etc/sysctl.conf'
+   else
+      ssh $node -n "sudo echo "$reservedTrafodionPorts","$reserved_ports" >> /etc/sysctl.conf"
+   fi
+   ssh $node -n 'sudo chmod 644 /etc/sysctl.conf'
+   ssh $node -n 'sudo /sbin/sysctl -p'
    else
       echo "***ERROR: Unable to reserve DCS ports (37800 and 40010)."
       exit -1