diff options
author | Silvio Rhatto <rhatto@riseup.net> | 2014-04-17 22:20:31 -0300 |
---|---|---|
committer | Silvio Rhatto <rhatto@riseup.net> | 2014-04-17 22:20:31 -0300 |
commit | c4b22590e9ac6ce18b585262a9dea2647ae84ad6 (patch) | |
tree | 24d7b24ba29f2fa6cb56f4f01604158c77a41bc8 /files | |
parent | 52913f4f34f699f9c680b99cc61a9273e759608f (diff) | |
download | puppet-backup-c4b22590e9ac6ce18b585262a9dea2647ae84ad6.tar.gz puppet-backup-c4b22590e9ac6ce18b585262a9dea2647ae84ad6.tar.bz2 |
Fix identity and check remote at sync-media
Diffstat (limited to 'files')
-rw-r--r-- | files/sync-media | 18 |
1 files changed, 18 insertions, 0 deletions
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 |