changeset 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 809ba4a960bc
files scripts/training.sh
diffstat 1 files changed, 28 insertions(+), 24 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/training.sh	Tue Feb 02 21:24:28 2016 +0000
+++ b/scripts/training.sh	Thu Feb 04 22:39:09 2016 +0000
@@ -5,33 +5,37 @@
 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
+
+	prefix=${3:+$3-}
 
-     for i in $(eval echo {01..${2:-10}}); do
-    	mkdir -p $BASEDIR/training-$i
-     done
+	mkdir -p $BASEDIR/${prefix}training-00/config
+	
+	if [ ! -f $BASEDIR/${prefix}training-00/config/application.properties ]; then	    
+		echo "application.admin.password=training" > ${prefix}training-00/config/application.properties
+		echo "application.admin.reset=true" >> ${prefix}training-00/config/application.properties
+		echo "cache.config.file=ehcache-compact.xml" >> ${prefix}training-00/config/application.properties	
+	fi
+	
+    for i in $(eval echo {01..${2:-10}}); do
+    	mkdir -p $BASEDIR/${prefix}training-$i
+    done
 
-     for t in $( ls -d training-* ); do
-        if [ ! $t == "training-00" ]; then
+    for t in $( ls -d *training-* ); do
+        if [ ! $t == "${prefix}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
-
+			echo $t
+			
+			mkdir -p ${BASEDIR}/$t/config
+			cp ${BASEDIR}/${prefix}training-00/config/application.properties ${BASEDIR}/$t/config/application.properties
+		   
+		   	sed "s/${prefix}training-00/$t/g" ${prefix}training-00/docker-compose.yml > $t/docker-compose.yml		   
+			if [ -f $BASEDIR/${prefix}training-00/docker-compose.override.yml ]; then
+				sed "s/${prefix}training-00/$t/g" ${prefix}training-00/docker-compose.override.yml > $t/docker-compose.override.yml
+			fi
+		   
         fi 
-     done
-
-     ;;
+    done
+    ;;
 
   compose)
 
@@ -59,7 +63,7 @@
 
   *)
       echo "usage:"
-      echo "  create  [n:-10]          creates training-nn configs based on training-00 directory"
+      echo "  create  [n:-10] [prefix] 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"
    ;;