#!/bin/bash
export JAVA_HOME=/usr/local/java/jdk1.7.0_79
export JRE_HOME=/usr/local/java/jdk1.7.0_79/jre
tomcat_pid=`/usr/sbin/lsof -n -P -t -i :8080`
[ -n "$tomcat_pid" ] && kill -9 $tomcat_pid
sudo rm /usr/local/tomcat/apache-tomcat-7.0.75/webapps/apollo-rest.war
sudo rm -fr /usr/local/tomcat/apache-tomcat-7.0.75/webapps/apollo-rest
sudo rm /usr/local/tomcat/apache-tomcat-7.0.75/webapps/apollo-manager.war
sudo rm -fr /usr/local/tomcat/apache-tomcat-7.0.75/webapps/apollo-manager
sudo cp /var/lib/jenkins/jobs/apollo/workspace/apollo-rest/target/apollo-rest.war /usr/local/tomcat/apache-tomcat-7.0.75/webapps/
sudo cp /var/lib/jenkins/jobs/apollo/workspace/apollo-manager/target/apollo-manager.war /usr/local/tomcat/apache-tomcat-7.0.75/webapps/
cd /usr/local/tomcat/apache-tomcat-7.0.75/bin/
sudo ./startup.sh