]> gitweb.fluxo.info Git - hydra.git/commitdiff
Hydra: sync after init
authorSilvio Rhatto <rhatto@riseup.net>
Wed, 23 Oct 2013 00:57:56 +0000 (22:57 -0200)
committerSilvio Rhatto <rhatto@riseup.net>
Wed, 23 Oct 2013 00:57:56 +0000 (22:57 -0200)
share/hydra/init
share/hydra/sync

index 791d4e1f10de163547cebfd4ff6b41d36335cb28..81706038340cdff71dcfdc7f1879b32bf4ddffd0 100755 (executable)
@@ -22,10 +22,11 @@ hydra_config_load
 
 # Command line arguments
 BASEDIR="$1"
+REMOTE="$2"
 
 # Validation
 if [ -z "$BASEDIR" ]; then
-  echo "Usage: hydra [hydra] register <path>"
+  echo "Usage: hydra [hydra] init <path> [remote]"
   exit 1
 elif grep -q -e "^$HYDRA=" $CONFIG &> /dev/null; then
   echo "Hydra $HYDRA already defined"
@@ -41,14 +42,11 @@ mkdir -p $BASEDIR
 chmod 700 $BASEDIR
 echo "$HYDRA=\"$BASEDIR\"" >> $CONFIG
 
-# Puppet configuration
-echo "Searching for a puppet repository at $BASEDIR..."
-PUPPET="$(dirname `find $BASEDIR -name puppet.conf | tail -n 1` 2> /dev/null)"
-
-# TODO: setup or clone initial repositories
-
-if [ ! -z "$PUPPET" ]; then
-  echo "Found puppet repository at $PUPPET."
-  echo "PUPPET=$PUPPET" >> $PREFERENCES
+# Optional remote configuration
+if [ ! -z "$REMOTE" ]; then
+  echo "Using $REMOTE as private gitolite address."
+  echo "PRIVATE_REPOS=$REMOTE" >> $PREFERENCES
 fi
 
+# Setup or clone initial repositories
+hydra $HYDRA sync
index e3fb571794600477382e16848b3b76c9dfb55005..1c3724d28c731242fe5eb358a7d5c990c0322093 100755 (executable)
@@ -27,15 +27,21 @@ else
 fi
 
 # 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..."
 
+    # TODO: check if git-annex is installed
     if [ "$repository" == "bootless" ]; then
       ( cd $HYDRA_FOLDER/$repository && git annex sync )
     else
@@ -49,3 +55,16 @@ if [ "$UPDATE_KEYRINGER" != "no" ]; then
   echo "Syncing keyringer..."
   keyringer $HYDRA git pull
 fi
+
+# Update puppet configuration.
+if [ -z "$PUPPET" ]; then
+  echo "Searching for a puppet repository at $BASEDIR..."
+  PUPPET="$(dirname `find $BASEDIR -name puppet.conf | tail -n 1` 2> /dev/null)"
+
+  if [ ! -z "$PUPPET" ]; then
+    if ! grep -q -e "^PUPPET=" $PREFERENCES; then
+      echo "Found puppet repository at $PUPPET."
+      echo "PUPPET=$PUPPET" >> $PREFERENCES
+    fi
+  fi
+fi