aboutsummaryrefslogtreecommitdiff
path: root/files/sync-media-init
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2013-05-31 15:38:59 -0300
committerSilvio Rhatto <rhatto@riseup.net>2013-05-31 15:38:59 -0300
commit3e2b07f09b0cde2fbc2a7a7c2cfcf88452945583 (patch)
tree96ebd2b0d63bdcb68e02732f0cfe05f6d0b9f969 /files/sync-media-init
parent21723c5e2a0426eef1e87d65fd356505f0046648 (diff)
downloadpuppet-backup-3e2b07f09b0cde2fbc2a7a7c2cfcf88452945583.tar.gz
puppet-backup-3e2b07f09b0cde2fbc2a7a7c2cfcf88452945583.tar.bz2
Adding sync-media-expor and sync-media-init
Diffstat (limited to 'files/sync-media-init')
-rw-r--r--files/sync-media-init43
1 files changed, 43 insertions, 0 deletions
diff --git a/files/sync-media-init b/files/sync-media-init
new file mode 100644
index 0000000..e16dbf0
--- /dev/null
+++ b/files/sync-media-init
@@ -0,0 +1,43 @@
+#!/bin/bash
+#
+# Add git-annex remotes to repository in removable media.
+#
+
+# Parameters
+BASENAME="`basename $0`"
+VOLUME="$1"
+DOMAIN="`facter DOMAIN`"
+MEDIA="/media/$VOLUME/media.$DOMAIN"
+#REMOTE_BOXES=""
+#REMOTE_VOLUMES=""
+
+# Syntax check
+if [ -z "$VOLUME" ]; then
+ echo "usage: $BASENAME <VOLUME>"
+ exit 1
+fi
+
+# Process each repository
+for file in `ls $MEDIA`; do
+ if [ -d "$MEDIA/$file/.git/annex" ]; then
+ (
+ echo Processing "$MEDIA/$file..."
+ cd $MEDIA/$file
+ echo "Removing origin..."
+ git remote rm origin
+ git annex init $VOLUME
+
+ for remote in $REMOTE_BOXES; do
+ echo "Adding /var/cache/$remote/media/$file remote..."
+ git remote add $remote /var/cache/$remote/media/$file
+ done
+
+ for remote in $REMOTE_VOLUMES; do
+ echo "Adding /media/$remote/media.$DOMAIN/$file..."
+ git remote add $remote /media/$remote/media.$DOMAIN/$file
+ done
+
+ echo ""
+ )
+ fi
+done