summaryrefslogtreecommitdiff
path: root/share
diff options
context:
space:
mode:
Diffstat (limited to 'share')
-rwxr-xr-xshare/hydractl/sync-media39
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