#!/bin/bash # # Copy repositories to remote destination. # # 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 # 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..." elif [ -d "$file/.git" ]; then # If remote destination, add a git post-receive hook git clone $file $file.git && \ cp -a $APP_BASE/lib/hydra/hooks/post-receive $file.git/.git/hooks/post-receive && \ rsync -avz $file.git/ $DESTINATION:/var/cache/media/$file/ && \ rm -rf $file.git else rsync -avz $file/ $DESTINATION:/var/cache/media/$file/ fi 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