Created
May 15, 2019 22:39
-
-
Save UlisseMini/6e576fde4891f4d19cc7525d3dade603 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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