aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--files/sync-media18
1 files changed, 18 insertions, 0 deletions
diff --git a/files/sync-media b/files/sync-media
index ca5884b..79a1059 100644
--- a/files/sync-media
+++ b/files/sync-media
@@ -7,11 +7,21 @@ DISK="$1"
VOLUME="/media/$DISK"
CACHE="/var/cache/media"
DOMAIN="`facter domain`"
+HOST="`facter hostname`"
MEDIA="media.$DOMAIN"
INCOMING="$CACHE/incoming"
WHOAMI="`whoami`"
OPTIONS="$*"
+# Fix identity
+function sync_media_identity {
+ if [ -z "`git config user.email`" ] || [ -z "`git config user.name`" ]; then
+ repo="$(basename `pwd`)"
+ git config user.name "$repo asset manager"
+ git config user.email "$repo@assset.manager"
+ fi
+}
+
# Add files into the annex
function sync_media_add {
git annex add .
@@ -75,6 +85,7 @@ if [ -d "$CACHE" ]; then
(
cd $CACHE/$folder
echo "Syncing $CACHE/$folder..."
+ sync_media_identity
sync_media_add
git annex sync
@@ -128,6 +139,13 @@ if [ ! -z "$DRIVE" ] && [ -d "$VOLUME/$MEDIA" ]; then
(
cd $VOLUME/$MEDIA/$folder
echo "Syncing $VOLUME/$MEDIA/$folder..."
+
+ # Check remote
+ if ! git remote | grep -q "^$HOST$"; then
+ git remote add $HOST $CACHE/$folder
+ fi
+
+ sync_media_identity
sync_media_add
git annex sync
git annex get . --numcopies=3