comparison scripts/training.sh @ 90:63cb9be89a26 production v1.0.0

flow: Merged <release> 'v1.0.0' to <master> ('production').
author smith@nwoca.org
date Thu, 22 Sep 2016 01:49:20 +0100
parents e155908fa039
children
comparison
equal deleted inserted replaced
1:44f401c902ba 90:63cb9be89a26
1 #!/bin/bash
2
3 BASEDIR=$PWD
4
5 case "$1" in
6
7 create)
8
9 prefix=${3:+$3-}
10
11 mkdir -p $BASEDIR/${prefix}training-00/config
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
22
23 for t in $( ls -d *training-* ); do
24 if [ ! $t == "${prefix}training-00" ]; then
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
36 fi
37 done
38 ;;
39
40 compose)
41
42 for t in $( ls -d *training-* ); do
43 cd $BASEDIR/$t
44 docker-compose ${*:2}
45 done
46 ;;
47
48 reset)
49
50 for t in $( ls -d *training-* ); do
51 cd $BASEDIR/$t
52
53 docker-compose stop
54 docker-compose rm -f usasdb uspsdb usasapp uspsapp
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:"
66 echo " create [n:-10] [prefix] creates training-nn configs based on training-00 directory"
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