]> gitweb.fluxo.info Git - hydra.git/commitdiff
Remote destination support at sync-media-export
authorSilvio Rhatto <rhatto@riseup.net>
Sun, 2 Oct 2016 20:01:43 +0000 (17:01 -0300)
committerSilvio Rhatto <rhatto@riseup.net>
Sun, 2 Oct 2016 20:01:43 +0000 (17:01 -0300)
share/hydractl/sync-media-export

index 7b47639d5c3212e6f8cec3d2c3f1830fbb67ca54..8647acc1882a0af55c3b11b6899b3bd4e35d98ea 100755 (executable)
@@ -1,6 +1,6 @@
 #!/bin/bash
 #
-# Copy git-annex repositories to remote server.
+# Copy git-annex repositories to remote destination.
 #
 
 # Parameters
@@ -23,15 +23,23 @@ for file in `ls $MEDIA`; do
 
     cd $MEDIA
 
-    if ssh $DESTINATION if [ -d \"/var/cache/media/$file\" ] \; then echo exists\; fi | grep -q exists; then
-      echo "Remote $file already exists, skipping..."
-      continue;
-    fi
+    # Check for remote or local destinations
+    if [ ! -d "$DESTINATION" ]; then
+      if ssh $DESTINATION if [ -d \"/var/cache/media/$file\" ] \; then echo exists\; fi | grep -q exists; then
+        echo "Remote $file already exists, skipping..."
+        continue;
+      fi
 
-    git clone $file $file.git && \
-    rsync -avz $file.git/ $DESTINATION:/var/cache/media/$file/ && \
-    rm -rf $file.git
-    echo ""
+      git clone $file $file.git && \
+      rsync -avz $file.git/ $DESTINATION:/var/cache/media/$file/ && \
+      rm -rf $file.git
+      echo ""
+    else
+      mkdir -p $DESTINATION/var/cache/media
+      if [ ! -d "$DESTINATION/var/cache/media/$FILE" ]; then
+        ( cd $DESTINATION/var/cache/media && git clone $MEDIA/$file )
+      fi
+    fi
     )
   fi
 done