#!/bin/ksh
local_host=`hostname`
env=`echo ${local_host} | awk '{if(match($0,"dev-")>=1) print "dev";else print "sit"}'`
echo "Env for ${local_host} is $env"
ls -l /opt/vFabric/tc-genesys/lib/log4j2.xml > /tmp/${local_host}_`whoami`.txt
echo "Checking setenv.sh" >> /tmp/${local_host}_`whoami`.txt
cat /opt/vFabric/tc-genesys/bin/setenv.sh >> /tmp/${local_host}_`whoami`.txt
echo "Checking context.xml" >> /tmp/${local_host}_`whoami`.txt
cat /opt/vFabric/tc-genesys/conf/context.xml >> /tmp/${local_host}_`whoami`.txt
echo "Checking catalina.properties" >> /tmp/${local_host}_`whoami`.txt
cat /opt/vFabric/tc-genesys/conf/catalina.properties >> /tmp/${local_host}_`whoami`.txt
echo "Skipping server.xml" >> /tmp/${local_host}_`whoami`.txt
#cat /opt/vFabric/tc-genesys/conf/server.xml >> /tmp/${local_host}_`whoami`.txt
ls -l /opt/vFabric/tc-genesys/conf/*.pfx >> /tmp/${local_host}_`whoami`.txt
du -bs /opt/vFabric/tc-genesys/webapps/*.war >> /tmp/${local_host}_`whoami`.txt
du -bs /opt/vFabric/truist-ivr/shared_libraries/*.jar >> /tmp/${local_host}_`whoami`.txt
du -bs /opt/vFabric/truist-ivr/ndm-libraries/*.xml >> /tmp/${local_host}_`whoami`.txt
cd /opt/vFabric/truist-ivr/properties/$env/
du -bs application.properties >> /tmp/${local_host}_`whoami`.txt
du -bs backend-properties.xml >> /tmp/${local_host}_`whoami`.txt
du -bs sf-routing.xml >> /tmp/${local_host}_`whoami`.txt
ps aux | egrep java | egrep "tc-genesys " >> /tmp/${local_host}_`whoami`.txt
#curl -k https://${local_host}:8443/TruistMain/src-gen/Main.vxml >> /tmp/${local_host}_`whoami`.txt

#for server in prd-vgentcs01 prd-vgentcs02 prd-vgentcs03 prd-vgentcs04 prd-vgentcs05 prd-vgentcs06 prd-vgentcs07 prd-vgentcs08 drs-vgentcs02 drs-vgentcs03 drs-vgentcs04 drs-vgentcs05 drs-vgentcs06 drs-vgentcs07 drs-vgentcs08
#for server in ${local_host} drs-vgentcs02 drs-vgentcs03 drs-vgentcs04 drs-vgentcs05 drs-vgentcs06 drs-vgentcs07 drs-vgentcs08
#for server in prd-vgentcs01 prd-vgentcs02 prd-vgentcs03 prd-vgentcs04 prd-vgentcs05 prd-vgentcs06 prd-vgentcs07 prd-vgentcs08 
for server in $1
do
        echo "";
	env=`echo ${server} | awk '{if(match($0,"dev-")>=1) print "dev";else print "sit"}'`
	echo "Env for ${server} $env"
	#UPDATE SECTION BEGIN
        #ssh ${server} "rm /opt/vFabric/tc-genesys/webapps/*.war" > /tmp/${server}_`whoami`.txt
        #scp /opt/vFabric/tc-genesys/webapps/*.war ${server}:/opt/vFabric/tc-genesys/webapps
        #ssh ${server} "chmod 775 /opt/vFabric/tc-genesys/webapps/*.war" > /tmp/${server}_`whoami`.txt
        #ssh ${server} "rm /opt/vFabric/truist-ivr/shared_libraries/*.jar" > /tmp/${server}_`whoami`.txt
	#UPDATE SECTION END
        ssh ${server} "ls -l /opt/vFabric/tc-genesys/lib/log4j2.xml" > /tmp/${server}_`whoami`.txt
        echo "Checking setenv.sh" >> /tmp/${server}_`whoami`.txt
        ssh ${server} "cat /opt/vFabric/tc-genesys/bin/setenv.sh" >> /tmp/${server}_`whoami`.txt
        echo "Checking context.xml" >> /tmp/${server}_`whoami`.txt
        ssh ${server} "cat /opt/vFabric/tc-genesys/conf/context.xml" >> /tmp/${server}_`whoami`.txt
        echo "Checking catalina.properties" >> /tmp/${server}_`whoami`.txt
        ssh ${server} "cat /opt/vFabric/tc-genesys/conf/catalina.properties" >> /tmp/${server}_`whoami`.txt
        echo "Skipping server.xml" >> /tmp/${server}_`whoami`.txt
        #ssh ${server} "cat /opt/vFabric/tc-genesys/conf/server.xml"  >> /tmp/${server}_`whoami`.txt
        ssh ${server} "ls -l /opt/vFabric/tc-genesys/conf/*.pfx" >> /tmp/${server}_`whoami`.txt
        ssh ${server} "du -bs /opt/vFabric/tc-genesys/webapps/*.war" >> /tmp/${server}_`whoami`.txt
        ssh ${server} "du -bs /opt/vFabric/truist-ivr/shared_libraries/*.jar" >> /tmp/${server}_`whoami`.txt
        ssh ${server} "du -bs /opt/vFabric/truist-ivr/ndm-libraries/*.xml" >> /tmp/${server}_`whoami`.txt
        ssh ${server} "cd /opt/vFabric/truist-ivr/properties/$env/;du -bs application.properties" >> /tmp/${server}_`whoami`.txt
        ssh ${server} "cd /opt/vFabric/truist-ivr/properties/$env/;du -bs backend-properties.xml" >> /tmp/${server}_`whoami`.txt
        ssh ${server} "cd /opt/vFabric/truist-ivr/properties/$env/;du -bs sf-routing.xml" >> /tmp/${server}_`whoami`.txt
        ssh ${server} "ps aux | egrep java | egrep 'tc-genesys '" >> /tmp/${server}_`whoami`.txt
        #curl -k https://${server}:8443/TruistMain/src-gen/Main.vxml >> /tmp/${server}_`whoami`.txt
	echo "FILES DIFFERENT ON SERVER ${server}"
        diff -w /tmp/${local_host}_`whoami`.txt /tmp/${server}_`whoami`.txt
done

