From 3e2b07f09b0cde2fbc2a7a7c2cfcf88452945583 Mon Sep 17 00:00:00 2001 From: Silvio Rhatto Date: Fri, 31 May 2013 15:38:59 -0300 Subject: Adding sync-media-expor and sync-media-init --- files/sync-media-export | 37 +++++++++++++++++++++++++++++++++++++ files/sync-media-init | 43 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 80 insertions(+) create mode 100644 files/sync-media-export create mode 100644 files/sync-media-init (limited to 'files') diff --git a/files/sync-media-export b/files/sync-media-export new file mode 100644 index 0000000..7b47639 --- /dev/null +++ b/files/sync-media-export @@ -0,0 +1,37 @@ +#!/bin/bash +# +# Copy git-annex repositories to remote server. +# + +# Parameters +BASENAME="`basename $0`" +DESTINATION="$1" +DOMAIN="`facter DOMAIN`" +MEDIA="/var/cache/media" + +# Syntax check +if [ -z "$DESTINATION" ]; then + echo "usage: $BASENAME " + 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 + + 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 "" + ) + fi +done 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 " + 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 -- cgit v1.2.3