Skip to content

Instantly share code, notes, and snippets.

@joeljuca
Created October 6, 2016 18:12
Show Gist options
  • Save joeljuca/ebcf06f4cf4754933ffe96db15babaa0 to your computer and use it in GitHub Desktop.
Save joeljuca/ebcf06f4cf4754933ffe96db15babaa0 to your computer and use it in GitHub Desktop.
#!/bin/bash
# settings
HOST='myapp.com.br'
USER='john'
BASE_PATH='/tomcat_home'
WEBAPPS_PATH="${PROJECT_PATH}/webapps"
# local steps
mvn package
scp path/to/my-app.war "${USER}@${HOST}:/tmp"
# remote steps
step_01="${BASE_PATH}/bin/shutdown.sh"
step_02="sleep 5"
step_03="rm -fR ${WEBAPPS_PATH}/MyApp ${WEBAPPS_PATH}/MyApp.war"
step_04="cp /tmp/my-app.war ${WEBAPPS_PATH}"
step_05="${BASE_PATH}/bin/startup.sh"
# execute remote steps into one single SSH tunnel
steps="${step_01}; ${step_02}; ${step_03}; ${step_04}; ${step_05}"
ssh "${USER}@${HOST}" "${commands}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment