aboutsummaryrefslogtreecommitdiff
path: root/files
diff options
context:
space:
mode:
Diffstat (limited to 'files')
-rw-r--r--files/sync-media75
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