aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2016-06-24 15:12:17 -0300
committerSilvio Rhatto <rhatto@riseup.net>2016-06-24 15:12:17 -0300
commitcbc1885cf22182952d0a1b31779c89cff26decd4 (patch)
treea41659187dfb60643e157a36bbb189ea6c6d36cd
parent30529ff43974ce04ddbe6cc801564b79e75bcc1d (diff)
downloadhydra-cbc1885cf22182952d0a1b31779c89cff26decd4.tar.gz
hydra-cbc1885cf22182952d0a1b31779c89cff26decd4.tar.bz2
Support networks both with and without superprojects
-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"