Skip to content

Instantly share code, notes, and snippets.

@jep-a
Last active November 10, 2018 22:05
Show Gist options
  • Save jep-a/30aa6749bbfafb90f55347e67c830ff0 to your computer and use it in GitHub Desktop.
Save jep-a/30aa6749bbfafb90f55347e67c830ff0 to your computer and use it in GitHub Desktop.
rsync/unison sftp bootstrap script
#!/usr/bin/env bash
local_dir="./"
if [[ $1 == init ]]
then
bash -c "scp $2/.uniconfig ${local_dir}"
fi
config=".uniconfig"
if [[ ! -e $config ]]
then
echo "$config missing"
exit 1
fi
. $config
if [[ ! -v remote_name ]] || [[ ! -v remote_dir ]]
then
echo "remote missing"
exit 1
fi
if [[ $1 == init ]]
then
rsync_cmd="rsync -atvz $(printf -- " --exclude \"%s\"" ${ignore[*]}) ${remote_name}:${remote_dir} ${local_dir}"
bash -c "$rsync_cmd"
fi
unison_cmd="unison -perms=0 -ignorecase=true -repeat=watch $(printf -- " -ignore=\"Name {.*,*,*/,.*/}%s\"" ${ignore[*]}) ssh://${remote_name}/${remote_dir} ${local_dir}"
bash -c "$unison_cmd"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment