Skip to content

Instantly share code, notes, and snippets.

@edgardleal
Created April 22, 2015 22:41
Show Gist options
  • Select an option

  • Save edgardleal/93cc7982db2b8b6cf7fc to your computer and use it in GitHub Desktop.

Select an option

Save edgardleal/93cc7982db2b8b6cf7fc to your computer and use it in GitHub Desktop.
#!/bin/bash
# # ~/.netrc
# machine ftp.example.com
# login user
# password secret
declare -r last_deploy_file=".last_deploy"
declare -r exclude="*.swp"
declare -r stop_deploy_file=".stop_deploy"
declare -r running_file=".running"
declare -r interval="3"
declare -r server="localhost"
function do_deploy()
{
declare files="$(find ./ -cnewer $last_deploy_file -type f)"
for i in $(echo $files)
do
if [ ! "$(echo $i | grep -v swp)" == "" ]; then
echo put $i | ftp $server
fi
done
touch $last_deploy_file
}
if [ "" == "$@" ]; then
do_deploy
else
if [ "$(echo $@ | grep -v 'start')" == "" ]; then
touch "$running_file"
while [ ! -f ${stop_deploy_file} ]
do
do_deploy
sleep $interval
done
rm "$stop_deploy_file"
rm "$running_file"
else
if [ "$(echo $@ | grep -v 'stop')" == "" ]; then
touch $stop_deploy_file
fi
fi
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment