Skip to content

Instantly share code, notes, and snippets.

@UlisseMini
Created May 15, 2019 22:39
Show Gist options
  • Save UlisseMini/6e576fde4891f4d19cc7525d3dade603 to your computer and use it in GitHub Desktop.
Save UlisseMini/6e576fde4891f4d19cc7525d3dade603 to your computer and use it in GitHub Desktop.
#!/bin/bash
set -e
# https://unix.stackexchange.com/questions/70615/bash-script-echo-output-in-box
function print() {
local s="$*"
tput setaf 3
echo " -${s//?/-}-
| ${s//?/ } |
| $(tput setaf 4)$s$(tput setaf 3) |
| ${s//?/ } |
-${s//?/-}-"
tput sgr 0
}
HOST="mydomain.com"
USER="username"
# directory to copy into on the remote host
TARGET="~/.builds/${PWD##*/}"
print "Copying source files to $HOST:$TARGET"
rsync -az --info=progress2 --delete . \
--rsync-path "mkdir -p $TARGET && rsync" \
-e "ssh -l '$USER'" "$HOST:$TARGET" \
print "Running '$@' on $HOST"
ssh "$USER@$HOST" \
"source ~/.profile ;\
cd $TARGET ;\
$@"
print "Copying files back from $HOST:$TARGET"
rsync -az --info=progress2 --delete \
-e "ssh -l '$USER'" "$HOST:$TARGET" .. \
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment