Skip to content

Instantly share code, notes, and snippets.

@raphiz
Last active August 29, 2015 14:25
Show Gist options
  • Save raphiz/a4d01ae4ca0d23d652f7 to your computer and use it in GitHub Desktop.
Save raphiz/a4d01ae4ca0d23d652f7 to your computer and use it in GitHub Desktop.
FTP Deplozment Script
#!/usr/bin/env bash
# Abort if a command fails!
set -e
DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
if [ ! -n "$HOST" ];then
echo "missing option \"HOST\", aborting"
exit 1
fi
if [ ! -n "$USER" ];then
echo "missing option \"USER\", aborting"
exit 1
fi
if [ ! -n "$PASSWORD" ];then
echo "missing option \"PASSWORD\", aborting"
exit 1
fi
if [ ! -n "$DIRECTORY" ];then
echo "missing option \"DIRECTORY\", aborting"
exit 1
fi
# Go into the directory, where the site was generated
cd "$DIR/_site/"
echo "Uploading..."
lftp -e "
open $HOST
set ssl:verify-certificate yes
set ftp:ssl-allow on
set cmd:fail-exit true
user $USER $PASSWORD
cd $DIRECTORY
mirror --reverse --delete --ignore-time --verbose --parallel . .
bye
"
# Complete!
echo "Done!"
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment