]> gitweb.fluxo.info Git - hydra.git/commitdiff
Hydra sync: fix keyringer routines (2)
authorSilvio Rhatto <rhatto@riseup.net>
Wed, 23 Oct 2013 01:21:37 +0000 (23:21 -0200)
committerSilvio Rhatto <rhatto@riseup.net>
Wed, 23 Oct 2013 01:21:37 +0000 (23:21 -0200)
share/hydra/sync

index ea191461e87e7ba3f5ffcbdefd6a3006231e7bfc..44f6f14a455a6138cd7e17bf8f0918e5180805ba 100755 (executable)
 source $APP_BASE/lib/hydra/functions || exit 1
 hydra_config_load
 
+# Sync each repository.
+function hydra_sync {
+  for repository in $*; do
+    if [ "$repository" == "keyringer" ]; then
+      UPDATE_KEYRINGER="yes"
+      continue
+    fi
+  
+    if [ ! -d "$HYDRA_FOLDER/$repository/.git" ]; then
+      git clone $PRIVATE_REPOS/$repository $HYDRA_FOLDER/$repository
+    fi
+  
+    if [ -d "$HYDRA_FOLDER/$repository/.git" ]; then
+      echo "Syncing $repository..."
+  
+      if [ "$repository" == "bootless" ]; then
+        ( cd $HYDRA_FOLDER/$repository && git annex sync )
+      else
+        ( cd $HYDRA_FOLDER/$repository && git pull origin master && git submodule update --init )
+      fi
+    fi
+  done
+}
+
 # Basic parameters.
 if [ -z "$1" ]; then
   REPOSITORIES="bootless dns gitolite/public gitolite/private gitosis/public gitosis/private puppet"
@@ -31,40 +55,18 @@ for req in git-annex; do
   hydra_install_package $req
 done
 
-# Sync each repository.
 # TODO: split between public and private repositories
-for repository in $REPOSITORIES; do
-  if [ "$repository" == "keyringer" ]; then
-    UPDATE_KEYRINGER="yes"
-    continue
-  fi
-
-  if [ ! -d "$HYDRA_FOLDER/$repository/.git" ]; then
-    git clone $PRIVATE_REPOS/$repository $HYDRA_FOLDER/$repository
-  fi
-
-  if [ -d "$HYDRA_FOLDER/$repository/.git" ]; then
-    echo "Syncing $repository..."
-
-    if [ "$repository" == "keyringer" ]; then
-      if ! which keyringer &> /dev/null; then
-        echo "Please install keyringer for a full hydra experience."
-      elif [ ! -e "$HOME/.keyringer/$HYDRA" ]; then
-        echo "Initializing keyring for $HYDRA..."
-        keyringer $HYDRA init $HYDRA_FOLDER/$repository
-      fi
-    fi
-
-    if [ "$repository" == "bootless" ]; then
-      ( cd $HYDRA_FOLDER/$repository && git annex sync )
-    else
-      ( cd $HYDRA_FOLDER/$repository && git pull origin master && git submodule update --init )
-    fi
-  fi
-done
+hydra_sync $REPOSITORIES
 
 # Update keyring.
 if [ "$UPDATE_KEYRINGER" != "no" ]; then
+  if ! which keyringer &> /dev/null; then
+    echo "Please install keyringer for a full hydra experience."
+  elif [ ! -e "$HOME/.keyringer/$HYDRA" ]; then
+    echo "Initializing keyring for $HYDRA..."
+    keyringer $HYDRA init $HYDRA_FOLDER/$repository
+  fi
+
   echo "Syncing keyringer..."
   keyringer $HYDRA git pull
 fi