]> gitweb.fluxo.info Git - hydra.git/commitdiff
Support networks both with and without superprojects
authorSilvio Rhatto <rhatto@riseup.net>
Fri, 24 Jun 2016 18:12:17 +0000 (15:12 -0300)
committerSilvio Rhatto <rhatto@riseup.net>
Fri, 24 Jun 2016 18:12:17 +0000 (15:12 -0300)
doc/management.rst
doc/todo.rst
lib/hydra/misc
share/hydra/init
share/hydra/sync

index 85427b819db3e0c308004e7a210f4ede7fcef3ca..e927337f55323846d5d547bf0a242cba5dae0589 100644 (file)
@@ -31,4 +31,8 @@ all the needed repositories and configurations to a local folder
 
 ::
 
-    hydra example init ~/file/example git@admin.example.org:example.git
+    hydra example init ~/file/example git@admin.example.org:
+
+This will try to fetch a superproject from git@admin.example.org:example.git
+-- if exists, plus submodules -- or each git repository used by a network
+previously created by the `init` action (`config.git`, `puppet.git`, etc).
index 5914024d3446ba415269e695e8fbbfa3250aa6c7..607a4f43c75ca8e39a5c59903d4c0d0b8e732a83 100644 (file)
@@ -1,6 +1,5 @@
 TODO
 ====
 
-- init: version control in the superproject?
 - metrics and alarms subsystem.
 - deploy: lockfile.
index 09fb3d79ee69a33a15406c1092513943be811396..894502dffaa63eead37b260fa55b22700c22eab4 100644 (file)
@@ -2,6 +2,7 @@
 
 # Set needed environment variables and do basic checks
 function hydra_set_env {
+  export BASEREPOS="config doc bootless dns git/public git/private puppet"
   export OSVERSION="`cut -d . -f 1 /etc/debian_version`"
   export COMMIT="`( cd $APP_BASE && git log -n 1 --pretty=oneline 2> /dev/null | cut -d " " -f 1 )`"
   export CONFIG="$HOME/.hydra/config"
index 4a6d0c1456ecd4946be3e020f084bc7d2aaa8f12..a69e885a868c00ec223c2ceb4c0b6d89052c2401 100755 (executable)
@@ -38,20 +38,29 @@ fi
 
 # Clone configuration repository or setup a new hydra
 if [ ! -z "$REMOTE" ]; then
-  git clone $REMOTE $BASEDIR
+  mkdir -p $BASEDIR
+
+  # Try to clone the superproject first
+  git clone $REMOTE $BASEDIR 2> /dev/null
 
   (
     cd $BASEDIR
 
     # Initialize only the required repositories
     for repo in $BASEREPOS; do
-      git submodule update --init $repo
+      if [ -e '.gitmodules' ] && grep -q \"config\" .gitmodules; then
+        git submodule update --init $repo
+      else
+        git clone ${REMOTE}$repo `basename $repo .git`
+      fi
     done
   )
 else
   # Create the superproject
   mkdir -p $BASEDIR
-  hydra_git_init $BASEDIR
+
+  # Optional: version control in the superproject
+  #hydra_git_init $BASEDIR
 
   # Create config repository
   if [ ! -d "$BASEDIR/config" ]; then
index 9b1d0971bd03323bb539662895708df226850ecc..f062c98ef94f6115b2c7d612fb91c55cbd82142a 100755 (executable)
@@ -67,7 +67,7 @@ function hydra_sync {
 
 # Basic parameters.
 if [ -z "$1" ]; then
-  REPOSITORIES="config doc bootless dns git/public git/private puppet"
+  REPOSITORIES="$BASEREPOS"
 else
   REPOSITORIES="$*"
   UPDATE_KEYRINGER="no"