#!/bin/bash
#
###################################################################################################################################
# Script: 		service_binrep_update.sh
# Description: 	Service administration script
# Author: 		ABS Laundry Business Solutions
# Version: 		9.08.00
#### Changelog of script ##########################################################################################################
# Date        Author    Version 	Change   
# 13-jun-2011 JMI	1.2     	Initial setup
# 17-jun-2011 JMI	1.3     	removed rsync compression option
#                               	- merged rsync jobs for example /Lib & /License
#                                 	  included in one job
#                               	- binary replication based on global repository
# 14-aug-2015 ROP  	1.7     	Changed for rolling updates
# 24-mar-2017 MBU       1.8     	Changes for uhfmonitor application
# 16-aug-2017 MBU	1.9     	Bugfix if structure line 776 command not found
# 27-Dec-2018 MBU	3.0		Added parallel web deployment procedure
# 26-Mar-2019 MBU	3.3		Added support to deploy new webapplications: wua=webclient my uniform assistant wrd=webclient residential delivery wrr=webclient route returns
#					Bugfix: Install glassfish on non web servers
# 04-Apr-2019 MBU	4.0		Added exclusion option for CUSTOMER reports with ABSM_EXCLUDECUSTREP setting
#					Added custom heapsize setting
# 17-Apr-2019 MBU	4.1		Synchronization of application server libraries for report server only slot
# 07-May-2019 MBU	4.2		Bugfix: Parallel deploy custom skin for WP2 gives deployment error
# 27-Jun-2019 MBU	4.3		Bugfix: Service retrieval on partial environment name hit
# 20-Mar-2024 RAY       6.0  		Support for Glassfish411, Payara5, Tomee8, Tomee91 and Tomcat90
# 03-Apr-2024 RAY       9.08.00		Renamed version
# 25-Apr-2024 RAY       9.08.00         Added Support for Tomcat9 - ABS-164468
# 01-Jul-2024 RAY       9.08.01         Added Support for Tomcat9 and Tomcat10 - ABS-165658
# 19-Aug-2024 RAY       9.08.01         Added Support for Tomcat9 for 9.08.00 - ABS-167946
# 21-Aug-2024 RAY       9.08.01         TI changes for replacing TomEE with Tomcat in 9.08.00 - ABS-167946
# 04-Nov-2024 RAY	9.09.00 	Absmenu update supporting Java21 for ABSSolute 9.09.00 - ABS-170835
# 04-Nov-2024 RAY	9.09.00 	Absmenu update supporting Plugins folder - INSTALLER-176
# 04-Nov-2024 RAY	9.09.00 	Absmenu update supporting Application Server new Classpath location - ABS-170842
# 03-Dec-2024 RAY	9.09.00 	Bugfix: Deploy remote web applications
# 01-Jun-2025 RAY       9.09.02         ABSSolute Server - Standardization & hot redeploy - TS-839
# 09-Oct-2025 RAY       9.09.02         ABSSolute Server - Fixed issue creating deploy directory on remote server
# 10-Dec-2025 RAY       9.09.02         Java 17 minor version update to Vestis - TS-1955
#################################################################################################################################

pushd () {
    command pushd "$@" > /dev/null
}

popd () {
    command popd "$@" > /dev/null
}

