From c4b22590e9ac6ce18b585262a9dea2647ae84ad6 Mon Sep 17 00:00:00 2001 From: Silvio Rhatto Date: Thu, 17 Apr 2014 22:20:31 -0300 Subject: Fix identity and check remote at sync-media --- files/sync-media | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/files/sync-media b/files/sync-media index ca5884b..79a1059 100644 --- a/files/sync-media +++ b/files/sync-media @@ -7,11 +7,21 @@ DISK="$1" VOLUME="/media/$DISK" CACHE="/var/cache/media" DOMAIN="`facter domain`" +HOST="`facter hostname`" MEDIA="media.$DOMAIN" INCOMING="$CACHE/incoming" WHOAMI="`whoami`" OPTIONS="$*" +# Fix identity +function sync_media_identity { + if [ -z "`git config user.email`" ] || [ -z "`git config user.name`" ]; then + repo="$(basename `pwd`)" + git config user.name "$repo asset manager" + git config user.email "$repo@assset.manager" + fi +} + # Add files into the annex function sync_media_add { git annex add . @@ -75,6 +85,7 @@ if [ -d "$CACHE" ]; then ( cd $CACHE/$folder echo "Syncing $CACHE/$folder..." + sync_media_identity sync_media_add git annex sync @@ -128,6 +139,13 @@ if [ ! -z "$DRIVE" ] && [ -d "$VOLUME/$MEDIA" ]; then ( cd $VOLUME/$MEDIA/$folder echo "Syncing $VOLUME/$MEDIA/$folder..." + + # Check remote + if ! git remote | grep -q "^$HOST$"; then + git remote add $HOST $CACHE/$folder + fi + + sync_media_identity sync_media_add git annex sync git annex get . --numcopies=3 -- cgit v1.2.3