Created
July 28, 2013 23:32
-
-
Save blbradley/6100716 to your computer and use it in GitHub Desktop.
Deploy over SFTP, for those moments when your host tells you to go fuck yourself.
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/sh | |
# Requirements: | |
# Install expect and make sure it's on your path | |
# sftp with working '-r' option | |
GIT_DIR=$1 | |
HOST=$2 | |
PASSWORD=$3 | |
if [ ! -d "$GIT_DIR" ] ; then | |
echo "First argument is not a directory. Exiting..." | |
exit 1 | |
fi | |
DIRS=`cd $GIT_DIR && git ls-files | sed 's:[^/]*$::'| sed '/^$/d' | sort -u` | |
FILES=`cd $GIT_DIR && git ls-files` | |
expect - <<END | |
set timeout -1 | |
spawn sftp -r $HOST | |
expect password: | |
send "$PASSWORD\r" | |
expect sftp> | |
send "lcd $GIT_DIR\r" | |
foreach d { $DIRS } { | |
expect sftp> | |
send "mkdir \$d\r" | |
} | |
foreach f { $FILES } { | |
expect sftp> | |
send "put \$f\r" | |
} | |
expect sftp> | |
send "quit\r" | |
expect eof | |
exit 0 | |
END |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment