#!/bin/bash
set -xe

statusCheck(){
        if [ $1 != "0" ];then
                echo "[ERROR] :: The above command failed with the error code [ $1 ] : $(readlink -f $0)"
                exit 1
        fi
}

executeDeployment(){
        scp -r -i ~/.ssh/quicklab.key -o "UserKnownHostsFile /dev/null" -o "StrictHostKeyChecking no" -o "IdentitiesOnly=yes" /home/shchavan/development/Cases/03221269/esb_exit_testing_remote.sh quicklab@$hostName:/home/quicklab

        ssh -t -t -i ~/.ssh/quicklab.key -o "UserKnownHostsFile /dev/null" -o "StrictHostKeyChecking no" -o "IdentitiesOnly=yes" quicklab@$hostName <<EOF
sudo su - fuse
export fcName="test"
export JAVA_HOME=/home/quicklab/openjdk11
bash -x /home/quicklab/$1
exit
exit
EOF
}

##################################### EXECUTION POINT STARTS ########################################################
#hostName="node-0.shchavanvm1.lab.pnq2.cee.redhat.com"
hostName="node-0.shchavanvm74.lab.pnq2.cee.redhat.com"
executeDeployment esb_exit_testing_remote.sh; statusCheck $?
###################################### EXECUTION POINT ENDS #########################################################
