aboutsummaryrefslogtreecommitdiff
path: root/share
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2016-10-23 14:27:22 -0200
committerSilvio Rhatto <rhatto@riseup.net>2016-10-23 14:27:22 -0200
commit536c33213619751b41519049ac2d12a29ab553ff (patch)
tree9b4d8fad8ae82d64bef0ce66d34089e07e0492bc /share
parent17487c2cb97c3a4c4a945dfe813d86bc111866b7 (diff)
downloadhydra-536c33213619751b41519049ac2d12a29ab553ff.tar.gz
hydra-536c33213619751b41519049ac2d12a29ab553ff.tar.bz2
Sync-media: handle git-only repositories
Diffstat (limited to 'share')
-rwxr-xr-xshare/hydractl/sync-media29
1 files changed, 21 insertions, 8 deletions
diff --git a/share/hydractl/sync-media b/share/hydractl/sync-media
index 39b1ab3..c486ff7 100755
--- a/share/hydractl/sync-media
+++ b/share/hydractl/sync-media
@@ -191,15 +191,21 @@ for folder in `ls $CACHE`; do
if [ ! -z "$DRIVE" ]; then
mkdir -p $VOLUME/$MEDIA
- if [ -d "$CACHE/$folder/.git/annex" ]; then
+ if [ -d "$CACHE/$folder/.git" ]; then
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 && git config sync-media.getall true && \
- cd $CACHE/$folder && git remote add $DRIVE $VOLUME/$MEDIA/$folder
+ git clone $CACHE/$folder && cd $folder && sync_media_identity && git remote rename origin $HOST
+ cd $CACHE/$folder && git remote add $DRIVE $VOLUME/$MEDIA/$folder
)
+
+ if [ -d "$CACHE/$folder/.git/annex" ]; then
+ (
+ cd $VOLUME/$MEDIA
+ git annex init $DRIVE && git config sync-media.getall true
+ )
+ fi
fi
elif [ ! -d "$VOLUME/$MEDIA/$folder" ]; then
mkdir -p $VOLUME/$MEDIA/$folder
@@ -233,7 +239,7 @@ if [ ! -z "$DRIVE" ] && [ -d "$VOLUME/$MEDIA" ]; then
sync_media_dropunused
#git annex drop --auto --numcopies=2
)
- elif [ -d "$CACHE/$folder" ]; then
+ elif [ -d "$CACHE/$folder" ] && [ ! -d "$CACHE/$folder/.git" ]; then
# Avoid those configured to be skipped
if [ ! -e "$CACHE/$folder/.sync-media/skip" ]; then
echo "Syncing $CACHE/$folder with $VOLUME/$MEDIA/$folder..."
@@ -252,13 +258,20 @@ if [ ! -z "$DRIVE" ] && [ -d "$VOLUME/$MEDIA" ]; then
# Ensure the local cache has each repository listed in the removable media
if [ ! -d "$CACHE/$folder" ]; then
- if [ -d "$VOLUME/$MEDIA/$folder/.git/annex" ]; then
+ if [ -d "$VOLUME/$MEDIA/$folder/.git" ]; then
(
cd $CACHE
echo "Initializing $CACHE/$folder..."
- git clone $VOLUME/$MEDIA/$folder && cd $folder && sync_media_identity && git annex init $HOST && \
- git remote rename origin $REMOTE && cd $VOLUME/$MEDIA/$folder && git remote add $HOST $CACHE/$folder
+ git clone $VOLUME/$MEDIA/$folder && cd $folder && sync_media_identity && git remote rename origin $REMOTE
+ cd $VOLUME/$MEDIA/$folder && git remote add $HOST $CACHE/$folder
)
+
+ if [ -d "$VOLUME/$MEDIA/$folder/.git/annex" ]; then
+ (
+ cd $CACHE
+ git annex init $HOST
+ )
+ fi
else
echo "Syncing $VOLUME/$MEDIA/$folder into $CACHE/$folder..."
rsync -av --delete --exclude=.sync-media $VOLUME/$MEDIA/$folder/ $CACHE/$folder/