blob: 15b63483057f733b00baa9ca19612b66d6658fdc [file] [log] [blame]
Instrumental97083ef2018-04-25 15:22:38 -05001#!/bin/bash
Instrumentalaab31282018-05-11 17:14:48 -05002DOCKER=/usr/bin/docker
Instrumentalc4867332018-05-11 13:15:28 -05003
Instrumentalaab31282018-05-11 17:14:48 -05004if [ "`$DOCKER ps -a | grep aaf_cass`" == "" ]; then
5 $DOCKER run --name aaf_cass -d cassandra:3.11
Instrumental47786842018-05-11 12:08:58 -05006 echo "aaf_cass Starting"
Instrumentalc4867332018-05-11 13:15:28 -05007 for CNT in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15; do
Instrumentalaab31282018-05-11 17:14:48 -05008 if [ "`$DOCKER container logs aaf_cass | grep 'listening for CQL clients'`" == "" ]; then
Instrumentalc4867332018-05-11 13:15:28 -05009 echo "Sleep 10"
10 sleep 10
11 else
Instrumentalc4867332018-05-11 13:15:28 -050012 break
13 fi
14 done
Instrumentalaab31282018-05-11 17:14:48 -050015 echo "Check for running Docker Container aaf_cass, then run again."
16 exit
Instrumental47786842018-05-11 12:08:58 -050017fi
Instrumental71037c32018-03-26 13:51:48 -070018
Instrumentalaab31282018-05-11 17:14:48 -050019sleep 20
20echo "Running containers"
21$DOCKER container ps
Instrumentalc4867332018-05-11 13:15:28 -050022
Instrumentalaa7f4402018-05-11 16:03:52 -050023echo "Creating /opt/app/cass_init dir on aaf_cass"
Instrumentalaab31282018-05-11 17:14:48 -050024$DOCKER exec aaf_cass mkdir -p /opt/app/cass_init
Instrumentalaa7f4402018-05-11 16:03:52 -050025echo "cp the following files to /opt/app/cass_init dir on aaf_cass"
26ls ../src/main/cql
Instrumentalaab31282018-05-11 17:14:48 -050027$DOCKER cp "../src/main/cql/." aaf_cass:/opt/app/cass_init
Instrumentalaa7f4402018-05-11 16:03:52 -050028echo "The following files are on /opt/app/cass_init dir on aaf_cass"
Instrumentalaab31282018-05-11 17:14:48 -050029$DOCKER exec -it aaf_cass ls /opt/app/cass_init
Instrumentalf482ea02018-04-10 15:03:24 -050030
Instrumental71037c32018-03-26 13:51:48 -070031echo "Docker Installed Basic Cassandra on aaf_cass. Executing the following "
32echo "NOTE: This creator provided is only a Single Instance. For more complex Cassandra, create independently"
33echo ""
34echo " cd /opt/app/cass_init"
35echo " cqlsh -u root -p root -f keyspace.cql"
36echo " cqlsh -u root -p root -f init.cql"
37echo " cqlsh -u root -p root -f osaaf.cql"
38echo ""
39echo "The following will give you a temporary identity with which to start working, or emergency"
40echo " cqlsh -u root -p root -f temp_identity.cql"
Instrumental47786842018-05-11 12:08:58 -050041echo "Create Keyspaces and Tables"
Instrumentalaab31282018-05-11 17:14:48 -050042$DOCKER exec -it aaf_cass bash -c '\
Instrumental71037c32018-03-26 13:51:48 -070043cd /opt/app/cass_init; \
44echo "Creating Keyspace";cqlsh -u root -p root -f keyspace.cql;\
45echo "Creating init";cqlsh -u root -p root -f init.cql;\
46echo "Creating osaaf";cqlsh -u root -p root -f osaaf.cql;\
47echo "Creating temp Identity";cqlsh -u root -p root -f temp_identity.cql'
48
49echo "Inspecting aafcassadra. Use to get the IP address to update org.osaaf.cassandra.props"
Instrumentalaab31282018-05-11 17:14:48 -050050$DOCKER inspect aaf_cass | grep '"IPAddress' | head -1