Created
December 4, 2015 22:39
-
-
Save juanluisrp/8b3db94839ca6df69ac0 to your computer and use it in GitHub Desktop.
Update, compile and deploy GeoNetwork into Tomcat
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
GN_SOURCES=geonetwork | |
GN_PROFILES=env-prod | |
DEPLOY_NAME=geonetwork-ngr3 | |
GN_DATA_DIR=/var/local/geonetwork/${DEPLOY_NAME} | |
RED='\e[31m' | |
EC='\e[0m' | |
cd ${GN_SOURCES} | |
branch=$(git symbolic-ref HEAD | sed -e 's,.*/\(.*\),\1,') | |
echo -e "Updating branch ${RED}${branch}${EC}..." | |
read -p "Would you like to continue? (y/n) " accept | |
if [ "$accept" != "y" ]; then | |
echo -e "${RED}Deployment aborted${EC}" | |
exit -1 | |
fi | |
# Save local changes. | |
git stash save | |
# Pull branch from remote | |
git pull origin | |
# Apply the local changes | |
git stash pop | |
echo -e "${RED}Compiling ${GN_SOURCES}${EC}" | |
# Compile GN | |
mvn clean install -DskipTests -P${GN_PROFILES} | |
if [ $? -ne 0 ]; then | |
echo -e "${RED}mvn clean install FAILED${EC}" | |
exit -2 | |
fi | |
echo -e "${RED}Deleting old version and uncompressing WAR...${EC}" | |
cd .. | |
rm -rf ${DEPLOY_NAME} | |
unzip ${GN_SOURCES}/web/target/geonetwork.war -d ${DEPLOY_NAME} | |
echo -e "${RED}Stopping Tomcat, removing old deployed verion and cleaning wro4j cache...${EC}" | |
# Stop Tomcat, remove old deployed GN | |
service tomcat7 stop | |
rm -rf /var/lib/tomcat7/webapps/${DEPLOY_NAME} | |
# Delete wro4j cache | |
rm ${GN_DATA_DIR}/wro4j* | |
echo -e "${RED}Deploying new version and starting Tomcat...${EC}" | |
# Deploy the new GN version and start Tomcat | |
mv ${DEPLOY_NAME} /var/lib/tomcat7/webapps/ | |
service tomcat7 start |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment