diff options
author | Silvio Rhatto <rhatto@riseup.net> | 2023-10-01 15:18:26 -0300 |
---|---|---|
committer | Silvio Rhatto <rhatto@riseup.net> | 2023-10-01 15:18:26 -0300 |
commit | 312470869f99b72b8d1ec68376b3288ce575db0f (patch) | |
tree | abbe35321f6059c32cc797d0368ca33658ce9c91 /share/hydractl | |
parent | 8eda5834f48fc49f433e650949c934f69be6a6d5 (diff) | |
download | hydra-312470869f99b72b8d1ec68376b3288ce575db0f.tar.gz hydra-312470869f99b72b8d1ec68376b3288ce575db0f.tar.bz2 |
Feat: hydractl: sync-media: support for specifying a repository in the command line
Diffstat (limited to 'share/hydractl')
-rwxr-xr-x | share/hydractl/sync-media | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/share/hydractl/sync-media b/share/hydractl/sync-media index 09f7239..6486198 100755 --- a/share/hydractl/sync-media +++ b/share/hydractl/sync-media @@ -9,6 +9,7 @@ hydra_config_load # Parameters REMOTE="$1" +REPOSITORY="$2" VOLUME="/media/$REMOTE" DOMAIN="`facter domain`" HOST="`facter hostname`" @@ -182,8 +183,15 @@ $sudo chown $WHOAMI. $CACHE $sudo chown $WHOAMI. $CACHE/* sync_media_incoming_perms +# Check if a specific repository was passed via the command line +if [ -z "$REPOSITORY" ] && [ -d "$CACHE/$REPOSITORY" ] && ! echo "$REPOSITORY" | grep -q '--'; then + REPOSITORIES="$REPOSITORY" +else + REPOSITORIES="`ls $CACHE`" +fi + # Iterate over existing repositories in the local cache -for folder in `ls $CACHE`; do +for folder in $REPOSITORIES; do # Sync each repository in the local cache if [ -d "$CACHE/$folder/.git/annex" ]; then if [ "`git -C $CACHE/$folder config sync-media.skip`" == "true" ]; then @@ -237,8 +245,15 @@ done # Process removable or remote media if [ ! -z "$DRIVE" ] && [ -d "$VOLUME/$MEDIA" ]; then + # Check if a specific repository was passed via the command line + if [ -z "$REPOSITORY" ] && [ -d "$VOLUME/$MEDIA/$REPOSITORY" ] && ! echo "$REPOSITORY" | grep -q '--'; then + REPOSITORIES="$REPOSITORY" + else + REPOSITORIES="`ls $VOLUME/$MEDIA`" + fi + # Iterate over existing repositories in the removable media - for folder in `ls $VOLUME/$MEDIA`; do + for folder in $REPOSITORIES; do # Sync each local repository in the removable media if [ -d "$VOLUME/$MEDIA/$folder/.git/annex" ]; then |