Merge "Improve coverage of cadi-core"
[aaf/authz.git] / auth / auth-cass / docker / dinstall.sh
1 #!/bin/bash 
2 DOCKER=/usr/bin/docker
3
4 if [ "`$DOCKER ps -a | grep aaf_cass`" == "" ]; then
5   $DOCKER run --name aaf_cass  -d cassandra:3.11
6   echo "aaf_cass Starting"
7   for CNT in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15; do
8      if [ "`$DOCKER container logs aaf_cass | grep 'listening for CQL clients'`" == "" ]; then
9                 echo "Sleep 10"
10         sleep 10
11      else 
12         break
13      fi
14   done
15   echo "Check for running Docker Container aaf_cass, then run again."
16   exit
17 fi 
18
19 sleep 20
20 echo "Running containers"
21 $DOCKER container ps
22
23 echo "Creating /opt/app/cass_init dir on aaf_cass"
24 $DOCKER exec aaf_cass mkdir -p /opt/app/cass_init
25 echo "cp the following files to /opt/app/cass_init dir on aaf_cass"
26 ls ../src/main/cql
27 $DOCKER cp "../src/main/cql/." aaf_cass:/opt/app/cass_init
28 echo "The following files are on /opt/app/cass_init dir on aaf_cass"
29 $DOCKER exec -it aaf_cass ls /opt/app/cass_init
30
31 echo "Docker Installed Basic Cassandra on aaf_cass.  Executing the following "
32 echo "NOTE: This creator provided is only a Single Instance. For more complex Cassandra, create independently"
33 echo ""
34 echo " cd /opt/app/cass_init"  
35 echo " cqlsh -u root -p root -f keyspace.cql"
36 echo " cqlsh -u root -p root -f init.cql"
37 echo " cqlsh -u root -p root -f osaaf.cql"
38 echo ""
39 echo "The following will give you a temporary identity with which to start working, or emergency"
40 echo " cqlsh -u root -p root -f temp_identity.cql"
41 echo "Create Keyspaces and Tables"
42 $DOCKER exec -it aaf_cass bash -c '\
43 cd /opt/app/cass_init; \
44 echo "Creating Keyspace";cqlsh -u root -p root -f keyspace.cql;\
45 echo "Creating init";cqlsh -u root -p root -f init.cql;\
46 echo "Creating osaaf";cqlsh -u root -p root -f osaaf.cql;\
47 echo "Creating temp Identity";cqlsh -u root -p root -f temp_identity.cql'
48
49 echo "Inspecting aafcassadra.  Use to get the IP address to update org.osaaf.cassandra.props"
50 $DOCKER inspect aaf_cass | grep '"IPAddress' | head -1