Last active
September 23, 2017 17:11
-
-
Save rponte/6793599 to your computer and use it in GitHub Desktop.
Deploying a java app with shellscript through SSH - simple and efficient
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 | |
set -e # Exit script immediately on first error. | |
#set -x # Print commands and their arguments as they are executed. | |
# generate war file with ant or gradle or whatever you want | |
ant war | |
# upload the generated war file to the web server | |
scp -P 5122 target/war/MyApp-SNAPSHOT.war [email protected]:~/MyApp.war | |
# deploy the uploded war file in tomcat | |
ssh -p 5122 [email protected] 'bash -s' <<'ENDSSH' | |
pwd | |
tomcat_home/bin/shutdown.sh | |
sleep 5 | |
rm -rf tomcat_home/webapps/MyApp | |
rm -rf tomcat_home/webapps/MyApp.war | |
cp MyApp.war tomcat_home/webapps | |
tomcat_home/bin/startup.sh | |
ENDSSH |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment