aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/management.rst6
-rw-r--r--doc/todo.rst1
-rw-r--r--lib/hydra/misc1
-rwxr-xr-xshare/hydra/init15
-rwxr-xr-xshare/hydra/sync2
5 files changed, 19 insertions, 6 deletions
diff --git a/doc/management.rst b/doc/management.rst
index 85427b8..e927337 100644
--- a/doc/management.rst
+++ b/doc/management.rst
@@ -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).
diff --git a/doc/todo.rst b/doc/todo.rst
index 5914024..607a4f4 100644
--- a/doc/todo.rst
+++ b/doc/todo.rst
@@ -1,6 +1,5 @@
TODO
====
-- init: version control in the superproject?
- metrics and alarms subsystem.
- deploy: lockfile.
diff --git a/lib/hydra/misc b/lib/hydra/misc
index 09fb3d7..894502d 100644
--- a/lib/hydra/misc
+++ b/lib/hydra/misc
@@ -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"
diff --git a/share/hydra/init b/share/hydra/init
index 4a6d0c1..a69e885 100755
--- a/share/hydra/init
+++ b/share/hydra/init
@@ -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
diff --git a/share/hydra/sync b/share/hydra/sync
index 9b1d097..f062c98 100755
--- a/share/hydra/sync
+++ b/share/hydra/sync
@@ -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"