# Cleanup method when exiting ABSMENU during parallel web deploy
stop_web_deploy_parallel()
{
	for pidfile in $ABSMENUPATH/tmp/*.pid
	do
		if [ -f $pidfile ]
		then
			kill $(cat $pidfile)
		fi
	done
	
	rm -f $ABSMENUPATH/tmp/*.pid
	rm -f $ABSMENUPATH/tmp/*.deploylist
}

# Cleanup method when exiting ABSMENU during parallel webserver deploy
stop_webserver_deploy_parallel()
{
	for pidfile in $ABSMENUPATH/tmp/*.pid
	do
		kill $(cat $pidfile)
	done
	
	rm -f $ABSMENUPATH/tmp/*.pid
	rm -f $ABSMENUPATH/tmp/*.deploylist
}

# Cleanup method when exiting ABSMENU during parallel webserver delete
stop_delete_web_server_parallel()
{
	for pidfile in $ABSMENUPATH/tmp/*.pid
	do
		if [ -f $pidfile ]
		then
			kill $(cat $pidfile)
		fi
	done
	
	rm -f $ABSMENUPATH/tmp/*.pid
	rm -f $ABSMENUPATH/tmp/*.delwslist
}

# Copied from abs.sh
# Not used
make_wideslot()
{
# take $1 and make it $SLOTPOS positions wide
# if $SLOTPOS < length($1) then do not change the slotnumber
    WIDESLOT=$1
    if [ $SLOTPOS -ge ${#WIDESLOT} ]
    then
        WIDESLOT="00000000000000"$1
        WIDESLOT=${WIDESLOT:(-$SLOTPOS)}
    fi
	export WIDESLOT
    return $WIDESLOT
}

# Copied from abs.sh
make_wideslot_v1()
{
# take $1 and make it $SLOTPOS positions wide
# if $SLOTPOS < length($1) then do not change the slotnumber
    WIDESLOT=$1
    if [ $SLOTPOS -ge ${#WIDESLOT} ]
    then
		WIDESLOT=`printf '0%d' ${WIDESLOT#0}`
    fi
	export WIDESLOT
    return $WIDESLOT
}

# Check SNMP status code. Return SNMP status
snmpcheck_app_server()
{
	# $1 = SNMP_SERVER
	# $2 = SNMP_SLOT

	SNMP_SERVER=$1
	SNMP_SLOT=$2
	
	[ ${#SNMP_SLOT} == 1 ] && SNMPVALUE=$(snmpwalk -c public -v 1 udp:$SNMP_SERVER:50${SNMP_SLOT}14 1.3.6.1.4.1.227.1.1 | rev | head -c2 | rev | xargs)
	[ ${#SNMP_SLOT} == 2 ] && SNMPVALUE=$(snmpwalk -c public -v 1 udp:$SNMP_SERVER:5${SNMP_SLOT}14 1.3.6.1.4.1.227.1.1 | rev | head -c2 | rev | xargs)
	
	[ "$SNMPVALUE" == "1" ] && return 0
	return 1
}

# Copied from abs.sh
snmpcheck_app_server_v0()
{
	# Check SNMP status code. Return SNMP status
	# $1 = SNMP_SERVERPORT
	SNMP_SERVER=$1
	SNMP_PORT=$2
	SNMP_SERVERPORT=$SNMP_SERVER":"$SNMP_PORT
	
	SNMPVALUE=$(snmpwalk -c public -r 1 -v 1 udp:$SNMP_SERVERPORT 1.3.6.1.4.1.227.1.1 | rev | head -c2 | rev | xargs)
	
	[ "$SNMPVALUE" != "1" ] && return 1
	return 0
}

# Start processing with PID files
delete_web_server_parallel()
{
	# $1 = environment
	
	# No web applications
	[ $(grep '^ *'$1"[[:blank:]]" $ABSMENUGLOBALCONFIG | awk '$4!="app" && $4!="rep" { print $0 } ' | wc -l) -eq 0 ] && return 0
	
	# Remove old pid files and deploy lists
	if [ -f $ABSMENUPATH/tmp/*.pid ]
	then
		rm -f $ABSMENUPATH/tmp/*.pid
	fi
	if [ -f $ABSMENUPATH/tmp/*.delwslist ]
	then
		rm -f $ABSMENUPATH/tmp/*.delwslist
	fi
	
	# Register TRAP function
	trap stop_delete_web_server_parallel EXIT
	
	# Launching webserver install process
	grep '^ *'$1"[[:blank:]]" $ABSMENUGLOBALCONFIG | sort -k2,2 -k5,5 -k4,4 | awk '$4!="app" && $4!="rep" { print $2,$5 } ' | uniq | while read ABSM_SERVERNAME ABSM_SLOT
	do
		absmenu_logline "Start Delete process of web server on $ABSM_SERVERNAME on slot $ABSM_SLOT "
		delete_web_server_slot_parallel $1 $ABSM_SERVERNAME $ABSM_SLOT &
		sleep 1
	done
	
	# Check amount of PID files until 0 (check processes instead)
	echo ""
	echo "****************** Delete Web Server overview *******************"
	echo "**************** This process might take a while ****************"
	while [ $(find $ABSMENUPATH/tmp -name '*.pid' | wc -l ) -ne 0 ]
	do
		sleep 1
	done
	if [ -f $ABSMENUPATH/tmp/*.delwslist ]
	then
		[ $(cat $ABSMENUPATH/tmp/*.delwslist | wc -l) -eq 0 ] && echo "******* The were no errors during the delete process *******"
		rm -f $ABSMENUPATH/tmp/*.delwslist
	fi
	trap '' EXIT
	echo ""
}

# Delete a specific web slot from an environment
delete_web_server_slot_parallel()
{
	# $1 = Environment
	# $2 = Server name
	# $3 = Slot number
	
	ABSM_ENVIRONMENT=$1
	ABSM_SERVERNAME=$2
	ABSM_SLOT=$3
	
	PIDFILE=$ABSMENUPATH/tmp/"$ABSM_SERVERNAME"_"$ABSM_SLOT".pid
	ABSMSCRIPTLOGNAME=`date +"$ABSMENULOGPATH"/absmenu_parallel_"$ABSM_SERVERNAME"_"$ABSM_SLOT"_%Y_%V.log`
	PROCESSID=$BASHPID
	ENDTIMESTAMP=$(date --date="$GFSNMPMAXAPPSTARTTIME min" +"%s")
	
	# Create PID
	echo $PROCESSID  > $PIDFILE
	absmenu_logline "Start deleting the webserver with the PID file: $PIDFILE (logfile = $ABSMSCRIPTLOGNAME)"
	echo "Deleting webserver on $ABSM_SERVERNAME slot $ABSM_SLOT (logfile = $ABSMSCRIPTLOGNAME)"
	
	# Create webserver deploy list
	grep '^ *'$ABSM_ENVIRONMENT"[[:blank:]]" $ABSMENUGLOBALCONFIG | sort -k29,29 | awk '$4!="app" && $4!="rep" { print $29 } ' | uniq | while read WEBSERVER_VERSION
	do
		# Delete webserver slot from the server
		delete_webserver $ABSM_ENVIRONMENT $ABSM_SERVERNAME $ABSM_SLOT $WEBSERVER_VERSION &> /dev/null
	done
	
	rm $PIDFILE
	kill $PROCESSID
}


# Start processing with PID files
start_web_deploy_parallel()
{
	# $1 = environment
	
	# No web applications
	[ $(grep '^ *'$1"[[:blank:]]" $ABSMENUGLOBALCONFIG | awk '$4!="app" && $4!="rep" { print $0 } ' | wc -l) -eq 0 ] && return 0
	
	# Remove old pid files and deploy lists
	rm -f $ABSMENUPATH/tmp/*.pid
	rm -f $ABSMENUPATH/tmp/*.deploylist
	
	# Register TRAP function
	trap stop_web_deploy_parallel EXIT
	
	# Creating the WAR files in the repository for deployment
	echo ""
	create_repository_warfiles $1 &> /dev/null
	
	# Launching webserver install process
	grep '^ *'$1"[[:blank:]]" $ABSMENUGLOBALCONFIG | sort -k2,2 -k5,5 -k4,4 | awk '$4!="app" && $4!="rep" { print $2,$5 } ' | uniq | while read ABSM_SERVERNAME ABSM_SLOT
	do
		absmenu_logline "Start web deployment process for webserver on $ABSM_SERVERNAME on slot $ABSM_SLOT"
		install_web_slot_parallel $1 $ABSM_SERVERNAME $ABSM_SLOT &
		sleep 1
	done
	
	# Check amount of PID files until 0 (check processes instead)
	echo ""
	echo "******************** Web deployment overview *******************"
	echo "**************** This process might take a while ***************"
	while [ $(find $ABSMENUPATH/tmp -name '*.pid' | wc -l ) -ne 0 ]
	do
		sleep 1
	done
	[ $(cat $ABSMENUPATH/tmp/*.deploylist | wc -l) -eq 0 ] && echo "******* The were no errors during the deployment process *******"
	rm -f $ABSMENUPATH/tmp/*.deploylist
	
	# Removing war files from repository
	remove_repository_warfiles $1
	trap '' EXIT
	echo ""
}

# Start processing with PID files
start_webserver_deploy_parallel()
{
	# $1 = environment
	
	# No web applications
	[ $(grep '^ *'$1"[[:blank:]]" $ABSMENUGLOBALCONFIG | awk '$4!="app" && $4!="rep" { print $0 } ' | wc -l) -eq 0 ] && return 0
	
	# Remove old pid files and deploy lists
	rm -f $ABSMENUPATH/tmp/*.pid
	rm -f $ABSMENUPATH/tmp/*.deploylist
	# Register TRAP function
	trap stop_webserver_deploy_parallel EXIT
	
	# Launching webserver install process
	grep '^ *'$1"[[:blank:]]" $ABSMENUGLOBALCONFIG | sort -k2,2 -k5,5 -k4,4 | awk '$4!="app" && $4!="rep" { print $2,$5 } ' | uniq | while read ABSM_SERVERNAME ABSM_SLOT
	do
		absmenu_logline "Start deployment process for webserver on $ABSM_SERVERNAME on slot $ABSM_SLOT"
		install_webserver_slot_parallel $1 $ABSM_SERVERNAME $ABSM_SLOT &
		sleep 1
	done
	
	# Check amount of PID files until 0 (check processes instead)
	echo ""
	echo "******************** Webserver deployment overview *******************"
	echo "******************* This process might take a while ******************"
	while [ $(find $ABSMENUPATH/tmp -name '*.pid' | wc -l ) -ne 0 ]
	do
		sleep 1
	done
	if [ -e $ABSMENUPATH/tmp/*.deploylist ]
	then
		[ $(cat $ABSMENUPATH/tmp/*.deploylist | wc -l) -eq 0 ] && rm -f $ABSMENUPATH/tmp/*.deploylist
	fi
	echo "******* The were no errors during the webserver deployment process *******"
	
	trap '' EXIT
	echo ""
}

# Installs a specific web slot from an environment
install_webserver_slot_parallel()
{
	# $1 = Environment
	# $2 = Server name
	# $3 = Slot number
	
	ABSM_ENVIRONMENT=$1
	ABSM_SERVERNAME=$2
	ABSM_SLOT=$3
	
	PIDFILE=$ABSMENUPATH/tmp/"$ABSM_SERVERNAME"_"$ABSM_SLOT".pid
	ABSMSCRIPTLOGNAME=`date +"$ABSMENULOGPATH"/absmenu_parallel_"$ABSM_SERVERNAME"_"$ABSM_SLOT"_%Y_%V.log`
	PROCESSID=$BASHPID
	ENDTIMESTAMP=$(date --date="$GFSNMPMAXAPPSTARTTIME min" +"%s")
	
	# Create PID
	echo $PROCESSID  > $PIDFILE
	absmenu_logline "Start installation of the webserver with the PID file: $PIDFILE (logfile = $ABSMSCRIPTLOGNAME)"
	echo "Deploying webserver on $ABSM_SERVERNAME slot $ABSM_SLOT (logfile = $ABSMSCRIPTLOGNAME)"
	
	# Create webserver deploy list
	grep '^ *'$ABSM_ENVIRONMENT"[[:blank:]]" $ABSMENUGLOBALCONFIG | sort -k29,29 | awk '$4!="app" && $4!="rep" { print $29 } ' | uniq | while read WEBSERVER_VERSION
	do
		# Install webserver on the server
		install_cleanup_webserver $ABSM_ENVIRONMENT $ABSM_SERVERNAME $ABSM_SLOT $WEBSERVER_VERSION &> /dev/null
	done
	
	rm $PIDFILE
	kill $PROCESSID
}	
	
# Installs a specific web slot for an environment
install_web_slot_parallel()
{
	# $1 = Environment
	# $2 = Server name
	# $3 = Slot number
	
	ABSM_ENVIRONMENT=$1
	ABSM_SERVERNAME=$2
	ABSM_SLOT=$3
	
	PIDFILE=$ABSMENUPATH/tmp/"$ABSM_SERVERNAME"_"$ABSM_SLOT".pid
	ABSMSCRIPTLOGNAME=`date +"$ABSMENULOGPATH"/absmenu_parallel_"$ABSM_SERVERNAME"_"$ABSM_SLOT"_%Y_%V.log`
	PROCESSID=$BASHPID
	ENDTIMESTAMP=$(date --date="$GFSNMPMAXAPPSTARTTIME min" +"%s")
	
	# Create PID
	echo $PROCESSID  > $PIDFILE
	absmenu_logline "Start installation of the webserver with the PID file: $PIDFILE (logfile = $ABSMSCRIPTLOGNAME)"
	echo "Deploying web applications on $ABSM_SERVERNAME slot $ABSM_SLOT (logfile = $ABSMSCRIPTLOGNAME)"
	
	# Create web server deploy list
	grep '^ *'$ABSM_ENVIRONMENT"[[:blank:]]" $ABSMENUGLOBALCONFIG | sort -k29,29 | awk '$4!="app" && $4!="rep" { print $29 } ' | uniq | while read WEBSERVER_VERSION
	do
		# Install webserver on the server
		install_cleanup_webserver $ABSM_ENVIRONMENT $ABSM_SERVERNAME $ABSM_SLOT $WEBSERVER_VERSION &> /dev/null
	done
	
	# Create deploy list
	grep '^ *'$ABSM_ENVIRONMENT"[[:blank:]]" $ABSMENUGLOBALCONFIG | sort -k2,2 -k5,5 -k4,4 | awk -v a="$ABSM_SERVERNAME" -v b="$ABSM_SLOT" '$2==a && $5==b && $4!="app" && $4!="rep" { print "DEPLOY", $1, $2, $4, $5, $19, $20, $21, $22, $23, $24 } ' > $ABSMENUPATH/tmp/"$ABSM_SERVERNAME"_"$ABSM_SLOT".deploylist
	DEPLOYLIST=$ABSMENUPATH/tmp/"$ABSM_SERVERNAME"_"$ABSM_SLOT".deploylist
	
	# Check if the domain is running
	if [ $GLASSFISHPATH ]
	then
		check_glassfish_domainstatus $ABSM_ENVIRONMENT $ABSM_SERVERNAME $ABSM_SLOT
		if [ $? -ne 0 ] 
		then
			absmenu_logline "Cancelled installation of the webserver with the PID file: $PIDFILE (logfile = $ABSMSCRIPTLOGNAME)"
			cat $DEPLOYLIST | while read ABSM_DEPLOYSTATUS ABSM_ENVIRONMENT ABSM_SERVERNAME ABSM_TYPE ABSM_SLOT ABSM_GFDOMAIN ABSM_WEBCONTEXT ABSM_WEBNAME ABSM_WEBLIB ABSM_CONNAPPSRV ABSM_CONNAPPSLOT
			do
				# Remove line from deploylist
				sed -i "/$ABSM_WEBNAME/d" $DEPLOYLIST
				# Add to deploylist with error
				echo "GFINSTALLERROR $ABSM_ENVIRONMENT $ABSM_SERVERNAME $ABSM_TYPE $ABSM_SLOT $ABSM_GFDOMAIN $ABSM_WEBCONTEXT $ABSM_WEBNAME $ABSM_WEBLIB $ABSM_CONNAPPSRV $ABSM_CONNAPPSLOT" >> $DEPLOYLIST
				echo "- $ABSM_SERVERNAME slot $ABSM_SLOT $ABSM_WEBCONTEXT ($ABSM_TYPE): Glassfish/Payara Webserver did not install successfully."
			done
			rm $PIDFILE
			kill $PROCESSID
		fi
	fi
	
	if [ $TOMEE8FOLDERNAME ]
	then
		check_web_status $ABSM_ENVIRONMENT $ABSM_SERVERNAME $ABSM_SLOT
		if [ $? -ne 0 ] 
		then
			absmenu_logline "Cancelled installation of the webserver with the PID file: $PIDFILE (logfile = $ABSMSCRIPTLOGNAME)"
			cat $DEPLOYLIST | while read ABSM_DEPLOYSTATUS ABSM_ENVIRONMENT ABSM_SERVERNAME ABSM_TYPE ABSM_SLOT ABSM_GFDOMAIN ABSM_WEBCONTEXT ABSM_WEBNAME ABSM_WEBLIB ABSM_CONNAPPSRV ABSM_CONNAPPSLOT
			do
				# Remove line from deploylist
				sed -i "/$ABSM_WEBNAME/d" $DEPLOYLIST
				# Add to deploylist with error
				echo "GFINSTALLERROR $ABSM_ENVIRONMENT $ABSM_SERVERNAME $ABSM_TYPE $ABSM_SLOT $ABSM_GFDOMAIN $ABSM_WEBCONTEXT $ABSM_WEBNAME $ABSM_WEBLIB $ABSM_CONNAPPSRV $ABSM_CONNAPPSLOT" >> $DEPLOYLIST
				echo "- $ABSM_SERVERNAME slot $ABSM_SLOT $ABSM_WEBCONTEXT ($ABSM_TYPE): Tomee8 Webserver did not install successfully."
			done
			rm $PIDFILE
			kill $PROCESSID
		fi
	fi
	
	if [ $TOMEEFOLDERNAME ]
	then
		check_tomee_status $ABSM_ENVIRONMENT $ABSM_SERVERNAME $ABSM_SLOT
		if [ $? -ne 0 ] 
		then
			absmenu_logline "Cancelled installation of the webserver with the PID file: $PIDFILE (logfile = $ABSMSCRIPTLOGNAME)"
			cat $DEPLOYLIST | while read ABSM_DEPLOYSTATUS ABSM_ENVIRONMENT ABSM_SERVERNAME ABSM_TYPE ABSM_SLOT ABSM_GFDOMAIN ABSM_WEBCONTEXT ABSM_WEBNAME ABSM_WEBLIB ABSM_CONNAPPSRV ABSM_CONNAPPSLOT
			do
				case $ABSM_TYPE in
					gws|w4m|wsr|wmr) ;;
					wp2|wum|wcl|wua|wrd|wrr|wsb|wfb|wcp|ara) 
						# Remove line from deploylist
						sed -i "/$ABSM_WEBNAME/d" $DEPLOYLIST
						# Add to deploylist with error
						echo "GFINSTALLERROR $ABSM_ENVIRONMENT $ABSM_SERVERNAME $ABSM_TYPE $ABSM_SLOT $ABSM_GFDOMAIN $ABSM_WEBCONTEXT $ABSM_WEBNAME $ABSM_WEBLIB $ABSM_CONNAPPSRV $ABSM_CONNAPPSLOT" >> $DEPLOYLIST
						echo "- $ABSM_SERVERNAME slot $ABSM_SLOT $ABSM_WEBCONTEXT ($ABSM_TYPE): Tomee91 Webserver did not install successfully."
						;;
				esac
			done
			rm $PIDFILE
			kill $PROCESSID
		fi
	fi
	
	if [ $TOMCATFOLDERNAME ]
	then
		check_tomcat_status $ABSM_ENVIRONMENT $ABSM_SERVERNAME $ABSM_SLOT
		if [ $? -ne 0 ] 
		then
			absmenu_logline "Cancelled installation of the webserver with the PID file: $PIDFILE (logfile = $ABSMSCRIPTLOGNAME)"
			cat $DEPLOYLIST | while read ABSM_DEPLOYSTATUS ABSM_ENVIRONMENT ABSM_SERVERNAME ABSM_TYPE ABSM_SLOT ABSM_GFDOMAIN ABSM_WEBCONTEXT ABSM_WEBNAME ABSM_WEBLIB ABSM_CONNAPPSRV ABSM_CONNAPPSLOT
			do
				case $ABSM_TYPE in
					wp2|wum|wcl|wua|wrd|wrr|wsb|wfb|wcp|ara) ;;
					gws|w4m|wsr|wmr)
						# Remove line from deploylist
						sed -i "/$ABSM_WEBNAME/d" $DEPLOYLIST
						# Add to deploylist with error
						echo "GFINSTALLERROR $ABSM_ENVIRONMENT $ABSM_SERVERNAME $ABSM_TYPE $ABSM_SLOT $ABSM_GFDOMAIN $ABSM_WEBCONTEXT $ABSM_WEBNAME $ABSM_WEBLIB $ABSM_CONNAPPSRV $ABSM_CONNAPPSLOT" >> $DEPLOYLIST
						echo "- $ABSM_SERVERNAME slot $ABSM_SLOT $ABSM_WEBCONTEXT ($ABSM_TYPE): Tomcat90 Webserver did not install successfully."
						;;
				esac
			done
			rm $PIDFILE
			kill $PROCESSID
		fi
	fi
	
	if [ $TOMCAT9FOLDERNAME ]
	then
		check_tomcat9_status $ABSM_ENVIRONMENT $ABSM_SERVERNAME $ABSM_SLOT
		if [ $? -ne 0 ] 
		then
			absmenu_logline "Cancelled installation of the Tomcat9 webserver with the PID file: $PIDFILE (logfile = $ABSMSCRIPTLOGNAME)"
			cat $DEPLOYLIST | while read ABSM_DEPLOYSTATUS ABSM_ENVIRONMENT ABSM_SERVERNAME ABSM_TYPE ABSM_SLOT ABSM_GFDOMAIN ABSM_WEBCONTEXT ABSM_WEBNAME ABSM_WEBLIB ABSM_CONNAPPSRV ABSM_CONNAPPSLOT
			do
				case $ABSM_TYPE in
					wp2|wum|wcl|wrd|wrr|wsb|wfb|wcp|gws|w4m|wsr|wmr)
						# Remove line from deploylist
						sed -i "/$ABSM_WEBNAME/d" $DEPLOYLIST
						# Add to deploylist with error
						echo "GFINSTALLERROR $ABSM_ENVIRONMENT $ABSM_SERVERNAME $ABSM_TYPE $ABSM_SLOT $ABSM_GFDOMAIN $ABSM_WEBCONTEXT $ABSM_WEBNAME $ABSM_WEBLIB $ABSM_CONNAPPSRV $ABSM_CONNAPPSLOT" >> $DEPLOYLIST
						echo "- $ABSM_SERVERNAME slot $ABSM_SLOT $ABSM_WEBCONTEXT ($ABSM_TYPE): Tomcat9 Webserver did not install successfully."
						;;
				esac
			done
			rm $PIDFILE
			kill $PROCESSID
		fi
	fi
	
	if [ $TOMCAT10FOLDERNAME ]
	then
		check_tomcat10_status $ABSM_ENVIRONMENT $ABSM_SERVERNAME $ABSM_SLOT
		if [ $? -ne 0 ]
		then
			absmenu_logline "Cancelled installation of the Tomcat10 webserver with the PID file: $PIDFILE (logfile = $ABSMSCRIPTLOGNAME)"
			cat $DEPLOYLIST | while read ABSM_DEPLOYSTATUS ABSM_ENVIRONMENT ABSM_SERVERNAME ABSM_TYPE ABSM_SLOT ABSM_GFDOMAIN ABSM_WEBCONTEXT ABSM_WEBNAME ABSM_WEBLIB ABSM_CONNAPPSRV ABSM_CONNAPPSLOT
			do
				case $ABSM_TYPE in
					wp2|wum|wcl|wrd|wrr|wsb|wfb|wcp)
						# Remove line from deploylist
						sed -i "/$ABSM_WEBNAME/d" $DEPLOYLIST
						# Add to deploylist with error
						echo "GFINSTALLERROR $ABSM_ENVIRONMENT $ABSM_SERVERNAME $ABSM_TYPE $ABSM_SLOT $ABSM_GFDOMAIN $ABSM_WEBCONTEXT $ABSM_WEBNAME $ABSM_WEBLIB $ABSM_CONNAPPSRV $ABSM_CONNAPPSLOT" >> $DEPLOYLIST
						echo "- $ABSM_SERVERNAME slot $ABSM_SLOT $ABSM_WEBCONTEXT ($ABSM_TYPE): Tomcat10 Webserver did not install successfully."
						;;
				esac
			done
			rm $PIDFILE
			kill $PROCESSID
		fi
	fi
		
	# Move binaries to server
	create_server_warfiles $ABSM_ENVIRONMENT $ABSM_SERVERNAME $ABSM_SLOT &> /dev/null
	
	# Deploy based on SNMP until $ENDTIMESTAMP is reached (or deploylist is empty )
	while true 
	do
		# Perform deploy of each webapp and remove line from the deploylist if deployed is performed		
		cat $DEPLOYLIST | awk -v a="DEPLOY" '$1==a  { print $0 } ' | while read ABSM_DEPLOYSTATUS ABSM_ENVIRONMENT ABSM_SERVERNAME ABSM_TYPE ABSM_SLOT ABSM_GFDOMAIN ABSM_WEBCONTEXT ABSM_WEBNAME ABSM_WEBLIB ABSM_CONNAPPSRV ABSM_CONNAPPSLOT WEBSERVER_VERSION
		do
			#Check SNMP - make_wideslot returns slot value into $WIDESLOT
			make_wideslot $ABSM_CONNAPPSLOT

			snmpcheck_app_server $ABSM_CONNAPPSRV "5"$ABSM_CONNAPPSLOT"14" &> /dev/null
			#snmpcheck_app_server $ABSM_CONNAPPSRV "5"$WIDESLOT"14"
			if [ $? -ne 1 ]
			then
				# Remove line from deploylist
				sed -i "/$ABSM_WEBNAME/d" $DEPLOYLIST

				# Check if Glassfish webserver is present and start deployment
				if [ $GLASSFISHPATH ] 
				then
					# Deploy web application
					deploy_glassfish_warfiles $ABSM_ENVIRONMENT $ABSM_SERVERNAME $ABSM_TYPE $ABSM_SLOT $ABSM_WEBNAME $ABSM_GFDOMAIN $ABSM_WEBCONTEXT $ABSM_WEBLIB &> /dev/null
:<<COMMENT
					if [ $? -ne 1 ]
					then
						echo "DEPLOYFAILED $ABSM_ENVIRONMENT $ABSM_SERVERNAME $ABSM_TYPE $ABSM_SLOT $ABSM_GFDOMAIN $ABSM_WEBCONTEXT $ABSM_WEBNAME $ABSM_WEBLIB $ABSM_CONNAPPSRV $ABSM_CONNAPPSLOT $WEBSERVER_VERSION" >> $DEPLOYLIST
						echo "- $ABSM_SERVERNAME slot $ABSM_SLOT $ABSM_WEBCONTEXT ($ABSM_TYPE): Deployment error - check the Glassish server logs for more details."
					fi
COMMENT
				fi
				
				# Check if Tomee8 web server is present and start deployment
				if [ $TOMEE8FOLDERNAME ]
				then
					# Deploy web application to Tomee8
					case "$ABSM_TYPE" in
						wp2|wum|wcl|wua|wrd|wrr|wsb|wfb|wcp|ara|gws|w4m|wsr|wmr)    deploy_web_warfiles $ABSM_ENVIRONMENT $ABSM_SERVERNAME $ABSM_TYPE $ABSM_SLOT &> /dev/null
																					;;
					esac
:<<COMMENT
					snmpcheck_web
					if [ $? -ne 1 ]
					then
						echo "DEPLOYFAILED $ABSM_ENVIRONMENT $ABSM_SERVERNAME $ABSM_TYPE $ABSM_SLOT $ABSM_CONNAPPSRV $ABSM_CONNAPPSLOT $WEBSERVER_VERSION" >> $DEPLOYLIST
						echo "- $ABSM_SERVERNAME slot $ABSM_SLOT $ABSM_WEBCONTEXT ($ABSM_TYPE): Deployment error - check the Tomee8 server logs for more details."
					fi
COMMENT
				fi

				# Check if Tomee91 web server is present and start deployment
				if [ $TOMEEFOLDERNAME ]
				then
					# Deploy web application to Tomee91
					case "$ABSM_TYPE" in
						wp2|wum|wcl|wua|wrd|wrr|wsb|wfb|wcp|ara)    deploy_tomee_warfiles $ABSM_ENVIRONMENT $ABSM_SERVERNAME $ABSM_TYPE $ABSM_SLOT &> /dev/null
																	;;
					esac
:<<COMMENT
					snmpcheck_tomee		
					if [ $? -ne 1 ]
					then
						echo "DEPLOYFAILED $ABSM_ENVIRONMENT $ABSM_SERVERNAME $ABSM_TYPE $ABSM_SLOT $ABSM_CONNAPPSRV $ABSM_CONNAPPSLOT $WEBSERVER_VERSION" >> $DEPLOYLIST
						echo "- $ABSM_SERVERNAME slot $ABSM_SLOT $ABSM_WEBCONTEXT ($ABSM_TYPE): Deployment error - check the Tomee91 server logs for more details."
					fi
COMMENT
				fi
				
				# Check if Tomcat90 web server is present and start deployment
				if [ $TOMCATFOLDERNAME ]
				then
					# Deploy web application to Tomcat90
					case "$ABSM_TYPE" in
						gws|w4m|wsr|wmr)    deploy_tomcat_warfiles $ABSM_ENVIRONMENT $ABSM_SERVERNAME $ABSM_TYPE $ABSM_SLOT &> /dev/null ;;
					esac
:<<COMMENT
					snmpcheck_tomcat
					if [ $? -ne 1 ]
					then
						echo "DEPLOYFAILED $ABSM_ENVIRONMENT $ABSM_SERVERNAME $ABSM_TYPE $ABSM_SLOT $ABSM_CONNAPPSRV $ABSM_CONNAPPSLOT $WEBSERVER_VERSION" >> $DEPLOYLIST
						echo "- $ABSM_SERVERNAME slot $ABSM_SLOT $ABSM_WEBCONTEXT ($ABSM_TYPE): Deployment error - check the Tomcat90 server logs for more details."
					fi
COMMENT
				fi

				# Check if Tomcat9 web server is present and start deployment
				if [ $TOMCAT9FOLDERNAME ]
				then
					if [ ! $TOMCAT10FOLDERNAME ]
					then
						# Deploy web application to Tomcat9
						case "$ABSM_TYPE" in
							wp2|wum|wcl|wrd|wrr|wsb|wfb|wcp|gws|w4m|wsr|wmr)    deploy_tomcat9_warfiles $ABSM_ENVIRONMENT $ABSM_SERVERNAME $ABSM_TYPE $ABSM_SLOT &> /dev/null ;;
						esac
					else
						# Deploy web application to corresponding Tomcat version
						case "$ABSM_TYPE" in
							gws|w4m|wsr|wmr)    deploy_tomcat9_warfiles $ABSM_ENVIRONMENT $ABSM_SERVERNAME $ABSM_TYPE $ABSM_SLOT &> /dev/null ;;
							wp2|wum|wcl|wrd|wrr|wsb|wfb|wcp)    deploy_tomcat10_warfiles $ABSM_ENVIRONMENT $ABSM_SERVERNAME $ABSM_TYPE $ABSM_SLOT &> /dev/null ;;
						esac
					fi
:<<COMMENT
					snmpcheck_tomcat9
					if [ $? -ne 1 ]
					then
						echo "DEPLOYFAILED $ABSM_ENVIRONMENT $ABSM_SERVERNAME $ABSM_TYPE $ABSM_SLOT $ABSM_CONNAPPSRV $ABSM_CONNAPPSLOT $WEBSERVER_VERSION" >> $DEPLOYLIST
						echo "- $ABSM_SERVERNAME slot $ABSM_SLOT $ABSM_WEBCONTEXT ($ABSM_TYPE): Deployment error - check the Tomcat9 server logs for more details."
					fi
COMMENT
				fi

				# Check if Tomcat10 web server is present and start deployment
				if [ $TOMCAT10FOLDERNAME ]
				then
					# Deploy web application to Tomcat10
					case "$ABSM_TYPE" in
						wp2|wum|wcl|wrd|wrr|wsb|wfb|wcp)    deploy_tomcat10_warfiles $ABSM_ENVIRONMENT $ABSM_SERVERNAME $ABSM_TYPE $ABSM_SLOT &> /dev/null ;;
					esac
:<<COMMENT
					snmpcheck_tomcat10
					if [ $? -ne 1 ]
					then
						echo "DEPLOYFAILED $ABSM_ENVIRONMENT $ABSM_SERVERNAME $ABSM_TYPE $ABSM_SLOT $ABSM_CONNAPPSRV $ABSM_CONNAPPSLOT $WEBSERVER_VERSION" >> $DEPLOYLIST
						echo "- $ABSM_SERVERNAME slot $ABSM_SLOT $ABSM_WEBCONTEXT ($ABSM_TYPE): Deployment error - check the Tomcat10 server logs for more details."
					fi
COMMENT
				fi
				
			elif [ $(date +"%s") -gt $ENDTIMESTAMP ]
			then
				# Remove line from deploylist
				sed -i "/$ABSM_WEBNAME/d" $DEPLOYLIST
				# Add with SNMPFAILED status to DEPLOYLIST
				echo "SNMPFAILED $ABSM_ENVIRONMENT $ABSM_SERVERNAME $ABSM_TYPE $ABSM_SLOT $ABSM_GFDOMAIN $ABSM_WEBCONTEXT $ABSM_WEBNAME $ABSM_WEBLIB $ABSM_CONNAPPSRV $ABSM_CONNAPPSLOT $WEBSERVER_VERSION" >> $DEPLOYLIST
				echo "- $ABSM_SERVERNAME slot $ABSM_SLOT $ABSM_WEBCONTEXT ($ABSM_TYPE): The underlying application server ($ABSM_CONNAPPSRV slot $ABSM_CONNAPPSLOT) did not repond successfully on the SNMP check."
			fi
		done
		
		# Check if the deploylist is empty. If so the while loop will be broken away from
		[ $(cat $DEPLOYLIST | awk -v a="DEPLOY" '$1==a  { print $0 } ' | wc -l) -eq 0 ] && break
	done
			
	# Remove PIDFILE and deploylist
	if [ $(cat $DEPLOYLIST | wc -l) -eq 0 ] 
	then
		absmenu_logline "Successfull web deploy on the server $ABSM_SERVERNAME slot $ABSM_SLOT"
	else
		DEPLOYMESSAGE="Unsuccessfull web deploy on the server $ABSM_SERVERNAME slot $ABSM_SLOT"
		[ $(cat $DEPLOYLIST |  awk -v a="DEPLOYFAILED" '$1==a { print $0 } ' | wc -l) -gt 0 ] && DEPLOYMESSAGE="$DEPLOYMESSAGE. Deployment error on $(cat $DEPLOYLIST |  awk -v a="DEPLOYFAILED" '$1==a { printf "%s ", $4 } ')"
		[ $(cat $DEPLOYLIST |  awk -v a="SNMPFAILED" '$1==a { print $0 } ' | wc -l) -gt 0 ] && DEPLOYMESSAGE="$DEPLOYMESSAGE. SNMP dependency error on $(cat $DEPLOYLIST |  awk -v a="SNMPFAILED" '$1==a { printf "%s ", $4 } ')"
		absmenu_logline "$DEPLOYMESSAGE"
	fi
	absmenu_logline "Finished installation of the webserver with the PID file: $PIDFILE (logfile = $ABSMSCRIPTLOGNAME)"
	rm $PIDFILE
}

# Check if webserver is present, and if it is the correct version. 
# If not a reinstall will be performed. 
# When it is installed the domain will be clean up
# New on 04.04.2024
# Updated on 20.04.2024
# Updated on 01.07.2024
install_cleanup_webserver()
{
	# $1 Environment
	# $2 Local or Remote server
	# $3 Slot number
	# $4 Webserver Version (411, 56, 55, 8, 90, 91, 9, 10)
	
	ABSM_ENVIRONMENT=$1
	ABSM_SERVERNAME=$2
	ABSM_SLOT=$3
	WEBSERVER_VER=$4
	
	grep '^ *'$ABSM_ENVIRONMENT"[[:blank:]]" $ABSMENUGLOBALCONFIG | sort -k2,2 -k5,5 -k4,4 | awk -v a="$ABSM_SERVERNAME" -v b="$ABSM_SLOT" -v c="$WEBSERVER_VER" '$2==a && $5==b && $29==c && $4!="app" && $4!="rep" { print $0 } ' | head -1 | while read ABSM_ENVIRONMENT ABSM_SERVERNAME ABSM_SERVICE ABSM_TYPE ABSM_SLOT ABSM_LOCAL_HOME ABSM_REMOTE_HOME ABSM_USER ABSM_PWD ABSM_ORATNS ABSM_ORAHOME ABSM_DBSERVERNAME ABSM_DBDRIVERTYPE ABSM_DBPORTNUMBER ABSM_HEAPSPACE ABSM_STATIONNR ABSM_GFUSER ABSM_GFPASWRD ABSM_GFDOMAIN ABSM_WEBCONTEXT ABSM_WEBNAME ABSM_WEBLIB ABSM_CONNAPPSRV ABSM_CONNAPPSLOT ABSM_CONNREPSRV ABSM_CONNREPSLOT ABSM_USENATIVE ABSM_EXCLUDECUSTREP ABSM_WEB_VERSION ABSM_CLIENTDISTR_SRV ABSM_CLIENTDISTR_DIR ABSM_USER2 ABSM_PWD2 ABSM_STATIONNR2 ABSM_INET_KEY
	do
		# Sync Server Libs if needed
		# ABSM_WEB_VERSION is the version set in service_reg file:
		#   411 for glassfish
		#   55-6 for Payara
		#   8 for tomee8
		#   91 for tomee91
		#   90 for tomcat90
                #   9 for Tomcat9
		#   10 for Tomcat10
		if [ "$ABS_ROOTSERVER" == "$ABSM_SERVERNAME" ] 
		then
			[ ! -d $ABSM_LOCAL_HOME/Server/Lib ] && mkdir -p $ABSM_LOCAL_HOME/Server/Lib
		else
			ssh -q -n $ABSM_SERVERNAME "[ ! -d $ABSM_LOCAL_HOME/Server/Lib ] && mkdir -p $ABSM_LOCAL_HOME/Server/Lib"
		fi
		if [ "$ABS_ROOTSERVER" == "$ABSMENUREPOSITORYSERVER" ] 
		then
			rsync -tav --delete -e "ssh -q" $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Future/Server/Lib $ABSM_SERVERNAME:$ABSM_LOCAL_HOME/Server
		else
			ssh -q -n $ABSMENUREPOSITORYSERVER "rsync -tav --delete -e \"ssh -q\" $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Future/Server/Lib $ABSM_SERVERNAME:$ABSM_LOCAL_HOME/Server"
		fi
	
		# Glassfish411
		[ "$ABSM_WEB_VERSION" == "411" ] && export WEBSRVNAME="glass"
		# New Payara 5.2022.5
		[ "$ABSM_WEB_VERSION" == "55" ] && export WEBSRVNAME="glass"
		# Old Payara 5.2020.6
		[ "$ABSM_WEB_VERSION" == "56" ] && export WEBSRVNAME="glass"
		# Tomee8
		[ "$ABSM_WEB_VERSION" == "8" ] && export WEBSRVNAME="web"	
		# Tomee91
		[ "$ABSM_WEB_VERSION" == "91" ] && export WEBSRVNAME="tomee"
		# Tomcat90
		[ "$ABSM_WEB_VERSION" == "90" ] && export WEBSRVNAME="tomcat"
		# Tomcat9
		[ "$ABSM_WEB_VERSION" == "9" ] && export WEBSRVNAME="tomcat9"
		# Tomcat10
		[ "$ABSM_WEB_VERSION" == "10" ] && export WEBSRVNAME="tomcat10"			

		if [ "$ABS_ROOTSERVER" == "$ABSM_SERVERNAME" ]
		then
			#Glassfish411/Payara55-6 Local
			if [ "$WEBSRVNAME" == "glass" ]
			then
				if [ -e $ABSM_LOCAL_HOME/$GLASSFISHPATH/bin/asadmin ]
				then
					# Check version of installed glassfish
					INSTALLED_GF_VERSION=`$ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t glass -c showversion`
					[ "$INSTALLED_GF_VERSION" == "$ABSM_WEB_VERSION" ] && ABSM_REFRESH_GF_INSTALL="no" || ABSM_REFRESH_GF_INSTALL="upgrade"
				else
					ABSM_REFRESH_GF_INSTALL="install"
				fi
				if [ $ABSM_REFRESH_GF_INSTALL != "no" ]
				then
					# correct glassfish not found, so deploy glassfish and create domain
					[ $ABSM_REFRESH_GF_INSTALL == "install" ] && absmenu_logline "Installing glassfish $ABSM_WEB_VERSION"
					[ $ABSM_REFRESH_GF_INSTALL == "upgrade" ] && absmenu_logline "Upgrade glassfish $INSTALLED_GF_VERSION to $ABSM_WEB_VERSION"
					mkdir -p $ABSM_LOCAL_HOME
					[ "$ABSM_WEB_VERSION" == "411" ] && WEBSRVNAME="glassfish" || WEBSRVNAME="payara"
					
					if [ "$ABS_ROOTSERVER" == "$ABSMENUREPOSITORYSERVER" ] 
					then
						rsync -tav --delete -e "ssh -q" $ABSMENUREPOSITORYLOCATION/static_zips/${WEBSRVNAME}_$ABSM_WEB_VERSION.zip $ABSM_SERVERNAME:$ABSM_LOCAL_HOME
					else
						ssh -q -n $ABSMENUREPOSITORYSERVER "rsync -tav --delete -e \"ssh -q\" $ABSMENUREPOSITORYLOCATION/static_zips/${WEBSRVNAME}_$ABSM_WEB_VERSION.zip $ABSM_SERVERNAME:$ABSM_LOCAL_HOME";
					fi
					pushd $ABSM_LOCAL_HOME
					# if upgrading glassfish to a different version, first stop glassfish and remove completely
					if [ $ABSM_REFRESH_GF_INSTALL == "upgrade" ]
					then
						$ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t glass -c stop
						rm -Rf $ABSM_LOCAL_HOME/$GLASSFISHPATH
					fi
					unzip -o ${WEBSRVNAME}_$ABSM_WEB_VERSION.zip
					cd $ABSM_LOCAL_HOME/$GLASSFISHPATH
					chmod a+x mq/bin/* bin/* glassfish/config/* glassfish/bin/* javadb/bin/* pkg/lib/*
					rm -f $ABSM_LOCAL_HOME/${WEBSRVNAME}_$ABSM_WEB_VERSION.zip
					$ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t glass -c enable
					$ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t glass -c deletedomain -b $ABSM_GFDOMAIN
					$ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t glass -c createdomain -b $ABSM_GFDOMAIN
					popd
					WEBSRVNAME=glass
				fi
				$ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t $ABSM_TYPE -M $ABSM_HEAPSPACE -c maxheap_glass
				$ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t glass -c start
			fi

			#Tomee8 Local
			if [ "$WEBSRVNAME" == "web" ]
			then
				if [ -e $ABSM_LOCAL_HOME/$TOMEE8FOLDERNAME/bin/tomee ]
				then
					# Check version of installed tomee
					INSTALLED_WEB_VERSION=`$ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t web -c showversion`
					[ "$INSTALLED_WEB_VERSION" == "$ABSM_WEB_VERSION" ] && ABSM_REFRESH_WEB_INSTALL="no" || ABSM_REFRESH_WEB_INSTALL="upgrade"
				else
					ABSM_REFRESH_WEB_INSTALL="install"
				fi
				if [ $ABSM_REFRESH_WEB_INSTALL != "no" ]
				then
					# correct tomee web server not found, so deploy it
					[ $ABSM_REFRESH_WEB_INSTALL == "install" ] && absmenu_logline "Installing Tomee8 $ABSM_WEB_VERSION"
					[ $ABSM_REFRESH_WEB_INSTALL == "upgrade" ] && absmenu_logline "Upgrade Tomee8 $INSTALLED_WEB_VERSION to $ABSM_WEB_VERSION"
					mkdir -p $ABSM_LOCAL_HOME
					WEBSRVNAME=tomee
					if [ "$ABS_ROOTSERVER" == "$ABSMENUREPOSITORYSERVER" ] 
					then
						rsync -tav --delete -e "ssh -q" $ABSMENUREPOSITORYLOCATION/static_zips/${WEBSRVNAME}_$ABSM_WEB_VERSION.zip $ABSM_SERVERNAME:$ABSM_LOCAL_HOME
					else
						ssh -q -n $ABSMENUREPOSITORYSERVER "rsync -tav --delete -e \"ssh -q\" $ABSMENUREPOSITORYLOCATION/static_zips/${WEBSRVNAME}_$ABSM_WEB_VERSION.zip $ABSM_SERVERNAME:$ABSM_LOCAL_HOME";
					fi
					pushd $ABSM_LOCAL_HOME
					# if upgrading tomee8 to a different version, first stop tomee8 and remove completely
					if [ $ABSM_REFRESH_WEB_INSTALL == "upgrade" ]
					then
						# stop tomee8
						$ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t web -c stop
						# delete tomee8 directory recursively
						rm -Rf $ABSM_LOCAL_HOME/$TOMEE8FOLDERNAME
					fi
					# unzip tomee8
					unzip -o ${WEBSRVNAME}_$ABSM_WEB_VERSION.zip
					# delete tomee8 bundle
					rm -f $ABSM_LOCAL_HOME/${WEBSRVNAME}_$ABSM_WEB_VERSION.zip
					WEBSRVNAME=web
					[ "$INSTALLED_WEB_VERSION" == "$ABSM_WEB_VERSION" ] && cleanup_web $1
					popd
				fi
				$ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t $ABSM_TYPE -M $ABSM_HEAPSPACE -c maxheap_web
				$ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t web -c start
			fi
			
			#Tomee91 Local
			if [ "$WEBSRVNAME" == "tomee" ]
			then
				if [ -e $ABSM_LOCAL_HOME/$TOMEEFOLDERNAME/bin/tomee.sh ]
				then
					# Check version of installed tomee91
					INSTALLED_TOMEE_VERSION=`$ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t tomee -c showversion`
					[ "$INSTALLED_TOMEE_VERSION" == "$ABSM_WEB_VERSION" ] && ABSM_REFRESH_TOMEE_INSTALL="no" || ABSM_REFRESH_TOMEE_INSTALL="upgrade"
				else
					ABSM_REFRESH_TOMEE_INSTALL="install"
				fi
				if [ $ABSM_REFRESH_TOMEE_INSTALL != "no" ]
				then
					# correct Tomee91 web server not found, so deploy it
					[ $ABSM_REFRESH_TOMEE_INSTALL == "install" ] && absmenu_logline "Installing Tomee91 $ABSM_WEB_VERSION"
					[ $ABSM_REFRESH_TOMEE_INSTALL == "upgrade" ] && absmenu_logline "Upgrade Tomee91 $INSTALLED_TOMEE_VERSION to $ABSM_WEB_VERSION"
					mkdir -p $ABSM_LOCAL_HOME
					if [ "$ABS_ROOTSERVER" == "$ABSMENUREPOSITORYSERVER" ] 
					then
						rsync -tav --delete -e "ssh -q" $ABSMENUREPOSITORYLOCATION/static_zips/${WEBSRVNAME}_$ABSM_WEB_VERSION.zip $ABSM_SERVERNAME:$ABSM_LOCAL_HOME
					else
						ssh -q -n $ABSMENUREPOSITORYSERVER "rsync -tav --delete -e \"ssh -q\" $ABSMENUREPOSITORYLOCATION/static_zips/${WEBSRVNAME}_$ABSM_WEB_VERSION.zip $ABSM_SERVERNAME:$ABSM_LOCAL_HOME";
					fi
					pushd $ABSM_LOCAL_HOME
					# if upgrading Tomee91 to a different version, first stop Tomee91 and remove completely
					if [ $ABSM_REFRESH_TOMEE_INSTALL == "upgrade" ]
					then
						# stop Tomee91
						$ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t tomee -c stop
						# delete Tomee91 directory recursively
						rm -Rf $ABSM_LOCAL_HOME/$TOMEEFOLDERNAME
					fi
					# unzip Tomee91
					unzip -o ${WEBSRVNAME}_$ABSM_WEB_VERSION.zip
					# delete Tomee91 bundle - no more needed
					rm -f $ABSM_LOCAL_HOME/${WEBSRVNAME}_$ABSM_WEB_VERSION.zip
					[ "$INSTALLED_TOMEE_VERSION" == "$ABSM_WEB_VERSION" ] && cleanup_tomee $1
					popd
				fi
				$ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t $ABSM_TYPE -M $ABSM_HEAPSPACE -c maxheap_tomee
				$ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t tomee -c restart
			fi

			#Tomcat90 Local
			if [ "$WEBSRVNAME" == "tomcat" ]
			then
				if [ -e $ABSM_LOCAL_HOME/$TOMCATFOLDERNAME/bin/tomcat9.exe ]
				then
					# Check version of installed tomcat90
					INSTALLED_TOMCAT_VERSION=`$ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t tomcat -c showversion`
					[ "$INSTALLED_TOMCAT_VERSION" == "$ABSM_WEB_VERSION" ] && ABSM_REFRESH_TOMCAT_INSTALL="no" || ABSM_REFRESH_TOMCAT_INSTALL="upgrade"
				else
					ABSM_REFRESH_TOMCAT_INSTALL="install"
				fi
				if [ $ABSM_REFRESH_TOMCAT_INSTALL != "no" ]
				then
					# correct tomcat90 web server not found, so deploy it
					[ $ABSM_REFRESH_TOMCAT_INSTALL == install ] && absmenu_logline "Installing Tomcat $ABSM_WEB_VERSION"
					[ $ABSM_REFRESH_TOMCAT_INSTALL == upgrade ] && absmenu_logline "Upgrade Tomcat $INSTALLED_TOMCAT_VERSION to $ABSM_WEB_VERSION"
					mkdir -p $ABSM_LOCAL_HOME
					if [ "$ABS_ROOTSERVER" == "$ABSMENUREPOSITORYSERVER" ] 
					then
						rsync -tav --delete -e "ssh -q" $ABSMENUREPOSITORYLOCATION/static_zips/${WEBSRVNAME}_$ABSM_WEB_VERSION.zip $ABSM_SERVERNAME:$ABSM_LOCAL_HOME
					else
						ssh -q -n $ABSMENUREPOSITORYSERVER "rsync -tav --delete -e \"ssh -q\" $ABSMENUREPOSITORYLOCATION/static_zips/${WEBSRVNAME}_$ABSM_WEB_VERSION.zip $ABSM_SERVERNAME:$ABSM_LOCAL_HOME";
					fi
					pushd $ABSM_LOCAL_HOME
					# if upgrading tomcat90 to a different version, first stop tomcat and remove completely
					if [ $ABSM_REFRESH_TOMCAT_INSTALL == "upgrade" ]
					then
						# stop tomcat90
						$ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t tomcat -c stop
						# delete tomcat90 directory recursively
						rm -Rf $ABSM_LOCAL_HOME/$TOMCATFOLDERNAME
					fi
					# unzip tomcat90
					unzip -o ${WEBSRVNAME}_$ABSM_WEB_VERSION.zip
					# delete tomcat bundle
					rm -f $ABSM_LOCAL_HOME/${WEBSRVNAME}_$ABSM_WEB_VERSION.zip
					[ "$INSTALLED_TOMCAT_VERSION" == "$ABSM_WEB_VERSION" ] && cleanup_tomcat $1
					popd
				fi
				$ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t $ABSM_TYPE -M $ABSM_HEAPSPACE -c maxheap_tomcat
				$ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t tomcat -c restart
			fi
			
			#Tomcat9 Local
			if [ "$WEBSRVNAME" == "tomcat9" ]
			then
				if [ -e $ABSM_LOCAL_HOME/$TOMCAT9FOLDERNAME/bin/startup.sh ]
				then
					# Check version of installed tomcat9
					INSTALLED_TOMCAT9_VERSION=`$ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t tomcat9 -c showversion`
					[ "$INSTALLED_TOMCAT9_VERSION" == "$ABSM_WEB_VERSION" ] && ABSM_REFRESH_TOMCAT9_INSTALL="no" || ABSM_REFRESH_TOMCAT9_INSTALL="upgrade"
				else
					ABSM_REFRESH_TOMCAT9_INSTALL="install"
				fi
				if [ $ABSM_REFRESH_TOMCAT9_INSTALL != "no" ]
				then
					# correct tomcat9 web server not found, so deploy it
					[ $ABSM_REFRESH_TOMCAT9_INSTALL == install ] && absmenu_logline "Installing Tomcat9 $ABSM_WEB_VERSION"
					[ $ABSM_REFRESH_TOMCAT9_INSTALL == upgrade ] && absmenu_logline "Upgrade Tomcat9 $INSTALLED_TOMCAT9_VERSION to $ABSM_WEB_VERSION"
					mkdir -p $ABSM_LOCAL_HOME
					WEBSRVNAME=tomcat
					if [ "$ABS_ROOTSERVER" == "$ABSMENUREPOSITORYSERVER" ] 
					then
						rsync -tav --delete -e "ssh -q" $ABSMENUREPOSITORYLOCATION/static_zips/${WEBSRVNAME}_$ABSM_WEB_VERSION.zip $ABSM_SERVERNAME:$ABSM_LOCAL_HOME
					else
						ssh -q -n $ABSMENUREPOSITORYSERVER "rsync -tav --delete -e \"ssh -q\" $ABSMENUREPOSITORYLOCATION/static_zips/${WEBSRVNAME}_$ABSM_WEB_VERSION.zip $ABSM_SERVERNAME:$ABSM_LOCAL_HOME";
					fi
					pushd $ABSM_LOCAL_HOME
					# if upgrading tomcat9 to a different version, first stop tomcat and remove completely
					if [ $ABSM_REFRESH_TOMCAT9_INSTALL == "upgrade" ]
					then
						# stop tomcat9
						$ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t tomcat9 -c stop
						# delete tomcat9 directory recursively
						rm -Rf $ABSM_LOCAL_HOME/$TOMCAT9FOLDERNAME
					fi
					# unzip tomcat9
					unzip -o ${WEBSRVNAME}_$ABSM_WEB_VERSION.zip
					# delete tomcat9 bundle
					rm -f $ABSM_LOCAL_HOME/${WEBSRVNAME}_$ABSM_WEB_VERSION.zip
					WEBSRVNAME=tomcat9
					[ "$INSTALLED_TOMCAT9_VERSION" == "$ABSM_WEB_VERSION" ] && cleanup_tomcat9 $1
					popd
				fi
				$ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t $ABSM_TYPE -M $ABSM_HEAPSPACE -c maxheap_tomcat9
				$ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t tomcat9 -c restart
			fi
			
			#Tomcat10 Local
			if [ "$WEBSRVNAME" == "tomcat10" ]
			then
				if [ -e $ABSM_LOCAL_HOME/$TOMCAT10FOLDERNAME/bin/startup.sh ]
				then
					# Check version of installed tomcat10
					INSTALLED_TOMCAT10_VERSION=`$ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t tomcat10 -c showversion`
					[ "$INSTALLED_TOMCAT10_VERSION" == "$ABSM_WEB_VERSION" ] && ABSM_REFRESH_TOMCAT10_INSTALL="no" || ABSM_REFRESH_TOMCAT10_INSTALL="upgrade"
				else
					ABSM_REFRESH_TOMCAT10_INSTALL="install"
				fi
				if [ $ABSM_REFRESH_TOMCAT10_INSTALL != "no" ]
				then
					# correct tomcat10 web server not found, so deploy it
					[ $ABSM_REFRESH_TOMCAT10_INSTALL == install ] && absmenu_logline "Installing Tomcat10 $ABSM_WEB_VERSION"
					[ $ABSM_REFRESH_TOMCAT10_INSTALL == upgrade ] && absmenu_logline "Upgrade Tomcat10 $INSTALLED_TOMCAT10_VERSION to $ABSM_WEB_VERSION"
					mkdir -p $ABSM_LOCAL_HOME
					WEBSRVNAME=tomcat
					if [ "$ABS_ROOTSERVER" == "$ABSMENUREPOSITORYSERVER" ] 
					then
						rsync -tav --delete -e "ssh -q" $ABSMENUREPOSITORYLOCATION/static_zips/${WEBSRVNAME}_$ABSM_WEB_VERSION.zip $ABSM_SERVERNAME:$ABSM_LOCAL_HOME
					else
						ssh -q -n $ABSMENUREPOSITORYSERVER "rsync -tav --delete -e \"ssh -q\" $ABSMENUREPOSITORYLOCATION/static_zips/${WEBSRVNAME}_$ABSM_WEB_VERSION.zip $ABSM_SERVERNAME:$ABSM_LOCAL_HOME";
					fi
					pushd $ABSM_LOCAL_HOME
					# if upgrading tomcat10 to a different version, first stop tomcat and remove completely
					if [ $ABSM_REFRESH_TOMCAT10_INSTALL == "upgrade" ]
					then
						# stop tomcat10
						$ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t tomcat10 -c stop
						# delete tomcat10 directory recursively
						rm -Rf $ABSM_LOCAL_HOME/$TOMCAT10FOLDERNAME
					fi
					# unzip tomcat10
					unzip -o ${WEBSRVNAME}_$ABSM_WEB_VERSION.zip
					# delete tomcat10 bundle
					rm -f $ABSM_LOCAL_HOME/${WEBSRVNAME}_$ABSM_WEB_VERSION.zip
					WEBSRVNAME=tomcat10
					[ "$INSTALLED_TOMCAT10_VERSION" == "$ABSM_WEB_VERSION" ] && cleanup_tomcat10 $1
					popd
				fi
				$ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t $ABSM_TYPE -M $ABSM_HEAPSPACE -c maxheap_tomcat10
				$ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t tomcat10 -c restart
			fi
		else
			#Glassfish411/Payara55-6 Remote
			if [ "$WEBSRVNAME" == "glass" ]
			then
				if [ `ssh -q -n $ABSM_SERVERNAME "[ -e $ABSM_LOCAL_HOME/$GLASSFISHPATH/bin/asadmin ] && echo 1"` ]
				then
					# Check version of installed glassfish
					INSTALLED_GF_VERSION=`ssh -q -n $ABSM_SERVERNAME "$ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t glass -c showversion"`
					[ "$INSTALLED_GF_VERSION" == "$ABSM_WEB_VERSION" ] && ABSM_REFRESH_GF_INSTALL="no" || ABSM_REFRESH_GF_INSTALL="upgrade"
				else
					ABSM_REFRESH_GF_INSTALL="install"
				fi
				[ "$ABSM_WEB_VERSION" == "411" ] && WEBSRVNAME="glassfish" || WEBSRVNAME="payara"
				if [ "$ABSM_REFRESH_GF_INSTALL" != "no" ]
				then
					# create glassfish + domain
					echo -n .
					ssh -q -n $ABSM_SERVERNAME "mkdir -p $ABSM_LOCAL_HOME"
					echo -n .
					ssh -q -n $ABSMENUREPOSITORYSERVER "rsync -tav --delete -e \"ssh -q\" $ABSMENUREPOSITORYLOCATION/static_zips/${WEBSRVNAME}_$ABSM_WEB_VERSION.zip $ABSM_SERVERNAME:$ABSM_LOCAL_HOME";
					echo -n .
					if [ $ABSM_REFRESH_GF_INSTALL == "upgrade" ]
					then
						absmenu_logline "Upgrade ${WEBSRVNAME} $INSTALLED_GF_VERSION to $ABSM_WEB_VERSION"
						ssh -q -n $ABSM_SERVERNAME "$ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t glass -c stop; rm -Rf $ABSM_LOCAL_HOME/$GLASSFISHPATH"
						echo -n .
					else
						absmenu_logline "Installing ${WEBSRVNAME} $ABSM_WEB_VERSION"
					fi
					ssh -q -n $ABSM_SERVERNAME "cd $ABSM_LOCAL_HOME; unzip -o ${WEBSRVNAME}_$ABSM_WEB_VERSION.zip"
					echo -n .
					ssh -q -n $ABSM_SERVERNAME "cd $ABSM_LOCAL_HOME/$GLASSFISHPATH; chmod a+x mq/bin/* bin/* glassfish/config/* glassfish/bin/* javadb/bin/* pkg/lib/*"
					echo -n .
					ssh -q -n $ABSM_SERVERNAME "rm -f $ABSM_LOCAL_HOME/${WEBSRVNAME}_$ABSM_WEB_VERSION.zip"
					echo -n .
					ssh -q -n $ABSM_SERVERNAME "$ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t glass -c enable"
					echo -n .
					ssh -q -n $ABSM_SERVERNAME "$ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t glass -c deletedomain -b $ABSM_GFDOMAIN"
					echo -n .
					ssh -q -n $ABSM_SERVERNAME "$ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t glass -c createdomain -b $ABSM_GFDOMAIN"
					echo .
				fi
				WEBSRVNAME=glass
				ssh -q -n $ABSM_SERVERNAME "$ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t $ABSM_TYPE -M $ABSM_HEAPSPACE -c maxheap_glass"
				ssh -q -n $ABSM_SERVERNAME "$ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t glass -c start"
			fi

			#Tomee8 Remote
			if [ "$WEBSRVNAME" == "web" ]
			then
				if [ `ssh -q -n $ABSM_SERVERNAME "[ -e $ABSM_LOCAL_HOME/$TOMEE8FOLDERNAME/bin/tomee ] && echo 1"` ]
				then
					# Check version of installed tomee8
					INSTALLED_WEB_REMOTE_VERSION=`ssh -q -n $ABSM_SERVERNAME "$ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t web -c showversion"`
					[ "$INSTALLED_WEB_REMOTE_VERSION" == "$ABSM_WEB_VERSION" ] && ABSM_REFRESH_WEB_REMOTE_INSTALL="no" || ABSM_REFRESH_WEB_REMOTE_INSTALL="upgrade"			
				else
					ABSM_REFRESH_WEB_REMOTE_INSTALL="install"
				fi
				if [ $ABSM_REFRESH_WEB_REMOTE_INSTALL != "no" ]
				then
					# correct tomee8 remote web server not found, so deploy it
					[ $ABSM_REFRESH_WEB_REMOTE_INSTALL == "install" ] && absmenu_logline "Installing Tomee8 Remote $ABSM_WEB_VERSION"
					[ $ABSM_REFRESH_WEB_REMOTE_INSTALL == "upgrade" ] && absmenu_logline "Upgrade Tomee8 Remote $INSTALLED_WEB_REMOTE_VERSION to $ABSM_WEB_VERSION"
					ssh -q -n $ABSM_SERVERNAME "mkdir -p $ABSM_LOCAL_HOME"
					WEBSRVNAME=tomee
					if [ "$ABS_ROOTSERVER" == "$ABSMENUREPOSITORYSERVER" ] 
					then
						rsync -tav --delete -e "ssh -q" $ABSMENUREPOSITORYLOCATION/static_zips/${WEBSRVNAME}_$ABSM_WEB_VERSION.zip $ABSM_SERVERNAME:$ABSM_LOCAL_HOME
					else
						ssh -q -n $ABSMENUREPOSITORYSERVER "rsync -tav --delete -e \"ssh -q\" $ABSMENUREPOSITORYLOCATION/static_zips/${WEBSRVNAME}_$ABSM_WEB_VERSION.zip $ABSM_SERVERNAME:$ABSM_LOCAL_HOME";
					fi
					# if upgrading tomee8 to a different version, first stop tomee8 and remove completely
					if [ $ABSM_REFRESH_WEB_REMOTE_INSTALL == "upgrade" ]
					then
						# stop tomee8
						ssh -q -n $ABSM_SERVERNAME "$ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t web -c stop"
						# delete tomee8 directory recursively
						ssh -q -n $ABSM_SERVERNAME "rm -Rf $ABSM_LOCAL_HOME/$TOMEE8FOLDERNAME"
					fi
					# unzip tomee8
					ssh -q -n $ABSM_SERVERNAME "cd $ABSM_LOCAL_HOME; unzip -o ${WEBSRVNAME}_$ABSM_WEB_VERSION.zip"
					# delete tomee8 bundle
					ssh -q -n $ABSM_SERVERNAME "cd $ABSM_LOCAL_HOME; rm -f ${WEBSRVNAME}_$ABSM_WEB_VERSION.zip"
					WEBSRVNAME=web
					[ "$INSTALLED_WEB_REMOTE_VERSION" == "$ABSM_WEB_VERSION" ] && cleanup_web $1
				fi
				ssh -q -n $ABSM_SERVERNAME "$ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t $ABSM_TYPE -M $ABSM_HEAPSPACE -c maxheap_web"
				ssh -q -n $ABSM_SERVERNAME "$ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t web -c start"
			fi

			#Tomee91 Remote
			if [ "$WEBSRVNAME" == "tomee" ]
			then
				if [ `ssh -q -n $ABSM_SERVERNAME "[ -e $ABSM_LOCAL_HOME/$TOMEEFOLDERNAME/bin/tomee.sh ] && echo 1"` ]
				then
					# Check version of installed tomee91
					INSTALLED_TOMEE_REMOTE_VERSION=`ssh -q -n $ABSM_SERVERNAME "$ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t tomee -c showversion"`
					[ "$INSTALLED_TOMEE_REMOTE_VERSION" == "$ABSM_WEB_VERSION" ] && ABSM_REFRESH_TOMEE_REMOTE_INSTALL="no" || ABSM_REFRESH_TOMEE_REMOTE_INSTALL="upgrade"			
				else
					ABSM_REFRESH_TOMEE_REMOTE_INSTALL="install"
				fi
				if [ $ABSM_REFRESH_TOMEE_REMOTE_INSTALL != "no" ]
				then
					# correct tomee91 remote web server not found, so deploy it
					[ $ABSM_REFRESH_TOMEE_REMOTE_INSTALL == "install" ] && absmenu_logline "Installing Tomee91 Remote $ABSM_WEB_VERSION"
					[ $ABSM_REFRESH_TOMEE_REMOTE_INSTALL == "upgrade" ] && absmenu_logline "Upgrade Tomee91 Remote $INSTALLED_TOMEE_REMOTE_VERSION to $ABSM_WEB_VERSION"
					ssh -q -n $ABSM_SERVERNAME "mkdir -p $ABSM_LOCAL_HOME"
					if [ "$ABS_ROOTSERVER" == "$ABSMENUREPOSITORYSERVER" ] 
					then
						rsync -tav --delete -e "ssh -q" $ABSMENUREPOSITORYLOCATION/static_zips/${WEBSRVNAME}_$ABSM_WEB_VERSION.zip $ABSM_SERVERNAME:$ABSM_LOCAL_HOME
					else
						ssh -q -n $ABSMENUREPOSITORYSERVER "rsync -tav --delete -e \"ssh -q\" $ABSMENUREPOSITORYLOCATION/static_zips/${WEBSRVNAME}_$ABSM_WEB_VERSION.zip $ABSM_SERVERNAME:$ABSM_LOCAL_HOME";
					fi
					# if upgrading tomee91 to a different version, first stop tomee91 and remove completely
					if [ $ABSM_REFRESH_TOMEE_REMOTE_INSTALL == "upgrade" ]
					then
						# stop tomee91
						ssh -q -n $ABSM_SERVERNAME "$ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t tomee -c stop"
						# delete tomee91 directory recursively
						ssh -q -n $ABSM_SERVERNAME "rm -Rf $ABSM_LOCAL_HOME/$TOMEEFOLDERNAME"
					fi
					# unzip tomee91
					ssh -q -n $ABSM_SERVERNAME "cd $ABSM_LOCAL_HOME; unzip -o ${WEBSRVNAME}_$ABSM_WEB_VERSION.zip"
					# delete tomee91 bundle
					ssh -q -n $ABSM_SERVERNAME "cd $ABSM_LOCAL_HOME; rm -f ${WEBSRVNAME}_$ABSM_WEB_VERSION.zip"
					[ "$INSTALLED_TOMEE_REMOTE_VERSION" == "$ABSM_WEB_VERSION" ] && cleanup_tomee $1
				fi
				ssh -q -n $ABSM_SERVERNAME "$ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t $ABSM_TYPE -M $ABSM_HEAPSPACE -c maxheap_tomee"
				ssh -q -n $ABSM_SERVERNAME "$ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t tomee -c restart"
			fi
			
			#Tomcat90 Remote
			if [ "$WEBSRVNAME" == "tomcat" ]
			then
				if [ `ssh -q -n $ABSM_SERVERNAME "[ -e $ABSM_LOCAL_HOME/$TOMCATFOLDERNAME/bin/tomcat9.exe ] && echo 1"` ]
				then
					# Check version of installed tomcat90
					INSTALLED_TOMCAT_REMOTE_VERSION=`ssh -q -n $ABSM_SERVERNAME "$ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t tomcat -c showversion"`
					[ "$INSTALLED_TOMCAT_REMOTE_VERSION" == "$ABSM_WEB_VERSION" ] && ABSM_REFRESH_TOMCAT_REMOTE_INSTALL="no" || ABSM_REFRESH_TOMCAT_REMOTE_INSTALL="upgrade"				
				else
					ABSM_REFRESH_TOMCAT_REMOTE_INSTALL="install"
				fi
				if [ $ABSM_REFRESH_TOMCAT_REMOTE_INSTALL != "no" ]
				then
					# correct tomcat90 remote web server not found, so deploy it
					[ $ABSM_REFRESH_TOMCAT_REMOTE_INSTALL == "install" ] && absmenu_logline "Installing Tomcat90 Remote $ABSM_WEB_VERSION"
					[ $ABSM_REFRESH_TOMCAT_REMOTE_INSTALL == "upgrade" ] && absmenu_logline "Upgrade Tomcat90 Remote $INSTALLED_TOMCAT_REMOTE_VERSION to $ABSM_WEB_VERSION"
					ssh -q -n $ABSM_SERVERNAME "mkdir -p $ABSM_LOCAL_HOME"
					if [ "$ABS_ROOTSERVER" == "$ABSMENUREPOSITORYSERVER" ] 
					then
						rsync -tav --delete -e "ssh -q" $ABSMENUREPOSITORYLOCATION/static_zips/${WEBSRVNAME}_$ABSM_WEB_VERSION.zip $ABSM_SERVERNAME:$ABSM_LOCAL_HOME
					else
						ssh -q -n $ABSMENUREPOSITORYSERVER "rsync -tav --delete -e \"ssh -q\" $ABSMENUREPOSITORYLOCATION/static_zips/${WEBSRVNAME}_$ABSM_WEB_VERSION.zip $ABSM_SERVERNAME:$ABSM_LOCAL_HOME";
					fi
					# if upgrading tomcat90 to a different version, first stop tomcat90 and remove completely
					if [ $ABSM_REFRESH_TOMCAT_REMOTE_INSTALL == "upgrade" ]
					then
						# stop tomcat90
						ssh -q -n $ABSM_SERVERNAME "$ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t tomcat -c stop"
						# delete tomcat90 directory recursively
						ssh -q -n $ABSM_SERVERNAME "rm -Rf $ABSM_LOCAL_HOME/$TOMCATFOLDERNAME"
					fi
					# unzip tomcat90
					ssh -q -n $ABSM_SERVERNAME "cd $ABSM_LOCAL_HOME; unzip -o ${WEBSRVNAME}_$ABSM_WEB_VERSION.zip"
					# delete tomcat90 bundle
					ssh -q -n $ABSM_SERVERNAME "cd $ABSM_LOCAL_HOME; rm -f ${WEBSRVNAME}_$ABSM_WEB_VERSION.zip"
					[ "$INSTALLED_TOMCAT_REMOTE_VERSION" == "$ABSM_WEB_VERSION" ] && cleanup_tomcat $1
				fi
				ssh -q -n $ABSM_SERVERNAME "$ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t $ABSM_TYPE -M $ABSM_HEAPSPACE -c maxheap_tomcat"
				ssh -q -n $ABSM_SERVERNAME "$ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t tomcat -c restart"
			fi

			#Tomcat9 Remote
			if [ "$WEBSRVNAME" == "tomcat9" ]
			then
				if [ `ssh -q -n $ABSM_SERVERNAME "[ -e $ABSM_LOCAL_HOME/$TOMCAT9FOLDERNAME/bin/startup.sh ] && echo 1"` ]
				then
					# Check version of installed tomcat9
					INSTALLED_TOMCAT9_REMOTE_VERSION=`ssh -q -n $ABSM_SERVERNAME "$ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t tomcat9 -c showversion"`
					[ "$INSTALLED_TOMCAT9_REMOTE_VERSION" == "$ABSM_WEB_VERSION" ] && ABSM_REFRESH_TOMCAT9_REMOTE_INSTALL="no" || ABSM_REFRESH_TOMCAT9_REMOTE_INSTALL="upgrade"				
				else
					ABSM_REFRESH_TOMCAT9_REMOTE_INSTALL="install"
				fi
				if [ $ABSM_REFRESH_TOMCAT9_REMOTE_INSTALL != "no" ]
				then
					# correct tomcat9 remote web server not found, so deploy it
					[ $ABSM_REFRESH_TOMCAT9_REMOTE_INSTALL == "install" ] && absmenu_logline "Installing Tomcat9 Remote $ABSM_WEB_VERSION"
					[ $ABSM_REFRESH_TOMCAT9_REMOTE_INSTALL == "upgrade" ] && absmenu_logline "Upgrade Tomcat9 Remote $INSTALLED_TOMCAT9_REMOTE_VERSION to $ABSM_WEB_VERSION"
					ssh -q -n $ABSM_SERVERNAME "mkdir -p $ABSM_LOCAL_HOME"
					WEBSRVNAME=tomcat
					if [ "$ABS_ROOTSERVER" == "$ABSMENUREPOSITORYSERVER" ] 
					then
						rsync -tav --delete -e "ssh -q" $ABSMENUREPOSITORYLOCATION/static_zips/${WEBSRVNAME}_$ABSM_WEB_VERSION.zip $ABSM_SERVERNAME:$ABSM_LOCAL_HOME
					else
						ssh -q -n $ABSMENUREPOSITORYSERVER "rsync -tav --delete -e \"ssh -q\" $ABSMENUREPOSITORYLOCATION/static_zips/${WEBSRVNAME}_$ABSM_WEB_VERSION.zip $ABSM_SERVERNAME:$ABSM_LOCAL_HOME";
					fi
					# if upgrading tomcat9 to a different version, first stop tomcat9 and remove completely
					if [ $ABSM_REFRESH_TOMCAT9_REMOTE_INSTALL == "upgrade" ]
					then
						# stop tomcat9
						ssh -q -n $ABSM_SERVERNAME "$ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t tomcat9 -c stop"
						# delete tomcat9 directory recursively
						ssh -q -n $ABSM_SERVERNAME "rm -Rf $ABSM_LOCAL_HOME/$TOMCAT9FOLDERNAME"
					fi
					# unzip tomcat9
					ssh -q -n $ABSM_SERVERNAME "cd $ABSM_LOCAL_HOME; unzip -o ${WEBSRVNAME}_$ABSM_WEB_VERSION.zip"
					# delete tomcat9 bundle
					ssh -q -n $ABSM_SERVERNAME "cd $ABSM_LOCAL_HOME; rm -f ${WEBSRVNAME}_$ABSM_WEB_VERSION.zip"
					WEBSRVNAME=tomcat9
					[ "$INSTALLED_TOMCAT9_REMOTE_VERSION" == "$ABSM_WEB_VERSION" ] && cleanup_tomcat9 $1
				fi
				ssh -q -n $ABSM_SERVERNAME "$ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t $ABSM_TYPE -M $ABSM_HEAPSPACE -c maxheap_tomcat9"
				ssh -q -n $ABSM_SERVERNAME "$ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t tomcat9 -c restart"
			fi
			
			#Tomcat10 Remote
			if [ "$WEBSRVNAME" == "tomcat10" ]
			then
				if [ `ssh -q -n $ABSM_SERVERNAME "[ -e $ABSM_LOCAL_HOME/$TOMCAT10FOLDERNAME/bin/startup.sh ] && echo 1"` ]
				then
					# Check version of installed tomcat10
					INSTALLED_TOMCAT10_REMOTE_VERSION=`ssh -q -n $ABSM_SERVERNAME "$ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t tomcat10 -c showversion"`
					[ "$INSTALLED_TOMCAT10_REMOTE_VERSION" == "$ABSM_WEB_VERSION" ] && ABSM_REFRESH_TOMCAT10_REMOTE_INSTALL="no" || ABSM_REFRESH_TOMCAT10_REMOTE_INSTALL="upgrade"				
				else
					ABSM_REFRESH_TOMCAT10_REMOTE_INSTALL="install"
				fi
				if [ $ABSM_REFRESH_TOMCAT10_REMOTE_INSTALL != "no" ]
				then
					# correct tomcat10 remote web server not found, so deploy it
					[ $ABSM_REFRESH_TOMCAT10_REMOTE_INSTALL == "install" ] && absmenu_logline "Installing Tomcat10 Remote $ABSM_WEB_VERSION"
					[ $ABSM_REFRESH_TOMCAT10_REMOTE_INSTALL == "upgrade" ] && absmenu_logline "Upgrade Tomcat10 Remote $INSTALLED_TOMCAT10_REMOTE_VERSION to $ABSM_WEB_VERSION"
					ssh -q -n $ABSM_SERVERNAME "mkdir -p $ABSM_LOCAL_HOME"
					WEBSRVNAME=tomcat
					if [ "$ABS_ROOTSERVER" == "$ABSMENUREPOSITORYSERVER" ] 
					then
						rsync -tav --delete -e "ssh -q" $ABSMENUREPOSITORYLOCATION/static_zips/${WEBSRVNAME}_$ABSM_WEB_VERSION.zip $ABSM_SERVERNAME:$ABSM_LOCAL_HOME
					else
						ssh -q -n $ABSMENUREPOSITORYSERVER "rsync -tav --delete -e \"ssh -q\" $ABSMENUREPOSITORYLOCATION/static_zips/${WEBSRVNAME}_$ABSM_WEB_VERSION.zip $ABSM_SERVERNAME:$ABSM_LOCAL_HOME";
					fi
					# if upgrading tomcat10 to a different version, first stop tomcat10 and remove completely
					if [ $ABSM_REFRESH_TOMCAT10_REMOTE_INSTALL == "upgrade" ]
					then
						# stop tomcat10
						ssh -q -n $ABSM_SERVERNAME "$ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t tomcat10 -c stop"
						# delete tomcat10 directory recursively
						ssh -q -n $ABSM_SERVERNAME "rm -Rf $ABSM_LOCAL_HOME/$TOMCAT10FOLDERNAME"
					fi
					# unzip tomcat10
					ssh -q -n $ABSM_SERVERNAME "cd $ABSM_LOCAL_HOME; unzip -o ${WEBSRVNAME}_$ABSM_WEB_VERSION.zip"
					# delete tomcat10 bundle
					ssh -q -n $ABSM_SERVERNAME "cd $ABSM_LOCAL_HOME; rm -f ${WEBSRVNAME}_$ABSM_WEB_VERSION.zip"
					WEBSRVNAME=tomcat10
					[ "$INSTALLED_TOMCAT10_REMOTE_VERSION" == "$ABSM_WEB_VERSION" ] && cleanup_tomcat10 $1
				fi
				ssh -q -n $ABSM_SERVERNAME "$ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t $ABSM_TYPE -M $ABSM_HEAPSPACE -c maxheap_tomcat10"
				ssh -q -n $ABSM_SERVERNAME "$ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t tomcat10 -c restart"
			fi
		fi
	done
}

# Check if webserver is present, and delete it
delete_webserver()
{
	# $1 Environment
	# $2 Local or Remote server
	# $3 Slot number
	# $4 Webserver Version (411, 56, 55, 8, 90, 91, 9, 10)
	
	ABSM_ENVIRONMENT=$1
	ABSM_SERVERNAME=$2
	ABSM_SLOT=$3
	WEBSERVER_VER=$4
	
	grep '^ *'$ABSM_ENVIRONMENT"[[:blank:]]" $ABSMENUGLOBALCONFIG | sort -k2,2 -k5,5 -k4,4 | awk -v a="$ABSM_SERVERNAME" -v b="$ABSM_SLOT" -v c="$WEBSERVER_VER" '$2==a && $5==b && $29==c && $4!="app" && $4!="rep" { print $0 } ' | head -1 | while read ABSM_ENVIRONMENT ABSM_SERVERNAME ABSM_SERVICE ABSM_TYPE ABSM_SLOT ABSM_LOCAL_HOME ABSM_REMOTE_HOME ABSM_USER ABSM_PWD ABSM_ORATNS ABSM_ORAHOME ABSM_DBSERVERNAME ABSM_DBDRIVERTYPE ABSM_DBPORTNUMBER ABSM_HEAPSPACE ABSM_STATIONNR ABSM_GFUSER ABSM_GFPASWRD ABSM_GFDOMAIN ABSM_WEBCONTEXT ABSM_WEBNAME ABSM_WEBLIB ABSM_CONNAPPSRV ABSM_CONNAPPSLOT ABSM_CONNREPSRV ABSM_CONNREPSLOT ABSM_USENATIVE ABSM_EXCLUDECUSTREP ABSM_WEB_VERSION ABSM_CLIENTDISTR_SRV ABSM_CLIENTDISTR_DIR ABSM_USER2 ABSM_PWD2 ABSM_STATIONNR2 ABSM_INET_KEY
	do
		# Sync Server Libs if needed
		# ABSM_WEB_VERSION is the version set in service_reg file:
		#   411 for glassfish
		#   55-6 for Payara
		#   8 for tomee8
		#   91 for tomee91
		#   90 for tomcat90
        #   9 for Tomcat9
		#   10 for Tomcat10
			
		# Glassfish411
		[ "$ABSM_WEB_VERSION" == "411" ] && export WEBSRVNAME="glass"
		# New Payara 5.2022.5
		[ "$ABSM_WEB_VERSION" == "55" ] && export WEBSRVNAME="glass"
		# Old Payara 5.2020.6
		[ "$ABSM_WEB_VERSION" == "56" ] && export WEBSRVNAME="glass"
		# Tomee8
		[ "$ABSM_WEB_VERSION" == "8" ] && export WEBSRVNAME="web"	
		# Tomee91
		[ "$ABSM_WEB_VERSION" == "91" ] && export WEBSRVNAME="tomee"
		# Tomcat90
		[ "$ABSM_WEB_VERSION" == "90" ] && export WEBSRVNAME="tomcat"
		# Tomcat9
		[ "$ABSM_WEB_VERSION" == "9" ] && export WEBSRVNAME="tomcat9"
		# Tomcat10
		[ "$ABSM_WEB_VERSION" == "10" ] && export WEBSRVNAME="tomcat10"		

		if [ "$ABS_ROOTSERVER" == "$ABSM_SERVERNAME" ]
		then
			#Glassfish411/Payara55-6 Local
			if [ "$WEBSRVNAME" == "glass" ]
			then
				if [ -e $ABSM_LOCAL_HOME/$GLASSFISHPATH/bin/asadmin ]
				then
					# Check version of installed glassfish
					INSTALLED_GF_VERSION=`$ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t glass -c showversion`
					[ "$INSTALLED_GF_VERSION" == "$ABSM_WEB_VERSION" ] && ABSM_REFRESH_GF_INSTALL="delete" || ABSM_REFRESH_GF_INSTALL="skip"
				fi
				if [ $ABSM_REFRESH_GF_INSTALL != "skip" ]
				then
					# delete glassfish
					absmenu_logline "Deleting glassfish $ABSM_WEB_VERSION"
					[ "$ABSM_WEB_VERSION" == "411" ] && WEBSRVNAME="glassfish" || WEBSRVNAME="payara"
					pushd $ABSM_LOCAL_HOME
					# stop glassfish
					$ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t glass -c stop
					# delete glassfish
					rm -Rf $ABSM_LOCAL_HOME/$GLASSFISHPATH
					popd
					WEBSRVNAME=glass
					$ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t $ABSM_TYPE -c resetheap_glass
				fi
			fi

			#Tomee8 Local
			if [ "$WEBSRVNAME" == "web" ]
			then
				if [ -e $ABSM_LOCAL_HOME/$TOMEE8FOLDERNAME/bin/tomee ]
				then
					# Check version of installed tomee8
					INSTALLED_WEB_VERSION=`$ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t web -c showversion`
					[ "$INSTALLED_WEB_VERSION" == "$ABSM_WEB_VERSION" ] && ABSM_REFRESH_WEB_INSTALL="delete" || ABSM_REFRESH_WEB_INSTALL="skip"
				fi
				if [ $ABSM_REFRESH_WEB_INSTALL != "skip" ]
				then
					# delete Tomee8
					absmenu_logline "Deleting Tomee8 $ABSM_WEB_VERSION"
					WEBSRVNAME=tomee
					pushd $ABSM_LOCAL_HOME
					# stop tomee8
					$ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t web -c stop
					# delete tomee8 directory recursively
					rm -Rf $ABSM_LOCAL_HOME/$TOMEE8FOLDERNAME
					popd
					WEBSRVNAME=web
					$ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t $ABSM_TYPE -c resetheap_web
				fi
			fi
			
			#Tomee91 Local
			if [ "$WEBSRVNAME" == "tomee" ]
			then
				if [ -e $ABSM_LOCAL_HOME/$TOMEEFOLDERNAME/bin/tomee.sh ]
				then
					# Check version of installed tomee91
					INSTALLED_TOMEE_VERSION=`$ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t tomee -c showversion`
					[ "$INSTALLED_TOMEE_VERSION" == "$ABSM_WEB_VERSION" ] && ABSM_REFRESH_TOMEE_INSTALL="delete" || ABSM_REFRESH_TOMEE_INSTALL="skip"
				fi
				if [ $ABSM_REFRESH_TOMEE_INSTALL != "skip" ]
				then
					# delete Tomee91
					absmenu_logline "Deleting Tomee91 $ABSM_WEB_VERSION"
					WEBSRVNAME=tomee
					pushd $ABSM_LOCAL_HOME
					# stop Tomee91
					$ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t tomee -c stop
					# delete Tomee91 directory recursively
					rm -Rf $ABSM_LOCAL_HOME/$TOMEEFOLDERNAME
					popd
					WEBSRVNAME=tomee
					$ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t $ABSM_TYPE -c resetheap_tomee
				fi
			fi

			#Tomcat90 Local
			if [ "$WEBSRVNAME" == "tomcat" ]
			then
				if [ -e $ABSM_LOCAL_HOME/$TOMCATFOLDERNAME/bin/tomcat9.exe ]
				then
					# Check version of installed tomcat90
					INSTALLED_TOMCAT_VERSION=`$ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t tomcat -c showversion`
					[ "$INSTALLED_TOMCAT_VERSION" == "$ABSM_WEB_VERSION" ] && ABSM_REFRESH_TOMCAT_INSTALL="delete" || ABSM_REFRESH_TOMCAT_INSTALL="skip"
				fi
				if [ $ABSM_REFRESH_TOMCAT_INSTALL != "skip" ]
				then
					# delete tomcat90
					absmenu_logline "Installing Tomcat90 $ABSM_WEB_VERSION"
					WEBSRVNAME=tomcat
					pushd $ABSM_LOCAL_HOME
					# stop tomcat90
					$ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t tomcat -c stop
					# delete tomcat90 directory recursively
					rm -Rf $ABSM_LOCAL_HOME/$TOMCATFOLDERNAME
					popd
					WEBSRVNAME=tomcat
					$ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t $ABSM_TYPE -M $ABSM_HEAPSPACE -c maxheap_tomcat
				fi
			fi
			
			#Tomcat9 Local
			if [ "$WEBSRVNAME" == "tomcat9" ]
			then
				if [ -e $ABSM_LOCAL_HOME/$TOMCAT9FOLDERNAME/bin/startup.sh ]
				then
					# Check version of installed tomcat9
					INSTALLED_TOMCAT9_VERSION=`$ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t tomcat9 -c showversion`
					[ "$INSTALLED_TOMCAT9_VERSION" == "$ABSM_WEB_VERSION" ] && ABSM_REFRESH_TOMCAT9_INSTALL="delete" || ABSM_REFRESH_TOMCAT9_INSTALL="skip"
				fi
				if [ $ABSM_REFRESH_TOMCAT9_INSTALL != "skip" ]
				then
					# delete tomcat9
					absmenu_logline "Deleting Tomcat9 $ABSM_WEB_VERSION"
					WEBSRVNAME=tomcat
					pushd $ABSM_LOCAL_HOME
					# stop tomcat9
					$ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t tomcat9 -c stop
					# delete tomcat9 directory recursively
					rm -Rf $ABSM_LOCAL_HOME/$TOMCAT9FOLDERNAME
					WEBSRVNAME=tomcat9
					popd
					$ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t $ABSM_TYPE -c resetheap_tomcat9
				fi
			fi

			#Tomcat10 Local
			if [ "$WEBSRVNAME" == "tomcat10" ]
			then
				if [ -e $ABSM_LOCAL_HOME/$TOMCAT10FOLDERNAME/bin/startup.sh ]
				then
					# Check version of installed tomcat10
					INSTALLED_TOMCAT10_VERSION=`$ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t tomcat10 -c showversion`
					[ "$INSTALLED_TOMCAT10_VERSION" == "$ABSM_WEB_VERSION" ] && ABSM_REFRESH_TOMCAT10_INSTALL="delete" || ABSM_REFRESH_TOMCAT10_INSTALL="skip"
				fi
				if [ $ABSM_REFRESH_TOMCAT10_INSTALL != "skip" ]
				then
					# delete tomcat10
					absmenu_logline "Deleting Tomcat10 $ABSM_WEB_VERSION"
					WEBSRVNAME=tomcat
					pushd $ABSM_LOCAL_HOME
					# stop tomcat10
					$ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t tomcat10 -c stop
					# delete tomcat10 directory recursively
					rm -Rf $ABSM_LOCAL_HOME/$TOMCAT10FOLDERNAME
					WEBSRVNAME=tomcat10
					popd
					$ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t $ABSM_TYPE -c resetheap_tomcat10
				fi
			fi
		else
			#Glassfish411/Payara55-6 Remote
			if [ "$WEBSRVNAME" == "glass" ]
			then
				if [ `ssh -q -n $ABSM_SERVERNAME "[ -e $ABSM_LOCAL_HOME/$GLASSFISHPATH/bin/asadmin ] && echo 1"` ]
				then
					# Check version of installed glassfish
					INSTALLED_GF_VERSION=`ssh -q -n $ABSM_SERVERNAME "$ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t glass -c showversion"`
					[ "$INSTALLED_GF_VERSION" == "$ABSM_WEB_VERSION" ] && ABSM_REFRESH_GF_INSTALL="delete" || ABSM_REFRESH_GF_INSTALL="skip"
				fi
				[ "$ABSM_WEB_VERSION" == "411" ] && WEBSRVNAME="glassfish" || WEBSRVNAME="payara"
				if [ "$ABSM_REFRESH_GF_INSTALL" != "skip" ]
				then
					absmenu_logline "Deleting ${WEBSRVNAME} $INSTALLED_GF_VERSION to $ABSM_WEB_VERSION"
					ssh -q -n $ABSM_SERVERNAME "$ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t glass -c stop; rm -Rf $ABSM_LOCAL_HOME/$GLASSFISHPATH"
				fi
				WEBSRVNAME=glass
				ssh -q -n $ABSM_SERVERNAME "$ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t $ABSM_TYPE -c maxheap_glass"
			fi

			#Tomee8 Remote
			if [ "$WEBSRVNAME" == "web" ]
			then
				if [ `ssh -q -n $ABSM_SERVERNAME "[ -e $ABSM_LOCAL_HOME/$TOMEE8FOLDERNAME/bin/tomee ] && echo 1"` ]
				then
					# Check version of installed tomee8
					INSTALLED_WEB_REMOTE_VERSION=`ssh -q -n $ABSM_SERVERNAME "$ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t web -c showversion"`
					[ "$INSTALLED_WEB_REMOTE_VERSION" == "$ABSM_WEB_VERSION" ] && ABSM_REFRESH_WEB_REMOTE_INSTALL="delete" || ABSM_REFRESH_WEB_REMOTE_INSTALL="skip"			
				fi
				if [ $ABSM_REFRESH_WEB_REMOTE_INSTALL != "skip" ]
				then
					# delete tomee8
					absmenu_logline "Deleting Tomee8 Remote $ABSM_WEB_VERSION"
					WEBSRVNAME=tomee
					# stop tomee8
					ssh -q -n $ABSM_SERVERNAME "$ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t web -c stop"
					# delete tomee8 directory recursively
					ssh -q -n $ABSM_SERVERNAME "rm -Rf $ABSM_LOCAL_HOME/$TOMEE8FOLDERNAME"
					WEBSRVNAME=web
					ssh -q -n $ABSM_SERVERNAME "$ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t $ABSM_TYPE -c resetheap_web"
				fi
			fi

			#Tomee91 Remote
			if [ "$WEBSRVNAME" == "tomee" ]
			then
				if [ `ssh -q -n $ABSM_SERVERNAME "[ -e $ABSM_LOCAL_HOME/$TOMEEFOLDERNAME/bin/tomee.sh ] && echo 1"` ]
				then
					# Check version of installed tomee91
					INSTALLED_TOMEE_REMOTE_VERSION=`ssh -q -n $ABSM_SERVERNAME "$ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t tomee -c showversion"`
					[ "$INSTALLED_TOMEE_REMOTE_VERSION" == "$ABSM_WEB_VERSION" ] && ABSM_REFRESH_TOMEE_REMOTE_INSTALL="delete" || ABSM_REFRESH_TOMEE_REMOTE_INSTALL="skip"			
				fi
				if [ $ABSM_REFRESH_TOMEE_REMOTE_INSTALL != "skip" ]
				then
					# delete tomee91
					absmenu_logline "Deleting Tomee91 Remote $ABSM_WEB_VERSION"
					WEBSRVNAME=tomee
					# stop tomee91
					ssh -q -n $ABSM_SERVERNAME "$ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t tomee -c stop"
					# delete tomee91 directory recursively
					ssh -q -n $ABSM_SERVERNAME "rm -Rf $ABSM_LOCAL_HOME/$TOMEEFOLDERNAME"
					WEBSRVNAME=tomee
					ssh -q -n $ABSM_SERVERNAME "$ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t $ABSM_TYPE -M $ABSM_HEAPSPACE -c maxheap_tomee"
				fi
			fi
			
			#Tomcat90 Remote
			if [ "$WEBSRVNAME" == "tomcat" ]
			then
				if [ `ssh -q -n $ABSM_SERVERNAME "[ -e $ABSM_LOCAL_HOME/$TOMCATFOLDERNAME/bin/tomcat9.exe ] && echo 1"` ]
				then
					# Check version of installed tomcat90
					INSTALLED_TOMCAT_REMOTE_VERSION=`ssh -q -n $ABSM_SERVERNAME "$ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t tomcat -c showversion"`
					[ "$INSTALLED_TOMCAT_REMOTE_VERSION" == "$ABSM_WEB_VERSION" ] && ABSM_REFRESH_TOMCAT_REMOTE_INSTALL="delete" || ABSM_REFRESH_TOMCAT_REMOTE_INSTALL="skip"				
				fi
				if [ $ABSM_REFRESH_TOMCAT_REMOTE_INSTALL != "skip" ]
				then
					# delete tomcat90
					absmenu_logline "Deleting Tomcat90 Remote $ABSM_WEB_VERSION"
					WEBSRVNAME=tomcat
					# stop tomcat90
					ssh -q -n $ABSM_SERVERNAME "$ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t tomcat -c stop"
					# delete tomcat90 directory recursively
					ssh -q -n $ABSM_SERVERNAME "rm -Rf $ABSM_LOCAL_HOME/$TOMCATFOLDERNAME"
					WEBSRVNAME=tomcat
					ssh -q -n $ABSM_SERVERNAME "$ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t $ABSM_TYPE -c resetheap_tomcat"
				fi
			fi

			#Tomcat9 Remote
			if [ "$WEBSRVNAME" == "tomcat9" ]
			then
				if [ `ssh -q -n $ABSM_SERVERNAME "[ -e $ABSM_LOCAL_HOME/$TOMCAT9FOLDERNAME/bin/startup.sh ] && echo 1"` ]
				then
					# Check version of installed tomcat9
					INSTALLED_TOMCAT9_REMOTE_VERSION=`ssh -q -n $ABSM_SERVERNAME "$ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t tomcat9 -c showversion"`
					[ "$INSTALLED_TOMCAT9_REMOTE_VERSION" == "$ABSM_WEB_VERSION" ] && ABSM_REFRESH_TOMCAT9_REMOTE_INSTALL="delete" || ABSM_REFRESH_TOMCAT9_REMOTE_INSTALL="skip"				
				fi
				if [ $ABSM_REFRESH_TOMCAT9_REMOTE_INSTALL != "skip" ]
				then
					# delete tomcat9
					absmenu_logline "Installing Tomcat9 Remote $ABSM_WEB_VERSION"
					WEBSRVNAME=tomcat
					# stop tomcat9
					ssh -q -n $ABSM_SERVERNAME "$ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t tomcat9 -c stop"
					# delete tomcat9 directory recursively
					ssh -q -n $ABSM_SERVERNAME "rm -Rf $ABSM_LOCAL_HOME/$TOMCAT9FOLDERNAME"
					WEBSRVNAME=tomcat9
					ssh -q -n $ABSM_SERVERNAME "$ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t $ABSM_TYPE -c resetheap_tomcat9"
				fi
			fi

			#Tomcat10 Remote
			if [ "$WEBSRVNAME" == "tomcat10" ]
			then
				if [ `ssh -q -n $ABSM_SERVERNAME "[ -e $ABSM_LOCAL_HOME/$TOMCAT10FOLDERNAME/bin/startup.sh ] && echo 1"` ]
				then
					# Check version of installed tomcat10
					INSTALLED_TOMCAT10_REMOTE_VERSION=`ssh -q -n $ABSM_SERVERNAME "$ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t tomcat10 -c showversion"`
					[ "$INSTALLED_TOMCAT10_REMOTE_VERSION" == "$ABSM_WEB_VERSION" ] && ABSM_REFRESH_TOMCAT10_REMOTE_INSTALL="delete" || ABSM_REFRESH_TOMCAT10_REMOTE_INSTALL="skip"				
				fi
				if [ $ABSM_REFRESH_TOMCAT10_REMOTE_INSTALL != "skip" ]
				then
					# delete tomcat10
					absmenu_logline "Installing Tomcat10 Remote $ABSM_WEB_VERSION"
					WEBSRVNAME=tomcat
					# stop tomcat10
					ssh -q -n $ABSM_SERVERNAME "$ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t tomcat10 -c stop"
					# delete tomcat10 directory recursively
					ssh -q -n $ABSM_SERVERNAME "rm -Rf $ABSM_LOCAL_HOME/$TOMCAT10FOLDERNAME"
					WEBSRVNAME=tomcat10
					ssh -q -n $ABSM_SERVERNAME "$ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t $ABSM_TYPE -c resetheap_tomcat10"
				fi
			fi
		fi
	done
}

# Check the status of the glassfish domain. Running equals return code 0. Anything but running is return code 1
check_glassfish_domainstatus()
{
	# $1 Environment
	# $2 Remote server
	# $3 Slot number
	
	ABSM_ENVIRONMENT=$1
	ABSM_SERVERNAME=$2
	ABSM_SLOT=$3
	ABSM_GFDOMAIN=$(grep '^ *'$ABSM_ENVIRONMENT"[[:blank:]]" $ABSMENUGLOBALCONFIG | sort -k2,2 -k5,5 -k4,4 | awk -v a="$ABSM_SERVERNAME" -v b="$ABSM_SLOT" '$2==a && $5==b && $4!="app" && $4!="rep" { print $19 } ' | sort -u)
	
	if [ "$ABS_ROOTSERVER" == "$ABSM_SERVERNAME" ] 
	then
			STATUS=$($ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t glass -c statusdomain -b $ABSM_GFDOMAIN | tail -1)
		else
			STATUS=$(ssh -q -n $ABSM_SERVERNAME "$ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t glass -c statusdomain -b $ABSM_GFDOMAIN | tail -1")
	fi
	
	[ "$STATUS" == "running" ] && return 0
	return 1
}

check_web_status()
{
	# $1 Environment
	# $2 Remote server
	# $3 Slot number
	
	ABSM_ENVIRONMENT=$1
	ABSM_SERVERNAME=$2
	ABSM_SLOT=$3

	if [ "$ABS_ROOTSERVER" == "$ABSM_SERVERNAME" ] 
	then
		STATUS=$($ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t web -c webstatus | tail -1)
	else
		STATUS=$(ssh -q -n $ABSM_SERVERNAME "$ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t web -c webstatus | tail -1")
	fi	
		
	[ "$STATUS" == "running" ] && return 0
	return 1
}

check_tomee_status()
{
	# $1 Environment
	# $2 Remote server
	# $3 Slot number
	
	ABSM_ENVIRONMENT=$1
	ABSM_SERVERNAME=$2
	ABSM_SLOT=$3

	if [ "$ABS_ROOTSERVER" == "$ABSM_SERVERNAME" ] 
	then
		STATUS=$($ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t tomee -c tomeestatus | tail -1)
	else
		STATUS=$(ssh -q -n $ABSM_SERVERNAME "$ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t tomee -c tomeestatus | tail -1")
	fi	

	[ "$STATUS" == "running" ] && return 0
	return 1
}

check_tomcat_status()
{
	# $1 Environment
	# $2 Remote server
	# $3 Slot number
	
	ABSM_ENVIRONMENT=$1
	ABSM_SERVERNAME=$2
	ABSM_SLOT=$3

	if [ "$ABS_ROOTSERVER" == "$ABSM_SERVERNAME" ] 
	then
		STATUS=$($ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t tomcat -c tomcatstatus | tail -1)
	else
		STATUS=$(ssh -q -n $ABSM_SERVERNAME "$ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t tomcat -c tomcatstatus | tail -1")
	fi	
		
	[ "$STATUS" == "running" ] && return 0
	return 1
}

check_tomcat9_status()
{
	# $1 Environment
	# $2 Remote server
	# $3 Slot number
	
	ABSM_ENVIRONMENT=$1
	ABSM_SERVERNAME=$2
	ABSM_SLOT=$3

	if [ "$ABS_ROOTSERVER" == "$ABSM_SERVERNAME" ] 
	then
		STATUS=$($ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t tomcat9 -c tomcat9status | tail -1)
	else
		STATUS=$(ssh -q -n $ABSM_SERVERNAME "$ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t tomcat9 -c tomcat9status | tail -1")
	fi	
		
	[ "$STATUS" == "running" ] && return 0
	return 1
}

check_tomcat10_status()
{
	# $1 Environment
	# $2 Remote server
	# $3 Slot number
	
	ABSM_ENVIRONMENT=$1
	ABSM_SERVERNAME=$2
	ABSM_SLOT=$3

	if [ "$ABS_ROOTSERVER" == "$ABSM_SERVERNAME" ] 
	then
		STATUS=$($ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t tomcat10 -c tomcat10status | tail -1)
	else
		STATUS=$(ssh -q -n $ABSM_SERVERNAME "$ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t tomcat10 -c tomcat10status | tail -1")
	fi	
		
	[ "$STATUS" == "running" ] && return 0
	return 1
}

#Not Used - there are seperate functions for glassfish 411, payara55, payara56, tomee8, tomee91, tomcat90, tomcat9 and tomcat10
snmpcheck_webapps()
{
	ssh -n -q $ABSM_SERVERNAME [ ! -d $ABS_ROOTDIR/$ABSM_SLOT/$TOMEEFOLDERNAME/webapps ] && return 0
	echo "$MSGINDENT Checking SNMP status of deployed Glassfish411/Payara55-6 web applications"

	if [ "$ABS_ROOTSERVER" == "$ABSM_SERVERNAME" ]
	then
		for directory in `find $ABS_ROOTDIR/$ABSM_SLOT/$TOMEEFOLDERNAME/webapps -mindepth 1 -maxdepth 1 -type d ! -name 'host-manager' ! -name 'ROOT' ! -name 'docs' ! -name 'manager'`
		do
		# Check for web directories
			if [ $(find $directory -name "AbsSnmpAgentSettings.properties" | wc -l) -gt 0 ]
			then
				# ---> Process snmp properties
				SNMPPORT=$( grep "^NMSADDRESS=" $directory/WEB-INF/AbsSnmpAgentSettings.properties |  tr -d '[:space:]' | sed 's/NMSADDRESS=//' | egrep -o '.{5}$' )

				SNMPVALUE=$( snmpwalk -c public -v 1 udp:$ABSM_SERVERNAME:$SNMPPORT 1.3.6.1.4.1.227 | rev | head -c2 | rev | xargs )
			fi
		done
		return $SNMPVALUE
	else
        SNMPDIR=$( ssh -q -n $ABSM_SERVERNAME "find $ABS_ROOTDIR/$ABSM_SLOT/$TOMEEFOLDERNAME/webapps -mindepth 1 -maxdepth 1 -type d" )
        for directory in $SNMPDIR
        do
            # Check for web directories
            if [ $( ssh -q -n $ABSM_SERVERNAME "find $directory -name "AbsSnmpAgentSettings.properties" | wc -l " ) -gt 0 ]
                then
                    # ---> Process snmp properties
                    SNMPPORT=$( ssh -q -n $ABSM_SERVERNAME "grep "^NMSADDRESS=" $directory/WEB-INF/AbsSnmpAgentSettings.properties |  tr -d '[:space:]' | sed 's/NMSADDRESS=//' | egrep -o '.{5}$'" )

					SNMPVALUE=$( snmpwalk -c public -v 1 udp:$ABSM_SERVERNAME:$SNMPPORT 1.3.6.1.4.1.227 | rev | head -c2 | rev | xargs )
			fi
		done
		return $SNMPVALUE
	fi
}

snmpcheck_web()
{
	ssh -n -q $ABSM_SERVERNAME [ ! -d $ABS_ROOTDIR/$ABSM_SLOT/$TOMEE8FOLDERNAME/webapps ] && return 0
	echo "$MSGINDENT Checking SNMP status of deployed Tomee8 web applications"

	if [ "$ABS_ROOTSERVER" == "$ABSM_SERVERNAME" ]
	then
		for directory in `find $ABS_ROOTDIR/$ABSM_SLOT/$TOMEE8FOLDERNAME/webapps -mindepth 1 -maxdepth 1 -type d ! -name 'host-manager' ! -name 'ROOT' ! -name 'docs' ! -name 'manager'`
		do
		# Check for web directories
			if [ $(find $directory -name "AbsSnmpAgentSettings.properties" | wc -l) -gt 0 ]
			then
				# ---> Process snmp properties
				SNMPPORT=$( grep "^NMSADDRESS=" $directory/WEB-INF/AbsSnmpAgentSettings.properties |  tr -d '[:space:]' | sed 's/NMSADDRESS=//' | egrep -o '.{5}$' )

				SNMPVALUE=$( snmpwalk -c public -v 1 udp:$ABSM_SERVERNAME:$SNMPPORT 1.3.6.1.4.1.227 | rev | head -c2 | rev | xargs )
			fi
		done
		return $SNMPVALUE
	else
        SNMPDIR=$( ssh -q -n $ABSM_SERVERNAME "find $ABS_ROOTDIR/$ABSM_SLOT/$TOMEE8FOLDERNAME/webapps -mindepth 1 -maxdepth 1 -type d ! -name 'host-manager' ! -name 'ROOT' ! -name 'docs' ! -name 'manager'" )
        for directory in $SNMPDIR
        do
            # Check for web directories
            if [ $( ssh -q -n $ABSM_SERVERNAME "find $directory -name "AbsSnmpAgentSettings.properties" | wc -l" ) -gt 0 ]
                then
                    # ---> Process snmp properties
                    SNMPPORT=$( ssh -q -n $ABSM_SERVERNAME "grep "^NMSADDRESS=" $directory/WEB-INF/AbsSnmpAgentSettings.properties |  tr -d '[:space:]' | sed 's/NMSADDRESS=//' | egrep -o '.{5}$'" )

					SNMPVALUE=$( snmpwalk -c public -v 1 udp:$ABSM_SERVERNAME:$SNMPPORT 1.3.6.1.4.1.227 | rev | head -c2 | rev | xargs )
			fi
		done
		return $SNMPVALUE
	fi
}

snmpcheck_tomee()
{
	ssh -n -q $ABSM_SERVERNAME [ ! -d $ABS_ROOTDIR/$ABSM_SLOT/$TOMEEFOLDERNAME/webapps ] && return 0
	echo "$MSGINDENT Checking SNMP status of deployed Tomee91 web applications"

	if [ "$ABS_ROOTSERVER" == "$ABSM_SERVERNAME" ]
	then
		for directory in `find $ABS_ROOTDIR/$ABSM_SLOT/$TOMEEFOLDERNAME/webapps -mindepth 1 -maxdepth 1 -type d ! -name 'host-manager' ! -name 'ROOT' ! -name 'docs' ! -name 'manager'`
		do
		# Check for web directories
			if [ $(find $directory -name "AbsSnmpAgentSettings.properties" | wc -l) -gt 0 ]
			then
				# ---> Process snmp properties
				SNMPPORT=$( grep "^NMSADDRESS=" $directory/WEB-INF/AbsSnmpAgentSettings.properties |  tr -d '[:space:]' | sed 's/NMSADDRESS=//' | egrep -o '.{5}$' )

				SNMPVALUE=$( snmpwalk -c public -v 1 udp:$ABSM_SERVERNAME:$SNMPPORT 1.3.6.1.4.1.227 | rev | head -c2 | rev | xargs )
			fi
		done
		return $SNMPVALUE
	else
        SNMPDIR=$( ssh -q -n $ABSM_SERVERNAME "find $ABS_ROOTDIR/$ABSM_SLOT/$TOMEEFOLDERNAME/webapps -mindepth 1 -maxdepth 1 -type d ! -name 'host-manager' ! -name 'ROOT' ! -name 'docs' ! -name 'manager'" )
        for directory in $SNMPDIR
        do
            # Check for web directories
            if [ $( ssh -q -n $ABSM_SERVERNAME "find $directory -name "AbsSnmpAgentSettings.properties" | wc -l" ) -gt 0 ]
                then
                    # ---> Process snmp properties
                    SNMPPORT=$( ssh -q -n $ABSM_SERVERNAME "grep "^NMSADDRESS=" $directory/WEB-INF/AbsSnmpAgentSettings.properties |  tr -d '[:space:]' | sed 's/NMSADDRESS=//' | egrep -o '.{5}$'" )

					SNMPVALUE=$( snmpwalk -c public -v 1 udp:$ABSM_SERVERNAME:$SNMPPORT 1.3.6.1.4.1.227 | rev | head -c2 | rev | xargs )
			fi
		done
		return $SNMPVALUE
	fi
}

snmpcheck_tomcat()
{
	ssh -n -q $ABSM_SERVERNAME [ ! -d $ABS_ROOTDIR/$ABSM_SLOT/$TOMCATFOLDERNAME/webapps ] && return 0
	echo "$MSGINDENT Checking SNMP status of deployed Tomcat90 web applications"

	if [ "$ABS_ROOTSERVER" == "$ABSM_SERVERNAME" ]
	then
		for directory in `find $ABS_ROOTDIR/$ABSM_SLOT/$TOMCATFOLDERNAME/webapps -mindepth 1 -maxdepth 1 -type d ! -name 'host-manager' ! -name 'ROOT' ! -name 'docs' ! -name 'manager'`
		do
		# Check for web directories
			if [ $(find $directory -name "AbsSnmpAgentSettings.properties" | wc -l) -gt 0 ]
			then
				# ---> Process snmp properties
				SNMPPORT=$( grep "^NMSADDRESS=" $directory/WEB-INF/AbsSnmpAgentSettings.properties |  tr -d '[:space:]' | sed 's/NMSADDRESS=//' | egrep -o '.{5}$' )

				SNMPVALUE=$( snmpwalk -c public -v 1 udp:$ABSM_SERVERNAME:$SNMPPORT 1.3.6.1.4.1.227 | rev | head -c2 | rev | xargs )
			fi
		done
		return $SNMPVALUE
	else
        SNMPDIR=$( ssh -q -n $ABSM_SERVERNAME "find $ABS_ROOTDIR/$ABSM_SLOT/$TOMCATFOLDERNAME/webapps -mindepth 1 -maxdepth 1 -type d ! -name 'host-manager' ! -name 'ROOT' ! -name 'docs' ! -name 'manager'" )
        for directory in $SNMPDIR
        do
            # Check for web directories
            if [ $( ssh -q -n $ABSM_SERVERNAME "find $directory -name "AbsSnmpAgentSettings.properties" | wc -l " ) -gt 0 ]
                then
                    # ---> Process snmp properties
                    SNMPPORT=$( ssh -q -n $ABSM_SERVERNAME "grep "^NMSADDRESS=" $directory/WEB-INF/AbsSnmpAgentSettings.properties |  tr -d '[:space:]' | sed 's/NMSADDRESS=//' | egrep -o '.{5}$'" )

					SNMPVALUE=$( snmpwalk -c public -v 1 udp:$ABSM_SERVERNAME:$SNMPPORT 1.3.6.1.4.1.227 | rev | head -c2 | rev | xargs )
			fi
		done
		return $SNMPVALUE
	fi
}

snmpcheck_tomcat9()
{
	ssh -n -q $ABSM_SERVERNAME [ ! -d $ABS_ROOTDIR/$ABSM_SLOT/$TOMCAT9FOLDERNAME/webapps ] && return 0
	echo "$MSGINDENT Checking SNMP status of deployed Tomcat9 web application"

	if [ "$ABS_ROOTSERVER" == "$ABSM_SERVERNAME" ]
	then
		for directory in `find $ABS_ROOTDIR/$ABSM_SLOT/$TOMCAT9FOLDERNAME/webapps -mindepth 1 -maxdepth 1 -type d ! -name 'host-manager' ! -name 'ROOT' ! -name 'docs' ! -name 'manager'`
		do
		# Check for web directories
			if [ $(find $directory -name "AbsSnmpAgentSettings.properties" | wc -l) -gt 0 ]
			then
				# ---> Process snmp properties
				SNMPPORT=$( grep "^NMSADDRESS=" $directory/WEB-INF/AbsSnmpAgentSettings.properties |  tr -d '[:space:]' | sed 's/NMSADDRESS=//' | egrep -o '.{5}$' )

				SNMPVALUE=$( snmpwalk -c public -v 1 udp:$ABSM_SERVERNAME:$SNMPPORT 1.3.6.1.4.1.227 | rev | head -c2 | rev | xargs )
			fi
		done
		return $SNMPVALUE
	else
        SNMPDIR=$( ssh -q -n $ABSM_SERVERNAME "find $ABS_ROOTDIR/$ABSM_SLOT/$TOMCAT9FOLDERNAME/webapps -mindepth 1 -maxdepth 1 -type d ! -name 'host-manager' ! -name 'ROOT' ! -name 'docs' ! -name 'manager'" )
        for directory in $SNMPDIR
        do
            # Check for web directories
            if [ $( ssh -q -n $ABSM_SERVERNAME "find $directory -name "AbsSnmpAgentSettings.properties" | wc -l " ) -gt 0 ]
                then
                    # ---> Process snmp properties
                    SNMPPORT=$( ssh -q -n $ABSM_SERVERNAME "grep "^NMSADDRESS=" $directory/WEB-INF/AbsSnmpAgentSettings.properties |  tr -d '[:space:]' | sed 's/NMSADDRESS=//' | egrep -o '.{5}$'" )

					SNMPVALUE=$( snmpwalk -c public -v 1 udp:$ABSM_SERVERNAME:$SNMPPORT 1.3.6.1.4.1.227 | rev | head -c2 | rev | xargs )
			fi
		done
		return $SNMPVALUE
	fi
}

snmpcheck_tomcat10()
{
	ssh -n -q $ABSM_SERVERNAME [ ! -d $ABS_ROOTDIR/$ABSM_SLOT/$TOMCAT10FOLDERNAME/webapps ] && return 0
	echo "$MSGINDENT Checking SNMP status of deployed Tomcat10 web application"

	if [ "$ABS_ROOTSERVER" == "$ABSM_SERVERNAME" ]
	then
		for directory in `find $ABS_ROOTDIR/$ABSM_SLOT/$TOMCAT10FOLDERNAME/webapps -mindepth 1 -maxdepth 1 -type d ! -name 'host-manager' ! -name 'ROOT' ! -name 'docs' ! -name 'manager'`
		do
		# Check for web directories
			if [ $(find $directory -name "AbsSnmpAgentSettings.properties" | wc -l) -gt 0 ]
			then
				# ---> Process snmp properties
				SNMPPORT=$( grep "^NMSADDRESS=" $directory/WEB-INF/AbsSnmpAgentSettings.properties |  tr -d '[:space:]' | sed 's/NMSADDRESS=//' | egrep -o '.{5}$' )

				SNMPVALUE=$( snmpwalk -c public -v 1 udp:$ABSM_SERVERNAME:$SNMPPORT 1.3.6.1.4.1.227 | rev | head -c2 | rev | xargs )
			fi
		done
		return $SNMPVALUE
	else
        SNMPDIR=$( ssh -q -n $ABSM_SERVERNAME "find $ABS_ROOTDIR/$ABSM_SLOT/$TOMCAT10FOLDERNAME/webapps -mindepth 1 -maxdepth 1 -type d ! -name 'host-manager' ! -name 'ROOT' ! -name 'docs' ! -name 'manager'" )
        for directory in $SNMPDIR
        do
            # Check for web directories
            if [ $( ssh -q -n $ABSM_SERVERNAME "find $directory -name "AbsSnmpAgentSettings.properties" | wc -l " ) -gt 0 ]
                then
                    # ---> Process snmp properties
                    SNMPPORT=$( ssh -q -n $ABSM_SERVERNAME "grep "^NMSADDRESS=" $directory/WEB-INF/AbsSnmpAgentSettings.properties |  tr -d '[:space:]' | sed 's/NMSADDRESS=//' | egrep -o '.{5}$'" )

					SNMPVALUE=$( snmpwalk -c public -v 1 udp:$ABSM_SERVERNAME:$SNMPPORT 1.3.6.1.4.1.227 | rev | head -c2 | rev | xargs )
			fi
		done
		return $SNMPVALUE
	fi
}

# Function to create WAR files in the repository location $ABSMENU/repository/WEB for uploading to the webservers
create_repository_warfiles()
{
	# $1 = Environment
	ABSM_ENVIRONMENT=$1
	absmenu_logline "Creating WAR files in the repository"
	grep '^ *'$1"[[:blank:]]" $ABSMENUGLOBALCONFIG | awk '$4!="app" && $4!="rep" { print $4 } ' | sort -u | while read ABSM_TYPE  
	do
		if [ "$ABS_ROOTSERVER" == "$ABSMENUREPOSITORYSERVER" ] 
		then
			[ ! -d $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Future/Web/$ABSM_TYPE ] && mkdir -p $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Future/Web/$ABSM_TYPE
			[ -e $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Future/Web/$ABSM_TYPE.war ] && rm -f $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Future/Web/$ABSM_TYPE.war
			pushd $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Future/Web/$ABSM_TYPE
			zip -r ../$ABSM_TYPE.war *
			popd
		else
			ssh -q -n $ABSMENUREPOSITORYSERVER "[ ! -d $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Future/Web/$ABSM_TYPE ] && mkdir -p $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Future/Web/$ABSM_TYPE"
			ssh -q -n $ABSMENUREPOSITORYSERVER "[ -e $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Future/Web/$ABSM_TYPE.war ] && rm -f $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Future/Web/$ABSM_TYPE.war"
			ssh -q -n $ABSMENUREPOSITORYSERVER "cd $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Future/Web/$ABSM_TYPE; zip -r ../$ABSM_TYPE.war * ;"
		fi
		absmenu_logline "     ) WAR file for $ABSM_TYPE created in the repository"
	done
}

# Function to delete WAR files in the repository location $ABSMENU/repository/WEB
remove_repository_warfiles()
{
	# $1 = Environment
	ABSM_ENVIRONMENT=$1
	absmenu_logline "Removing WAR files from the repository"
	grep '^ *'$ABSM_ENVIRONMENT"[[:blank:]]" $ABSMENUGLOBALCONFIG | awk '$4!="app" && $4!="rep" { print $4 } ' | sort -u | while read ABSM_TYPE  
	do
		if [ "$ABS_ROOTSERVER" == "$ABSMENUREPOSITORYSERVER" ] 
		then
			rm -f $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Future/Web/$ABSM_TYPE.war
		else
			ssh -q -n $ABSMENUREPOSITORYSERVER "[ -e $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Future/Web/$ABSM_TYPE.war ] && rm -f $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Future/Web/$ABSM_TYPE.war"
		fi
		absmenu_logline "     ) WAR file for $ABSM_TYPE removed from the repository"
	done
}

# Move web applications to the server and generate server specific warfile on the server
create_server_warfiles()
{
	# $1 = Environment
	# $2 = ABSM_SERVERNAME
	# $3 = ABSM_SLOT
	
	ABSM_ENVIRONMENT=$1
	ABSM_SERVERNAME=$2
	ABSM_SLOT=$3

	grep '^ *'$ABSM_ENVIRONMENT"[[:blank:]]" $ABSMENUGLOBALCONFIG | sort -k2,2 -k5,5 -k4,4 | awk -v a="$ABSM_SERVERNAME" -v b="$ABSM_SLOT" '$2==a && $5==b && $4!="app" && $4!="rep" { print $0 } ' | while read ABSM_ENVIRONMENT ABSM_SERVERNAME ABSM_SERVICE ABSM_TYPE ABSM_SLOT ABSM_LOCAL_HOME ABSM_REMOTE_HOME ABSM_USER ABSM_PWD ABSM_ORATNS ABSM_ORAHOME ABSM_DBSERVERNAME ABSM_DBDRIVERTYPE ABSM_DBPORTNUMBER ABSM_HEAPSPACE ABSM_STATIONNR ABSM_GFUSER ABSM_GFPASWRD ABSM_GFDOMAIN ABSM_WEBCONTEXT ABSM_WEBNAME ABSM_WEBLIB ABSM_CONNAPPSRV ABSM_CONNAPPSLOT ABSM_CONNREPSRV ABSM_CONNREPSLOT ABSM_USENATIVE ABSM_EXCLUDECUSTREP ABSM_WEB_VERSION ABSM_CLIENTDISTR_SRV ABSM_CLIENTDISTR_DIR ABSM_USER2 ABSM_PWD2 ABSM_STATIONNR2 ABSM_INET_KEY
    do
		# 1) copy custom jar
		if [ "$ABSM_TYPE" == wpo ]
		then
			if [ "$ABS_ROOTSERVER" == "$ABSMENUREPOSITORYSERVER" ] 
			then
				[ -e $ABSMENUREPOSITORYLOCATION/static_zips/$ABSM_WEBLIB ] && rsync -tav --delete -e "ssh -q" $ABSMENUREPOSITORYLOCATION/static_zips/$ABSM_WEBLIB $ABSM_SERVERNAME:$ABSM_LOCAL_HOME/$GLASSFISHPATH/glassfish/domains/$ABSM_GFDOMAIN/lib/applibs
			else
				ssh -q -n $ABSMENUREPOSITORYSERVER "[ -e $ABSMENUREPOSITORYLOCATION/static_zips/$ABSM_WEBLIB ] && rsync -tav --delete -e \"ssh -q\" $ABSMENUREPOSITORYLOCATION/static_zips/$ABSM_WEBLIB $ABSM_SERVERNAME:$ABSM_LOCAL_HOME/$GLASSFISHPATH/glassfish/domains/$ABSM_GFDOMAIN/lib/applibs"
			fi
		fi
		if [ -f $ABSMENUREPOSITORYLOCATION/static_zips/$ABSM_WEBLIB ] && [ "$ABSM_TYPE" == "wp2" ]
		then
			if [ "$ABS_ROOTSERVER" == "$ABSMENUREPOSITORYSERVER" ] 
			then
				[ ! -d $ABSM_LOCAL_HOME/deploy ] && mkdir -p $ABSM_LOCAL_HOME/deploy
				[ -e $ABSMENUREPOSITORYLOCATION/static_zips/$ABSM_WEBLIB ] && rsync -tav --delete -e "ssh -q" $ABSMENUREPOSITORYLOCATION/static_zips/$ABSM_WEBLIB $ABSM_SERVERNAME:$ABSM_LOCAL_HOME/deploy
			else
				ssh -q -n $ABSM_SERVERNAME "[ ! -d $ABSM_LOCAL_HOME/deploy ] && mkdir -p $ABSM_LOCAL_HOME/deploy"
				ssh -q -n $ABSMENUREPOSITORYSERVER "[ -e $ABSMENUREPOSITORYLOCATION/static_zips/$ABSM_WEBLIB ] && rsync -tav --delete -e \"ssh -q\" $ABSMENUREPOSITORYLOCATION/static_zips/$ABSM_WEBLIB $ABSM_SERVERNAME:$ABSM_LOCAL_HOME/deploy"
			fi
		fi

		# 2) sync files to the glassfish server deploy folder
		absmenu_logline "    1) Syncing files from $ABSMENUREPOSITORYSERVER:$ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Future/Web/$ABSM_TYPE to $ABSM_SERVERNAME:$ABSM_LOCAL_HOME/deploy"
		echo "Syncing files from $ABSMENUREPOSITORYSERVER:$ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Future/Web/$ABSM_TYPE to $ABSM_SERVERNAME:$ABSM_LOCAL_HOME/deploy"
		if [ "$ABS_ROOTSERVER" == "$ABSM_SERVERNAME" ] 
		then
			[ ! -d $ABSM_LOCAL_HOME/deploy ] && mkdir -p $ABSM_LOCAL_HOME/deploy
		else
			ssh -q -n $ABSM_SERVERNAME "[ ! -d $ABSM_LOCAL_HOME/deploy ] && mkdir -p $ABSM_LOCAL_HOME/deploy"
		fi

		# 2.1 Send created war file (create_warfiles) in repository location to the deploy folder and clean up
		if [ "$ABS_ROOTSERVER" == "$ABSMENUREPOSITORYSERVER" ] 
		then
			if [ -e $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Future/Web/$ABSM_TYPE.war ]
			then
				rsync -tav --delete -e "ssh -q" $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Future/Web/$ABSM_TYPE.war $ABSM_SERVERNAME:$ABSM_LOCAL_HOME/deploy
			fi
		else
			echo -n .
			ssh -q -n $ABSMENUREPOSITORYSERVER "[ -e $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Future/Web/$ABSM_TYPE.war ] && rsync -tav --delete -e \"ssh -q\" $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Future/Web/$ABSM_TYPE.war $ABSM_SERVERNAME:$ABSM_LOCAL_HOME/deploy"
			echo -n .
		fi
		
		# 2.2 (re)create deploy dirs (wpo/gws/ws2/w4m/wp2/wsr/wum/wcl/wua/wrd/wrr/wsb/wmr/wfb/wcp) and unzip war in the new dir. 
		if [ "$ABS_ROOTSERVER" == "$ABSM_SERVERNAME" ] 
		then
			pushd $ABSM_LOCAL_HOME/deploy
			[ -d $ABSM_TYPE ] && rm -Rf $ABSM_TYPE
			mkdir $ABSM_TYPE
			cd $ABSM_TYPE
			unzip -o ../$ABSM_TYPE.war
			rm -f ../$ABSM_TYPE.war
			[ "$ABSM_TYPE" == "wpo" -o "$ABSM_TYPE" == "wp2" ] && rm -f $ABSM_LOCAL_HOME/deploy/$ABSM_TYPE/WEB-INF/lib/xml-apis*.jar $ABSM_LOCAL_HOME/deploy/$ABSM_TYPE/WEB-INF/lib/xercesImpl*.jar 2> /dev/null
			popd
			
			# process custom wp2 files
			if [ -f $ABSMENUREPOSITORYLOCATION/static_zips/$ABSM_WEBLIB ] && [ "$ABSM_TYPE" == "wp2" ] 
			then
				unzip -o $ABSM_LOCAL_HOME/deploy/$ABSM_WEBLIB -d $ABSM_LOCAL_HOME/deploy/wp2/resources/abs/1_0/
				rm -f $ABSM_LOCAL_HOME/deploy/$ABSM_WEBLIB
				ABSM_WEBLIB="X"
			fi
			
			if [ "$ABSAPPSERVER" ] # copy patchserver.jar, resourcefiles and log4j and snmp sample config from appserver
			then
				[ ! -d $ABSM_LOCAL_HOME/deploy/$ABSM_TYPE/WEB-INF/lib/abs ] && mkdir -p $ABSM_LOCAL_HOME/deploy/$ABSM_TYPE/WEB-INF/lib/abs
				if [ "$ABS_ROOTSERVER" == "$ABSMENUREPOSITORYSERVER" ] 
				then
					rsync -tav --delete -e "ssh -q" $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Future/Server/Lib/patchserver*.jar $ABSM_SERVERNAME:$ABSM_LOCAL_HOME/deploy/$ABSM_TYPE/WEB-INF/lib/abs
					[ "$ABSM_TYPE" == "wpo" -o "$ABSM_TYPE" == "wp2" ] && rsync -tav --delete -e "ssh -q" $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Future/Server/Lib/resource*.jar $ABSM_SERVERNAME:$ABSM_LOCAL_HOME/deploy/$ABSM_TYPE/WEB-INF/lib/abs
					rsync -tav --delete -e "ssh -q" $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Future/Server/Config/sample_AbsSnmpAgentSettings.properties $ABSM_SERVERNAME:$ABSM_LOCAL_HOME/deploy/$ABSM_TYPE/WEB-INF
					rsync -tav --delete -e "ssh -q" $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Future/Server/Config/sample_log4j.properties $ABSM_SERVERNAME:$ABSM_LOCAL_HOME/deploy/$ABSM_TYPE/WEB-INF
				else
					echo -n .
					ssh -q -n $ABSMENUREPOSITORYSERVER "rsync -tav --delete -e \"ssh -q\" $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Future/Server/Lib/patchserver*.jar $ABSM_SERVERNAME:$ABSM_LOCAL_HOME/deploy/$ABSM_TYPE/WEB-INF/lib/abs"
					echo -n .
					[ "$ABSM_TYPE" == "wpo" -o "$ABSM_TYPE" == "wp2" ] && ssh -q -n $ABSMENUREPOSITORYSERVER "rsync -tav --delete -e \"ssh -q\" $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Future/Server/Lib/resource*.jar $ABSM_SERVERNAME:$ABSM_LOCAL_HOME/deploy/$ABSM_TYPE/WEB-INF/lib/abs"
					echo -n .
					ssh -q -n $ABSMENUREPOSITORYSERVER "rsync -tav --delete -e \"ssh -q\" $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Future/Server/Config/sample_AbsSnmpAgentSettings.properties $ABSM_SERVERNAME:$ABSM_LOCAL_HOME/deploy/$ABSM_TYPE/WEB-INF"
					echo -n .
					ssh -q -n $ABSMENUREPOSITORYSERVER "rsync -tav --delete -e \"ssh -q\" $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Future/Server/Config/sample_log4j.properties $ABSM_SERVERNAME:$ABSM_LOCAL_HOME/deploy/$ABSM_TYPE/WEB-INF"
					echo .
				fi
			fi
		else
			echo -n .
			ssh -q -n $ABSM_SERVERNAME "cd $ABSM_LOCAL_HOME/deploy; [ -d $ABSM_TYPE ] && rm -Rf $ABSM_TYPE"
			echo -n .
			ssh -q -n $ABSM_SERVERNAME "cd $ABSM_LOCAL_HOME/deploy; mkdir $ABSM_TYPE; cd $ABSM_TYPE; unzip -o ../$ABSM_TYPE.war; rm -f ../$ABSM_TYPE.war"
			echo .
			[ "$ABSM_TYPE" == "wpo" -o "$ABSM_TYPE" == "wp2" ] && ssh -q -n $ABSM_SERVERNAME "rm -f $ABSM_LOCAL_HOME/deploy/$ABSM_TYPE/WEB-INF/lib/xml-apis*.jar $ABSM_LOCAL_HOME/deploy/$ABSM_TYPE/WEB-INF/lib/xercesImpl*.jar 2> /dev/null"

			# process custom wp2 files
			if [ -f $ABSMENUREPOSITORYLOCATION/static_zips/$ABSM_WEBLIB ] && [ "$ABSM_TYPE" == "wp2" ] 
			then
				ssh -q -n $ABSM_SERVERNAME "unzip -o $ABSM_LOCAL_HOME/deploy/$ABSM_WEBLIB -d $ABSM_LOCAL_HOME/deploy/wp2/resources/abs/1_0/"
				ssh -q -n $ABSM_SERVERNAME "rm -f $ABSM_LOCAL_HOME/deploy/$ABSM_WEBLIB"
				ABSM_WEBLIB="X"
			fi		
			
			if [ "$ABSAPPSERVER" ] # copy patchserver.jar, resourcefiles and log4j and snmp sample config from appserver
			then
				echo -n .
				ssh -q -n $ABSM_SERVERNAME "[ ! -d $ABSM_LOCAL_HOME/deploy/$ABSM_TYPE/WEB-INF/lib/abs ] && mkdir -p $ABSM_LOCAL_HOME/deploy/$ABSM_TYPE/WEB-INF/lib/abs"
				echo -n .
				ssh -q -n $ABSMENUREPOSITORYSERVER "rsync -tav --delete -e \"ssh -q\" $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Future/Server/Lib/patchserver*.jar $ABSM_SERVERNAME:$ABSM_LOCAL_HOME/deploy/$ABSM_TYPE/WEB-INF/lib/abs"
				echo -n .
				[ "$ABSM_TYPE" == "wpo" -o "$ABSM_TYPE" == "wp2" ] && ssh -q -n $ABSMENUREPOSITORYSERVER "rsync -tav --delete -e \"ssh -q\" $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Future/Server/Lib/resource*.jar $ABSM_SERVERNAME:$ABSM_LOCAL_HOME/deploy/$ABSM_TYPE/WEB-INF/lib/abs"
				echo -n .
				ssh -q -n $ABSMENUREPOSITORYSERVER "rsync -tav --delete -e \"ssh -q\" $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Future/Server/Config/sample_AbsSnmpAgentSettings.properties $ABSM_SERVERNAME:$ABSM_LOCAL_HOME/deploy/$ABSM_TYPE/WEB-INF"
				echo -n .
				ssh -q -n $ABSMENUREPOSITORYSERVER "rsync -tav --delete -e \"ssh -q\" $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Future/Server/Config/sample_log4j.properties $ABSM_SERVERNAME:$ABSM_LOCAL_HOME/deploy/$ABSM_TYPE/WEB-INF"
				echo .
			fi
		fi
		
		# 3) generate properties
		absmenu_logline "    2) Generating properties in $ABSM_SERVERNAME:$ABSM_LOCAL_HOME/deploy/$ABSM_TYPE"
		echo "Generating properties in $ABSM_SERVERNAME:$ABSM_LOCAL_HOME/deploy/$ABSM_TYPE"
		. $ABSMENUPATH/bin/generate_properties.sh web normal "$ABSMENU_CURRENT_ENVIRONMENT" "$ABSM_TYPE" "$ABSM_SERVERNAME" "$ABSM_SLOT" "$ABSM_LOCAL_HOME" "$ABSM_USER" "$ABSM_PWD" "$ABSM_STATIONNR" "$ABSM_CONNAPPSRV" "$ABSM_CONNAPPSLOT" "$ABSM_CONNREPSRV" "$ABSM_CONNREPSLOT" "$ABSM_WEBNAME" "$ABSM_ORATNS" "$ABSM_ORAHOME" "$ABSM_USER" "$ABSM_PWD" "$ABSM_USENATIVE" "$ABSM_INET_KEY" "$ABSM_GFDOMAIN" "$ABSM_USER2" "$ABSM_PWD2" "$ABSM_STATIONNR2" "$ABSM_DBSERVERNAME" "$ABSM_DBDRIVERTYPE" "$ABSM_DBPORTNUMBER"
		
		# 5) create new war-file
		absmenu_logline "    3) Generating war-file $ABSM_SERVERNAME:$ABSM_LOCAL_HOME/deploy/$ABSM_TYPE/$ABSM_WEBNAME.war"
		echo "Generating war-file $ABSM_SERVERNAME:$ABSM_LOCAL_HOME/deploy/$ABSM_TYPE/$ABSM_WEBNAME.war"
		if [ "$ABS_ROOTSERVER" == "$ABSM_SERVERNAME" ] 
		then
			[ -e $ABSM_LOCAL_HOME/deploy/$ABSM_TYPE/$ABSM_WEBNAME.war ] && rm -f $ABSM_LOCAL_HOME/deploy/$ABSM_TYPE/$ABSM_WEBNAME.war
			pushd $ABSM_LOCAL_HOME/deploy/$ABSM_TYPE
			zip -r -q $ABSM_WEBNAME.war *
			popd
		else
			echo -n .
			ssh -q -n $ABSM_SERVERNAME "[ -e $ABSM_LOCAL_HOME/deploy/$ABSM_TYPE/$ABSM_WEBNAME.war ] && rm -f $ABSM_LOCAL_HOME/deploy/$ABSM_TYPE/$ABSM_WEBNAME.war"
			echo -n .
			ssh -q -n $ABSM_SERVERNAME "cd $ABSM_LOCAL_HOME/deploy/$ABSM_TYPE; zip -r -q $ABSM_WEBNAME.war *"
			echo .
		fi
	done
}

# Move Glassfish/Payara web applications to the server
deploy_glassfish_warfiles()
{
	# $1 = Environment
	# $2 = ABSM_SERVERNAME
	# $3 = ABSM_TYPE
	# $4 = ABSM_SLOT
	# $5 = ABSM_WEBNAME
	# $6 = ABSM_GFDOMAIN
	# $7 = ABSM_WEBCONTEXT
	# $8 = ABSM_WEBLIB
	
	ABSM_ENVIRONMENT=$1
	ABSM_SERVERNAME=$2
	ABSM_TYPE=$3
	ABSM_SLOT=$4
	ABSM_WEBNAME=$5
	ABSM_GFDOMAIN=$6
	ABSM_WEBCONTEXT=$7
	ABSM_WEBLIB=$8
	
	absmenu_logline "Deploying WAR file $ABSM_WEBNAME.war for the $ABSM_TYPE web application on the server $ABSM_SERVERNAME"
	echo "Deploy $ABSM_SERVERNAME:$ABSM_LOCAL_HOME/deploy/$ABSM_TYPE/$ABSM_WEBNAME.war"
	
	TMPWEBLIB=$ABSM_WEBLIB
	[ "$ABSM_TYPE" == "wp2" ] && TMPWEBLIB="X"
	
	if [ "$ABS_ROOTSERVER" == "$ABSM_SERVERNAME" ] 
	then
		$ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t glass -c deploy -b $ABSM_GFDOMAIN -w $ABSM_TYPE:$ABSM_WEBNAME:$ABSM_WEBCONTEXT:$TMPWEBLIB
	else
		ssh -q -n $ABSM_SERVERNAME "$ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t glass -c deploy -b $ABSM_GFDOMAIN -w $ABSM_TYPE:$ABSM_WEBNAME:$ABSM_WEBCONTEXT:$TMPWEBLIB"
	fi
	return $?
}

# Move tomee8 web application to the server
deploy_web_warfiles()
{
    echo "start deploy_web_warfiles"
	# $1 = Environment
	# $2 = ABSM_SERVERNAME
	# $3 = ABSM_TYPE
	# $4 = ABSM_SLOT
	# $5 = ABSM_WEBNAME
	# $6 = ABSM_GFDOMAIN
	# $7 = ABSM_WEBCONTEXT
	# $8 = ABSM_WEBLIB
	
	ABSM_ENVIRONMENT=$1
	ABSM_SERVERNAME=$2
	ABSM_TYPE=$3
	ABSM_SLOT=$4
	
	absmenu_logline "Deploying WAR file $ABSM_WEBNAME.war for the $ABSM_TYPE web application on the server $ABSM_SERVERNAME"
	echo "Deploy $ABSM_SERVERNAME:$ABSM_LOCAL_HOME/deploy/$ABSM_TYPE/$ABSM_WEBNAME.war"
	
	TMPWEBLIB=$ABSM_WEBLIB
	[ "$ABSM_TYPE" == "wp2" ] && TMPWEBLIB="X"
	
	if [ "$ABS_ROOTSERVER" == "$ABSM_SERVERNAME" ] 
	then
		$ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t web -c deploy_web -w $ABSM_TYPE
	else
		ssh -q -n $ABSM_SERVERNAME "$ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t web -c deploy_web -w $ABSM_TYPE" 
	fi	
	return $?
}

# Move tomee91 web application to the server
deploy_tomee_warfiles()
{
    echo "start deploy_tomee_warfiles"
	# $1 = Environment
	# $2 = ABSM_SERVERNAME
	# $3 = ABSM_TYPE
	# $4 = ABSM_SLOT
	# $5 = ABSM_WEBNAME
	# $6 = ABSM_GFDOMAIN
	# $7 = ABSM_WEBCONTEXT
	# $8 = ABSM_WEBLIB
	
	ABSM_ENVIRONMENT=$1
	ABSM_SERVERNAME=$2
	ABSM_TYPE=$3
	ABSM_SLOT=$4
	
	absmenu_logline "Deploying WAR file $ABSM_WEBNAME.war for the $ABSM_TYPE web application on the server $ABSM_SERVERNAME"
	echo "Deploy $ABSM_SERVERNAME:$ABSM_LOCAL_HOME/deploy/$ABSM_TYPE/$ABSM_WEBNAME.war"
	
	TMPWEBLIB=$ABSM_WEBLIB
	[ "$ABSM_TYPE" == "wp2" ] && TMPWEBLIB="X"
	
	if [ "$ABS_ROOTSERVER" == "$ABSM_SERVERNAME" ] 
	then
		$ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t tomee -c deploy_tomee -w $ABSM_TYPE
	else
		ssh -q -n $ABSM_SERVERNAME "$ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t tomee -c deploy_tomee -w $ABSM_TYPE"
	fi	
	return $?
}

# Move tomcat90 web application to the server
deploy_tomcat_warfiles()
{
   echo "start deploy_tomcat_warfiles"
	# $1 = Environment
	# $2 = ABSM_SERVERNAME
	# $3 = ABSM_TYPE
	# $4 = ABSM_SLOT
	# $5 = ABSM_WEBNAME
	# $6 = ABSM_GFDOMAIN
	# $7 = ABSM_WEBCONTEXT
	# $8 = ABSM_WEBLIB
	
	ABSM_ENVIRONMENT=$1
	ABSM_SERVERNAME=$2
	ABSM_TYPE=$3
	ABSM_SLOT=$4
	
	absmenu_logline "Deploying WAR file $ABSM_WEBNAME.war for the $ABSM_TYPE web application on the server $ABSM_SERVERNAME"
	echo "Deploy $ABSM_SERVERNAME:$ABSM_LOCAL_HOME/deploy/$ABSM_TYPE/$ABSM_WEBNAME.war"
	
	#Not relevant for Tomcat
	#TMPWEBLIB=$ABSM_WEBLIB
	#[ "$ABSM_TYPE" == "wp2" ] && TMPWEBLIB="X"
	
	if [ "$ABS_ROOTSERVER" == "$ABSM_SERVERNAME" ] 
	then
		$ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t tomcat -c deploy_tomcat -w $ABSM_TYPE
	else
		ssh -q -n $ABSM_SERVERNAME "$ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t tomcat -c deploy_tomcat -w $ABSM_TYPE" 
	fi	
	return $?
}

# Move tomcat9 web application to the server
deploy_tomcat9_warfiles()
{
   echo "start deploy_tomcat9_warfiles"
	# $1 = Environment
	# $2 = ABSM_SERVERNAME
	# $3 = ABSM_TYPE
	# $4 = ABSM_SLOT
	# $5 = ABSM_WEBNAME
	# $6 = ABSM_GFDOMAIN
	# $7 = ABSM_WEBCONTEXT
	# $8 = ABSM_WEBLIB
	
	ABSM_ENVIRONMENT=$1
	ABSM_SERVERNAME=$2
	ABSM_TYPE=$3
	ABSM_SLOT=$4
	
	absmenu_logline "Deploying WAR file $ABSM_WEBNAME.war for the $ABSM_TYPE web application on Tomcat9 Webserver $ABSM_SERVERNAME"
	echo "Deploy $ABSM_SERVERNAME:$ABSM_LOCAL_HOME/deploy/$ABSM_TYPE/$ABSM_WEBNAME.war"
	
	TMPWEBLIB=$ABSM_WEBLIB
	[ "$ABSM_TYPE" == "wp2" ] && TMPWEBLIB="X"
	
	if [ "$ABS_ROOTSERVER" == "$ABSM_SERVERNAME" ] 
	then
		$ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t tomcat9 -c deploy_tomcat9 -w $ABSM_TYPE
	else
		ssh -q -n $ABSM_SERVERNAME "$ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t tomcat9 -c deploy_tomcat9 -w $ABSM_TYPE" 
	fi	
	return $?
}

# Move tomcat10 web application to the server
deploy_tomcat10_warfiles()
{
   echo "start deploy_tomcat10_warfiles"
	# $1 = Environment
	# $2 = ABSM_SERVERNAME
	# $3 = ABSM_TYPE
	# $4 = ABSM_SLOT
	# $5 = ABSM_WEBNAME
	# $6 = ABSM_GFDOMAIN
	# $7 = ABSM_WEBCONTEXT
	# $8 = ABSM_WEBLIB
	
	ABSM_ENVIRONMENT=$1
	ABSM_SERVERNAME=$2
	ABSM_TYPE=$3
	ABSM_SLOT=$4
	
	absmenu_logline "Deploying WAR file $ABSM_WEBNAME.war for the $ABSM_TYPE web application on Tomcat10 Webserver $ABSM_SERVERNAME"
	echo "Deploy $ABSM_SERVERNAME:$ABSM_LOCAL_HOME/deploy/$ABSM_TYPE/$ABSM_WEBNAME.war"
	
	TMPWEBLIB=$ABSM_WEBLIB
	[ "$ABSM_TYPE" == "wp2" ] && TMPWEBLIB="X"
	
	if [ "$ABS_ROOTSERVER" == "$ABSM_SERVERNAME" ] 
	then
		$ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t tomcat10 -c deploy_tomcat10 -w $ABSM_TYPE
	else
		ssh -q -n $ABSM_SERVERNAME "$ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t tomcat10 -c deploy_tomcat10 -w $ABSM_TYPE" 
	fi	
	return $?
}

# update web components
updateweb()
{
# 1) check if glassfish is present. If not, deploy and create domain
# 2) copy custom jar and server LIBs if needed
# 3) sync files to the glassfish server deploy folder
#    3.1) zip repository location, send it to the deploy folder and clean up
#    3.2) (re)create empty deploy dir (wpo/gws/ws2/w4m/wp2/wsr/wum/wmr/wfb/wcp) and unzip in the new dir
# 4) generate properties
# 5) create new war-file
# 6) make sure the glassfish domain is running
# 7) deploy new war

	# Glassfish 4.1.1
	[ "$ABSM_WEB_VERSION" == "411" ] && export WEBSRVNAME="glass"
	# New Payara 5.2022.5
	[ "$ABSM_WEB_VERSION" == "55" ] && export WEBSRVNAME="glass"
	# Old Payara 5.2020.6
	[ "$ABSM_WEB_VERSION" == "56" ] && export WEBSRVNAME="glass"
	# Tomee8
	[ "$ABSM_WEB_VERSION" == "8" ] && export WEBSRVNAME="web"	
	# Tomee	91
	[ "$ABSM_WEB_VERSION" == "91" ] && export WEBSRVNAME="tomee"
	# Tomcat 90
	[ "$ABSM_WEB_VERSION" == "90" ] && export WEBSRVNAME="tomcat"
	# Tomcat 9
	[ "$ABSM_WEB_VERSION" == "9" ] && export WEBSRVNAME="tomcat9"
	# Tomcat 10
	[ "$ABSM_WEB_VERSION" == "10" ] && export WEBSRVNAME="tomcat10"
	
	export ABSMESSAGE="Updating ${WEBSRVNAME} Webserver"
	absmenu_log

    GFADMINPORT="5"$ABSM_SLOT"34"
    [ ${#GFADMINPORT} == "4" ] && GFADMINPORT="50"$ABSM_SLOT"34"

    WEBNAME="$ABSM_WEBNAME"
    case "$ABSM_TYPE" in
        wpo)    WEBTYPE="web portal";;
        ws2)    WEBTYPE="webservice2";;
        wp2)    WEBTYPE="new web portal";;
		wum)    WEBTYPE="uhf monitor";;
		wua)    WEBTYPE="webclient my uniform assistant";;
		wrd)    WEBTYPE="webclient residential delivery";;
		wrr)    WEBTYPE="webclient route returns";;
        wsb)    WEBTYPE="webclient replace smart barcode";;
        wfb)    WEBTYPE="absmobilefirebaseservices";;
		wcl)    WEBTYPE="web client";;
        wcp)    WEBTYPE="webclientcleanroompackinginstructions";;
		gws)    WEBTYPE="generic webservice";;
		w4m)    WEBTYPE="mobile app webservice";;
        wsr)    WEBTYPE="REST webservice";;
        wmr)    WEBTYPE="Mobile RestService"
    esac
    echo "Deploying binaries for the $WEBTYPE web application on ${WEBSRVNAME} server $ABSM_SERVERNAME, slot $ABSM_SLOT"

    # 1) check if glassfish is present, and if it is the correct version
	if [ "$ABS_ROOTSERVER" == "$ABSM_SERVERNAME" ]
	then
		#Glassfish/Payara Local
		if [ "$WEBSRVNAME" == "glass" ]
		then
			if [ -e $ABSM_LOCAL_HOME/$GLASSFISHPATH/bin/asadmin ]
			then
				# Check version of installed glassfish
				INSTALLED_GF_VERSION=`$ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t glass -c showversion`
				[ "$INSTALLED_GF_VERSION" == "$ABSM_WEB_VERSION" ] && ABSM_REFRESH_GF_INSTALL="no" || ABSM_REFRESH_GF_INSTALL="upgrade"
			else
				ABSM_REFRESH_GF_INSTALL="install"
			fi
			if [ $ABSM_REFRESH_GF_INSTALL != "no" ]
			then
				# correct glassfish not found, so deploy glassfish and create domain
				[ $ABSM_REFRESH_GF_INSTALL == "install" ] && absmenu_logline "Installing glassfish $ABSM_WEB_VERSION"
				[ $ABSM_REFRESH_GF_INSTALL == "upgrade" ] && absmenu_logline "Upgrade glassfish $INSTALLED_GF_VERSION to $ABSM_WEB_VERSION"
				
				mkdir -p $ABSM_LOCAL_HOME
				[ "$ABSM_WEB_VERSION" == "411" ] && WEBSRVNAME=glassfish || WEBSRVNAME=payara
				if [ "$ABS_ROOTSERVER" == "$ABSMENUREPOSITORYSERVER" ] 
				then
					rsync -tav --delete -e "ssh -q" $ABSMENUREPOSITORYLOCATION/static_zips/${WEBSRVNAME}_$ABSM_WEB_VERSION.zip $ABSM_SERVERNAME:$ABSM_LOCAL_HOME
				else
					ssh -q -n $ABSMENUREPOSITORYSERVER "rsync -tav --delete -e \"ssh -q\" $ABSMENUREPOSITORYLOCATION/static_zips/${WEBSRVNAME}_$ABSM_WEB_VERSION.zip $ABSM_SERVERNAME:$ABSM_LOCAL_HOME";
				fi
				pushd $ABSM_LOCAL_HOME
				# if upgrading glassfish to a different version, first stop gf and remove completely
				if [ $ABSM_REFRESH_GF_INSTALL == "upgrade" ]
				then
					$ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t glass -c stop
					rm -Rf $ABSM_LOCAL_HOME/$GLASSFISHPATH
				fi
				unzip -o ${WEBSRVNAME}_$ABSM_WEB_VERSION.zip
				cd $ABSM_LOCAL_HOME/$GLASSFISHPATH
				chmod a+x mq/bin/* bin/* glassfish/config/* glassfish/bin/* javadb/bin/* pkg/lib/*
				rm -f $ABSM_LOCAL_HOME/${WEBSRVNAME}_$ABSM_WEB_VERSION.zip
				$ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t glass -c enable
				$ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t glass -c deletedomain -b $ABSM_GFDOMAIN
				$ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t glass -c createdomain -b $ABSM_GFDOMAIN
				popd
				WEBSRVNAME=glass
			fi
			$ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t $ABSM_TYPE -M $ABSM_HEAPSPACE -c maxheap_glass
			$ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t glass -c start
		fi

		#Tomee8 Local
		if [ "$WEBSRVNAME" == "web" ]
		then
			if [ -e $ABSM_LOCAL_HOME/$TOMEE8FOLDERNAME/bin/tomee ]
			then
				# Check version of installed tomee8
				INSTALLED_WEB_VERSION=`$ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t web -c showversion`
				[ "$INSTALLED_WEB_VERSION" == "$ABSM_WEB_VERSION" ] && ABSM_REFRESH_WEB_INSTALL="no" || ABSM_REFRESH_WEB_INSTALL="upgrade"
			else
				ABSM_REFRESH_WEB_INSTALL="install"
			fi
			if [ $ABSM_REFRESH_WEB_INSTALL != "no" ]
			then
				# correct tomee8 web server not found, so deploy it
				[ $ABSM_REFRESH_WEB_INSTALL == "install" ] && absmenu_logline "Installing Tomee8 $ABSM_WEB_VERSION"
				[ $ABSM_REFRESH_WEB_INSTALL == "upgrade" ] && absmenu_logline "Upgrade Tomee8 $INSTALLED_WEB_VERSION to $ABSM_WEB_VERSION"
				mkdir -p $ABSM_LOCAL_HOME
				WEBSRVNAME=tomee
				if [ "$ABS_ROOTSERVER" == "$ABSMENUREPOSITORYSERVER" ] 
				then
					rsync -tav --delete -e "ssh -q" $ABSMENUREPOSITORYLOCATION/static_zips/${WEBSRVNAME}_$ABSM_WEB_VERSION.zip $ABSM_SERVERNAME:$ABSM_LOCAL_HOME
				else
					ssh -q -n $ABSMENUREPOSITORYSERVER "rsync -tav --delete -e \"ssh -q\" $ABSMENUREPOSITORYLOCATION/static_zips/${WEBSRVNAME}_$ABSM_WEB_VERSION.zip $ABSM_SERVERNAME:$ABSM_LOCAL_HOME";
				fi
				pushd $ABSM_LOCAL_HOME
				# if upgrading tomee8 to a different version, first stop tomee8 and remove completely
				if [ $ABSM_REFRESH_WEB_INSTALL == "upgrade" ]
				then
					# stop tomee8
					$ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t web -c stop
					# delete tomee8 directory recursively
					rm -Rf $ABSM_LOCAL_HOME/$TOMEE8FOLDERNAME
				fi
				# unzip tomee8
				unzip -o ${WEBSRVNAME}_$ABSM_WEB_VERSION.zip
				# delete tomee8 bundle
				rm -f $ABSM_LOCAL_HOME/${WEBSRVNAME}_$ABSM_WEB_VERSION.zip
				WEBSRVNAME=web
				[ "$INSTALLED_WEB_VERSION" == "$ABSM_WEB_VERSION" ] && cleanup_web $1
				popd
			fi
			$ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t $ABSM_TYPE -M $ABSM_HEAPSPACE -c maxheap_web
			$ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t web -c start
		fi

		#Tomee91 Local
		if [ "$WEBSRVNAME" == "tomee" ]
		then
			if [ -e $ABSM_LOCAL_HOME/$TOMEEFOLDERNAME/bin/tomee.sh ]
			then
				# Check version of installed Tomee91
				INSTALLED_TOMEE_VERSION=`$ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t tomee -c showversion`
				[ "$INSTALLED_TOMEE_VERSION" == "$ABSM_WEB_VERSION" ] && ABSM_REFRESH_TOMEE_INSTALL="no" || ABSM_REFRESH_TOMEE_INSTALL="upgrade"
			else
				ABSM_REFRESH_TOMEE_INSTALL="install"
			fi
			if [ $ABSM_REFRESH_TOMEE_INSTALL != "no" ]
			then
				# correct Tomee91 web server not found, so deploy it
				[ $ABSM_REFRESH_TOMEE_INSTALL == "install" ] && absmenu_logline "Installing Tomee91 $ABSM_WEB_VERSION"
				[ $ABSM_REFRESH_TOMEE_INSTALL == "upgrade" ] && absmenu_logline "Upgrade Tomee91 $INSTALLED_TOMEE_VERSION to $ABSM_WEB_VERSION"
				mkdir -p $ABSM_LOCAL_HOME
				if [ "$ABS_ROOTSERVER" == "$ABSMENUREPOSITORYSERVER" ] 
				then
					rsync -tav --delete -e "ssh -q" $ABSMENUREPOSITORYLOCATION/static_zips/${WEBSRVNAME}_$ABSM_WEB_VERSION.zip $ABSM_SERVERNAME:$ABSM_LOCAL_HOME
				else
					ssh -q -n $ABSMENUREPOSITORYSERVER "rsync -tav --delete -e \"ssh -q\" $ABSMENUREPOSITORYLOCATION/static_zips/${WEBSRVNAME}_$ABSM_WEB_VERSION.zip $ABSM_SERVERNAME:$ABSM_LOCAL_HOME";
				fi
				pushd $ABSM_LOCAL_HOME
				# if upgrading Tomee91 to a different version, first stop Tomee91 and remove completely
				if [ $ABSM_REFRESH_TOMEE_INSTALL == "upgrade" ]
				then
					# stop Tomee91
					$ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t tomee -c stop
					# delete Tomee91 directory recursively
					rm -Rf $ABSM_LOCAL_HOME/$TOMEEFOLDERNAME
				fi
				# unzip Tomee91
				unzip -o ${WEBSRVNAME}_$ABSM_WEB_VERSION.zip
				# delete Tomee91 bundle
				rm -f $ABSM_LOCAL_HOME/${WEBSRVNAME}_$ABSM_WEB_VERSION.zip
				[ "$INSTALLED_TOMEE_VERSION" == "$ABSM_WEB_VERSION" ] && cleanup_tomee $1
				popd
			fi
			$ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t $ABSM_TYPE -M $ABSM_HEAPSPACE -c maxheap_tomee
			$ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t tomee -c restart
		fi

		#Tomcat90 Local
		if [ "$WEBSRVNAME" == "tomcat" ]
		then
			if [ -e $ABSM_LOCAL_HOME/$TOMCATFOLDERNAME/bin/tomcat9.exe ]
			then
				# Check version of installed Tomcat90
				INSTALLED_TOMCAT_VERSION=`$ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t tomcat -c showversion`
				[ "$INSTALLED_TOMCAT_VERSION" == "$ABSM_WEB_VERSION" ] && ABSM_REFRESH_TOMCAT_INSTALL="no" || ABSM_REFRESH_TOMCAT_INSTALL="upgrade"
			else
				ABSM_REFRESH_TOMCAT_INSTALL="install"
			fi
			if [ $ABSM_REFRESH_TOMCAT_INSTALL != "no" ]
			then
				# correct Tomcat90 web server not found, so deploy it
				[ $ABSM_REFRESH_TOMCAT_INSTALL == install ] && absmenu_logline "Installing Tomcat90 $ABSM_WEB_VERSION"
				[ $ABSM_REFRESH_TOMCAT_INSTALL == upgrade ] && absmenu_logline "Upgrade Tomcat90 $INSTALLED_TOMCAT_VERSION to $ABSM_WEB_VERSION"
				mkdir -p $ABSM_LOCAL_HOME
				if [ "$ABS_ROOTSERVER" == "$ABSMENUREPOSITORYSERVER" ] 
				then
					rsync -tav --delete -e "ssh -q" $ABSMENUREPOSITORYLOCATION/static_zips/${WEBSRVNAME}_$ABSM_WEB_VERSION.zip $ABSM_SERVERNAME:$ABSM_LOCAL_HOME
				else
					ssh -q -n $ABSMENUREPOSITORYSERVER "rsync -tav --delete -e \"ssh -q\" $ABSMENUREPOSITORYLOCATION/static_zips/${WEBSRVNAME}_$ABSM_WEB_VERSION.zip $ABSM_SERVERNAME:$ABSM_LOCAL_HOME";
				fi
				pushd $ABSM_LOCAL_HOME
				# if upgrading tomcat90 to a different version, first stop tomcat90 and remove completely
				if [ $ABSM_REFRESH_TOMCAT_INSTALL == "upgrade" ]
				then
					# stop Tomcat90
					$ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t tomcat -c stop
					# delete tomcat90 directory recursively
					rm -Rf $ABSM_LOCAL_HOME/$TOMCATFOLDERNAME
				fi
				# unzip Tomcat90
				unzip -o ${WEBSRVNAME}_$ABSM_WEB_VERSION.zip
				# delete Tomcat90 bundle
				rm -f $ABSM_LOCAL_HOME/${WEBSRVNAME}_$ABSM_WEB_VERSION.zip
				[ "$INSTALLED_TOMCAT_VERSION" == "$ABSM_WEB_VERSION" ] && cleanup_tomcat $1
				popd
			fi
			$ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t $ABSM_TYPE -M $ABSM_HEAPSPACE -c maxheap_tomcat
			$ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t tomcat -c restart
		fi

		#Tomcat9 Local
		if [ "$WEBSRVNAME" == "tomcat9" ]
		then
			if [ -e $ABSM_LOCAL_HOME/$TOMCAT9FOLDERNAME/bin/startup.sh ]
			then
				# Check version of installed Tomcat9
				INSTALLED_TOMCAT9_VERSION=`$ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t tomcat9 -c showversion`
				[ "$INSTALLED_TOMCAT9_VERSION" == "$ABSM_WEB_VERSION" ] && ABSM_REFRESH_TOMCAT9_INSTALL="no" || ABSM_REFRESH_TOMCAT9_INSTALL="upgrade"
			else
				ABSM_REFRESH_TOMCAT9_INSTALL="install"
			fi
			if [ $ABSM_REFRESH_TOMCAT9_INSTALL != "no" ]
			then
				# correct Tomcat9 web server not found, so deploy it
				[ $ABSM_REFRESH_TOMCAT9_INSTALL == install ] && absmenu_logline "Installing Tomcat9 $ABSM_WEB_VERSION"
				[ $ABSM_REFRESH_TOMCAT9_INSTALL == upgrade ] && absmenu_logline "Upgrade Tomcat9 $INSTALLED_TOMCAT9_VERSION to $ABSM_WEB_VERSION"
				WEBSRVNAME=tomcat
				mkdir -p $ABSM_LOCAL_HOME
				if [ "$ABS_ROOTSERVER" == "$ABSMENUREPOSITORYSERVER" ] 
				then
					rsync -tav --delete -e "ssh -q" $ABSMENUREPOSITORYLOCATION/static_zips/${WEBSRVNAME}_$ABSM_WEB_VERSION.zip $ABSM_SERVERNAME:$ABSM_LOCAL_HOME
				else
					ssh -q -n $ABSMENUREPOSITORYSERVER "rsync -tav --delete -e \"ssh -q\" $ABSMENUREPOSITORYLOCATION/static_zips/${WEBSRVNAME}_$ABSM_WEB_VERSION.zip $ABSM_SERVERNAME:$ABSM_LOCAL_HOME";
				fi
				pushd $ABSM_LOCAL_HOME
				# if upgrading tomcat9 to a different version, first stop tomcat9 and remove completely
				if [ $ABSM_REFRESH_TOMCAT9_INSTALL == "upgrade" ]
				then
					# stop Tomcat9
					$ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t tomcat9 -c stop
					# delete tomcat9 directory recursively
					rm -Rf $ABSM_LOCAL_HOME/$TOMCAT9FOLDERNAME
				fi
				# unzip Tomcat9
				unzip -o ${WEBSRVNAME}_$ABSM_WEB_VERSION.zip
				# delete Tomcat9 bundle
				rm -f $ABSM_LOCAL_HOME/${WEBSRVNAME}_$ABSM_WEB_VERSION.zip
				WEBSRVNAME=tomcat9
				[ "$INSTALLED_TOMCAT9_VERSION" == "$ABSM_WEB_VERSION" ] && cleanup_tomcat9 $1
				popd
			fi
			$ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t $ABSM_TYPE -M $ABSM_HEAPSPACE -c maxheap_tomcat9
			$ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t tomcat9 -c restart
		fi

		#Tomcat10 Local
		if [ "$WEBSRVNAME" == "tomcat10" ]
		then
			if [ -e $ABSM_LOCAL_HOME/$TOMCAT10FOLDERNAME/bin/startup.sh ]
			then
				# Check version of installed Tomcat10
				INSTALLED_TOMCAT10_VERSION=`$ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t tomcat10 -c showversion`
				[ "$INSTALLED_TOMCAT10_VERSION" == "$ABSM_WEB_VERSION" ] && ABSM_REFRESH_TOMCAT10_INSTALL="no" || ABSM_REFRESH_TOMCAT10_INSTALL="upgrade"
			else
				ABSM_REFRESH_TOMCAT10_INSTALL="install"
			fi
			if [ $ABSM_REFRESH_TOMCAT10_INSTALL != "no" ]
			then
				# correct Tomcat10 web server not found, so deploy it
				[ $ABSM_REFRESH_TOMCAT10_INSTALL == install ] && absmenu_logline "Installing Tomcat10 $ABSM_WEB_VERSION"
				[ $ABSM_REFRESH_TOMCAT10_INSTALL == upgrade ] && absmenu_logline "Upgrade Tomcat10 $INSTALLED_TOMCAT10_VERSION to $ABSM_WEB_VERSION"
				WEBSRVNAME=tomcat
				mkdir -p $ABSM_LOCAL_HOME
				if [ "$ABS_ROOTSERVER" == "$ABSMENUREPOSITORYSERVER" ] 
				then
					rsync -tav --delete -e "ssh -q" $ABSMENUREPOSITORYLOCATION/static_zips/${WEBSRVNAME}_$ABSM_WEB_VERSION.zip $ABSM_SERVERNAME:$ABSM_LOCAL_HOME
				else
					ssh -q -n $ABSMENUREPOSITORYSERVER "rsync -tav --delete -e \"ssh -q\" $ABSMENUREPOSITORYLOCATION/static_zips/${WEBSRVNAME}_$ABSM_WEB_VERSION.zip $ABSM_SERVERNAME:$ABSM_LOCAL_HOME";
				fi
				pushd $ABSM_LOCAL_HOME
				# if upgrading tomcat10 to a different version, first stop tomcat10 and remove completely
				if [ $ABSM_REFRESH_TOMCAT10_INSTALL == "upgrade" ]
				then
					# stop Tomcat10
					$ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t tomcat10 -c stop
					# delete tomcat10 directory recursively
					rm -Rf $ABSM_LOCAL_HOME/$TOMCAT10FOLDERNAME
				fi
				# unzip Tomcat10
				unzip -o ${WEBSRVNAME}_$ABSM_WEB_VERSION.zip
				# delete Tomcat10 bundle
				rm -f $ABSM_LOCAL_HOME/${WEBSRVNAME}_$ABSM_WEB_VERSION.zip
				WEBSRVNAME=tomcat10
				[ "$INSTALLED_TOMCAT10_VERSION" == "$ABSM_WEB_VERSION" ] && cleanup_tomcat10 $1
				popd
			fi
			$ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t $ABSM_TYPE -M $ABSM_HEAPSPACE -c maxheap_tomcat10
			$ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t tomcat10 -c restart
		fi
	else
		#Glassfish Remote
		if [ "$WEBSRVNAME" == "glass" ]
		then
			if [ `ssh -q -n $ABSM_SERVERNAME "[ -e $ABSM_LOCAL_HOME/$GLASSFISHPATH/bin/asadmin ] && echo 1"` ]
			then
				# Check version of installed glassfish
				INSTALLED_GF_VERSION=`ssh -q -n $ABSM_SERVERNAME "$ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t glass -c showversion"`
				[ "$INSTALLED_GF_VERSION" == "$ABSM_WEB_VERSION" ] && ABSM_REFRESH_GF_INSTALL="no" || ABSM_REFRESH_GF_INSTALL="upgrade"
			else
				ABSM_REFRESH_GF_INSTALL="install"
			fi
			[ $ABSM_WEB_VERSION == "411" ] && WEBSRVNAME=glassfish || WEBSRVNAME=payara
			if [ "$ABSM_REFRESH_GF_INSTALL" != "no" ]
			then
				# create glassfish + domain
				echo -n .
				ssh -q -n $ABSM_SERVERNAME "mkdir -p $ABSM_LOCAL_HOME"
				echo -n .
				ssh -q -n $ABSMENUREPOSITORYSERVER "rsync -tav --delete -e \"ssh -q\" $ABSMENUREPOSITORYLOCATION/static_zips/${WEBSRVNAME}_$ABSM_WEB_VERSION.zip $ABSM_SERVERNAME:$ABSM_LOCAL_HOME";
				echo -n .
				if [ $ABSM_REFRESH_GF_INSTALL == "upgrade" ]
				then
					absmenu_logline "Upgrade ${WEBSRVNAME} $INSTALLED_GF_VERSION to $ABSM_WEB_VERSION"
					ssh -q -n $ABSM_SERVERNAME "$ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t glass -c stop; rm -Rf $ABSM_LOCAL_HOME/$GLASSFISHPATH"
					echo -n .
				else
					absmenu_logline "Installing ${WEBSRVNAME} $ABSM_WEB_VERSION"
				fi
				ssh -q -n $ABSM_SERVERNAME "cd $ABSM_LOCAL_HOME; unzip -o ${WEBSRVNAME}_$ABSM_WEB_VERSION.zip"
				echo -n .
				ssh -q -n $ABSM_SERVERNAME "cd $ABSM_LOCAL_HOME/$GLASSFISHPATH; chmod a+x mq/bin/* bin/* glassfish/config/* glassfish/bin/* javadb/bin/* pkg/lib/*"
				echo -n .
				ssh -q -n $ABSM_SERVERNAME "rm -f $ABSM_LOCAL_HOME/${WEBSRVNAME}_$ABSM_WEB_VERSION.zip"
				echo -n .
				ssh -q -n $ABSM_SERVERNAME "$ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t glass -c enable"
				echo -n .
				ssh -q -n $ABSM_SERVERNAME "$ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t glass -c deletedomain -b $ABSM_GFDOMAIN"
				echo -n .
				ssh -q -n $ABSM_SERVERNAME "$ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t glass -c createdomain -b $ABSM_GFDOMAIN"
				echo .
			fi
			WEBSRVNAME=glass
			ssh -q -n $ABSM_SERVERNAME "$ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t $ABSM_TYPE -M $ABSM_HEAPSPACE -c maxheap_glass"
			ssh -q -n $ABSM_SERVERNAME "$ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t glass -c start"
		fi

		#Tomee8 Remote
		if [ "$WEBSRVNAME" == "web" ]
		then
			if [ `ssh -q -n $ABSM_SERVERNAME "[ -e $ABSM_LOCAL_HOME/$TOMEE8FOLDERNAME/bin/tomee ] && echo 1"` ]
			then
				# Check version of installed tomee8
				INSTALLED_WEB_REMOTE_VERSION=`ssh -q -n $ABSM_SERVERNAME "$ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t web -c showversion"`
				[ "$INSTALLED_WEB_REMOTE_VERSION" == "$ABSM_WEB_VERSION" ] && ABSM_REFRESH_WEB_REMOTE_INSTALL="no" || ABSM_REFRESH_WEB_REMOTE_INSTALL="upgrade"			
			else
				ABSM_REFRESH_WEB_REMOTE_INSTALL="install"
			fi
			if [ $ABSM_REFRESH_WEB_REMOTE_INSTALL != "no" ]
			then
				# correct tomee8 remote web server not found, so deploy it
				[ $ABSM_REFRESH_WEB_REMOTE_INSTALL == "install" ] && absmenu_logline "Installing Tomee8 Remote $ABSM_WEB_VERSION"
				[ $ABSM_REFRESH_WEB_REMOTE_INSTALL == "upgrade" ] && absmenu_logline "Upgrade Tomee8 Remote $INSTALLED_WEB_REMOTE_VERSION to $ABSM_WEB_VERSION"
				ssh -q -n $ABSM_SERVERNAME "mkdir -p $ABSM_LOCAL_HOME"
				WEBSRVNAME=tomee
				if [ "$ABS_ROOTSERVER" == "$ABSMENUREPOSITORYSERVER" ] 
				then
					rsync -tav --delete -e "ssh -q" $ABSMENUREPOSITORYLOCATION/static_zips/${WEBSRVNAME}_$ABSM_WEB_VERSION.zip $ABSM_SERVERNAME:$ABSM_LOCAL_HOME
				else
					ssh -q -n $ABSMENUREPOSITORYSERVER "rsync -tav --delete -e \"ssh -q\" $ABSMENUREPOSITORYLOCATION/static_zips/${WEBSRVNAME}_$ABSM_WEB_VERSION.zip $ABSM_SERVERNAME:$ABSM_LOCAL_HOME";
				fi
				# if upgrading tomee8 to a different version, first stop tomee8 and remove completely
				if [ $ABSM_REFRESH_WEB_REMOTE_INSTALL == "upgrade" ]
				then
					# stop tomee8
					ssh -q -n $ABSM_SERVERNAME "$ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t web -c stop"
					# delete tomee8 directory recursively
					ssh -q -n $ABSM_SERVERNAME "rm -Rf $ABSM_LOCAL_HOME/$TOMEE8FOLDERNAME"
				fi
				# unzip tomee8
				ssh -q -n $ABSM_SERVERNAME "cd $ABSM_LOCAL_HOME; unzip -o ${WEBSRVNAME}_$ABSM_WEB_VERSION.zip"
				# delete tomee8 bundle
				ssh -q -n $ABSM_SERVERNAME "cd $ABSM_LOCAL_HOME; rm -f ${WEBSRVNAME}_$ABSM_WEB_VERSION.zip"
				WEBSRVNAME=web
				[ "$INSTALLED_WEB_REMOTE_VERSION" == "$ABSM_WEB_VERSION" ] && cleanup_web $1
			fi
			ssh -q -n $ABSM_SERVERNAME "$ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t $ABSM_TYPE -M $ABSM_HEAPSPACE -c maxheap_web"
			ssh -q -n $ABSM_SERVERNAME "$ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t web -c start"
		fi
		
		#Tomee91 Remote
		if [ "$WEBSRVNAME" == "tomee" ]
		then
			if [ `ssh -q -n $ABSM_SERVERNAME "[ -e $ABSM_LOCAL_HOME/$TOMEEFOLDERNAME/bin/tomee.sh ] && echo 1"` ]
			then
				# Check version of installed tomee91
				INSTALLED_TOMEE_REMOTE_VERSION=`ssh -q -n $ABSM_SERVERNAME "$ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t tomee -c showversion"`
				[ "$INSTALLED_TOMEE_REMOTE_VERSION" == "$ABSM_WEB_VERSION" ] && ABSM_REFRESH_TOMEE_REMOTE_INSTALL="no" || ABSM_REFRESH_TOMEE_REMOTE_INSTALL="upgrade"			
			else
				ABSM_REFRESH_TOMEE_REMOTE_INSTALL="install"
			fi
			if [ $ABSM_REFRESH_TOMEE_REMOTE_INSTALL != "no" ]
			then
				# correct tomee91 remote web server not found, so deploy it
				[ $ABSM_REFRESH_TOMEE_REMOTE_INSTALL == "install" ] && absmenu_logline "Installing Tomee91 Remote $ABSM_WEB_VERSION"
				[ $ABSM_REFRESH_TOMEE_REMOTE_INSTALL == "upgrade" ] && absmenu_logline "Upgrade Tomee91 Remote $INSTALLED_TOMEE_REMOTE_VERSION to $ABSM_WEB_VERSION"
				ssh -q -n $ABSM_SERVERNAME "mkdir -p $ABSM_LOCAL_HOME"
				if [ "$ABS_ROOTSERVER" == "$ABSMENUREPOSITORYSERVER" ] 
				then
					rsync -tav --delete -e "ssh -q" $ABSMENUREPOSITORYLOCATION/static_zips/${WEBSRVNAME}_$ABSM_WEB_VERSION.zip $ABSM_SERVERNAME:$ABSM_LOCAL_HOME
				else
					ssh -q -n $ABSMENUREPOSITORYSERVER "rsync -tav --delete -e \"ssh -q\" $ABSMENUREPOSITORYLOCATION/static_zips/${WEBSRVNAME}_$ABSM_WEB_VERSION.zip $ABSM_SERVERNAME:$ABSM_LOCAL_HOME";
				fi
				# if upgrading tomee91 to a different version, first stop tomee91 and remove completely
				if [ $ABSM_REFRESH_TOMEE_REMOTE_INSTALL == "upgrade" ]
				then
					# stop tomee91
					ssh -q -n $ABSM_SERVERNAME "$ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t tomee -c stop"
					# delete tomee91 directory recursively
					ssh -q -n $ABSM_SERVERNAME "rm -Rf $ABSM_LOCAL_HOME/$TOMEEFOLDERNAME"
				fi
				# unzip tomee91
				ssh -q -n $ABSM_SERVERNAME "cd $ABSM_LOCAL_HOME; unzip -o ${WEBSRVNAME}_$ABSM_WEB_VERSION.zip"
				# delete tomee91 bundle
				ssh -q -n $ABSM_SERVERNAME "cd $ABSM_LOCAL_HOME; rm -f ${WEBSRVNAME}_$ABSM_WEB_VERSION.zip"
				[ "$INSTALLED_TOMEE_REMOTE_VERSION" == "$ABSM_WEB_VERSION" ] && cleanup_tomee $1
			fi
			ssh -q -n $ABSM_SERVERNAME "$ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t $ABSM_TYPE -M $ABSM_HEAPSPACE -c maxheap_tomee"
			ssh -q -n $ABSM_SERVERNAME "$ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t tomee -c restart"
		fi
		
		#Tomcat90 Remote
		if [ "$WEBSRVNAME" == "tomcat" ]
		then
			if [ `ssh -q -n $ABSM_SERVERNAME "[ -e $ABSM_LOCAL_HOME/$TOMCATFOLDERNAME/bin/tomcat9.exe ] && echo 1"` ]
			then
				# Check version of installed tomcat90
				INSTALLED_TOMCAT_REMOTE_VERSION=`ssh -q -n $ABSM_SERVERNAME "$ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t tomcat -c showversion"`
				[ "$INSTALLED_TOMCAT_REMOTE_VERSION" == "$ABSM_WEB_VERSION" ] && ABSM_REFRESH_TOMCAT_REMOTE_INSTALL="no" || ABSM_REFRESH_TOMCAT_REMOTE_INSTALL="upgrade"				
			else
				ABSM_REFRESH_TOMCAT_REMOTE_INSTALL="install"
			fi
			if [ $ABSM_REFRESH_TOMCAT_REMOTE_INSTALL != "no" ]
			then
				# correct tomcat90 remote web server not found, so deploy it
				[ $ABSM_REFRESH_TOMCAT_REMOTE_INSTALL == "install" ] && absmenu_logline "Installing Tomcat90 Remote $ABSM_WEB_VERSION"
				[ $ABSM_REFRESH_TOMCAT_REMOTE_INSTALL == "upgrade" ] && absmenu_logline "Upgrade Tomcat90 Remote $INSTALLED_TOMCAT_REMOTE_VERSION to $ABSM_WEB_VERSION"
				ssh -q -n $ABSM_SERVERNAME "mkdir -p $ABSM_LOCAL_HOME"
				if [ "$ABS_ROOTSERVER" == "$ABSMENUREPOSITORYSERVER" ] 
				then
					rsync -tav --delete -e "ssh -q" $ABSMENUREPOSITORYLOCATION/static_zips/${WEBSRVNAME}_$ABSM_WEB_VERSION.zip $ABSM_SERVERNAME:$ABSM_LOCAL_HOME
				else
					ssh -q -n $ABSMENUREPOSITORYSERVER "rsync -tav --delete -e \"ssh -q\" $ABSMENUREPOSITORYLOCATION/static_zips/${WEBSRVNAME}_$ABSM_WEB_VERSION.zip $ABSM_SERVERNAME:$ABSM_LOCAL_HOME";
				fi
				# if upgrading tomcat90 to a different version, first stop tomcat90 and remove completely
				if [ $ABSM_REFRESH_TOMCAT_REMOTE_INSTALL == "upgrade" ]
				then
					# stop tomcat90
					ssh -q -n $ABSM_SERVERNAME "$ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t tomcat -c stop"
					# delete tomcat90 directory recursively
					ssh -q -n $ABSM_SERVERNAME "rm -Rf $ABSM_LOCAL_HOME/$TOMCATFOLDERNAME"
				fi
				# unzip tomcat90
				ssh -q -n $ABSM_SERVERNAME "cd $ABSM_LOCAL_HOME; unzip -o ${WEBSRVNAME}_$ABSM_WEB_VERSION.zip"
				# delete tomcat90 bundle
				ssh -q -n $ABSM_SERVERNAME "cd $ABSM_LOCAL_HOME; rm -f ${WEBSRVNAME}_$ABSM_WEB_VERSION.zip"
				[ "$INSTALLED_TOMCAT_REMOTE_VERSION" == "$ABSM_WEB_VERSION" ] && cleanup_tomcat $1
			fi
			ssh -q -n $ABSM_SERVERNAME "$ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t $ABSM_TYPE -M $ABSM_HEAPSPACE -c maxheap_tomcat"
			ssh -q -n $ABSM_SERVERNAME "$ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t tomcat -c restart"
		fi
		
		#Tomcat9 Remote
		if [ "$WEBSRVNAME" == "tomcat9" ]
		then
			if [ `ssh -q -n $ABSM_SERVERNAME "[ -e $ABSM_LOCAL_HOME/$TOMCAT9FOLDERNAME/bin/startup.sh ] && echo 1"` ]
			then
				# Check version of installed tomcat9
				INSTALLED_TOMCAT9_REMOTE_VERSION=`ssh -q -n $ABSM_SERVERNAME "$ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t tomcat9 -c showversion"`
				[ "$INSTALLED_TOMCAT9_REMOTE_VERSION" == "$ABSM_WEB_VERSION" ] && ABSM_REFRESH_TOMCAT9_REMOTE_INSTALL="no" || ABSM_REFRESH_TOMCAT9_REMOTE_INSTALL="upgrade"				
			else
				ABSM_REFRESH_TOMCAT9_REMOTE_INSTALL="install"
			fi
			if [ $ABSM_REFRESH_TOMCAT9_REMOTE_INSTALL != "no" ]
			then
				# correct tomcat9 remote web server not found, so deploy it
				[ $ABSM_REFRESH_TOMCAT9_REMOTE_INSTALL == "install" ] && absmenu_logline "Installing Tomcat9 Remote $ABSM_WEB_VERSION"
				[ $ABSM_REFRESH_TOMCAT9_REMOTE_INSTALL == "upgrade" ] && absmenu_logline "Upgrade Tomcat9 Remote $INSTALLED_TOMCAT9_REMOTE_VERSION to $ABSM_WEB_VERSION"
				ssh -q -n $ABSM_SERVERNAME "mkdir -p $ABSM_LOCAL_HOME"
				WEBSRVNAME=tomcat
				if [ "$ABS_ROOTSERVER" == "$ABSMENUREPOSITORYSERVER" ] 
				then
					rsync -tav --delete -e "ssh -q" $ABSMENUREPOSITORYLOCATION/static_zips/${WEBSRVNAME}_$ABSM_WEB_VERSION.zip $ABSM_SERVERNAME:$ABSM_LOCAL_HOME
				else
					ssh -q -n $ABSMENUREPOSITORYSERVER "rsync -tav --delete -e \"ssh -q\" $ABSMENUREPOSITORYLOCATION/static_zips/${WEBSRVNAME}_$ABSM_WEB_VERSION.zip $ABSM_SERVERNAME:$ABSM_LOCAL_HOME";
				fi
				# if upgrading tomcat9 to a different version, first stop tomcat9 and remove completely
				if [ $ABSM_REFRESH_TOMCAT9_REMOTE_INSTALL == "upgrade" ]
				then
					# stop tomcat9
					ssh -q -n $ABSM_SERVERNAME "$ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t tomcat9 -c stop"
					# delete tomcat9 directory recursively
					ssh -q -n $ABSM_SERVERNAME "rm -Rf $ABSM_LOCAL_HOME/$TOMCAT9FOLDERNAME"
				fi
				# unzip tomcat9
				ssh -q -n $ABSM_SERVERNAME "cd $ABSM_LOCAL_HOME; unzip -o ${WEBSRVNAME}_$ABSM_WEB_VERSION.zip"
				# delete tomcat9 bundle
				ssh -q -n $ABSM_SERVERNAME "cd $ABSM_LOCAL_HOME; rm -f ${WEBSRVNAME}_$ABSM_WEB_VERSION.zip"
				WEBSRVNAME=tomcat9
				[ "$INSTALLED_TOMCAT9_REMOTE_VERSION" == "$ABSM_WEB_VERSION" ] && cleanup_tomcat9 $1
			fi
			ssh -q -n $ABSM_SERVERNAME "$ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t $ABSM_TYPE -M $ABSM_HEAPSPACE -c maxheap_tomcat9"
			ssh -q -n $ABSM_SERVERNAME "$ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t tomcat9 -c restart"
		fi

		#Tomcat10 Remote
		if [ "$WEBSRVNAME" == "tomcat10" ]
		then
			if [ `ssh -q -n $ABSM_SERVERNAME "[ -e $ABSM_LOCAL_HOME/$TOMCAT10FOLDERNAME/bin/startup.sh ] && echo 1"` ]
			then
				# Check version of installed tomcat10
				INSTALLED_TOMCAT10_REMOTE_VERSION=`ssh -q -n $ABSM_SERVERNAME "$ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t tomcat10 -c showversion"`
				[ "$INSTALLED_TOMCAT10_REMOTE_VERSION" == "$ABSM_WEB_VERSION" ] && ABSM_REFRESH_TOMCAT10_REMOTE_INSTALL="no" || ABSM_REFRESH_TOMCAT10_REMOTE_INSTALL="upgrade"				
			else
				ABSM_REFRESH_TOMCAT10_REMOTE_INSTALL="install"
			fi
			if [ $ABSM_REFRESH_TOMCAT10_REMOTE_INSTALL != "no" ]
			then
				# correct tomcat10 remote web server not found, so deploy it
				[ $ABSM_REFRESH_TOMCAT10_REMOTE_INSTALL == "install" ] && absmenu_logline "Installing Tomcat10 Remote $ABSM_WEB_VERSION"
				[ $ABSM_REFRESH_TOMCAT10_REMOTE_INSTALL == "upgrade" ] && absmenu_logline "Upgrade Tomcat10 Remote $INSTALLED_TOMCAT10_REMOTE_VERSION to $ABSM_WEB_VERSION"
				ssh -q -n $ABSM_SERVERNAME "mkdir -p $ABSM_LOCAL_HOME"
				WEBSRVNAME=tomcat
				if [ "$ABS_ROOTSERVER" == "$ABSMENUREPOSITORYSERVER" ] 
				then
					rsync -tav --delete -e "ssh -q" $ABSMENUREPOSITORYLOCATION/static_zips/${WEBSRVNAME}_$ABSM_WEB_VERSION.zip $ABSM_SERVERNAME:$ABSM_LOCAL_HOME
				else
					ssh -q -n $ABSMENUREPOSITORYSERVER "rsync -tav --delete -e \"ssh -q\" $ABSMENUREPOSITORYLOCATION/static_zips/${WEBSRVNAME}_$ABSM_WEB_VERSION.zip $ABSM_SERVERNAME:$ABSM_LOCAL_HOME";
				fi
				# if upgrading tomcat10 to a different version, first stop tomcat10 and remove completely
				if [ $ABSM_REFRESH_TOMCAT10_REMOTE_INSTALL == "upgrade" ]
				then
					# stop tomcat10
					ssh -q -n $ABSM_SERVERNAME "$ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t tomcat10 -c stop"
					# delete tomcat10 directory recursively
					ssh -q -n $ABSM_SERVERNAME "rm -Rf $ABSM_LOCAL_HOME/$TOMCAT10FOLDERNAME"
				fi
				# unzip tomcat10
				ssh -q -n $ABSM_SERVERNAME "cd $ABSM_LOCAL_HOME; unzip -o ${WEBSRVNAME}_$ABSM_WEB_VERSION.zip"
				# delete tomcat10 bundle
				ssh -q -n $ABSM_SERVERNAME "cd $ABSM_LOCAL_HOME; rm -f ${WEBSRVNAME}_$ABSM_WEB_VERSION.zip"
				WEBSRVNAME=tomcat10
				[ "$INSTALLED_TOMCAT10_REMOTE_VERSION" == "$ABSM_WEB_VERSION" ] && cleanup_tomcat10 $1
			fi
			ssh -q -n $ABSM_SERVERNAME "$ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t $ABSM_TYPE -M $ABSM_HEAPSPACE -c maxheap_tomcat10"
			ssh -q -n $ABSM_SERVERNAME "$ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t tomcat10 -c restart"
		fi
	fi
	
	# 2) copy custom jar and server LIBs if needed
	if [ "$ABSM_TYPE" == wpo ]
    then
        if [ "$ABS_ROOTSERVER" == "$ABSMENUREPOSITORYSERVER" ] 
        then
            [ -e $ABSMENUREPOSITORYLOCATION/static_zips/$ABSM_WEBLIB ] && rsync -tav --delete -e "ssh -q" $ABSMENUREPOSITORYLOCATION/static_zips/$ABSM_WEBLIB $ABSM_SERVERNAME:$ABSM_LOCAL_HOME/$GLASSFISHPATH/glassfish/domains/$ABSM_GFDOMAIN/lib/applibs
        else
            ssh -q -n $ABSMENUREPOSITORYSERVER "[ -e $ABSMENUREPOSITORYLOCATION/static_zips/$ABSM_WEBLIB ] && rsync -tav --delete -e \"ssh -q\" $ABSMENUREPOSITORYLOCATION/static_zips/$ABSM_WEBLIB $ABSM_SERVERNAME:$ABSM_LOCAL_HOME/$GLASSFISHPATH/glassfish/domains/$ABSM_GFDOMAIN/lib/applibs"
        fi
    fi
	if [ -f $ABSMENUREPOSITORYLOCATION/static_zips/$ABSM_WEBLIB ] && [ "$ABSM_TYPE" == "wp2" ]
    then
        if [ "$ABS_ROOTSERVER" == "$ABSM_SERVERNAME" ] 
        then
			[ ! -d $ABSM_LOCAL_HOME/deploy ] && mkdir -p $ABSM_LOCAL_HOME/deploy
            [ -e $ABSMENUREPOSITORYLOCATION/static_zips/$ABSM_WEBLIB ] && rsync -tav --delete -e "ssh -q" $ABSMENUREPOSITORYLOCATION/static_zips/$ABSM_WEBLIB $ABSM_SERVERNAME:$ABSM_LOCAL_HOME/deploy
        else
			ssh -q -n $ABSM_SERVERNAME "[ ! -d $ABSM_LOCAL_HOME/deploy ] && mkdir -p $ABSM_LOCAL_HOME/deploy"
            ssh -q -n $ABSMENUREPOSITORYSERVER "[ -e $ABSMENUREPOSITORYLOCATION/static_zips/$ABSM_WEBLIB ] && rsync -tav --delete -e \"ssh -q\" $ABSMENUREPOSITORYLOCATION/static_zips/$ABSM_WEBLIB $ABSM_SERVERNAME:$ABSM_LOCAL_HOME/deploy"
        fi
    fi
    if [ "$ABS_ROOTSERVER" == "$ABSM_SERVERNAME" ] 
    then
        [ ! -d $ABSM_LOCAL_HOME/Server/Lib ] && mkdir -p $ABSM_LOCAL_HOME/Server/Lib
    else
        ssh -q -n $ABSM_SERVERNAME "[ ! -d $ABSM_LOCAL_HOME/Server/Lib ] && mkdir -p $ABSM_LOCAL_HOME/Server/Lib"
    fi
    if [ "$ABS_ROOTSERVER" == "$ABSMENUREPOSITORYSERVER" ] 
    then
        rsync -tav --delete -e "ssh -q" $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Future/Server/Lib $ABSM_SERVERNAME:$ABSM_LOCAL_HOME/Server
    else
        ssh -q -n $ABSMENUREPOSITORYSERVER "rsync -tav --delete -e \"ssh -q\" $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Future/Server/Lib $ABSM_SERVERNAME:$ABSM_LOCAL_HOME/Server"
    fi

    # 3) sync files to the web server deploy folder
    export ABSMESSAGE="    1) Syncing files from $ABSMENUREPOSITORYSERVER:$ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Future/Web/$ABSM_TYPE to $ABSM_SERVERNAME:$ABSM_LOCAL_HOME/deploy"
    absmenu_log
    echo "Syncing files from $ABSMENUREPOSITORYSERVER:$ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Future/Web/$ABSM_TYPE to $ABSM_SERVERNAME:$ABSM_LOCAL_HOME/deploy"
    if [ "$ABS_ROOTSERVER" == "$ABSM_SERVERNAME" ] 
    then
        [ ! -d $ABSM_LOCAL_HOME/deploy ] && mkdir -p $ABSM_LOCAL_HOME/deploy
    else
        ssh -q -n $ABSM_SERVERNAME "[ ! -d $ABSM_LOCAL_HOME/deploy ] && mkdir -p $ABSM_LOCAL_HOME/deploy"
    fi

	# 3.1 create war in repository location, send it to the deploy folder and clean up
    if [ "$ABS_ROOTSERVER" == "$ABSMENUREPOSITORYSERVER" ] 
    then
        [ ! -d $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Future/Web/$ABSM_TYPE ] && mkdir -p $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Future/Web/$ABSM_TYPE
        [ -e $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Future/Web/$ABSM_TYPE.war ] && rm -f $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Future/Web/$ABSM_TYPE.war
        pushd $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Future/Web/$ABSM_TYPE
        zip -r ../$ABSM_TYPE.war *
        if [ -e ../$ABSM_TYPE.war ]
        then
            rsync -tav --delete -e "ssh -q" ../$ABSM_TYPE.war $ABSM_SERVERNAME:$ABSM_LOCAL_HOME/deploy
            rm -f ../$ABSM_TYPE.war
        fi
        popd
    else
        echo -n .
        ssh -q -n $ABSMENUREPOSITORYSERVER "[ ! -d $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Future/Web/$ABSM_TYPE ] && mkdir -p $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Future/Web/$ABSM_TYPE"
        echo -n .
        ssh -q -n $ABSMENUREPOSITORYSERVER "[ -e $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Future/Web/$ABSM_TYPE.war ] && rm -f $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Future/Web/$ABSM_TYPE.war"
        echo -n .
        ssh -q -n $ABSMENUREPOSITORYSERVER "cd $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Future/Web/$ABSM_TYPE; zip -r ../$ABSM_TYPE.war *;"
        echo -n .
        ssh -q -n $ABSMENUREPOSITORYSERVER "[ -e $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Future/Web/$ABSM_TYPE.war ] && rsync -tav --delete -e \"ssh -q\" $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Future/Web/$ABSM_TYPE.war $ABSM_SERVERNAME:$ABSM_LOCAL_HOME/deploy"
        echo -n .
        ssh -q -n $ABSMENUREPOSITORYSERVER "[ -e $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Future/Web/$ABSM_TYPE.war ] && rm -f $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Future/Web/$ABSM_TYPE.war"
        echo .
	fi
    
	# 3.2 (re)create deploy dirs (wpo/gws/ws2/w4m/wp2/wsr/wum/wcl/wua/wrd/wrr/wsb/wmr/wfb/wcp) and unzip war in the new dir. 
    if [ "$ABS_ROOTSERVER" == "$ABSM_SERVERNAME" ] 
    then
        pushd $ABSM_LOCAL_HOME/deploy
        [ -d $ABSM_TYPE ] && rm -Rf $ABSM_TYPE
        mkdir $ABSM_TYPE
        cd $ABSM_TYPE
        unzip -o ../$ABSM_TYPE.war
        rm -f ../$ABSM_TYPE.war
        [ "$ABSM_TYPE" == "wpo" -o "$ABSM_TYPE" == "wp2" ] && rm -f $ABSM_LOCAL_HOME/deploy/$ABSM_TYPE/WEB-INF/lib/xml-apis*.jar $ABSM_LOCAL_HOME/deploy/$ABSM_TYPE/WEB-INF/lib/xercesImpl*.jar 2> /dev/null
        popd
		
		# process custom wp2 files
		if [ -f $ABSMENUREPOSITORYLOCATION/static_zips/$ABSM_WEBLIB ] && [ "$ABSM_TYPE" == "wp2" ] 
		then
			unzip -o $ABSM_LOCAL_HOME/deploy/$ABSM_WEBLIB -d $ABSM_LOCAL_HOME/deploy/wp2/resources/abs/1_0/
			rm -f $ABSM_LOCAL_HOME/deploy/$ABSM_WEBLIB
			ABSM_WEBLIB="X"
		fi
		
		# copy patchserver.jar, resource files and log4j and snmp sample config from appserver
        if [ "$ABSAPPSERVER" ] 
        then
            [ ! -d $ABSM_LOCAL_HOME/deploy/$ABSM_TYPE/WEB-INF/lib/abs ] && mkdir -p $ABSM_LOCAL_HOME/deploy/$ABSM_TYPE/WEB-INF/lib/abs
            if [ "$ABS_ROOTSERVER" == "$ABSMENUREPOSITORYSERVER" ] 
            then
                rsync -tav --delete -e "ssh -q" $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Future/Server/Lib/patchserver*.jar $ABSM_SERVERNAME:$ABSM_LOCAL_HOME/deploy/$ABSM_TYPE/WEB-INF/lib/abs
                [ "$ABSM_TYPE" == "wpo" -o "$ABSM_TYPE" == "wp2" ] && rsync -tav --delete -e "ssh -q" $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Future/Server/Lib/resource*.jar $ABSM_SERVERNAME:$ABSM_LOCAL_HOME/deploy/$ABSM_TYPE/WEB-INF/lib/abs
                rsync -tav --delete -e "ssh -q" $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Future/Server/Config/sample_AbsSnmpAgentSettings.properties $ABSM_SERVERNAME:$ABSM_LOCAL_HOME/deploy/$ABSM_TYPE/WEB-INF
                rsync -tav --delete -e "ssh -q" $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Future/Server/Config/sample_log4j.properties $ABSM_SERVERNAME:$ABSM_LOCAL_HOME/deploy/$ABSM_TYPE/WEB-INF
            else
                echo -n .
                ssh -q -n $ABSMENUREPOSITORYSERVER "rsync -tav --delete -e \"ssh -q\" $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Future/Server/Lib/patchserver*.jar $ABSM_SERVERNAME:$ABSM_LOCAL_HOME/deploy/$ABSM_TYPE/WEB-INF/lib/abs"
                echo -n .
                [ "$ABSM_TYPE" == "wpo" -o "$ABSM_TYPE" == "wp2" ] && ssh -q -n $ABSMENUREPOSITORYSERVER "rsync -tav --delete -e \"ssh -q\" $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Future/Server/Lib/resource*.jar $ABSM_SERVERNAME:$ABSM_LOCAL_HOME/deploy/$ABSM_TYPE/WEB-INF/lib/abs"
                echo -n .
                ssh -q -n $ABSMENUREPOSITORYSERVER "rsync -tav --delete -e \"ssh -q\" $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Future/Server/Config/sample_AbsSnmpAgentSettings.properties $ABSM_SERVERNAME:$ABSM_LOCAL_HOME/deploy/$ABSM_TYPE/WEB-INF"
                echo -n .
                ssh -q -n $ABSMENUREPOSITORYSERVER "rsync -tav --delete -e \"ssh -q\" $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Future/Server/Config/sample_log4j.properties $ABSM_SERVERNAME:$ABSM_LOCAL_HOME/deploy/$ABSM_TYPE/WEB-INF"
                echo .
            fi
        fi
    else
        echo -n .
        ssh -q -n $ABSM_SERVERNAME "cd $ABSM_LOCAL_HOME/deploy; [ -d $ABSM_TYPE ] && rm -Rf $ABSM_TYPE"
        echo -n .
        ssh -q -n $ABSM_SERVERNAME "cd $ABSM_LOCAL_HOME/deploy; mkdir $ABSM_TYPE; cd $ABSM_TYPE; unzip -o ../$ABSM_TYPE.war; rm -f ../$ABSM_TYPE.war"
        echo .
        [ "$ABSM_TYPE" == "wpo" -o "$ABSM_TYPE" == "wp2" ] && ssh -q -n $ABSM_SERVERNAME "rm -f $ABSM_LOCAL_HOME/deploy/$ABSM_TYPE/WEB-INF/lib/xml-apis*.jar $ABSM_LOCAL_HOME/deploy/$ABSM_TYPE/WEB-INF/lib/xercesImpl*.jar 2> /dev/null"

		# process custom wp2 files
		if [ -f $ABSMENUREPOSITORYLOCATION/static_zips/$ABSM_WEBLIB ] && [ "$ABSM_TYPE" == "wp2" ] 
		then
			ssh -q -n $ABSM_SERVERNAME "unzip -o $ABSM_LOCAL_HOME/deploy/$ABSM_WEBLIB -d $ABSM_LOCAL_HOME/deploy/wp2/resources/abs/1_0/"
			ssh -q -n $ABSM_SERVERNAME "rm -f $ABSM_LOCAL_HOME/deploy/$ABSM_WEBLIB"
			ABSM_WEBLIB="X"
		fi		
		
        if [ "$ABSAPPSERVER" ] # copy patchserver.jar, resourcefiles and log4j and snmp sample config from appserver
        then
            echo -n .
            ssh -q -n $ABSM_SERVERNAME "[ ! -d $ABSM_LOCAL_HOME/deploy/$ABSM_TYPE/WEB-INF/lib/abs ] && mkdir -p $ABSM_LOCAL_HOME/deploy/$ABSM_TYPE/WEB-INF/lib/abs"
            echo -n .
            ssh -q -n $ABSMENUREPOSITORYSERVER "rsync -tav --delete -e \"ssh -q\" $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Future/Server/Lib/patchserver*.jar $ABSM_SERVERNAME:$ABSM_LOCAL_HOME/deploy/$ABSM_TYPE/WEB-INF/lib/abs"
            echo -n .
            [ "$ABSM_TYPE" == "wpo" -o "$ABSM_TYPE" == "wp2" ] && ssh -q -n $ABSMENUREPOSITORYSERVER "rsync -tav --delete -e \"ssh -q\" $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Future/Server/Lib/resource*.jar $ABSM_SERVERNAME:$ABSM_LOCAL_HOME/deploy/$ABSM_TYPE/WEB-INF/lib/abs"
            echo -n .
            ssh -q -n $ABSMENUREPOSITORYSERVER "rsync -tav --delete -e \"ssh -q\" $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Future/Server/Config/sample_AbsSnmpAgentSettings.properties $ABSM_SERVERNAME:$ABSM_LOCAL_HOME/deploy/$ABSM_TYPE/WEB-INF"
            echo -n .
            ssh -q -n $ABSMENUREPOSITORYSERVER "rsync -tav --delete -e \"ssh -q\" $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Future/Server/Config/sample_log4j.properties $ABSM_SERVERNAME:$ABSM_LOCAL_HOME/deploy/$ABSM_TYPE/WEB-INF"
            echo .
        fi
    fi
    
    # 4) generate properties
    export ABSMESSAGE="    2) Generating properties in $ABSM_SERVERNAME:$ABSM_LOCAL_HOME/deploy/$ABSM_TYPE"
    absmenu_log
    echo "Generating properties in $ABSM_SERVERNAME:$ABSM_LOCAL_HOME/deploy/$ABSM_TYPE"
    . $ABSMENUPATH/bin/generate_properties.sh web normal "$ABSMENU_CURRENT_ENVIRONMENT" "$ABSM_TYPE" "$ABSM_SERVERNAME" "$ABSM_SLOT" "$ABSM_LOCAL_HOME" "$ABSM_USER" "$ABSM_PWD" "$ABSM_STATIONNR" "$ABSM_CONNAPPSRV" "$ABSM_CONNAPPSLOT" "$ABSM_CONNREPSRV" "$ABSM_CONNREPSLOT" "$WEBNAME" "$ABSM_ORATNS" "$ABSM_ORAHOME" "$ABSM_USER" "$ABSM_PWD" "$ABSM_USENATIVE" "$ABSM_INET_KEY" "$ABSM_GFDOMAIN" "$ABSM_USER2" "$ABSM_PWD2" "$ABSM_STATIONNR2" "$ABSM_DBSERVERNAME" "$ABSM_DBDRIVERTYPE" "$ABSM_DBPORTNUMBER"
    
    # 5) create new war-file
    export ABSMESSAGE="    3) Generating war-file $ABSM_SERVERNAME:$ABSM_LOCAL_HOME/deploy/$ABSM_TYPE/$WEBNAME.war"
    absmenu_log
    echo "Generating war-file $ABSM_SERVERNAME:$ABSM_LOCAL_HOME/deploy/$ABSM_TYPE/$WEBNAME.war"
    if [ "$ABS_ROOTSERVER" == "$ABSM_SERVERNAME" ] 
    then
        [ -e $ABSM_LOCAL_HOME/deploy/$ABSM_TYPE/$WEBNAME.war ] && rm -f $ABSM_LOCAL_HOME/deploy/$ABSM_TYPE/$WEBNAME.war
        pushd $ABSM_LOCAL_HOME/deploy/$ABSM_TYPE
        zip -r -q $WEBNAME.war *
        popd
    else
        echo -n .
        ssh -q -n $ABSM_SERVERNAME "[ -e $ABSM_LOCAL_HOME/deploy/$ABSM_TYPE/$WEBNAME.war ] && rm -f $ABSM_LOCAL_HOME/deploy/$ABSM_TYPE/$WEBNAME.war"
        echo -n .
        ssh -q -n $ABSM_SERVERNAME "cd $ABSM_LOCAL_HOME/deploy/$ABSM_TYPE; zip -r -q $WEBNAME.war *"
        echo .
    fi

    # 6) make sure the web server is running
	    if [ "$ABS_ROOTSERVER" == "$ABSM_SERVERNAME" ] 
		then
			[ "$WEBSRVNAME" == "glass" ] && [ -e $ABSM_LOCAL_HOME/$GLASSFISHPATH/bin/asadmin ] && $ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t glass -c start -b $ABSM_GFDOMAIN -y 20
			[ "$WEBSRVNAME" == "web" ] && [ -e $ABSM_LOCAL_HOME/$TOMEE8FOLDERNAME/bin/tomee ] && $ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t web -c start -y 20
			[ "$WEBSRVNAME" == "tomee" ] && [ -e $ABSM_LOCAL_HOME/$TOMEEFOLDERNAME/bin/tomee.sh ] && $ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t tomee -c start -y 20
			[ "$WEBSRVNAME" == "tomcat" ] && [ -e $ABSM_LOCAL_HOME/$TOMCATFOLDERNAME/bin/tomcat9.exe ] && $ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t tomcat -c start -y 20
			[ "$WEBSRVNAME" == "tomcat9" ] && [ -e $ABSM_LOCAL_HOME/$TOMCAT9FOLDERNAME/bin/startup.sh ] && $ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t tomcat9 -c start -y 20
			[ "$WEBSRVNAME" == "tomcat10" ] && [ -e $ABSM_LOCAL_HOME/$TOMCAT10FOLDERNAME/bin/startup.sh ] && $ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t tomcat10 -c start -y 20
		else
			[ "$WEBSRVNAME" == "glass" ] && [ `ssh -q -n $ABSM_SERVERNAME "[ -e $ABSM_LOCAL_HOME/$GLASSFISHPATH/bin/asadmin ] && echo 1"` ] && ssh -q -n $ABSM_SERVERNAME "$ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t glass -c start -b $ABSM_GFDOMAIN -y 20"
			[ "$WEBSRVNAME" == "web" ] && [ `ssh -q -n $ABSM_SERVERNAME "[ -e $ABSM_LOCAL_HOME/$TOMEE8FOLDERNAME/bin/tomee ] && echo 1"` ] && ssh -q -n $ABSM_SERVERNAME "$ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t web -c start -y 20"
			[ "$WEBSRVNAME" == "tomee" ] && [ `ssh -q -n $ABSM_SERVERNAME "[ -e $ABSM_LOCAL_HOME/$TOMEEFOLDERNAME/bin/tomee.sh ] && echo 1"` ] && ssh -q -n $ABSM_SERVERNAME "$ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t tomee -c start -y 20"
			[ "$WEBSRVNAME" == "tomcat" ] && [ `ssh -q -n $ABSM_SERVERNAME "[ -e $ABSM_LOCAL_HOME/$TOMCATFOLDERNAME/bin/tomcat9.exe ] && echo 1"` ] && ssh -q -n $ABSM_SERVERNAME "$ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t tomcat -c start -y 20"
			[ "$WEBSRVNAME" == "tomcat9" ] && [ `ssh -q -n $ABSM_SERVERNAME "[ -e $ABSM_LOCAL_HOME/$TOMCAT9FOLDERNAME/bin/startup.sh ] && echo 1"` ] && ssh -q -n $ABSM_SERVERNAME "$ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t tomcat9 -c start -y 20"
			[ "$WEBSRVNAME" == "tomcat10" ] && [ `ssh -q -n $ABSM_SERVERNAME "[ -e $ABSM_LOCAL_HOME/$TOMCAT10FOLDERNAME/bin/startup.sh ] && echo 1"` ] && ssh -q -n $ABSM_SERVERNAME "$ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t tomcat10 -c start -y 20"
		fi

    # 7) deploy new version
    export ABSMESSAGE="    4) Deploy $ABSM_SERVERNAME:$ABSM_LOCAL_HOME/deploy/$ABSM_TYPE/$WEBNAME.war"
    absmenu_log
    echo "Deploy $ABSM_SERVERNAME:$ABSM_LOCAL_HOME/deploy/$ABSM_TYPE/$WEBNAME.war"
    
	if [ "$ABS_ROOTSERVER" == "$ABSM_SERVERNAME" ] 
    then
		[ -e $ABSM_LOCAL_HOME/$GLASSFISHPATH/bin/asadmin ] && $ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t glass -c deploy -b $ABSM_GFDOMAIN -w $ABSM_TYPE:$WEBNAME:$ABSM_WEBCONTEXT:$ABSM_WEBLIB
		[ -e $ABSM_LOCAL_HOME/$TOMEE8FOLDERNAME/bin/tomee ] && $ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t web -c deploy_web -w $ABSM_TYPE
		[ -e $ABSM_LOCAL_HOME/$TOMEEFOLDERNAME/bin/tomee.sh ] && $ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t tomee -c deploy_tomee -w $ABSM_TYPE
		[ -e $ABSM_LOCAL_HOME/$TOMCATFOLDERNAME/bin/tomcat9.exe ] && $ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t tomcat -c deploy_tomcat -w $ABSM_TYPE
		[ -e $ABSM_LOCAL_HOME/$TOMCAT9FOLDERNAME/bin/startup.sh ] && [ $ABSM_LOCAL_HOME/$TOMCAT10FOLDERNAME/bin/startup.sh ] && case $ABSM_TYPE in gws|w4m|wsr|wmr) $ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t tomcat9 -c deploy_tomcat9 -w $ABSM_TYPE;; wp2|wum|wcl|wua|wrd|wrr|wsb|wfb|wcp) $ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t tomcat10 -c deploy_tomcat10 -w $ABSM_TYPE;; esac
		[ -e $ABSM_LOCAL_HOME/$TOMCAT10FOLDERNAME/bin/startup.sh ] && [ $ABSM_LOCAL_HOME/$TOMCAT9FOLDERNAME/bin/startup.sh ] && case $ABSM_TYPE in gws|w4m|wsr|wmr) $ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t tomcat9 -c deploy_tomcat9 -w $ABSM_TYPE;; wp2|wum|wcl|wua|wrd|wrr|wsb|wfb|wcp) $ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t tomcat10 -c deploy_tomcat10 -w $ABSM_TYPE;; esac
		[ -e $ABSM_LOCAL_HOME/$TOMCAT9FOLDERNAME/bin/startup.sh ] && [ ! -e $ABSM_LOCAL_HOME/$TOMCAT10FOLDERNAME/bin/startup.sh ] && $ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t tomcat9 -c deploy_tomcat9 -w $ABSM_TYPE
		[ -e $ABSM_LOCAL_HOME/$TOMCAT10FOLDERNAME/bin/startup.sh ] && [ ! -e $ABSM_LOCAL_HOME/$TOMCAT9FOLDERNAME/bin/startup.sh ] && $ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t tomcat10 -c deploy_tomcat10 -w $ABSM_TYPE
	else
		ssh -q -n $ABSM_SERVERNAME "[ -e $ABSM_LOCAL_HOME/$GLASSFISHPATH/bin/asadmin ] && $ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t glass -c deploy -b $ABSM_GFDOMAIN -w $ABSM_TYPE:$WEBNAME:$ABSM_WEBCONTEXT:$ABSM_WEBLIB"
		ssh -q -n $ABSM_SERVERNAME "[ -e $ABSM_LOCAL_HOME/$TOMEE8FOLDERNAME/bin/tomee ] && $ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t web -c deploy_web -w $ABSM_TYPE"
		ssh -q -n $ABSM_SERVERNAME "[ -e $ABSM_LOCAL_HOME/$TOMEEFOLDERNAME/bin/tomee.sh ] && $ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t tomee -c deploy_tomee -w $ABSM_TYPE"
		ssh -q -n $ABSM_SERVERNAME "[ -e $ABSM_LOCAL_HOME/$TOMCATFOLDERNAME/bin/tomcat9.exe ] && $ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t tomcat -c deploy_tomcat -w $ABSM_TYPE"
		ssh -q -n $ABSM_SERVERNAME "[ -e $ABSM_LOCAL_HOME/$TOMCAT9FOLDERNAME/bin/startup.sh ] && [ $ABSM_LOCAL_HOME/$TOMCAT10FOLDERNAME/bin/startup.sh ] && case $ABSM_TYPE in gws|w4m|wsr|wmr) $ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t tomcat9 -c deploy_tomcat9 -w $ABSM_TYPE;; wp2|wum|wcl|wua|wrd|wrr|wsb|wfb|wcp) $ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t tomcat10 -c deploy_tomcat10 -w $ABSM_TYPE;; esac"
		ssh -q -n $ABSM_SERVERNAME "[ -e $ABSM_LOCAL_HOME/$TOMCAT10FOLDERNAME/bin/startup.sh ] && [ $ABSM_LOCAL_HOME/$TOMCAT9FOLDERNAME/bin/startup.sh ] && case $ABSM_TYPE in gws|w4m|wsr|wmr) $ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t tomcat9 -c deploy_tomcat9 -w $ABSM_TYPE;; wp2|wum|wcl|wua|wrd|wrr|wsb|wfb|wcp) $ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t tomcat10 -c deploy_tomcat10 -w $ABSM_TYPE;; esac"
		ssh -q -n $ABSM_SERVERNAME "[ -e $ABSM_LOCAL_HOME/$TOMCAT9FOLDERNAME/bin/startup.sh ] && [ ! -e $ABSM_LOCAL_HOME/$TOMCAT10FOLDERNAME/bin/startup.sh ] && $ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t tomcat9 -c deploy_tomcat9 -w $ABSM_TYPE"
		ssh -q -n $ABSM_SERVERNAME "[ -e $ABSM_LOCAL_HOME/$TOMCAT10FOLDERNAME/bin/startup.sh ] && [ ! -e $ABSM_LOCAL_HOME/$TOMCAT9FOLDERNAME/bin/startup.sh ] && $ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t tomcat10 -c deploy_tomcat10 -w $ABSM_TYPE"
	fi
}

# recreate domains for webservers so you always start clean
# Glassfish411/Payara5
cleanup_glassfish()
{
	# $1 = environment
	TMPDIR=$ABS_ROOTDIR/tmp
	TMPFILE=$TMPDIR/weblist.abs

	export ABSMESSAGE="     Recreate domains for webservers (cleanup)"
    absmenu_log
    echo 'Recreate domains for webservers if present (cleanup)'
	
	# empty list
	[ ! -d $TMPDIR ] && mkdir $TMPDIR
	[ -e $TMPFILE ] && rm -f $TMPFILE
	touch $TMPFILE
	
	# make a list of all web server/slot combinations in the chosen environment
    grep '^ *'$1"[[:blank:]]" $ABSMENUGLOBALCONFIG | sort -k2,2 -k5,5 -k4,4 | while read ABSM_ENVIRONMENT ABSM_SERVERNAME ABSM_SERVICE ABSM_TYPE ABSM_SLOT ABSM_LOCAL_HOME ABSM_REMOTE_HOME ABSM_USER ABSM_PWD ABSM_ORATNS ABSM_ORAHOME ABSM_DBSERVERNAME ABSM_DBDRIVERTYPE ABSM_DBPORTNUMBER ABSM_HEAPSPACE ABSM_STATIONNR ABSM_GFUSER ABSM_GFPASWRD ABSM_GFDOMAIN ABSM_WEBCONTEXT ABSM_WEBNAME ABSM_WEBLIB ABSM_CONNAPPSRV ABSM_CONNAPPSLOT ABSM_CONNREPSRV ABSM_CONNREPSLOT ABSM_USENATIVE ABSM_EXCLUDECUSTREP ABSM_WEB_VERSION ABSM_CLIENTDISTR_SRV ABSM_CLIENTDISTR_DIR ABSM_USER2 ABSM_PWD2 ABSM_STATIONNR2 ABSM_INET_KEY
    do
        case "$ABSM_TYPE" in 
            wpo|gws|ws2|w4m|wp2|wsr|wum|wcl|wua|wrd|wrr|wsb|wmr|wfb|wcp)   echo $ABSM_SERVERNAME $ABSM_SLOT $ABSM_GFDOMAIN >> $TMPFILE;;
        esac
	done

	# go through the list and re-create glassfish domains
	sort $TMPFILE | uniq | while read ABSM_SERVERNAME ABSM_SLOT ABSM_GFDOMAIN
    do
        if [ "$ABS_ROOTSERVER" == "$ABSM_SERVERNAME" ] 
        then
            $ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t glass -c deletedomain -b $ABSM_GFDOMAIN
            sleep 10
            $ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t glass -c createdomain -b $ABSM_GFDOMAIN
        else
            echo -n .
            ssh -q -n $ABSM_SERVERNAME "$ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t glass -c deletedomain -b $ABSM_GFDOMAIN"
            echo -n .
            ssh -q -n $ABSM_SERVERNAME "sleep 10; $ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t glass -c createdomain -b $ABSM_GFDOMAIN"
            echo .
        fi
	done
	rm -f $TMPFILE
}

# Cleanup for Tomee8 webservers so you always start clean
cleanup_web()
{
	# $1 = environment
	TMPDIR=$ABS_ROOTDIR/tmp
	TMPFILE=$TMPDIR/weblist.abs

	export ABSMESSAGE="     Tomee8 cleanup"
    absmenu_log
    echo 'Tomee8 cleanup'
	
	# empty list
	[ ! -d $TMPDIR ] && mkdir $TMPDIR
	[ -e $TMPFILE ] && rm -f $TMPFILE
	touch $TMPFILE
	
	# make a list of all web server/slot combinations in the chosen environment
    grep '^ *'$1"[[:blank:]]" $ABSMENUGLOBALCONFIG | sort -k2,2 -k5,5 -k4,4 | while read ABSM_ENVIRONMENT ABSM_SERVERNAME ABSM_SERVICE ABSM_TYPE ABSM_SLOT ABSM_LOCAL_HOME ABSM_REMOTE_HOME ABSM_USER ABSM_PWD ABSM_ORATNS ABSM_ORAHOME ABSM_DBSERVERNAME ABSM_DBDRIVERTYPE ABSM_DBPORTNUMBER ABSM_HEAPSPACE ABSM_STATIONNR ABSM_GFUSER ABSM_GFPASWRD ABSM_GFDOMAIN ABSM_WEBCONTEXT ABSM_WEBNAME ABSM_WEBLIB ABSM_CONNAPPSRV ABSM_CONNAPPSLOT ABSM_CONNREPSRV ABSM_CONNREPSLOT ABSM_USENATIVE ABSM_EXCLUDECUSTREP ABSM_WEB_VERSION ABSM_CLIENTDISTR_SRV ABSM_CLIENTDISTR_DIR ABSM_USER2 ABSM_PWD2 ABSM_STATIONNR2 ABSM_INET_KEY
    do
        case "$ABSM_TYPE" in 
            wp2|wum|wcl|wua|wrd|wrr|wsb|wfb|wcp|gws|w4m|wsr|wmr)   echo $ABSM_SERVERNAME $ABSM_SLOT >> $TMPFILE;;
        esac
	done

	# go through the list and delete tomee8 webapps
	sort $TMPFILE | uniq | while read ABSM_SERVERNAME ABSM_SLOT 
    do
        if [ "$ABS_ROOTSERVER" == "$ABSM_SERVERNAME" ] 
        then
			$ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t web -c stop
			[ -d $ABS_ROOTDIR/$ABSM_SLOT/$TOMEE8FOLDERNAME/webapps ] && find $ABS_ROOTDIR/$ABSM_SLOT/$TOMEE8FOLDERNAME/webapps -mindepth 1 -maxdepth 1 ! -name 'host-manager' ! -name 'ROOT' ! -name 'docs' ! -name 'manager' | xargs rm -rf 2> /dev/null
			[[ ! -z `ls $ABS_ROOTDIR/$ABSM_SLOT/$TOMEE8FOLDERNAME/logs/* 2> /dev/null` ]] && rm -rf $ABS_ROOTDIR/$ABSM_SLOT/$TOMEE8FOLDERNAME/logs/* 2> /dev/null
			sleep 10
			$ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t web -c start
		else
			echo -n .
			ssh -q -n $ABSM_SERVERNAME "$ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t web -c stop"
			echo -n .
			ssh -q -n $ABSM_SERVERNAME "find $ABS_ROOTDIR/$ABSM_SLOT/$TOMEE8FOLDERNAME/webapps -mindepth 1 -maxdepth 1 ! -name 'host-manager' ! -name 'ROOT' ! -name 'docs' ! -name 'manager' | xargs rm -rf 2> /dev/null"
			echo -n .
			ssh -q -n $ABSM_SERVERNAME "rm -rf $ABS_ROOTDIR/$ABSM_SLOT/$TOMEE8FOLDERNAME/logs/*"
			echo -n .
			ssh -q -n $ABSM_SERVERNAME "sleep 10; $ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t web -c start"
			echo .
		fi
	done
	rm -f $TMPFILE
}

# Cleanup for Tomee91 webservers so you always start clean
cleanup_tomee()
{
	# $1 = environment
	TMPDIR=$ABS_ROOTDIR/tmp
	TMPFILE=$TMPDIR/weblist.abs

	export ABSMESSAGE="     Tomee91 cleanup"
    absmenu_log
    echo 'Tomee91 cleanup'
	
	# empty list
	[ ! -d $TMPDIR ] && mkdir $TMPDIR
	[ -e $TMPFILE ] && rm -f $TMPFILE
	touch $TMPFILE
	
	# make a list of all web server/slot combinations in the chosen environment
    grep '^ *'$1"[[:blank:]]" $ABSMENUGLOBALCONFIG | sort -k2,2 -k5,5 -k4,4 | while read ABSM_ENVIRONMENT ABSM_SERVERNAME ABSM_SERVICE ABSM_TYPE ABSM_SLOT ABSM_LOCAL_HOME ABSM_REMOTE_HOME ABSM_USER ABSM_PWD ABSM_ORATNS ABSM_ORAHOME ABSM_DBSERVERNAME ABSM_DBDRIVERTYPE ABSM_DBPORTNUMBER ABSM_HEAPSPACE ABSM_STATIONNR ABSM_GFUSER ABSM_GFPASWRD ABSM_GFDOMAIN ABSM_WEBCONTEXT ABSM_WEBNAME ABSM_WEBLIB ABSM_CONNAPPSRV ABSM_CONNAPPSLOT ABSM_CONNREPSRV ABSM_CONNREPSLOT ABSM_USENATIVE ABSM_EXCLUDECUSTREP ABSM_WEB_VERSION ABSM_CLIENTDISTR_SRV ABSM_CLIENTDISTR_DIR ABSM_USER2 ABSM_PWD2 ABSM_STATIONNR2 ABSM_INET_KEY
    do
        case "$ABSM_TYPE" in 
            wp2|wum|wcl|wua|wrd|wrr|wsb|wfb|wcp)   echo $ABSM_SERVERNAME $ABSM_SLOT >> $TMPFILE;;
        esac
	done

	# go through the list and delete Tomee91 webapps
	sort $TMPFILE | uniq | while read ABSM_SERVERNAME ABSM_SLOT 
    do
        if [ "$ABS_ROOTSERVER" == "$ABSM_SERVERNAME" ] 
        then
			$ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t tomee -c stop
			[ -d $ABS_ROOTDIR/$ABSM_SLOT/$TOMEEFOLDERNAME/webapps ] && find $ABS_ROOTDIR/$ABSM_SLOT/$TOMEEFOLDERNAME/webapps -mindepth 1 -maxdepth 1 ! -name 'host-manager' ! -name 'ROOT' ! -name 'docs' ! -name 'manager' | xargs rm -rf 2> /dev/null
			[[ ! -z `ls $ABS_ROOTDIR/$ABSM_SLOT/$TOMEEFOLDERNAME/logs/* 2> /dev/null` ]] && rm -rf $ABS_ROOTDIR/$ABSM_SLOT/$TOMEEFOLDERNAME/logs/* 2> /dev/null
			sleep 10
			$ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t tomee -c start
		else
			echo -n .
			ssh -q -n $ABSM_SERVERNAME "$ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t tomee -c stop"
			echo -n .
			ssh -q -n $ABSM_SERVERNAME "find $ABS_ROOTDIR/$ABSM_SLOT/$TOMEEFOLDERNAME/webapps -mindepth 1 -maxdepth 1 ! -name 'host-manager' ! -name 'ROOT' ! -name 'docs' ! -name 'manager' | xargs rm -rf 2> /dev/null"
			echo -n .
			ssh -q -n $ABSM_SERVERNAME "rm -rf $ABS_ROOTDIR/$ABSM_SLOT/$TOMEEFOLDERNAME/logs/*"
			echo -n .
			ssh -q -n $ABSM_SERVERNAME "sleep 10; $ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t tomee -c start"
			echo .
		fi
	done
	rm -f $TMPFILE
}

# Cleanup for Tomcat90 webservers so you always start clean
cleanup_tomcat()
{
	# $1 = environment
	TMPDIR=$ABS_ROOTDIR/tmp
	TMPFILE=$TMPDIR/weblist.abs

	export ABSMESSAGE="     Tomcat90 cleanup"
    absmenu_log
    echo 'Tomcat90 cleanup'
	
	# empty list
	[ ! -d $TMPDIR ] && mkdir $TMPDIR
	[ -e $TMPFILE ] && rm -f $TMPFILE
	touch $TMPFILE
	
	# make a list of all web server/slot combinations in the chosen environment
    grep '^ *'$1"[[:blank:]]" $ABSMENUGLOBALCONFIG | sort -k2,2 -k5,5 -k4,4 | while read ABSM_ENVIRONMENT ABSM_SERVERNAME ABSM_SERVICE ABSM_TYPE ABSM_SLOT ABSM_LOCAL_HOME ABSM_REMOTE_HOME ABSM_USER ABSM_PWD ABSM_ORATNS ABSM_ORAHOME ABSM_DBSERVERNAME ABSM_DBDRIVERTYPE ABSM_DBPORTNUMBER ABSM_HEAPSPACE ABSM_STATIONNR ABSM_GFUSER ABSM_GFPASWRD ABSM_GFDOMAIN ABSM_WEBCONTEXT ABSM_WEBNAME ABSM_WEBLIB ABSM_CONNAPPSRV ABSM_CONNAPPSLOT ABSM_CONNREPSRV ABSM_CONNREPSLOT ABSM_USENATIVE ABSM_EXCLUDECUSTREP ABSM_WEB_VERSION ABSM_CLIENTDISTR_SRV ABSM_CLIENTDISTR_DIR ABSM_USER2 ABSM_PWD2 ABSM_STATIONNR2 ABSM_INET_KEY
    do
        case "$ABSM_TYPE" in 
            gws|w4m|wsr|wmr)   echo $ABSM_SERVERNAME $ABSM_SLOT >> $TMPFILE;;
        esac
	done

	# go through the list and delete tomcat webapps
	sort $TMPFILE | uniq | while read ABSM_SERVERNAME ABSM_SLOT 
    do
        if [ "$ABS_ROOTSERVER" == "$ABSM_SERVERNAME" ] 
        then
			$ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t tomcat -c stop
			[[ -d $ABS_ROOTDIR/$ABSM_SLOT/$TOMCATFOLDERNAME/webapps ]] && find $ABS_ROOTDIR/$ABSM_SLOT/$TOMCATFOLDERNAME/webapps -mindepth 1 -maxdepth 1 ! -name 'host-manager' ! -name 'ROOT' ! -name 'docs' ! -name 'manager' | xargs rm -rf 2> /dev/null
			[[ ! -z `ls $ABS_ROOTDIR/$ABSM_SLOT/$TOMCATFOLDERNAME/logs/* 2> /dev/null` ]] && rm -f $ABS_ROOTDIR/$ABSM_SLOT/$TOMCATFOLDERNAME/logs/* 2> /dev/null
			sleep 10
			$ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t tomcat -c start
		else
			echo -n .
			ssh -q -n $ABSM_SERVERNAME "$ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t tomcat -c stop"
			echo -n .
			ssh -q -n $ABSM_SERVERNAME "find $ABS_ROOTDIR/$ABSM_SLOT/$TOMCATFOLDERNAME/webapps -mindepth 1 -maxdepth 1 ! -name 'host-manager' ! -name 'ROOT' ! -name 'docs' ! -name 'manager' | xargs rm -rf 2> /dev/null"
			echo -n .
			ssh -q -n $ABSM_SERVERNAME "rm -rf $ABS_ROOTDIR/$ABSM_SLOT/$TOMCATFOLDERNAME/logs/*"
			echo -n .
			ssh -q -n $ABSM_SERVERNAME "sleep 10; $ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t tomcat -c start"
			echo .
		fi
	done
	rm -f $TMPFILE
}

# Cleanup for Tomcat9 webservers so you always start clean
cleanup_tomcat9()
{
	# $1 = environment
	TMPDIR=$ABS_ROOTDIR/tmp
	TMPFILE=$TMPDIR/weblist.abs

	export ABSMESSAGE="     Tomcat9 cleanup"
    absmenu_log
    echo 'Tomcat9 cleanup'
	
	# empty list
	[ ! -d $TMPDIR ] && mkdir $TMPDIR
	[ -e $TMPFILE ] && rm -f $TMPFILE
	touch $TMPFILE
	
	# make a list of all web server/slot combinations in the chosen environment
    grep '^ *'$1"[[:blank:]]" $ABSMENUGLOBALCONFIG | sort -k2,2 -k5,5 -k4,4 | while read ABSM_ENVIRONMENT ABSM_SERVERNAME ABSM_SERVICE ABSM_TYPE ABSM_SLOT ABSM_LOCAL_HOME ABSM_REMOTE_HOME ABSM_USER ABSM_PWD ABSM_ORATNS ABSM_ORAHOME ABSM_DBSERVERNAME ABSM_DBDRIVERTYPE ABSM_DBPORTNUMBER ABSM_HEAPSPACE ABSM_STATIONNR ABSM_GFUSER ABSM_GFPASWRD ABSM_GFDOMAIN ABSM_WEBCONTEXT ABSM_WEBNAME ABSM_WEBLIB ABSM_CONNAPPSRV ABSM_CONNAPPSLOT ABSM_CONNREPSRV ABSM_CONNREPSLOT ABSM_USENATIVE ABSM_EXCLUDECUSTREP ABSM_WEB_VERSION ABSM_CLIENTDISTR_SRV ABSM_CLIENTDISTR_DIR ABSM_USER2 ABSM_PWD2 ABSM_STATIONNR2 ABSM_INET_KEY
    do
        case "$ABSM_TYPE" in 
            wp2|wum|wcl|wua|wrd|wrr|wsb|wfb|wcp|gws|w4m|wsr|wmr)   echo $ABSM_SERVERNAME $ABSM_SLOT >> $TMPFILE;;
        esac
	done

	# go through the list and delete tomcat9 webapps
	sort $TMPFILE | uniq | while read ABSM_SERVERNAME ABSM_SLOT 
    do
        if [ "$ABS_ROOTSERVER" == "$ABSM_SERVERNAME" ] 
        then
			$ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t tomcat9 -c stop
			[[ -d $ABS_ROOTDIR/$ABSM_SLOT/$TOMCAT9FOLDERNAME/webapps ]] && find $ABS_ROOTDIR/$ABSM_SLOT/$TOMCAT9FOLDERNAME/webapps -mindepth 1 -maxdepth 1 ! -name 'host-manager' ! -name 'ROOT' ! -name 'docs' ! -name 'manager' | xargs rm -rf 2> /dev/null
			[[ ! -z `ls $ABS_ROOTDIR/$ABSM_SLOT/$TOMCAT9FOLDERNAME/logs/* 2> /dev/null` ]] && rm -f $ABS_ROOTDIR/$ABSM_SLOT/$TOMCAT9FOLDERNAME/logs/* 2> /dev/null
			sleep 10
			$ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t tomcat9 -c start
		else
			echo -n .
			ssh -q -n $ABSM_SERVERNAME "$ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t tomcat9 -c stop"
			echo -n .
			ssh -q -n $ABSM_SERVERNAME "find $ABS_ROOTDIR/$ABSM_SLOT/$TOMCAT9FOLDERNAME/webapps -mindepth 1 -maxdepth 1 ! -name 'host-manager' ! -name 'ROOT' ! -name 'docs' ! -name 'manager' | xargs rm -rf 2> /dev/null"
			echo -n .
			ssh -q -n $ABSM_SERVERNAME "rm -rf $ABS_ROOTDIR/$ABSM_SLOT/$TOMCAT9FOLDERNAME/logs/*"
			echo -n .
			ssh -q -n $ABSM_SERVERNAME "sleep 10; $ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t tomcat9 -c start"
			echo .
		fi
	done
	rm -f $TMPFILE
}

# Cleanup for Tomcat10 webservers so you always start clean
cleanup_tomcat10()
{
	# $1 = environment
	TMPDIR=$ABS_ROOTDIR/tmp
	TMPFILE=$TMPDIR/weblist.abs

	export ABSMESSAGE="     Tomcat10 cleanup"
    absmenu_log
    echo 'Tomcat10 cleanup'
	
	# empty list
	[ ! -d $TMPDIR ] && mkdir $TMPDIR
	[ -e $TMPFILE ] && rm -f $TMPFILE
	touch $TMPFILE
	
	# make a list of all web server/slot combinations in the chosen environment
    grep '^ *'$1"[[:blank:]]" $ABSMENUGLOBALCONFIG | sort -k2,2 -k5,5 -k4,4 | while read ABSM_ENVIRONMENT ABSM_SERVERNAME ABSM_SERVICE ABSM_TYPE ABSM_SLOT ABSM_LOCAL_HOME ABSM_REMOTE_HOME ABSM_USER ABSM_PWD ABSM_ORATNS ABSM_ORAHOME ABSM_DBSERVERNAME ABSM_DBDRIVERTYPE ABSM_DBPORTNUMBER ABSM_HEAPSPACE ABSM_STATIONNR ABSM_GFUSER ABSM_GFPASWRD ABSM_GFDOMAIN ABSM_WEBCONTEXT ABSM_WEBNAME ABSM_WEBLIB ABSM_CONNAPPSRV ABSM_CONNAPPSLOT ABSM_CONNREPSRV ABSM_CONNREPSLOT ABSM_USENATIVE ABSM_EXCLUDECUSTREP ABSM_WEB_VERSION ABSM_CLIENTDISTR_SRV ABSM_CLIENTDISTR_DIR ABSM_USER2 ABSM_PWD2 ABSM_STATIONNR2 ABSM_INET_KEY
    do
        case "$ABSM_TYPE" in 
            wp2|wum|wcl|wua|wrd|wrr|wsb|wfb|wcp|gws|w4m|wsr|wmr)   echo $ABSM_SERVERNAME $ABSM_SLOT >> $TMPFILE;;
        esac
	done

	# go through the list and delete tomcat10 webapps
	sort $TMPFILE | uniq | while read ABSM_SERVERNAME ABSM_SLOT 
    do
        if [ "$ABS_ROOTSERVER" == "$ABSM_SERVERNAME" ] 
        then
			$ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t tomcat10 -c stop
			[[ -d $ABS_ROOTDIR/$ABSM_SLOT/$TOMCAT10FOLDERNAME/webapps ]] && find $ABS_ROOTDIR/$ABSM_SLOT/$TOMCAT10FOLDERNAME/webapps -mindepth 1 -maxdepth 1 ! -name 'host-manager' ! -name 'ROOT' ! -name 'docs' ! -name 'manager' | xargs rm -rf 2> /dev/null
			[[ ! -z `ls $ABS_ROOTDIR/$ABSM_SLOT/$TOMCAT10FOLDERNAME/logs/* 2> /dev/null` ]] && rm -f $ABS_ROOTDIR/$ABSM_SLOT/$TOMCAT10FOLDERNAME/logs/* 2> /dev/null
			sleep 10
			$ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t tomcat10 -c start
		else
			echo -n .
			ssh -q -n $ABSM_SERVERNAME "$ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t tomcat10 -c stop"
			echo -n .
			ssh -q -n $ABSM_SERVERNAME "find $ABS_ROOTDIR/$ABSM_SLOT/$TOMCAT10FOLDERNAME/webapps -mindepth 1 -maxdepth 1 ! -name 'host-manager' ! -name 'ROOT' ! -name 'docs' ! -name 'manager' | xargs rm -rf 2> /dev/null"
			echo -n .
			ssh -q -n $ABSM_SERVERNAME "rm -rf $ABS_ROOTDIR/$ABSM_SLOT/$TOMCAT10FOLDERNAME/logs/*"
			echo -n .
			ssh -q -n $ABSM_SERVERNAME "sleep 10; $ABS_ROOTDIR/abs.sh -s $ABSM_SLOT -t tomcat10 -c start"
			echo .
		fi
	done
	rm -f $TMPFILE
}

# Function to synchronise the custom maximal heapspace value to the slot
synchronise_heapspace()
{	
	if [ "$ABSM_HEAPSPACE" == "X" ]
	then
		if [ "$ABS_ROOTSERVER" == "$ABSM_SERVERNAME" ] 
		then
			cd $ABS_ROOTDIR; ./abs.sh -s $ABSM_SLOT -t $ABSM_TYPE -c resetheap
		else
			ssh -n -q "$ABSM_SERVERNAME" "cd $ABS_ROOTDIR; ./abs.sh -s $ABSM_SLOT -t $ABSM_TYPE -c resetheap"
		fi
	elif [[ ! $ABSM_HEAPSPACE =~ [^[:digit:]] ]]
	then
		if [ "$ABS_ROOTSERVER" == "$ABSM_SERVERNAME" ] 
		then
			cd $ABS_ROOTDIR; ./abs.sh -s $ABSM_SLOT -t $ABSM_TYPE -M $ABSM_HEAPSPACE -c maxheap 
		else
			ssh -n -q "$ABSM_SERVERNAME" "cd $ABS_ROOTDIR; ./abs.sh -s $ABSM_SLOT -t $ABSM_TYPE -M $ABSM_HEAPSPACE -c maxheap" 
		fi
	fi	
}

# Function to synchronise the custom maximal heapspace value to the slot for glassfish/payara
synchronise_heapspace_glass()
{	
	if [ "$ABSM_HEAPSPACE" == "X" ]
	then
		if [ "$ABS_ROOTSERVER" == "$ABSM_SERVERNAME" ] 
		then
			cd $ABS_ROOTDIR; ./abs.sh -s $ABSM_SLOT -t $ABSM_TYPE -c resetheap_glass
		else
			ssh -n -q "$ABSM_SERVERNAME" "cd $ABS_ROOTDIR; ./abs.sh -s $ABSM_SLOT -t $ABSM_TYPE -c resetheap_glass"
		fi
	elif [[ ! $ABSM_HEAPSPACE =~ [^[:digit:]] ]]
	then
		if [ "$ABS_ROOTSERVER" == "$ABSM_SERVERNAME" ] 
		then
			cd $ABS_ROOTDIR; ./abs.sh -s $ABSM_SLOT -t $ABSM_TYPE -M $ABSM_HEAPSPACE -c maxheap_glass
		else
			ssh -n -q "$ABSM_SERVERNAME" "cd $ABS_ROOTDIR; ./abs.sh -s $ABSM_SLOT -t $ABSM_TYPE -M $ABSM_HEAPSPACE -c maxheap_glass" 
		fi
	fi	
}

# Function to synchronise the custom maximal heapspace value to the slot for tomee8
synchronise_heapspace_web()
{	
	if [ "$ABSM_HEAPSPACE" == "X" ]
	then
		if [ "$ABS_ROOTSERVER" == "$ABSM_SERVERNAME" ] 
		then
			cd $ABS_ROOTDIR; ./abs.sh -s $ABSM_SLOT -t $ABSM_TYPE -c resetheap_web
		else
			ssh -n -q "$ABSM_SERVERNAME" "cd $ABS_ROOTDIR; ./abs.sh -s $ABSM_SLOT -t $ABSM_TYPE -c resetheap_web"
		fi
	elif [[ ! $ABSM_HEAPSPACE =~ [^[:digit:]] ]]
	then
		if [ "$ABS_ROOTSERVER" == "$ABSM_SERVERNAME" ] 
		then
			cd $ABS_ROOTDIR; ./abs.sh -s $ABSM_SLOT -t $ABSM_TYPE -M $ABSM_HEAPSPACE -c maxheap_web
		else
			ssh -n -q "$ABSM_SERVERNAME" "cd $ABS_ROOTDIR; ./abs.sh -s $ABSM_SLOT -t $ABSM_TYPE -M $ABSM_HEAPSPACE -c maxheap_web" 
		fi
	fi	
}

# Function to synchronise the custom maximal heapspace value to the slot for tomee91
synchronise_heapspace_tomee()
{	
	if [ "$ABSM_HEAPSPACE" == "X" ]
	then
		if [ "$ABS_ROOTSERVER" == "$ABSM_SERVERNAME" ] 
		then
			cd $ABS_ROOTDIR; ./abs.sh -s $ABSM_SLOT -t $ABSM_TYPE -c resetheap_tomee
		else
			ssh -n -q "$ABSM_SERVERNAME" "cd $ABS_ROOTDIR; ./abs.sh -s $ABSM_SLOT -t $ABSM_TYPE -c resetheap_tomee"
		fi
	elif [[ ! $ABSM_HEAPSPACE =~ [^[:digit:]] ]]
	then
		if [ "$ABS_ROOTSERVER" == "$ABSM_SERVERNAME" ] 
		then
			cd $ABS_ROOTDIR; ./abs.sh -s $ABSM_SLOT -t $ABSM_TYPE -M $ABSM_HEAPSPACE -c maxheap_tomee
		else
			ssh -n -q "$ABSM_SERVERNAME" "cd $ABS_ROOTDIR; ./abs.sh -s $ABSM_SLOT -t $ABSM_TYPE -M $ABSM_HEAPSPACE -c maxheap_tomee" 
		fi
	fi	
}

# Function to synchronise the custom maximal heapspace value to the slot for tomcat90
synchronise_heapspace_tomcat()
{	
	if [ "$ABSM_HEAPSPACE" == "X" ]
	then
		if [ "$ABS_ROOTSERVER" == "$ABSM_SERVERNAME" ] 
		then
			cd $ABS_ROOTDIR; ./abs.sh -s $ABSM_SLOT -t $ABSM_TYPE -c resetheap_tomcat
		else
			ssh -n -q "$ABSM_SERVERNAME" "cd $ABS_ROOTDIR; ./abs.sh -s $ABSM_SLOT -t $ABSM_TYPE -c resetheap_tomcat"
		fi
	elif [[ ! $ABSM_HEAPSPACE =~ [^[:digit:]] ]]
	then
		if [ "$ABS_ROOTSERVER" == "$ABSM_SERVERNAME" ] 
		then
			cd $ABS_ROOTDIR; ./abs.sh -s $ABSM_SLOT -t $ABSM_TYPE -M $ABSM_HEAPSPACE -c maxheap_tomcat
		else
			ssh -n -q "$ABSM_SERVERNAME" "cd $ABS_ROOTDIR; ./abs.sh -s $ABSM_SLOT -t $ABSM_TYPE -M $ABSM_HEAPSPACE -c maxheap_tomcat" 
		fi
	fi	
}

# Function to synchronise the custom maximal heapspace value to the slot for tomcat9
synchronise_heapspace_tomcat9()
{	
	if [ "$ABSM_HEAPSPACE" == "X" ]
	then
		if [ "$ABS_ROOTSERVER" == "$ABSM_SERVERNAME" ]
		then
			cd $ABS_ROOTDIR; ./abs.sh -s $ABSM_SLOT -t $ABSM_TYPE -c resetheap_tomcat9
		else
			ssh -n -q "$ABSM_SERVERNAME" "cd $ABS_ROOTDIR; ./abs.sh -s $ABSM_SLOT -t $ABSM_TYPE -c resetheap_tomcat9"
		fi
	elif [[ ! $ABSM_HEAPSPACE =~ [^[:digit:]] ]]
	then
		if [ "$ABS_ROOTSERVER" == "$ABSM_SERVERNAME" ] 
		then
			cd $ABS_ROOTDIR; ./abs.sh -s $ABSM_SLOT -t $ABSM_TYPE -M $ABSM_HEAPSPACE -c maxheap_tomcat9
		else
			ssh -n -q "$ABSM_SERVERNAME" "cd $ABS_ROOTDIR; ./abs.sh -s $ABSM_SLOT -t $ABSM_TYPE -M $ABSM_HEAPSPACE -c maxheap_tomcat9" 
		fi
	fi	
}

# Function to synchronise the custom maximal heapspace value to the slot for tomcat10
synchronise_heapspace_tomcat10()
{	
	if [ "$ABSM_HEAPSPACE" == "X" ]
	then
		if [ "$ABS_ROOTSERVER" == "$ABSM_SERVERNAME" ]
		then
			cd $ABS_ROOTDIR; ./abs.sh -s $ABSM_SLOT -t $ABSM_TYPE -c resetheap_tomcat10
		else
			ssh -n -q "$ABSM_SERVERNAME" "cd $ABS_ROOTDIR; ./abs.sh -s $ABSM_SLOT -t $ABSM_TYPE -c resetheap_tomcat10"
		fi
	elif [[ ! $ABSM_HEAPSPACE =~ [^[:digit:]] ]]
	then
		if [ "$ABS_ROOTSERVER" == "$ABSM_SERVERNAME" ] 
		then
			cd $ABS_ROOTDIR; ./abs.sh -s $ABSM_SLOT -t $ABSM_TYPE -M $ABSM_HEAPSPACE -c maxheap_tomcat10
		else
			ssh -n -q "$ABSM_SERVERNAME" "cd $ABS_ROOTDIR; ./abs.sh -s $ABSM_SLOT -t $ABSM_TYPE -M $ABSM_HEAPSPACE -c maxheap_tomcat10" 
		fi
	fi	
}

deploy_fonts()
{
# $1 - environment
# $2 - fonts

	STANDARD=$ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Future/FONTS/STANDARD
	if [ "$ABS_ROOTSERVER" == "$ABSMENUREPOSITORYSERVER" ] 
	then
		if [ -e $ABSFONTSREPOSITORY/Fonts.zip ]
		then
			[ ! -d $STANDARD ] && mkdir -p $STANDARD
			pushd $ABSFONTSREPOSITORY
			unzip -o Fonts.zip -d $STANDARD
			popd
			export ABSMESSAGE="     $ABSFONTSREPOSITORY/Fonts.zip has successfully been deployed to $STANDARD"
			absmenu_log
			echo "$ABSFONTSREPOSITORY/Fonts.zip has successfully been deployed to $STANDARD"				
		else
			export ABSMESSAGE="     $ABSFONTSREPOSITORY/Fonts.zip not found for deploy."
            absmenu_log
			echo "$ABSFONTSREPOSITORY/Fonts.zip not found for deploy. Please resolve and retry."
		fi
	else
		export ABSMESSAGE="     Connot deploy fonts remotely"
        absmenu_log
		echo "Cannot deploy fonts remotely, absmenu repository not exist."
	fi
}

binrep_updateloop()
{
# $1 - environment
# $2 - all / reports / license (preselection) / heapsize
# $3 - app / rep / client / web / lic
###e.g: binrep_updateloop ilu heapspace app
###e.g: binrep_updateloop ilu heapspace web_heap

	# recreate domains for webservers so you always start clean
	# has to be done outside the "while read" loop so it gets done only once

	[ "$3" == "web" ] && cleanup_glassfish $1 && cleanup_web $1 && cleanup_tomee $1 && cleanup_tomcat $1 && cleanup_tomcat9 $1 && cleanup_tomcat10 $1

    grep '^ *'$1"[[:blank:]]" $ABSMENUGLOBALCONFIG | sort -k2,2 -k5,5 -k4,4 | while read ABSM_ENVIRONMENT ABSM_SERVERNAME ABSM_SERVICE ABSM_TYPE ABSM_SLOT ABSM_LOCAL_HOME ABSM_REMOTE_HOME ABSM_USER ABSM_PWD ABSM_ORATNS ABSM_ORAHOME ABSM_DBSERVERNAME ABSM_DBDRIVERTYPE ABSM_DBPORTNUMBER ABSM_HEAPSPACE ABSM_STATIONNR ABSM_GFUSER ABSM_GFPASWRD ABSM_GFDOMAIN ABSM_WEBCONTEXT ABSM_WEBNAME ABSM_WEBLIB ABSM_CONNAPPSRV ABSM_CONNAPPSLOT ABSM_CONNREPSRV ABSM_CONNREPSLOT ABSM_USENATIVE ABSM_EXCLUDECUSTREP ABSM_WEB_VERSION ABSM_CLIENTDISTR_SRV ABSM_CLIENTDISTR_DIR ABSM_USER2 ABSM_PWD2 ABSM_STATIONNR2 ABSM_INET_KEY
    do
        FILTER_OK=no
        if [ "$2" == "license" ]
        then
            FILTER_OK=yes
        else
            case "$ABSM_TYPE" in
                app|rep|client)     													[ "$3" == "$ABSM_TYPE" ] && FILTER_OK=yes
																						;;
                wpo|gws|ws2|w4m|wp2|wsr|wum|wcl|wua|wrd|wrr|wsb|wmr|wfb|wcp|glass|web)  [ "$3" == "web" ] || [ "$3" == "web_heap" ] && FILTER_OK=yes
																						;;
            esac
        fi

        if [ "$FILTER_OK" == "yes" ]
        then
            export ABSM_ENVIRONMENT ABSM_SERVERNAME ABSM_SERVICE ABSM_TYPE ABSM_SLOT ABSM_LOCAL_HOME ABSM_REMOTE_HOME ABSM_USER ABSM_PWD ABSM_ORATNS ABSM_ORAHOME ABSM_STATIONNR ABSM_GFUSER ABSM_GFPASWRD ABSM_GFDOMAIN ABSM_WEBCONTEXT ABSM_WEBNAME ABSM_WEBLIB ABSM_CONNAPPSRV ABSM_CONNAPPSLOT ABSM_CONNREPSRV ABSM_CONNREPSLOT ABSM_USENATIVE ABSM_WEB_VERSION ABSM_CLIENTDISTR_SRV ABSM_CLIENTDISTR_DIR ABSM_USER2 ABSM_PWD2 ABSM_STATIONNR2 ABSM_INET_KEY
			if [ "$2" == "license" ]    # sync licenses for app- and rep-servers
            then
                case "$ABSM_TYPE" in
                	app)    export ABSMESSAGE="     Copying new license to $ABSM_LOCAL_HOME/Server/License on server $ABSM_SERVERNAME"; absmenu_log
                            echo "Copying new license to $ABSM_LOCAL_HOME/Server/License on server $ABSM_SERVERNAME"
                            if [ "$ABS_ROOTSERVER" == "$ABSMENUREPOSITORYSERVER" ] 
                            then
								export ABSMESSAGE="     Copying new dialogs to $ABSM_LOCAL_HOME/Server/License on server $ABSM_SERVERNAME from $ABSMENU_CURRENT_ENVIRONMENT/Future/LICENSE/"; absmenu_log
                                rsync -tav --delete -e "ssh -q" $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Future/Server/License/* $ABSM_SERVERNAME:$ABSM_LOCAL_HOME/Server/License
								export ABSMESSAGE="     Copying new license to $ABSM_LOCAL_HOME/Server/License on server $ABSM_SERVERNAME from $ABSMENU_CURRENT_ENVIRONMENT/Future/LICENSE/"; absmenu_log
                                rsync -tav --delete -e "ssh -q" $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Future/LICENSE/* $ABSM_SERVERNAME:$ABSM_LOCAL_HOME/Server/License
                            else
                                export ABSMESSAGE="     Copying new dialogs to $ABSM_LOCAL_HOME/Server/License on server $ABSM_SERVERNAME from $ABSMENU_CURRENT_ENVIRONMENT/Future/LICENSE/"; absmenu_log
                                ssh -n -q $ABSMENUREPOSITORYSERVER "rsync -tav --delete -e \"ssh -q\" $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Future/Server/License/* $ABSM_SERVERNAME:$ABSM_LOCAL_HOME/Server/License"
                                export ABSMESSAGE="     Copying new license to $ABSM_LOCAL_HOME/Server/License on server $ABSM_SERVERNAME from $ABSMENU_CURRENT_ENVIRONMENT/Future/LICENSE/"; absmenu_log
                                ssh -n -q $ABSMENUREPOSITORYSERVER "rsync -tav --delete -e \"ssh -q\" $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Future/LICENSE/* $ABSM_SERVERNAME:$ABSM_LOCAL_HOME/Server/License"
                            fi;;
                	rep)    export ABSMESSAGE="     Applying Reportserver license to in $ABSM_LOCAL_HOME on server $ABSM_SERVERNAME"; absmenu_log
                            echo "Applying Reportserver license to in $ABSM_LOCAL_HOME on server $ABSM_SERVERNAME"
                            CRYSTALCLEARFILE="$ABSM_LOCAL_HOME/Reportserver/Config/crystalclear.properties"
							APPSERVERCOUNT=$(grep '^ *'$1"[[:blank:]]" $ABSMENUGLOBALCONFIG | awk -v a="$ABSM_SERVERNAME" ' $2!=a && $4=="app" { print $0 } ' | wc -l)
                            if [ "$ABS_ROOTSERVER" == "$ABSM_SERVERNAME" ] 
                            then
								[ $APPSERVERCOUNT -eq 0 ] && rsync -tav --delete -e "ssh -q" $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Future/Server/License/* $ABSM_SERVERNAME:$ABSM_LOCAL_HOME/Server/License
								[ $APPSERVERCOUNT -eq 0 ] && rsync -tav --delete -e "ssh -q" $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Future/LICENSE/* $ABSM_SERVERNAME:$ABSM_LOCAL_HOME/Server/License
								sed -i "/^licensekey=/ c\licensekey=$ABSM_INET_KEY" $CRYSTALCLEARFILE
                            else
								[ $APPSERVERCOUNT -eq 0 ] && ssh -n -q $ABSMENUREPOSITORYSERVER "rsync -tav --delete -e \"ssh -q\" $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Future/Server/License/* $ABSM_SERVERNAME:$ABSM_LOCAL_HOME/Server/License"
                                [ $APPSERVERCOUNT -eq 0 ] && ssh -n -q $ABSMENUREPOSITORYSERVER "rsync -tav --delete -e \"ssh -q\" $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Future/LICENSE/* $ABSM_SERVERNAME:$ABSM_LOCAL_HOME/Server/License"
                                ssh -n -q $ABSM_SERVERNAME "sed -i '/^licensekey=/ c\licensekey=$ABSM_INET_KEY' $CRYSTALCLEARFILE"
                            fi;;
                esac
			elif [ "$2" == "heapspace" ]
			then
				echo "----> Syncing Component: $ABSM_SERVERNAME - $ABSM_SLOT - $ABSM_TYPE"
				if [ "$3" == "web_heap" ]
				then
					case $ABSM_WEB_VERSION in
						411|55|56)	synchronise_heapspace_glass &> /dev/null
								;;
						8)		synchronise_heapspace_web &> /dev/null
								;;
						91)		synchronise_heapspace_tomee &> /dev/null
								;;
						90)		synchronise_heapspace_tomcat &> /dev/null
								;;
						9)		synchronise_heapspace_tomcat9 &> /dev/null
								;;
						10)		synchronise_heapspace_tomcat10 &> /dev/null
								;;
					esac
				fi
				case $ABSM_TYPE in
					app|rep)	synchronise_heapspace &> /dev/null
								;;
				esac
            else
                if [ "$2" == "reports" ] # sync reports and fonts only
                then
                    if [ "$ABSM_TYPE" == "rep" ]
                    then
                        export ABSMESSAGE="     Replicating reports and fonts for report server instance on $ABSM_SERVERNAME slot $ABSM_SLOT"; absmenu_log
                        echo "Replicating reports and fonts for report server instance on $ABSM_SERVERNAME slot $ABSM_SLOT"
                        if [ "$ABS_ROOTSERVER" == "$ABSMENUREPOSITORYSERVER" ] 
                        then
                            [ ! -d $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Future/Reportserver/Fonts ] && mkdir -p $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Future/Reportserver/Fonts
                            if [ "$ABSM_EXCLUDECUSTREP" == "true" ] 
							then 
								rsync --exclude 'CUSTOMER' -tav --delete -e "ssh -q" $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Future/Reportserver/CrReports $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Future/Reportserver/Fonts $ABSM_SERVERNAME:$ABSM_LOCAL_HOME/Reportserver
								rsync -tav -e "ssh -q" $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Future/FONTS/STANDARD/* $ABSM_SERVERNAME:$ABSM_LOCAL_HOME/Reportserver/Fonts
								rsync -tav -e "ssh -q" $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Future/FONTS/CUSTOMER/* $ABSM_SERVERNAME:$ABSM_LOCAL_HOME/Reportserver/Fonts
								rsync --exclude 'CUSTOMER' -tav --delete -e "ssh -q" $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Future/CUSTOMREPORTS/* $ABSM_SERVERNAME:$ABSM_LOCAL_HOME/Reportserver/CrReports
							else
								rsync -tav --delete -e "ssh -q" $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Future/Reportserver/CrReports $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Future/Reportserver/Fonts $ABSM_SERVERNAME:$ABSM_LOCAL_HOME/Reportserver
								rsync -tav -e "ssh -q" $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Future/FONTS/STANDARD/* $ABSM_SERVERNAME:$ABSM_LOCAL_HOME/Reportserver/Fonts
								rsync -tav -e "ssh -q" $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Future/FONTS/CUSTOMER/* $ABSM_SERVERNAME:$ABSM_LOCAL_HOME/Reportserver/Fonts
								rsync -tav --delete -e "ssh -q" $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Future/CUSTOMREPORTS/* $ABSM_SERVERNAME:$ABSM_LOCAL_HOME/Reportserver/CrReports
							fi
                        else
                            ssh -n -q $ABSMENUREPOSITORYSERVER "[ ! -d $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Future/Reportserver/Fonts ] && mkdir -p $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Future/Reportserver/Fonts"
                            if [ "$ABSM_EXCLUDECUSTREP" == "true" ] 
							then 
								ssh -n -q $ABSMENUREPOSITORYSERVER "rsync --exclude 'CUSTOMER'  -tav --delete -e \"ssh -q\" $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Future/Reportserver/CrReports $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Future/Reportserver/Fonts $ABSM_SERVERNAME:$ABSM_LOCAL_HOME/Reportserver"
								ssh -n -q $ABSMENUREPOSITORYSERVER "rsync -tav -e \"ssh -q\" $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Future/FONTS/STANDARD/* $ABSM_SERVERNAME:$ABSM_LOCAL_HOME/Reportserver/Fonts"
								ssh -n -q $ABSMENUREPOSITORYSERVER "rsync -tav -e \"ssh -q\" $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Future/FONTS/CUSTOMER/* $ABSM_SERVERNAME:$ABSM_LOCAL_HOME/Reportserver/Fonts"
								ssh -n -q $ABSMENUREPOSITORYSERVER "rsync --exclude 'CUSTOMER'  -tav --delete -e \"ssh -q\" $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Future/CUSTOMREPORTS/* $ABSM_SERVERNAME:$ABSM_LOCAL_HOME/Reportserver/CrReports"
                        	else
								ssh -n -q $ABSMENUREPOSITORYSERVER "rsync -tav --delete -e \"ssh -q\" $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Future/Reportserver/CrReports $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Future/Reportserver/Fonts $ABSM_SERVERNAME:$ABSM_LOCAL_HOME/Reportserver"
								ssh -n -q $ABSMENUREPOSITORYSERVER "rsync -tav -e \"ssh -q\" $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Future/FONTS/STANDARD/* $ABSM_SERVERNAME:$ABSM_LOCAL_HOME/Reportserver/Fonts"
								ssh -n -q $ABSMENUREPOSITORYSERVER "rsync -tav -e \"ssh -q\" $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Future/FONTS/CUSTOMER/* $ABSM_SERVERNAME:$ABSM_LOCAL_HOME/Reportserver/Fonts"
								ssh -n -q $ABSMENUREPOSITORYSERVER "rsync -tav --delete -e \"ssh -q\" $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Future/CUSTOMREPORTS/* $ABSM_SERVERNAME:$ABSM_LOCAL_HOME/Reportserver/CrReports"
                        	fi
						fi
                    fi
                else 
                    if [ "$ABSM_TYPE" == "client" ]
                    then
                        # update client distribution
                        export ABSMESSAGE="Updating CLIENT distrib"; absmenu_log
                        export ABSMESSAGE="     Replicating binaries for client distribution for $ABSM_SERVERNAME slot $ABSM_SLOT"
                        absmenu_log
                        echo "Replicating binaries for client distribution for $ABSM_SERVERNAME slot $ABSM_SLOT"
                        # 1) check if distrib exists. no --> create
                        #    server   : $ABSM_CLIENTDISTR_SRV 
                        #    directory: $ABSM_CLIENTDISTR_DIR
                        if [ "$ABS_ROOTSERVER" == "$ABSM_CLIENTDISTR_SRV" ] 
                        then
                            [ ! -d "$ABSM_CLIENTDISTR_DIR" ] && mkdir -p "$ABSM_CLIENTDISTR_DIR"
                        else
                            ssh -n -q "$ABSM_CLIENTDISTR_SRV" "[ ! -d \"$ABSM_CLIENTDISTR_DIR\" ] && mkdir -p \"$ABSM_CLIENTDISTR_DIR\""
                        fi
                        # 2) check if distrib exists. no --> message and stop trying
                        CLIENTDISTRIBOK=N
                        if [ "$ABS_ROOTSERVER" == "$ABSM_CLIENTDISTR_SRV" ] 
                        then
                            [ -d $ABSM_CLIENTDISTR_DIR ] && CLIENTDISTRIBOK=Y
                        else
                            CLIENTDISTRIBOK=`ssh -n -q "$ABSM_CLIENTDISTR_SRV" "if [ -d \"$ABSM_CLIENTDISTR_DIR\" ]; then echo Y; else echo N; fi"`
                        fi
                        # 3) rsync client to distrib
                        if [ "$CLIENTDISTRIBOK" == "Y" ]
                        then
                            # 3.1) sync binaries to distrib share
                            if [ "$ABS_ROOTSERVER" == "$ABSMENUREPOSITORYSERVER" ] 
                            then
                                rsync -tav --delete -e "ssh -q" "$ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Future/Client/Client" "$ABSM_CLIENTDISTR_SRV:$ABSM_CLIENTDISTR_DIR"
                                rsync -tav --delete -e "ssh -q" "$ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Future/Client/Server" "$ABSM_CLIENTDISTR_SRV:$ABSM_CLIENTDISTR_DIR"
                                rsync -tav -e "ssh -q" "$ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Future/Client/Users" "$ABSM_CLIENTDISTR_SRV:$ABSM_CLIENTDISTR_DIR"
                            else
                                ssh -n -q $ABSMENUREPOSITORYSERVER "rsync -tav --delete -e \"ssh -q\" \"$ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Future/Client/Client\" \"$ABSM_CLIENTDISTR_SRV:$ABSM_CLIENTDISTR_DIR\""
                                ssh -n -q $ABSMENUREPOSITORYSERVER "rsync -tav --delete -e \"ssh -q\" \"$ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Future/Client/Server\" \"$ABSM_CLIENTDISTR_SRV:$ABSM_CLIENTDISTR_DIR\""
                                ssh -n -q $ABSMENUREPOSITORYSERVER "rsync -tav --delete -e \"ssh -q\" \"$ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Future/Client/Users\" \"$ABSM_CLIENTDISTR_SRV:$ABSM_CLIENTDISTR_DIR\""
                            fi
                            
                            # 3.2) generate clientserver.sh
                            if [ "$ABS_ROOTSERVER" == "$ABSM_CLIENTDISTR_SRV" ] 
                            then
                                echo '#/bin/bash'> "$ABSM_CLIENTDISTR_DIR/clientserver.sh"
                                echo "CLIENTAPPSRV=$ABSM_CONNAPPSRV" >> "$ABSM_CLIENTDISTR_DIR/clientserver.sh"
                                echo "CLIENTAPPSRVSLOT=$ABSM_CONNAPPSLOT" >> "$ABSM_CLIENTDISTR_DIR/clientserver.sh"
                                echo "CLIENTREPSRV=$ABSM_CONNREPSRV" >> "$ABSM_CLIENTDISTR_DIR/clientserver.sh"
                                echo "CLIENTREPSRVSLOT=$ABSM_CONNREPSLOT" >> "$ABSM_CLIENTDISTR_DIR/clientserver.sh"
                                echo "USEDISTRIB=Y" >> "$ABSM_CLIENTDISTR_DIR/clientserver.sh"
                                echo "CLIENTDISTRIBSRV=$ABSM_CLIENTDISTR_SRV" >> "$ABSM_CLIENTDISTR_DIR/clientserver.sh"
                                echo "CLIENTDISTRIBDIR=$ABSM_CLIENTDISTR_DIR" >> "$ABSM_CLIENTDISTR_DIR/clientserver.sh"
                                chmod a+x "$ABSM_CLIENTDISTR_DIR/clientserver.sh"
                            else
                                echo -n .
                                ssh -n -q $ABSM_CLIENTDISTR_SRV "echo \"#/bin/bash\"> \"$ABSM_CLIENTDISTR_DIR/clientserver.sh\""
                                echo -n .
                                ssh -n -q $ABSM_CLIENTDISTR_SRV "echo \"CLIENTAPPSRV=$ABSM_CONNAPPSRV\" >> \"$ABSM_CLIENTDISTR_DIR/clientserver.sh\""
                                echo -n .
                                ssh -n -q $ABSM_CLIENTDISTR_SRV "echo \"CLIENTAPPSRVSLOT=$ABSM_CONNAPPSLOT\" >> \"$ABSM_CLIENTDISTR_DIR/clientserver.sh\""
                                echo -n .
                                ssh -n -q $ABSM_CLIENTDISTR_SRV "echo \"CLIENTREPSRV=$ABSM_CONNREPSRV\" >> \"$ABSM_CLIENTDISTR_DIR/clientserver.sh\""
                                echo -n .
                                ssh -n -q $ABSM_CLIENTDISTR_SRV "echo \"CLIENTREPSRVSLOT=$ABSM_CONNREPSLOT\" >> \"$ABSM_CLIENTDISTR_DIR/clientserver.sh\""
                                echo -n .
                                ssh -n -q $ABSM_CLIENTDISTR_SRV "echo \"USEDISTRIB=Y\" >> \"$ABSM_CLIENTDISTR_DIR/clientserver.sh\""
                                echo -n .
                                ssh -n -q $ABSM_CLIENTDISTR_SRV "echo \"CLIENTDISTRIBSRV=$ABSM_CLIENTDISTR_SRV\" >> \"$ABSM_CLIENTDISTR_DIR/clientserver.sh\""
                                echo -n .
                                ssh -n -q $ABSM_CLIENTDISTR_SRV "echo \"CLIENTDISTRIBDIR=$ABSM_CLIENTDISTR_DIR\" >> \"$ABSM_CLIENTDISTR_DIR/clientserver.sh\""
                                echo -n .
                                ssh -n -q $ABSM_CLIENTDISTR_SRV "chmod a+x \"$ABSM_CLIENTDISTR_DIR/clientserver.sh\""
                                echo .
                            fi
                        else
                            export ABSMESSAGE="     Problem creating client distribution location $ABSM_CLIENTDISTR_SRV:$ABSM_CLIENTDISTR_DIR"
                            absmenu_log
                            echo "Problem creating client distribution $ABSM_CLIENTDISTR_SRV:$ABSM_CLIENTDISTR_DIR"
                        fi
                    else
                        # normal (full) update
                        case "$ABSM_TYPE" in 
							app)       		                export ABSMESSAGE="     Replicating binaries for application server instance on $ABSM_SERVERNAME slot $ABSM_SLOT"
															absmenu_log
															echo "Replicating binaries for application server instance on $ABSM_SERVERNAME slot $ABSM_SLOT"
															if [ "$ABS_ROOTSERVER" == "$ABSM_SERVERNAME" ] 
															then
																[ ! -d $ABSM_LOCAL_HOME/Server/Bin ] && mkdir -p $ABSM_LOCAL_HOME/Server/Bin
																[ ! -d $ABSM_LOCAL_HOME/Server/Config ] && mkdir -p $ABSM_LOCAL_HOME/Server/Config
																[ ! -d $ABSM_LOCAL_HOME/Server/Lib ] && mkdir -p $ABSM_LOCAL_HOME/Server/Lib
																[ ! -d $ABSM_LOCAL_HOME/Server/License ] && mkdir -p $ABSM_LOCAL_HOME/Server/License
																[ ! -d $ABSM_LOCAL_HOME/Server/Log ] && mkdir -p $ABSM_LOCAL_HOME/Server/Log
																[ ! -d $ABSM_LOCAL_HOME/Server/sqlscripts ] && mkdir -p $ABSM_LOCAL_HOME/Server/sqlscripts
															else
																echo -n .
																ssh -n -q $ABSM_SERVERNAME "[ ! -d $ABSM_LOCAL_HOME/Server/Bin ] && mkdir -p $ABSM_LOCAL_HOME/Server/Bin"
																echo -n .
																ssh -n -q $ABSM_SERVERNAME "[ ! -d $ABSM_LOCAL_HOME/Server/Config ] && mkdir -p $ABSM_LOCAL_HOME/Server/Config"
																echo -n .
																ssh -n -q $ABSM_SERVERNAME "[ ! -d $ABSM_LOCAL_HOME/Server/Lib ] && mkdir -p $ABSM_LOCAL_HOME/Server/Lib"
																echo -n .
																ssh -n -q $ABSM_SERVERNAME "[ ! -d $ABSM_LOCAL_HOME/Server/License ] && mkdir -p $ABSM_LOCAL_HOME/Server/License"
																echo -n .
																ssh -n -q $ABSM_SERVERNAME "[ ! -d $ABSM_LOCAL_HOME/Server/Log ] && mkdir -p $ABSM_LOCAL_HOME/Server/Log"
																echo -n .
																ssh -n -q $ABSM_SERVERNAME "[ ! -d $ABSM_LOCAL_HOME/Server/sqlscripts ] && mkdir -p $ABSM_LOCAL_HOME/Server/sqlscripts"
																echo .
															fi
															if [ "$ABS_ROOTSERVER" == "$ABSMENUREPOSITORYSERVER" ] 
															then
																rsync -tav --delete -e "ssh -q" $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Future/Server/Bin $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Future/Server/Lib $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Future/Server/License $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Future/Server/sqlscripts $ABSM_SERVERNAME:$ABSM_LOCAL_HOME/Server
																rsync -tav --delete -e "ssh -q" $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Future/LICENSE/* $ABSM_SERVERNAME:$ABSM_LOCAL_HOME/Server/License
																rsync -tav --delete -e "ssh -q" $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Future/Server/Config/sample_*.properties $ABSM_SERVERNAME:$ABSM_LOCAL_HOME/Server/Config
															else
																ssh -n -q $ABSMENUREPOSITORYSERVER "rsync -tav --delete -e \"ssh -q\" $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Future/Server/Bin $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Future/Server/Lib $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Future/Server/License $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Future/Server/sqlscripts $ABSM_SERVERNAME:$ABSM_LOCAL_HOME/Server"
																ssh -n -q $ABSMENUREPOSITORYSERVER "rsync -tav --delete -e \"ssh -q\" $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Future/LICENSE $ABSM_SERVERNAME:$ABSM_LOCAL_HOME/Server/License"
																ssh -n -q $ABSMENUREPOSITORYSERVER "rsync -tav --delete -e \"ssh -q\" $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Future/Server/Config/sample_*.properties $ABSM_SERVERNAME:$ABSM_LOCAL_HOME/Server/Config"
															fi

															if [ "$ABS_ROOTSERVER" == "$ABSM_SERVERNAME" ] 
															then
																[ -e $ABSM_LOCAL_HOME/Server/Lib/reportserver.jar ] && rm -f $ABSM_LOCAL_HOME/Server/Lib/reportserver.jar
															else
																ssh -n -q $ABSM_SERVERNAME "[ -e $ABSM_LOCAL_HOME/Server/Lib/reportserver.jar ] && rm -f $ABSM_LOCAL_HOME/Server/Lib/reportserver.jar"
															fi
															if [ "$ABS_ROOTSERVER" == "$ABSMENUREPOSITORYSERVER" ] 
															then
																[ -e $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Future/Reportserver/Lib/ReportServer.jar ] && rsync -tav --delete -e "ssh -q" $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Future/Reportserver/Lib/ReportServer.jar $ABSM_SERVERNAME:$ABSM_LOCAL_HOME/Server/Lib
																[ -e $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Future/Reportserver/Lib/reportserver.jar ] && rsync -tav --delete -e "ssh -q" $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Future/Reportserver/Lib/reportserver.jar $ABSM_SERVERNAME:$ABSM_LOCAL_HOME/Server/Lib
															else
																[ -e $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Future/Reportserver/Lib/ReportServer.jar ] && ssh -n -q $ABSMENUREPOSITORYSERVER "rsync -tav --delete -e \"ssh -q\" $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Future/Reportserver/Lib/ReportServer.jar $ABSM_SERVERNAME:$ABSM_LOCAL_HOME/Server/Lib"
																[ -e $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Future/Reportserver/Lib/reportserver.jar ] && ssh -n -q $ABSMENUREPOSITORYSERVER "rsync -tav --delete -e \"ssh -q\" $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Future/Reportserver/Lib/reportserver.jar $ABSM_SERVERNAME:$ABSM_LOCAL_HOME/Server/Lib"
															fi
															if [ "$ABS_ROOTSERVER" == "$ABSM_SERVERNAME" ] 
															then
																[ ! -e $ABSM_LOCAL_HOME/Server/Lib/reportserver.jar ] && cp -f $ABSM_LOCAL_HOME/Server/Lib/ReportServer.jar $ABSM_LOCAL_HOME/Server/Lib/reportserver.jar
															else
																ssh -n -q $ABSM_SERVERNAME "[ ! -e $ABSM_LOCAL_HOME/Server/Lib/reportserver.jar ] && cp -f $ABSM_LOCAL_HOME/Server/Lib/ReportServer.jar $ABSM_LOCAL_HOME/Server/Lib/reportserver.jar"
															fi

															. $ABSMENUPATH/bin/generate_properties.sh app check "$1" "$ABSM_TYPE" "$ABSM_SERVERNAME" "$ABSM_SLOT" "$ABSM_LOCAL_HOME" "$ABSM_USER" "$ABSM_PWD" "$ABSM_STATIONNR" "$ABSM_CONNAPPSRV" "$ABSM_CONNAPPSLOT" "$ABSM_CONNREPSRV" "$ABSM_CONNREPSLOT" "$WEBNAME" "$ABSM_ORATNS" "$ABSM_ORAHOME" "$ABSM_USER" "$ABSM_PWD" "$ABSM_USENATIVE" "$ABSM_INET_KEY" "$ABSM_GFDOMAIN" "$ABSM_USER2" "$ABSM_PWD2" "$ABSM_STATIONNR2" "$ABSM_DBSERVERNAME" "$ABSM_DBDRIVERTYPE" "$ABSM_DBPORTNUMBER"
															if [ -z "$ABSAPPSERVER" ]
															then
																export ABSAPPSERVER=$ABSM_SERVERNAME
																export ABSAPPSERVERLIB="$ABSM_LOCAL_HOME/Server/Lib/patchserver.jar"
															fi
															synchronise_heapspace  &> /dev/null
															;;
										
							rep)                    		export ABSMESSAGE="     Replicating binaries for report server instance on $ABSM_SERVERNAME slot $ABSM_SLOT"
															absmenu_log
															echo "Replicating binaries for report server instance on $ABSM_SERVERNAME slot $ABSM_SLOT"
															APPSERVERCOUNT=$(grep '^ *'$1"[[:blank:]]" $ABSMENUGLOBALCONFIG | awk -v a="$ABSM_SERVERNAME" ' $2!=a && $4=="app" { print $0 } ' | wc -l)
															if [ "$ABS_ROOTSERVER" == "$ABSM_SERVERNAME" ] 
															then
																# Sync server libs,license is required
																if [ $APPSERVERCOUNT -eq 0 ]
																then
																	[ ! -d $ABSM_LOCAL_HOME/Server/Lib ] && mkdir -p $ABSM_LOCAL_HOME/Server/Lib
																	[ ! -d $ABSM_LOCAL_HOME/Server/License ] && mkdir -p $ABSM_LOCAL_HOME/Server/License
																	rsync -tav --delete -e "ssh -q" $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Future/Server/Lib $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Future/Server/License $ABSM_SERVERNAME:$ABSM_LOCAL_HOME/Server
																	rsync -tav --delete -e "ssh -q" $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Future/LICENSE/* $ABSM_SERVERNAME:$ABSM_LOCAL_HOME/Server/License
																fi
																[ ! -d $ABSM_LOCAL_HOME/Reportserver/Bin ] && mkdir -p $ABSM_LOCAL_HOME/Reportserver/Bin
																[ ! -d $ABSM_LOCAL_HOME/Reportserver/Lib ] && mkdir -p $ABSM_LOCAL_HOME/Reportserver/Lib
																[ ! -d $ABSM_LOCAL_HOME/Reportserver/Log ] && mkdir -p $ABSM_LOCAL_HOME/Reportserver/Log
																[ ! -d $ABSM_LOCAL_HOME/Reportserver/Fonts ] && mkdir -p $ABSM_LOCAL_HOME/Reportserver/Fonts
																[ ! -d $ABSM_LOCAL_HOME/Reportserver/Config ] && mkdir -p $ABSM_LOCAL_HOME/Reportserver/Config
																[ ! -d $ABSM_LOCAL_HOME/Reportserver/CrReports ] && mkdir -p $ABSM_LOCAL_HOME/Reportserver/CrReports
																[ $ABSSOLUTENUMVERSION -ge 90801 -a ! -d $ABSM_LOCAL_HOME/Reportserver/plugins ] && mkdir -p $ABSM_LOCAL_HOME/Reportserver/plugins
																[ $ABSSOLUTENUMVERSION -ge 90000 -a $ABSSOLUTENUMVERSION -lt 90801 -a ! -d $ABSM_LOCAL_HOME/Reportserver/Lib/plugins ] && mkdir -p $ABSM_LOCAL_HOME/Reportserver/Lib/plugins
															else
																# Sync server libs,license is required
																if [ $APPSERVERCOUNT -eq 0 ]
																then
																	echo -n .
																	ssh -n -q $ABSM_SERVERNAME "[ ! -d $ABSM_LOCAL_HOME/Server/Lib ] && mkdir -p $ABSM_LOCAL_HOME/Server/Lib"
																	echo -n .
																	ssh -n -q $ABSM_SERVERNAME "[ ! -d $ABSM_LOCAL_HOME/Server/License ] && mkdir -p $ABSM_LOCAL_HOME/Server/License"
																	echo .
																	ssh -n -q $ABSMENUREPOSITORYSERVER "rsync -tav --delete -e \"ssh -q\" $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Future/Server/Lib $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Future/Server/License $ABSM_SERVERNAME:$ABSM_LOCAL_HOME/Server"
																	ssh -n -q $ABSMENUREPOSITORYSERVER "rsync -tav --delete -e \"ssh -q\" $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Future/LICENSE/* $ABSM_SERVERNAME:$ABSM_LOCAL_HOME/Server/License"
																fi
																echo -n .
																ssh -n -q $ABSM_SERVERNAME "[ ! -d $ABSM_LOCAL_HOME/Reportserver/Bin ] && mkdir -p $ABSM_LOCAL_HOME/Reportserver/Bin"
																echo -n .
																ssh -n -q $ABSM_SERVERNAME "[ ! -d $ABSM_LOCAL_HOME/Reportserver/Lib ] && mkdir -p $ABSM_LOCAL_HOME/Reportserver/Lib"
																echo -n .
																ssh -n -q $ABSM_SERVERNAME "[ ! -d $ABSM_LOCAL_HOME/Reportserver/Log ] && mkdir -p $ABSM_LOCAL_HOME/Reportserver/Log"
																echo -n .
																ssh -n -q $ABSM_SERVERNAME "[ ! -d $ABSM_LOCAL_HOME/Reportserver/Fonts ] && mkdir -p $ABSM_LOCAL_HOME/Reportserver/Fonts"
																echo -n .
																ssh -n -q $ABSM_SERVERNAME "[ ! -d $ABSM_LOCAL_HOME/Reportserver/Config ] && mkdir -p $ABSM_LOCAL_HOME/Reportserver/Config"
																echo -n .
																ssh -n -q $ABSM_SERVERNAME "[ ! -d $ABSM_LOCAL_HOME/Reportserver/CrReports ] && mkdir -p $ABSM_LOCAL_HOME/Reportserver/CrReports"
																echo -n .
																ssh -n -q $ABSM_SERVERNAME "[ $ABSSOLUTENUMVERSION -ge 90801 -a ! -d $ABSM_LOCAL_HOME/Reportserver/plugins ] && mkdir -p $ABSM_LOCAL_HOME/Reportserver/plugins"
																echo -n .
																ssh -n -q $ABSM_SERVERNAME "[ $ABSSOLUTENUMVERSION -ge 90000 -a $ABSSOLUTENUMVERSION -lt 90801 -a ! -d $ABSM_LOCAL_HOME/Reportserver/Lib/plugins ] && mkdir -p $ABSM_LOCAL_HOME/Reportserver/Lib/plugins"
																echo .
															fi
															if [ "$ABS_ROOTSERVER" == "$ABSMENUREPOSITORYSERVER" ] 
															then
																if [ "$ABSM_EXCLUDECUSTREP" == "true" ]
																then 
																	rsync --exclude 'CUSTOMER' -tav --delete -e "ssh -q" $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Future/Reportserver/Bin $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Future/Reportserver/Lib $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Future/Reportserver/Fonts $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Future/Reportserver/CrReports $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Future/Reportserver/plugins $ABSM_SERVERNAME:$ABSM_LOCAL_HOME/Reportserver
																	rsync -tav -e "ssh -q" $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Future/FONTS/STANDARD/* $ABSM_SERVERNAME:$ABSM_LOCAL_HOME/Reportserver/Fonts
																	rsync -tav -e "ssh -q" $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Future/FONTS/CUSTOMER/* $ABSM_SERVERNAME:$ABSM_LOCAL_HOME/Reportserver/Fonts
																	rsync --exclude 'CUSTOMER' -tav --delete -e "ssh -q" $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Future/CUSTOMREPORTS/* $ABSM_SERVERNAME:$ABSM_LOCAL_HOME/Reportserver/CrReports
																else
																	rsync -tav --delete -e "ssh -q" $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Future/Reportserver/Bin $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Future/Reportserver/Lib $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Future/Reportserver/Fonts $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Future/Reportserver/CrReports $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Future/Reportserver/plugins $ABSM_SERVERNAME:$ABSM_LOCAL_HOME/Reportserver
																	rsync -tav -e "ssh -q" $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Future/FONTS/STANDARD/* $ABSM_SERVERNAME:$ABSM_LOCAL_HOME/Reportserver/Fonts
																	rsync -tav -e "ssh -q" $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Future/FONTS/CUSTOMER/* $ABSM_SERVERNAME:$ABSM_LOCAL_HOME/Reportserver/Fonts
																	rsync -tav --delete -e "ssh -q" $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Future/CUSTOMREPORTS/* $ABSM_SERVERNAME:$ABSM_LOCAL_HOME/Reportserver/CrReports
																fi
																rsync -tav --delete -e "ssh -q" $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Future/Reportserver/Config/sample_*.properties $ABSM_SERVERNAME:$ABSM_LOCAL_HOME/Reportserver/Config
																[ $ABSSOLUTENUMVERSION -ge 90000 ] && rsync -tav --delete -e "ssh -q" $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Future/Reportserver/Config/datasources.xml $ABSM_SERVERNAME:$ABSM_LOCAL_HOME/Reportserver/Config
															else
																if [ "$ABSM_EXCLUDECUSTREP" == "true" ] 
																then 
																	ssh -n -q $ABSMENUREPOSITORYSERVER "rsync --exclude 'CUSTOMER' -tav --delete -e \"ssh -q\" $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Future/Reportserver/Bin $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Future/Reportserver/Lib $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Future/Reportserver/Fonts $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Future/Reportserver/CrReports $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Future/Reportserver/plugins $ABSM_SERVERNAME:$ABSM_LOCAL_HOME/Reportserver"
																	ssh -n -q $ABSMENUREPOSITORYSERVER "rsync -tav -e \"ssh -q\" $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Future/FONTS/STANDARD/* $ABSM_SERVERNAME:$ABSM_LOCAL_HOME/Reportserver/Fonts"
																	ssh -n -q $ABSMENUREPOSITORYSERVER "rsync -tav -e \"ssh -q\" $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Future/FONTS/CUSTOMER/* $ABSM_SERVERNAME:$ABSM_LOCAL_HOME/Reportserver/Fonts"
																	ssh -n -q $ABSMENUREPOSITORYSERVER "rsync --exclude 'CUSTOMER' -tav --delete -e \"ssh -q\" $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Future/CUSTOMREPORTS/* $ABSM_SERVERNAME:$ABSM_LOCAL_HOME/Reportserver/CrReports"
																else
																	ssh -n -q $ABSMENUREPOSITORYSERVER "rsync -tav --delete -e \"ssh -q\" $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Future/Reportserver/Bin $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Future/Reportserver/Lib $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Future/Reportserver/Fonts $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Future/Reportserver/CrReports $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Future/Reportserver/plugins $ABSM_SERVERNAME:$ABSM_LOCAL_HOME/Reportserver"
																	ssh -n -q $ABSMENUREPOSITORYSERVER "rsync -tav -e \"ssh -q\" $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Future/FONTS/STANDARD/* $ABSM_SERVERNAME:$ABSM_LOCAL_HOME/Reportserver/Fonts"
																	ssh -n -q $ABSMENUREPOSITORYSERVER "rsync -tav -e \"ssh -q\" $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Future/FONTS/CUSTOMER/* $ABSM_SERVERNAME:$ABSM_LOCAL_HOME/Reportserver/Fonts"
																	ssh -n -q $ABSMENUREPOSITORYSERVER "rsync -tav --delete -e \"ssh -q\" $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Future/CUSTOMREPORTS/* $ABSM_SERVERNAME:$ABSM_LOCAL_HOME/Reportserver/CrReports"
																fi																
																ssh -n -q $ABSMENUREPOSITORYSERVER "rsync -tav --delete -e \"ssh -q\" $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Future/Reportserver/Config/sample_*.properties $ABSM_SERVERNAME:$ABSM_LOCAL_HOME/Reportserver/Config"
																ssh -n -q $ABSMENUREPOSITORYSERVER "[ $ABSSOLUTENUMVERSION -ge 90000 ] && rsync -tav --delete -e \"ssh -q\" $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Future/Reportserver/Config/datasources.xml $ABSM_SERVERNAME:$ABSM_LOCAL_HOME/Reportserver/Config"
															fi
															. $ABSMENUPATH/bin/generate_properties.sh rep check "$1" "$ABSM_TYPE" "$ABSM_SERVERNAME" "$ABSM_SLOT" "$ABSM_LOCAL_HOME" "$ABSM_USER" "$ABSM_PWD" "$ABSM_STATIONNR" "$ABSM_CONNAPPSRV" "$ABSM_CONNAPPSLOT" "$ABSM_CONNREPSRV" "$ABSM_CONNREPSLOT" "$WEBNAME" "$ABSM_ORATNS" "$ABSM_ORAHOME" "$ABSM_USER" "$ABSM_PWD" "$ABSM_USENATIVE" "$ABSM_INET_KEY" "$ABSM_GFDOMAIN"  "$ABSM_USER2" "$ABSM_PWD2" "$ABSM_STATIONNR2" "$ABSM_DBSERVERNAME" "$ABSM_DBDRIVERTYPE" "$ABSM_DBPORTNUMBER"
															synchronise_heapspace  &> /dev/null
															;;
													
                            wpo|gws|ws2|w4m|wp2|wsr|wum|wcl|wua|wrd|wrr|wsb|wmr|wfb|wcp)   	export ABSMESSAGE="Updating WEB"; absmenu_log
													# if the ../Future/Web exists then we will perform the update. Otherwise, nothing to do
													if [ -d $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Future/Web ]
													then
														updateweb
													else
														export ABSMESSAGE="There is no $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Future/Web/  therefore nothing to update!"; absmenu_log
													fi
													;;
                        esac
                    fi
                fi
            fi
        fi
    done
}

check_repository_for_old_junk()
{
    if [ "$ABS_ROOTSERVER" == "$ABSMENUREPOSITORYSERVER" ] 
    then
        rm -f "$ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT"/Future/Server/abskey.jar
        rm -f "$ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT"/Future/Server/CC-Viewer.jar
        rm -f "$ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT"/Future/Server/CrystalClear.jar
        rm -f "$ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT"/Future/Server/CCLib.jar
        rm -f "$ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT"/Future/Server/commons-logging-1.0.4.jar
        rm -f "$ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT"/Future/Server/jcfield450k.jar
        rm -f "$ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT"/Future/Server/junit.jar
        rm -f "$ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT"/Future/Reportserver/commons-digester3-3.2-with-deps.jar
        rm -f "$ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT"/Future/Reportserver/compass.jar
        rm -f "$ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT"/Future/Reportserver/adhocLoader.jar
        rm -f "$ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT"/Future/Reportserver/CCjetty.jar
        rm -f "$ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT"/Future/Reportserver/ehcache-core.jar
        rm -f "$ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT"/Future/Reportserver/milton-api-1.4.jar
        rm -f "$ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT"/Future/Reportserver/adhocClient.jar
        rm -f "$ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT"/Future/Reportserver/slf4j-simple-1.5.6.jar
        rm -f "$ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT"/Future/Reportserver/gwt-servlet.jar
        rm -f "$ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT"/Future/Reportserver/milton-servlet-1.4.jar
        rm -f "$ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT"/Future/Reportserver/TableLayout.jar
        rm -f "$ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT"/Future/Reportserver/jhall.jar
        rm -f "$ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT"/Future/Reportserver/Designer.jar
        rm -f "$ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT"/Future/Reportserver/jsp-api-2.0.jar
        rm -f "$ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT"/Future/Reportserver/mime-util.jar
        rm -f "$ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT"/Future/Reportserver/swing-layout.jar
        rm -f "$ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT"/Future/Reportserver/jortho.jar
        rm -f "$ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT"/Future/Reportserver/SBSTutorial.jar
        rm -f "$ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT"/Future/Reportserver/gwt-servlet-deps.jar
        rm -f "$ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT"/Future/Reportserver/CCLib.jar
        rm -f "$ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT"/Future/Reportserver/CCjetty-util.jar
        rm -f "$ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT"/Future/Reportserver/webdavclient4j-core-0.92.jar
        rm -f "$ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT"/Future/Reportserver/commons-httpclient-3.0.1.jar
        rm -f "$ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT"/Future/Reportserver/JnlpDesigner.jar
        rm -f "$ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT"/Future/Reportserver/commons-codec-1.3.jar
        rm -f "$ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT"/Future/Reportserver/jdom-1.0.jar
        rm -f "$ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT"/Future/Reportserver/commons-net-3.0.1.jar
        rm -f "$ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT"/Future/Reportserver/lucene-core.jar
    else
        ssh -n -q "rm -f \"$ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT\"/Future/Server/abskey.jar"
        ssh -n -q "rm -f \"$ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT\"/Future/Server/CC-Viewer.jar"
        ssh -n -q "rm -f \"$ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT\"/Future/Server/CrystalClear.jar"
        ssh -n -q "rm -f \"$ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT\"/Future/Server/CCLib.jar"
        ssh -n -q "rm -f \"$ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT\"/Future/Server/commons-logging-1.0.4.jar"
        ssh -n -q "rm -f \"$ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT\"/Future/Server/jcfield450k.jar"
        ssh -n -q "rm -f \"$ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT\"/Future/Server/junit.jar"
        ssh -n -q "rm -f \"$ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT\"/Future/Reportserver/commons-digester3-3.2-with-deps.jar"
        ssh -n -q "rm -f \"$ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT\"/Future/Reportserver/compass.jar"
        ssh -n -q "rm -f \"$ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT\"/Future/Reportserver/adhocLoader.jar"
        ssh -n -q "rm -f \"$ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT\"/Future/Reportserver/CCjetty.jar"
        ssh -n -q "rm -f \"$ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT\"/Future/Reportserver/ehcache-core.jar"
        ssh -n -q "rm -f \"$ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT\"/Future/Reportserver/milton-api-1.4.jar"
        ssh -n -q "rm -f \"$ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT\"/Future/Reportserver/adhocClient.jar"
        ssh -n -q "rm -f \"$ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT\"/Future/Reportserver/slf4j-simple-1.5.6.jar"
        ssh -n -q "rm -f \"$ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT\"/Future/Reportserver/gwt-servlet.jar"
        ssh -n -q "rm -f \"$ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT\"/Future/Reportserver/milton-servlet-1.4.jar"
        ssh -n -q "rm -f \"$ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT\"/Future/Reportserver/TableLayout.jar"
        ssh -n -q "rm -f \"$ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT\"/Future/Reportserver/jhall.jar"
        ssh -n -q "rm -f \"$ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT\"/Future/Reportserver/Designer.jar"
        ssh -n -q "rm -f \"$ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT\"/Future/Reportserver/jsp-api-2.0.jar"
        ssh -n -q "rm -f \"$ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT\"/Future/Reportserver/mime-util.jar"
        ssh -n -q "rm -f \"$ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT\"/Future/Reportserver/swing-layout.jar"
        ssh -n -q "rm -f \"$ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT\"/Future/Reportserver/jortho.jar"
        ssh -n -q "rm -f \"$ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT\"/Future/Reportserver/SBSTutorial.jar"
        ssh -n -q "rm -f \"$ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT\"/Future/Reportserver/gwt-servlet-deps.jar"
        ssh -n -q "rm -f \"$ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT\"/Future/Reportserver/CCLib.jar"
        ssh -n -q "rm -f \"$ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT\"/Future/Reportserver/CCjetty-util.jar"
        ssh -n -q "rm -f \"$ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT\"/Future/Reportserver/webdavclient4j-core-0.92.jar"
        ssh -n -q "rm -f \"$ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT\"/Future/Reportserver/commons-httpclient-3.0.1.jar"
        ssh -n -q "rm -f \"$ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT\"/Future/Reportserver/JnlpDesigner.jar"
        ssh -n -q "rm -f \"$ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT\"/Future/Reportserver/commons-codec-1.3.jar"
        ssh -n -q "rm -f \"$ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT\"/Future/Reportserver/jdom-1.0.jar"
        ssh -n -q "rm -f \"$ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT\"/Future/Reportserver/commons-net-3.0.1.jar"
        ssh -n -q "rm -f \"$ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT\"/Future/Reportserver/lucene-core.jar"
    fi
}

# ******************* Main ********************
# $1 - Environment
# $2 - Component: all / srv / webapps / webapps_parallel / webserver_only / delete_web_server
unset ABSAPPSERVER
export GFDEPALREADYSTARTED="no"
export TERM=linux

if [ "$2" == "reports" ]
then
    export ABSMESSAGE="Updating Report Server"; absmenu_log
	binrep_updateloop $1 $2 rep
fi

if [ "$2" == "heapspace" ]
then
	binrep_updateloop $1 $2 app 
	###e.g: binrep_updateloop ilu heapspace app
	binrep_updateloop $1 $2 rep 
	###e.g: binrep_updateloop ilu heapspace rep
	binrep_updateloop $1 $2 web_heap 
	###e.g: binrep_updateloop ilu heapspace web_heap
fi

if [ "$2" == "license" ]
then
    export ABSMESSAGE="Updating licenses"; absmenu_log
    binrep_updateloop $1 $2 lic
fi

if [ "$2" == "fonts" ]
then
    export ABSMESSAGE="Deploying fonts"; absmenu_log
    deploy_fonts $1
fi

if [ "$2" == "http_https" ]
then
    export ABSMESSAGE="Make Application and Report Server HTTP/HTTPS"; absmenu_log
    . $ABSMENUPATH/bin/make_http_https.sh $1
fi

if [ "$2" == "abs_encryption_key" ]
then
    export ABSMESSAGE="Install ABS Encryption Key"; absmenu_log
    . $ABSMENUPATH/bin/abs_encryption_key.sh $1
fi

if [ "$2" == "abs_deploy_certificates" ]
then
    export ABSMESSAGE="Deploy Server Certificates Online"; absmenu_log
    . $ABSMENUPATH/bin/abs_deploy_certificates.sh $1
fi

if [ "$2" == "webapps" ]
then
    export ABSMESSAGE="Updating Web applications"; absmenu_log
    export ABSMESSAGE="    make sure application server is running"; absmenu_log
    . $ABSMENUPATH/bin/service_administration.sh appstart
fi

if [ "$2" == "srv" -o "$2" == "all" ]
then
    export ABSMESSAGE="Updating Application Server"; absmenu_log
    [ $ABSSOLUTENUMVERSION -ge 90000 ] && check_repository_for_old_junk
	binrep_updateloop $1 $2 app
	if [ "$UNATTENDED_SCRIPTRUN" == "yes" ]
	then
		. $ABSMENUPATH/bin/service_administration.sh startupdate
		[ $? -eq 1 ] && return 1
	elif [ "$SCRIPTQUESTIONDONE" == "N" ]
	then
        export ABSMESSAGE="Waiting for update scripts to finish (manual confirmation)"; absmenu_log
		echo
		echo
		echo "***********************************************************************"
		echo "If there are any update scripts to run, then please start a Application server GUI"
		echo "(in a new session) and run the scripts now. After you completely"
		echo "finished running all the scripts that need running, press enter in"
		echo "this session to start the application servers and continue the"
		echo "software distribution"
		read -p "*********************************************************************** " ABSM_SCRIPTPAUSE
		echo
		echo
		export SCRIPTQUESTIONDONE=Y
    fi
	export ABSMESSAGE="Updating Report Server"; absmenu_log
	binrep_updateloop $1 $2 rep
	export ABSMESSAGE="Starting application and report servers"; absmenu_log				
	. $ABSMENUPATH/bin/service_administration.sh appstart
	[ $? -ne 0 ] && return 1
	. $ABSMENUPATH/bin/service_administration.sh repstart
	binrep_updateloop $1 $2 client
fi

case "$2" in 
	all) 				[ $GFPARALLELENABLE == "Y" ] && start_web_deploy_parallel $1 || binrep_updateloop $1 $2 web
						;;
	webapps)   			binrep_updateloop $1 $2 web
						;;
	webapps_parallel)	start_web_deploy_parallel $1
						;;
	webserver_only)		start_webserver_deploy_parallel $1
						;;
	delete_web_server)	delete_web_server_parallel $1
						;;
	restart_web_server)	restart_web_server_parallel $1
						;;
esac

export ABSMESSAGE="Replicate future repository to current repository"; absmenu_log
###echo "Replicate Future repository to Current repository"
export ABSMESSAGE="First checking if there is ../Future/Web in the repository server $ABSMENUREPOSITORYSERVER $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT "; absmenu_log
###echo $ABSMESSAGE

export FUTUREWEBEXISTS="TRUE"
if [ "$ABS_ROOTSERVER" == "$ABSMENUREPOSITORYSERVER" ] 
then
	[ ! -d $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Future/Web ] && export FUTUREWEBEXISTS="FALSE"
else
	[ ssh -n -q $ABSMENUREPOSITORYSERVER "[ ! -d $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Future/Web ]" ] && export FUTUREWEBEXISTS="FALSE"
fi

export ABSMESSAGE="Future web environment exists: $FUTUREWEBEXISTS"; absmenu_log
###echo $ABSMESSAGE

# Glassfish 4.1.1
[ "$ABSM_WEB_VERSION" == "411" ] && export WEBSRVNAME="glass"
# New Payara 2022
[ "$ABSM_WEB_VERSION" == "55" ] && export WEBSRVNAME="glass"
# Old Payara 2020
[ "$ABSM_WEB_VERSION" == "56" ] && export WEBSRVNAME="glass"
# Tomee8
[ "$ABSM_WEB_VERSION" == "8" ] && export WEBSRVNAME="web"	
# Tomee91
[ "$ABSM_WEB_VERSION" == "91" ] && export WEBSRVNAME="tomee"
# Tomcat90
[ "$ABSM_WEB_VERSION" == "90" ] && export WEBSRVNAME="tomcat"
# Tomcat9
[ "$ABSM_WEB_VERSION" == "9" ] && export WEBSRVNAME="tomcat9"
# Tomcat10
[ "$ABSM_WEB_VERSION" == "10" ] && export WEBSRVNAME="tomcat10"

if [ "$ABS_ROOTSERVER" == "$ABSMENUREPOSITORYSERVER" ] 
then
	[ ! -d $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Current/Server ] && mkdir -p $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Current/Server
	[ ! -d $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Current/LICENSE ] && mkdir -p $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Current/LICENSE
	[ ! -d $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Current/Reportserver ] && mkdir -p $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Current/Reportserver
	[ ! -d $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Current/CUSTOMREPORTS ] && mkdir -p $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Current/CUSTOMREPORTS
	[ ! -d $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Current/FONTS ] && mkdir -p $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Current/FONTS
	[ ! -d $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Current/CERTIFICATES ] && mkdir -p $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Current/CERTIFICATES
	###[ $FUTUREWEBEXISTS == "TRUE" ] && echo "Check ../Current/Web => create folder Current/Web"
	[ ! -d $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Current/Web ] && mkdir -p $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Current/Web
	rsync -ta --delete -e "ssh -q" $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Future/Server/* $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Current/Server
	rsync -ta --delete -e "ssh -q" $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Future/LICENSE/* $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Current/LICENSE
	rsync -ta --delete -e "ssh -q" $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Future/Reportserver/* $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Current/Reportserver
	rsync -ta --delete -e "ssh -q" $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Future/CUSTOMREPORTS/* $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Current/CUSTOMREPORTS
	rsync -ta --delete -e "ssh -q" $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Future/FONTS/* $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Current/FONTS
	rsync -ta --delete -e "ssh -q" $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Future/CERTIFICATES/* $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Current/CERTIFICATES
	###echo "FUTUREWEBEXISTS = $FUTUREWEBEXISTS rsync"
	[ $FUTUREWEBEXISTS == "TRUE" ] && rsync -ta --delete -e "ssh -q" $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Future/Web/* $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Current/Web
else
	echo -n .
	ssh -n -q $ABSMENUREPOSITORYSERVER "[ ! -d $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Current/Server ] && mkdir -p $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Current/Server"
	echo -n .
	ssh -n -q $ABSMENUREPOSITORYSERVER "[ ! -d $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Current/LICENSE ] && mkdir -p $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Current/LICENSE"
	echo -n .
	ssh -n -q $ABSMENUREPOSITORYSERVER "[ ! -d $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Current/Reportserver ] && mkdir -p $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Current/Reportserver"
	echo -n .
	ssh -n -q $ABSMENUREPOSITORYSERVER "[ ! -d $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Current/CUSTOMREPORTS ] && mkdir -p $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Current/CUSTOMREPORTS"
	echo -n .
	ssh -n -q $ABSMENUREPOSITORYSERVER "[ ! -d $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Current/FONTS ] && mkdir -p $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Current/FONTS"
	echo -n .
	ssh -n -q $ABSMENUREPOSITORYSERVER "[ ! -d $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Current/CERTIFICATES ] && mkdir -p $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Current/CERTIFICATES"
	echo -n .
	[ $FUTUREWEBEXISTS == "TRUE" ] && ssh -n -q $ABSMENUREPOSITORYSERVER "[ ! -d $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Current/Web ] && mkdir -p $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Current/Web"
	echo .
	ssh -n -q $ABSMENUREPOSITORYSERVER "rsync -ta --delete -e \"ssh -q\" $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Future/Server/* $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Current/Server"
	echo -n .
	ssh -n -q $ABSMENUREPOSITORYSERVER "rsync -ta --delete -e \"ssh -q\" $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Future/LICENSE/* $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Current/LICENSE"
	echo -n .
	ssh -n -q $ABSMENUREPOSITORYSERVER "rsync -ta --delete -e \"ssh -q\" $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Future/Reportserver/* $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Current/Reportserver"
	echo -n .
	ssh -n -q $ABSMENUREPOSITORYSERVER "rsync -ta --delete -e \"ssh -q\" $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Future/CUSTOMREPORTS/* $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Current/CUSTOMREPORTS"
	echo -n .
	ssh -n -q $ABSMENUREPOSITORYSERVER "rsync -ta --delete -e \"ssh -q\" $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Future/FONTS/* $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Current/FONTS"
	echo -n .
	ssh -n -q $ABSMENUREPOSITORYSERVER "rsync -ta --delete -e \"ssh -q\" $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Future/CERTIFICATES/* $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Current/CERTIFICATES"
	echo -n .
	[ $FUTUREWEBEXISTS == "TRUE" ] && ssh -n -q $ABSMENUREPOSITORYSERVER "rsync -ta --delete -e \"ssh -q\" $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Future/Web/* $ABSMENUREPOSITORYLOCATION/$ABSMENU_CURRENT_ENVIRONMENT/Current/Web"
fi
