Mercurial > public > ssdt-docker
diff scripts/training.sh @ 40:ef52df9248de
add training setup helper script
author | Dave smith <smith@nwoca.org> |
---|---|
date | Thu, 21 Jan 2016 11:37:30 -0500 |
parents | |
children | dfbb643b82a3 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/scripts/training.sh Thu Jan 21 11:37:30 2016 -0500 @@ -0,0 +1,68 @@ +#!/bin/bash + +BASEDIR=$PWD + +case "$1" in + + create) + + if [ ! -f $BASEDIR/training-00/docker-compose.override.yml ]; then + echo "no override file in training-00" + exit 0 + fi + if [ ! -f $BASEDIR/training-00/config/application.properties ]; then + echo "application.admin.password=training" > training-00/config/application.properties + echo "application.admin.reset=true" >> training-00/config/application.properties + fi + + for i in $(eval echo {01..${2:-10}}); do + mkdir -p $BASEDIR/training-$i + done + + for t in $( ls -d training-* ); do + if [ ! $t == "training-00" ]; then + + echo $t + ln -sf ${BASEDIR}/training-00/docker-compose.yml ${BASEDIR}/$t/docker-compose.yml + mkdir -p ${BASEDIR}/$t/config + cp ${BASEDIR}/training-00/config/application.properties ${BASEDIR}/$t/config/application.properties + sed "s/training-00/$t/g" training-00/docker-compose.override.yml > $t/docker-compose.override.yml + + fi + done + + ;; + + compose) + + for t in $( ls -d training-* ); do + cd $BASEDIR/$t + docker-compose ${*:2} + done + ;; + + reset) + + for t in $( ls -d training-* ); do + cd $BASEDIR/$t + + docker-compose stop + docker-compose rm -f usasdb uspsdb + docker-compose up -d usasdb uspsdb + sleep 30 # delay to allow database startup and restore + docker-compose up -d + sleep 60 # delay to prevent overwhelming host + + done + ;; + + + *) + echo "usage:" + echo " create [n:-10] creates training-nn configs based on training-00 directory" + echo " compose {cmd} [args...] executes docker compose command on each training instance" + echo " reset resets training database on each training instance" + ;; +esac +echo "done" +cd $BASEDIR