Mercurial > public > ssdt-docker
comparison 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 |
comparison
equal
deleted
inserted
replaced
39:297b56dfba19 | 40:ef52df9248de |
---|---|
1 #!/bin/bash | |
2 | |
3 BASEDIR=$PWD | |
4 | |
5 case "$1" in | |
6 | |
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 | |
18 for i in $(eval echo {01..${2:-10}}); do | |
19 mkdir -p $BASEDIR/training-$i | |
20 done | |
21 | |
22 for t in $( ls -d training-* ); do | |
23 if [ ! $t == "training-00" ]; then | |
24 | |
25 echo $t | |
26 ln -sf ${BASEDIR}/training-00/docker-compose.yml ${BASEDIR}/$t/docker-compose.yml | |
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 | |
31 fi | |
32 done | |
33 | |
34 ;; | |
35 | |
36 compose) | |
37 | |
38 for t in $( ls -d training-* ); do | |
39 cd $BASEDIR/$t | |
40 docker-compose ${*:2} | |
41 done | |
42 ;; | |
43 | |
44 reset) | |
45 | |
46 for t in $( ls -d training-* ); do | |
47 cd $BASEDIR/$t | |
48 | |
49 docker-compose stop | |
50 docker-compose rm -f usasdb uspsdb | |
51 docker-compose up -d usasdb uspsdb | |
52 sleep 30 # delay to allow database startup and restore | |
53 docker-compose up -d | |
54 sleep 60 # delay to prevent overwhelming host | |
55 | |
56 done | |
57 ;; | |
58 | |
59 | |
60 *) | |
61 echo "usage:" | |
62 echo " create [n:-10] creates training-nn configs based on training-00 directory" | |
63 echo " compose {cmd} [args...] executes docker compose command on each training instance" | |
64 echo " reset resets training database on each training instance" | |
65 ;; | |
66 esac | |
67 echo "done" | |
68 cd $BASEDIR |