public
Created

  • Download Gist
tomcat_war_deployment.sh
Shell
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
#!/bin/bash
##
# Deployment para Tomcat usando Git
##
 
# Configuração
WAR_DIR="/home/user/NetBeansProjects/project/dist"
WAR_FILE="project.war"
GIT_LOCAL="/home/user/git/project"
if [ "$1" = "root" ] ; then
TOMCAT_APP="/usr/local/tomcat/webapps/ROOT"
else
TOMCAT_APP="/usr/local/tomcat/webapps/project"
fi
 
# Ações
echo "1. Copiando arquivo war para área temporária"
cp $WAR_DIR/$WAR_FILE $GIT_LOCAL > /dev/null
cd $GIT_LOCAL > /dev/null
 
echo "2. Descompactando WAR"
jar xvf $WAR_FILE > /dev/null
rm $WAR_FILE > /dev/null
 
echo "3. Adicionando arquivos modificados no repositório Git"
git add .
git commit -a -m "`date`"
 
echo "4. Atualizando repositório online"
git push origin master
 
echo "5. Publicando alterações no Tomcat"
ssh stage "cd $TOMCAT_APP && git pull && /etc/init.d/tomcat restart && exit"

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.