-
-
Save jep-a/30aa6749bbfafb90f55347e67c830ff0 to your computer and use it in GitHub Desktop.
rsync/unison sftp bootstrap script
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
#!/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