Guest User

deploy-myapp.sh

a guest
Aug 4th, 2014
173
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/usr/bin/env bash
  2. #
  3. # Push the build to the deployment source location
  4. #
  5. #
  6.  
  7. #------------------------------------------------------------------------------
  8. # Defaults
  9. #------------------------------------------------------------------------------
  10. target_hosts="dev01 dev02 dev-3"
  11.  
  12. approot="/opt/company/myapp/"
  13.  
  14.  
  15. #------------------------------------------------------------------------------
  16. # Parse options and overrides
  17. #------------------------------------------------------------------------------
  18. usage () {
  19.     echo
  20.     echo "$0"
  21.     echo "Deploy to target hosts"
  22.     echo
  23.     echo "Usage:"
  24.     echo "   [-t 'HOST_LIST']"
  25.     echo
  26.     echo "Examples:"
  27.     echo "$0"
  28.     echo "$0 -t 'host01'"
  29.     echo "$0 -t 'host02 host05'"
  30.     echo
  31. }
  32.  
  33. while getopts ":t:" Option
  34. do
  35.     case $Option in
  36.         t ) target_hosts="$OPTARG";;
  37.         * ) usage; exit 1; ;;
  38.     esac
  39. done
  40. shift $(($OPTIND - 1))
  41.  
  42.  
  43. #------------------------------------------------------------------------------
  44. # Main
  45. #------------------------------------------------------------------------------
  46.  
  47. deploy () {
  48.     target="$1"
  49.  
  50.     echo "::>----------------------------------------------------------------"
  51.     echo "::> Deploying new build to $target"
  52.     echo "::>----------------------------------------------------------------"
  53.  
  54.     echo "::> syncing dre-rover changes"
  55.     rsync -avz --delete-after \
  56.         --exclude=.gitignore \
  57.         --exclude=.otherfile \
  58.         --exclude=myapp/somedir/ \
  59.         $approot/ root@$target:$approot/
  60.  
  61.     echo "::> deploy complete"
  62. };
  63.  
  64.  
  65. echo -n "::> "; date
  66.  
  67. for target_host in $target_hosts; do
  68.     deploy "$target_host"
  69. done
  70.  
  71. echo -n "::> "; date
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×