Mercurial > public > ssdt-docker
comparison scripts/training.sh @ 47:a0283d218ff5
handle training instances with prefix in directory name. use docker-compose.yml as template instead of linking. set application property to reduce memory requirements
author | smith@nwoca.org |
---|---|
date | Thu, 04 Feb 2016 22:39:09 +0000 |
parents | dfbb643b82a3 |
children | e155908fa039 |
comparison
equal
deleted
inserted
replaced
46:dfbb643b82a3 | 47:a0283d218ff5 |
---|---|
3 BASEDIR=$PWD | 3 BASEDIR=$PWD |
4 | 4 |
5 case "$1" in | 5 case "$1" in |
6 | 6 |
7 create) | 7 create) |
8 | |
9 if [ ! -f $BASEDIR/training-00/docker-compose.override.yml ]; then | |
10 echo "no override file in training-00" | |
11 exit 0 | |
12 fi | |
13 if [ ! -f $BASEDIR/training-00/config/application.properties ]; then | |
14 echo "application.admin.password=training" > training-00/config/application.properties | |
15 echo "application.admin.reset=true" >> training-00/config/application.properties | |
16 fi | |
17 | 8 |
18 for i in $(eval echo {01..${2:-10}}); do | 9 prefix=${3:+$3-} |
19 mkdir -p $BASEDIR/training-$i | |
20 done | |
21 | 10 |
22 for t in $( ls -d training-* ); do | 11 mkdir -p $BASEDIR/${prefix}training-00/config |
23 if [ ! $t == "training-00" ]; then | 12 |
13 if [ ! -f $BASEDIR/${prefix}training-00/config/application.properties ]; then | |
14 echo "application.admin.password=training" > ${prefix}training-00/config/application.properties | |
15 echo "application.admin.reset=true" >> ${prefix}training-00/config/application.properties | |
16 echo "cache.config.file=ehcache-compact.xml" >> ${prefix}training-00/config/application.properties | |
17 fi | |
18 | |
19 for i in $(eval echo {01..${2:-10}}); do | |
20 mkdir -p $BASEDIR/${prefix}training-$i | |
21 done | |
24 | 22 |
25 echo $t | 23 for t in $( ls -d *training-* ); do |
26 ln -sf ${BASEDIR}/training-00/docker-compose.yml ${BASEDIR}/$t/docker-compose.yml | 24 if [ ! $t == "${prefix}training-00" ]; then |
27 mkdir -p ${BASEDIR}/$t/config | |
28 cp ${BASEDIR}/training-00/config/application.properties ${BASEDIR}/$t/config/application.properties | |
29 sed "s/training-00/$t/g" training-00/docker-compose.override.yml > $t/docker-compose.override.yml | |
30 | 25 |
26 echo $t | |
27 | |
28 mkdir -p ${BASEDIR}/$t/config | |
29 cp ${BASEDIR}/${prefix}training-00/config/application.properties ${BASEDIR}/$t/config/application.properties | |
30 | |
31 sed "s/${prefix}training-00/$t/g" ${prefix}training-00/docker-compose.yml > $t/docker-compose.yml | |
32 if [ -f $BASEDIR/${prefix}training-00/docker-compose.override.yml ]; then | |
33 sed "s/${prefix}training-00/$t/g" ${prefix}training-00/docker-compose.override.yml > $t/docker-compose.override.yml | |
34 fi | |
35 | |
31 fi | 36 fi |
32 done | 37 done |
33 | 38 ;; |
34 ;; | |
35 | 39 |
36 compose) | 40 compose) |
37 | 41 |
38 for t in $( ls -d *training-* ); do | 42 for t in $( ls -d *training-* ); do |
39 cd $BASEDIR/$t | 43 cd $BASEDIR/$t |
57 ;; | 61 ;; |
58 | 62 |
59 | 63 |
60 *) | 64 *) |
61 echo "usage:" | 65 echo "usage:" |
62 echo " create [n:-10] creates training-nn configs based on training-00 directory" | 66 echo " create [n:-10] [prefix] creates training-nn configs based on training-00 directory" |
63 echo " compose {cmd} [args...] executes docker compose command on each training instance" | 67 echo " compose {cmd} [args...] executes docker compose command on each training instance" |
64 echo " reset resets training database on each training instance" | 68 echo " reset resets training database on each training instance" |
65 ;; | 69 ;; |
66 esac | 70 esac |
67 echo "done" | 71 echo "done" |