::
- 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).
# 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"
# 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