Friday 29 April 2016

deploy and undeploy an application in JBoss EAP 6 through shell script

I have written a shell script to deploy and undeploy an application in JBoss EAP 6.

 Download the following script and store it in your linux machine.
 Provide the file permissions and ownership for this script as you see fit. In this example, they are:

[root@middlewaretech script]# chmod 755  install_uninstall_APP.sh
[root@middlewaretech script]# ls -ltr install_uninstall_APP.sh
-rwxr-xr-x 1 jboss dba 1172 Apr 29 22:36 install_uninstall_APP.sh

#!/bin/bash
JBOSS_HOME=/u03/local/opt/jboss-eap-6.2
DC=192.168.1.12
DC_port=9999

#---------------------
#application deployment.....
#---------------------
deploy()
{
echo -e  "\nPlease enter the \"EAR\" or \"WAR\" with obsolete path !!!"
read EAR
echo -e  "\nPlease enter the \"server_group\" !!!"
read server_group

$JBOSS_HOME/bin/jboss-cli.sh --connect --controller=$DC:$DC_port --command="deploy "$EAR" --server-groups="$server_group 2>&1
echo -e "\n "$EAR " has deployed suucessupply on "$server_group
}
#
---------------------
#application undeployment.....
#---------------------
undeploy()
{
echo -e  "\nPlease enter the \"EAR\" or \"WAR\"  !!!"
read EAR
echo -e  "\nPlease enter the \"server_group\" !!!"
read server_group
$JBOSS_HOME/bin/jboss-cli.sh --connect --controller=$DC:$DC_port --command="undeploy "$EAR" --server-groups="$server_group 2>&1

echo -e "\n "$EAR "has undeployed suucessupply from "$server_group
}

echo -e "please enter one of the option from deploy/undeploy"
read operation
if [[ $operation == "deploy" ]];
then
deploy
elif [[ $operation  == "undeploy" ]];
then
undeploy
else
echo -e "\n\n Thank You!!! Bye!!!\n\n"
exit 0;
fi;


Let see how this script will work

while script executing time this script will ask deploy/undeploy, WAR/EAR and server-group details

Application deployment
 

Application Undeployment

I
I hope this information is helpful to you