aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2013-05-31 17:57:46 -0300
committerSilvio Rhatto <rhatto@riseup.net>2013-05-31 17:57:46 -0300
commitc2438e75d308517bd9cc692ac1036257be7911c0 (patch)
tree946c13cddd88adcda69db169a038f0b1d9359ab8
parent92600a1bfa402b596abb2e04bb51d565e9d5bf5e (diff)
downloadpuppet-backup-c2438e75d308517bd9cc692ac1036257be7911c0.tar.gz
puppet-backup-c2438e75d308517bd9cc692ac1036257be7911c0.tar.bz2
Command line support for adding remotes on sync-media-init
-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