aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--files/sync-media-init34
1 files changed, 26 insertions, 8 deletions
diff --git a/files/sync-media-init b/files/sync-media-init
index 72ed9e1..aee3541 100644
--- a/files/sync-media-init
+++ b/files/sync-media-init
@@ -6,15 +6,16 @@
# Parameters
BASENAME="`basename $0`"
VOLUME="$1"
+TYPES="$2"
DOMAIN="`facter DOMAIN`"
HOST="`facter hostname`"
-#LOCAL_BOXES=""
-#LOCAL_VOLUMES=""
-#REMOTE_BOXES=""
+CACHES=""
+VOLUMES=""
+BOXES=""
# Syntax check
if [ -z "$VOLUME" ]; then
- echo "usage: $BASENAME <VOLUME>"
+ echo "usage: $BASENAME <volume> [<caches|volumes|boxes> [remotes]]"
exit 1
fi
@@ -25,6 +26,19 @@ else
MEDIA="/media/$VOLUME/media.$DOMAIN"
fi
+# Determine remote type
+shift 2
+if [ "$TYPES" == 'caches' ]; then
+ # Remotes are caches of local boxes
+ CACHES="$*"
+elif [ "$TYPES" == 'volumes' ]; then
+ # Remotes are removable media
+ VOLUMES="$*"
+elif [ "$TYPES" == 'boxes' ]; then
+ # Remotes are remote boxes
+ BOXES="$*"
+fi
+
# Process each repository
for file in `ls $MEDIA`; do
if [ -d "$MEDIA/$file/.git" ]; then
@@ -41,18 +55,22 @@ for file in `ls $MEDIA`; do
git annex init $VOLUME
fi
- for remote in $LOCAL_BOXES; do
+ for remote in $CACHES; do
echo "Adding /var/cache/$remote/media/$file remote..."
git remote add $remote /var/cache/$remote/media/$file
done
- for remote in $LOCAL_VOLUMES; do
+ for remote in $VOLUMES; do
echo "Adding /media/$remote/media.$DOMAIN/$file..."
git remote add $remote /media/$remote/media.$DOMAIN/$file
done
- for remote in $REMOTE_BOXES; do
- echo "Adding /var/cache/$remote/media/$file remote..."
+ for remote in $BOXES; do
+ if ! echo $remote | grep -q '\.'; then
+ remote="$remote.$DOMAIN"
+ fi
+
+ echo "Adding ssh://$remote/var/cache/media/$file..."
git remote add $remote ssh://$remote/var/cache/media/$file
done