Skip to content

Instantly share code, notes, and snippets.

@akloboucnik
Created February 12, 2015 14:50
Show Gist options
  • Save akloboucnik/64744f3e4f202f9afd51 to your computer and use it in GitHub Desktop.
Save akloboucnik/64744f3e4f202f9afd51 to your computer and use it in GitHub Desktop.
Upload to instance
#!/bin/bash
# use to upload files in opt common to instance
# to usage with fswatch tool use like this:
# - copy to repository root
# - run: fswatch -0 . | xargs -0 -n1 -I {} ./uploadToInstance.sh {} akl-aa
#
# $1 - path to changed file
# $2 - instance hostname
# remove afplay part if not on mac
PWD=`pwd`
SOURCEFILE=$(echo $1 | sed "s_$PWD/__")
USER=${FREEIPA_USER:-`whoami`}
echo -n "$SOURCEFILE -> $USER@$2:/opt/common"
tar -c $SOURCEFILE \
| ssh $USER@$2 "sudo tar -x --no-same-owner -P -C /opt/common" &&
afplay "/System/Library/Sounds/Purr.aiff" && echo " ✓"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment