]> gitweb.fluxo.info Git - puppet-backup.git/commitdiff
Fix identity and check remote at sync-media
authorSilvio Rhatto <rhatto@riseup.net>
Fri, 18 Apr 2014 01:20:31 +0000 (22:20 -0300)
committerSilvio Rhatto <rhatto@riseup.net>
Fri, 18 Apr 2014 01:20:31 +0000 (22:20 -0300)
files/sync-media

index ca5884bc6ba589521a6f794780b894731d5e4459..79a1059756b96650c5ce36493af0aee29b3f6dd1 100644 (file)
@@ -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