Skip to content

Instantly share code, notes, and snippets.

@juanpujol
Last active December 10, 2015 09:49
Show Gist options
  • Save juanpujol/4416798 to your computer and use it in GitHub Desktop.
Save juanpujol/4416798 to your computer and use it in GitHub Desktop.
Quick deploy. Little shell script to connect and copy files to a server via SSH.
#!/bin/sh
# Execution:
# Without arguments the script will copy everythin on the $path
# ~ sh deploy.sh
#
# Or you can especify files or folders to copy via arguments.
# ~ sh deploy.sh index.html styles myfile.txt
# Folder:
# Remember to put the / after the name of the folder if you use this option.
# It can be an empty string if there's no folder.
# TODO - Work on coping the git tracked files from the log.
folder="app/"
git=false
domain="yourdomain.com"
user="username"
path="destination/path/to/copy/files"
files=()
if [ "$*" == "" ]; then
if [ "$git" == true ]; then
files+=`git log --pretty=format: --name-only $folder`
else
files+="$folder*"
fi
else
for i in $*
do
files+="$folder$i "
done
fi
echo Preparing to copy $files
echo Connecting to server. Please Wait...
scp -rp -c arcfour $files $user@$domain:$path
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment