diff options
author | Silvio Rhatto <rhatto@riseup.net> | 2016-03-17 09:43:08 -0300 |
---|---|---|
committer | Silvio Rhatto <rhatto@riseup.net> | 2016-03-17 09:43:08 -0300 |
commit | fd6e3c990484489eb620659f5371cd0e728807c1 (patch) | |
tree | 80c02943b6f290b4c5c4fdd213deb0d775913b30 | |
parent | 135d249ee64b4af139329e8d06646b3772dd2fa7 (diff) | |
download | puppet-backup-fd6e3c990484489eb620659f5371cd0e728807c1.tar.gz puppet-backup-fd6e3c990484489eb620659f5371cd0e728807c1.tar.bz2 |
Put drive config in the begining of sync-media
-rw-r--r-- | files/sync-media | 75 |
1 files changed, 38 insertions, 37 deletions
diff --git a/files/sync-media b/files/sync-media index 64e3f02..5ff3c0f 100644 --- a/files/sync-media +++ b/files/sync-media @@ -67,6 +67,15 @@ if echo $OPTIONS | grep -q -- "--dropunused"; then DROPUNUSED="true" fi +# Set drive config +if [ ! -z "$REMOTE" ]; then + # Check storage media + MOUNT="`mount | grep $VOLUME`" + if [ ! -z "$MOUNT" ]; then + DRIVE="$(basename `echo $MOUNT | awk '{ print $1 }'`)" + fi +fi + # Commit changes if [ -d "$CACHE" ]; then # Fix cache permissions @@ -107,7 +116,7 @@ if [ -d "$CACHE" ]; then fi # Ensure we have a reference to the remote repository - if [ -d "$VOLUME/$MEDIA/$folder/git/.annex" ]; then + if [ ! -z "$DRIVE" ] && [ -d "$VOLUME/$MEDIA/$folder/git/.annex" ]; then # Check remote if ! git remote | grep -q "^$REMOTE$"; then git remote add $REMOTE $VOLUME/$MEDIA/$folder @@ -135,44 +144,36 @@ if [ -d "$CACHE" ]; then fi done - if [ ! -z "$REMOTE" ]; then - # Check storage media - MOUNT="`mount | grep $VOLUME`" - if [ ! -z "$MOUNT" ]; then - DRIVE="$(basename `echo $MOUNT | awk '{ print $1 }'`)" - fi + if [ ! -z "$DRIVE" ]; then + if [ ! -d "$VOLUME/$MEDIA" ]; then + echo "Folder $VOLUME/$MEDIA does not exist..." + else + for folder in `ls $CACHE`; do + if [ -d "$CACHE/$folder/.git/annex" ]; then + if [ "`git -C $CACHE/$folder config sync-media.skip`" == "true" ]; then + continue + fi - if [ ! -z "$DRIVE" ]; then - if [ ! -d "$VOLUME/$MEDIA" ]; then - echo "Folder $VOLUME/$MEDIA does not exist..." - else - for folder in `ls $CACHE`; do - if [ -d "$CACHE/$folder/.git/annex" ]; then - if [ "`git -C $CACHE/$folder config sync-media.skip`" == "true" ]; then - continue - fi - - #if [ "`git -C $CACHE/$folder config sync-media.ready`" != "true" ]; then - # echo "Skipping $CACHE/$folder: not sync-media ready, please config your repo." - # continue - #fi - - if [ ! -d "$VOLUME/$MEDIA/$folder" ]; then - ( - cd $VOLUME/$MEDIA - echo "Initializing $VOLUME/$MEDIA/$folder..." - git clone $CACHE/$folder && cd $folder && sync_media_identity && git annex init $DRIVE && \ - git remote rename origin $HOST && cd $CACHE/$folder && git remote add $DRIVE $VOLUME/$MEDIA/$folder - ) - fi - elif [ ! -d "$VOLUME/$MEDIA/$folder" ]; then - if [ ! -e "$CACHE/$folder/.sync-media/skip" ]; then - echo "Syncing $VOLUME/$MEDIA/$folder..." - rsync -av --delete --exclude=.sync-media $CACHE/$folder/ $VOLUME/$MEDIA/$folder/ - fi + #if [ "`git -C $CACHE/$folder config sync-media.ready`" != "true" ]; then + # echo "Skipping $CACHE/$folder: not sync-media ready, please config your repo." + # continue + #fi + + if [ ! -d "$VOLUME/$MEDIA/$folder" ]; then + ( + cd $VOLUME/$MEDIA + echo "Initializing $VOLUME/$MEDIA/$folder..." + git clone $CACHE/$folder && cd $folder && sync_media_identity && git annex init $DRIVE && \ + git remote rename origin $HOST && cd $CACHE/$folder && git remote add $DRIVE $VOLUME/$MEDIA/$folder + ) fi - done - fi + elif [ ! -d "$VOLUME/$MEDIA/$folder" ]; then + if [ ! -e "$CACHE/$folder/.sync-media/skip" ]; then + echo "Syncing $VOLUME/$MEDIA/$folder..." + rsync -av --delete --exclude=.sync-media $CACHE/$folder/ $VOLUME/$MEDIA/$folder/ + fi + fi + done fi fi fi |