Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env bash
- #
- # Push the build to the deployment source location
- #
- #
- #------------------------------------------------------------------------------
- # Defaults
- #------------------------------------------------------------------------------
- target_hosts="dev01 dev02 dev-3"
- approot="/opt/company/myapp/"
- #------------------------------------------------------------------------------
- # Parse options and overrides
- #------------------------------------------------------------------------------
- usage () {
- echo
- echo "$0"
- echo "Deploy to target hosts"
- echo
- echo "Usage:"
- echo " [-t 'HOST_LIST']"
- echo
- echo "Examples:"
- echo "$0"
- echo "$0 -t 'host01'"
- echo "$0 -t 'host02 host05'"
- echo
- }
- while getopts ":t:" Option
- do
- case $Option in
- t ) target_hosts="$OPTARG";;
- * ) usage; exit 1; ;;
- esac
- done
- shift $(($OPTIND - 1))
- #------------------------------------------------------------------------------
- # Main
- #------------------------------------------------------------------------------
- deploy () {
- target="$1"
- echo "::>----------------------------------------------------------------"
- echo "::> Deploying new build to $target"
- echo "::>----------------------------------------------------------------"
- echo "::> syncing dre-rover changes"
- rsync -avz --delete-after \
- --exclude=.gitignore \
- --exclude=.otherfile \
- --exclude=myapp/somedir/ \
- $approot/ root@$target:$approot/
- echo "::> deploy complete"
- };
- echo -n "::> "; date
- for target_host in $target_hosts; do
- deploy "$target_host"
- done
- echo -n "::> "; date
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement