Mercurial > public > ssdt-docker
annotate scripts/training.sh @ 68:2418f77afad2
fix argument
author | smith@nwoca.org |
---|---|
date | Fri, 18 Mar 2016 01:12:11 +0100 |
parents | e155908fa039 |
children |
rev | line source |
---|---|
40 | 1 #!/bin/bash |
2 | |
3 BASEDIR=$PWD | |
4 | |
5 case "$1" in | |
6 | |
7 create) | |
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
smith@nwoca.org
parents:
46
diff
changeset
|
8 |
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
smith@nwoca.org
parents:
46
diff
changeset
|
9 prefix=${3:+$3-} |
40 | 10 |
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
smith@nwoca.org
parents:
46
diff
changeset
|
11 mkdir -p $BASEDIR/${prefix}training-00/config |
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
smith@nwoca.org
parents:
46
diff
changeset
|
12 |
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
smith@nwoca.org
parents:
46
diff
changeset
|
13 if [ ! -f $BASEDIR/${prefix}training-00/config/application.properties ]; then |
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
smith@nwoca.org
parents:
46
diff
changeset
|
14 echo "application.admin.password=training" > ${prefix}training-00/config/application.properties |
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
smith@nwoca.org
parents:
46
diff
changeset
|
15 echo "application.admin.reset=true" >> ${prefix}training-00/config/application.properties |
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
smith@nwoca.org
parents:
46
diff
changeset
|
16 echo "cache.config.file=ehcache-compact.xml" >> ${prefix}training-00/config/application.properties |
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
smith@nwoca.org
parents:
46
diff
changeset
|
17 fi |
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
smith@nwoca.org
parents:
46
diff
changeset
|
18 |
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
smith@nwoca.org
parents:
46
diff
changeset
|
19 for i in $(eval echo {01..${2:-10}}); do |
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
smith@nwoca.org
parents:
46
diff
changeset
|
20 mkdir -p $BASEDIR/${prefix}training-$i |
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
smith@nwoca.org
parents:
46
diff
changeset
|
21 done |
40 | 22 |
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
smith@nwoca.org
parents:
46
diff
changeset
|
23 for t in $( ls -d *training-* ); do |
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
smith@nwoca.org
parents:
46
diff
changeset
|
24 if [ ! $t == "${prefix}training-00" ]; then |
40 | 25 |
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
smith@nwoca.org
parents:
46
diff
changeset
|
26 echo $t |
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
smith@nwoca.org
parents:
46
diff
changeset
|
27 |
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
smith@nwoca.org
parents:
46
diff
changeset
|
28 mkdir -p ${BASEDIR}/$t/config |
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
smith@nwoca.org
parents:
46
diff
changeset
|
29 cp ${BASEDIR}/${prefix}training-00/config/application.properties ${BASEDIR}/$t/config/application.properties |
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
smith@nwoca.org
parents:
46
diff
changeset
|
30 |
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
smith@nwoca.org
parents:
46
diff
changeset
|
31 sed "s/${prefix}training-00/$t/g" ${prefix}training-00/docker-compose.yml > $t/docker-compose.yml |
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
smith@nwoca.org
parents:
46
diff
changeset
|
32 if [ -f $BASEDIR/${prefix}training-00/docker-compose.override.yml ]; then |
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
smith@nwoca.org
parents:
46
diff
changeset
|
33 sed "s/${prefix}training-00/$t/g" ${prefix}training-00/docker-compose.override.yml > $t/docker-compose.override.yml |
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
smith@nwoca.org
parents:
46
diff
changeset
|
34 fi |
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
smith@nwoca.org
parents:
46
diff
changeset
|
35 |
40 | 36 fi |
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
smith@nwoca.org
parents:
46
diff
changeset
|
37 done |
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
smith@nwoca.org
parents:
46
diff
changeset
|
38 ;; |
40 | 39 |
40 compose) | |
41 | |
46 | 42 for t in $( ls -d *training-* ); do |
40 | 43 cd $BASEDIR/$t |
44 docker-compose ${*:2} | |
45 done | |
46 ;; | |
47 | |
48 reset) | |
49 | |
46 | 50 for t in $( ls -d *training-* ); do |
40 | 51 cd $BASEDIR/$t |
52 | |
53 docker-compose stop | |
65
e155908fa039
improve import and training scripts. include all containers in info
smith@nwoca.org
parents:
47
diff
changeset
|
54 docker-compose rm -f usasdb uspsdb usasapp uspsapp |
40 | 55 docker-compose up -d usasdb uspsdb |
56 sleep 30 # delay to allow database startup and restore | |
57 docker-compose up -d | |
58 sleep 60 # delay to prevent overwhelming host | |
59 | |
60 done | |
61 ;; | |
62 | |
63 | |
64 *) | |
65 echo "usage:" | |
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
smith@nwoca.org
parents:
46
diff
changeset
|
66 echo " create [n:-10] [prefix] creates training-nn configs based on training-00 directory" |
40 | 67 echo " compose {cmd} [args...] executes docker compose command on each training instance" |
68 echo " reset resets training database on each training instance" | |
69 ;; | |
70 esac | |
71 echo "done" | |
72 cd $BASEDIR |