diff options
author | Silvio Rhatto <rhatto@riseup.net> | 2016-10-02 18:50:12 -0300 |
---|---|---|
committer | Silvio Rhatto <rhatto@riseup.net> | 2016-10-02 18:50:12 -0300 |
commit | 605585e80640077de889eae58a59283aaffabde5 (patch) | |
tree | 5c14a4938e550807d755781ee63dcc4b18572c9d /share/hydractl | |
parent | 46e00518dec147c889d2d9e1a20d0dc1806ee7e6 (diff) | |
download | hydra-605585e80640077de889eae58a59283aaffabde5.tar.gz hydra-605585e80640077de889eae58a59283aaffabde5.tar.bz2 |
Sync-media: unison support
Diffstat (limited to 'share/hydractl')
-rwxr-xr-x | share/hydractl/sync-media | 39 |
1 files changed, 27 insertions, 12 deletions
diff --git a/share/hydractl/sync-media b/share/hydractl/sync-media index e8f01dd..3045ae2 100755 --- a/share/hydractl/sync-media +++ b/share/hydractl/sync-media @@ -1,8 +1,13 @@ #!/bin/bash # -# sync-media assets using git-annex or rsync +# Sync media assets. # +# Load +source $APP_BASE/lib/hydra/functions || exit 1 +hydra_config_load + +# Parameters REMOTE="$1" VOLUME="/media/$REMOTE" DOMAIN="`facter domain`" @@ -13,6 +18,10 @@ INCOMING="$CACHE/incoming" WHOAMI="`whoami`" OPTIONS="$*" +# Dependencies +hydra_install_package rsync +hydra_install_package unison + # Fix identity function sync_media_identity { if [ -z "`git config --local user.email`" ] || [ -z "`git config --local user.name`" ]; then @@ -224,14 +233,17 @@ if [ ! -z "$DRIVE" ] && [ -d "$VOLUME/$MEDIA" ]; then elif [ -d "$CACHE/$folder" ]; then # Avoid those configured to be skipped if [ ! -e "$CACHE/$folder/.sync-media/skip" ]; then + echo "Syncing $CACHE/$folder with $VOLUME/$MEDIA/$folder..." + unison $CACHE/$folder $VOLUMER/$MEDIA/$folder -auto + # Avoid empty source folders - if [ ! -z "`ls -1 $CACHE/$folder`" ]; then - echo "Syncing $CACHE/$folder into $VOLUME/$MEDIA/$folder..." - rsync -av --delete --exclude=.sync-media $CACHE/$folder/ $VOLUME/$MEDIA/$folder/ - elif [ ! -z "`ls -1 $VOLUME/$MEDIA/$folder`" ]; then - echo "Syncing $VOLUME/$MEDIA/$folder into $CACHE/$folder..." - rsync -av --delete --exclude=.sync-media $VOLUME/$MEDIA/$folder/ $CACHE/$folder/ - fi + #if [ ! -z "`ls -1 $CACHE/$folder`" ]; then + # echo "Syncing $CACHE/$folder into $VOLUME/$MEDIA/$folder..." + # rsync -av --delete --exclude=.sync-media $CACHE/$folder/ $VOLUME/$MEDIA/$folder/ + #elif [ ! -z "`ls -1 $VOLUME/$MEDIA/$folder`" ]; then + # echo "Syncing $VOLUME/$MEDIA/$folder into $CACHE/$folder..." + # rsync -av --delete --exclude=.sync-media $VOLUME/$MEDIA/$folder/ $CACHE/$folder/ + #fi fi fi @@ -266,11 +278,14 @@ elif [ ! -z "$REMOTE" ]; then git annex sync ) else + echo "Syncing $CACHE/$folder with ssh://$REMOTE.$DOMAIN/$CACHE/$folder..." + unison $CACHE/$folder ssh://$REMOTE.$DOMAIN/$CACHE/$folder/ -auto + # Avoid empty source folders or those configured to be skipped - if [ ! -e "$CACHE/$folder/.sync-media/skip" ] && [ ! -z "`ls -1 $CACHE/$folder`" ]; then - echo "Syncing $CACHE/$folder into $REMOTE.$DOMAIN:$CACHE/$folder..." - rsync -av --delete --exclude=.sync-media $CACHE/$folder/ $REMOTE.$DOMAIN:$CACHE/$folder/ - fi + #if [ ! -e "$CACHE/$folder/.sync-media/skip" ] && [ ! -z "`ls -1 $CACHE/$folder`" ]; then + # echo "Syncing $CACHE/$folder into $REMOTE.$DOMAIN:$CACHE/$folder..." + # rsync -av --delete --exclude=.sync-media $CACHE/$folder/ $REMOTE.$DOMAIN:$CACHE/$folder/ + #fi fi done fi |