Skip to content

Instantly share code, notes, and snippets.

@rduarte
Created December 8, 2009 14:01
Show Gist options
  • Save rduarte/251653 to your computer and use it in GitHub Desktop.
Save rduarte/251653 to your computer and use it in GitHub Desktop.
#!/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"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment