blob: d6fcb9f94b0574ef1b930f7387cbf136db540d1f [file] [log] [blame]
Instrumental97083ef2018-04-25 15:22:38 -05001#!/bin/bash
Instrumental3926bb22018-05-19 08:15:14 -05002if [ -e /usr/bin/docker ]; then
3 DOCKER=/usr/bin/docker
4elif [ -e /usr/local/bin/docker ]; then
5 DOCKER=/usr/local/bin/docker
6else
7 echo Docker not available in /usr/bin or /usr/local/bin
8 exit
9fi
Instrumental4ad47632018-07-13 15:49:26 -050010
11if [ "$($DOCKER volume ls | grep aaf_cass_data)" = "" ]; then
12 $DOCKER volume create aaf_cass_data
13 echo "Created Cassandra Volume aaf_cass_data"
14fi
15
Instrumental1cbf57f2018-05-14 14:37:59 -050016echo "Running DInstall"
Instrumentalaab31282018-05-11 17:14:48 -050017if [ "`$DOCKER ps -a | grep aaf_cass`" == "" ]; then
Instrumental1cbf57f2018-05-14 14:37:59 -050018 echo "starting Cass from 'run'"
Instrumental3926bb22018-05-19 08:15:14 -050019 # NOTE: These HEAP Sizes are minimal. Not set for full organizations.
Instrumental4ad47632018-07-13 15:49:26 -050020 $DOCKER run \
21 --name aaf_cass \
22 -e HEAP_NEWSIZE=512M \
23 -e MAX_HEAP_SIZE=1024M \
24 -e CASSANDRA_DC=dc1 \
25 -e CASSANDRA_CLUSTER_NAME=osaaf \
26 --mount 'type=volume,src=aaf_cass_data,dst=/var/lib/cassandra,volume-driver=local' \
27 -d cassandra:3.11
Instrumental3926bb22018-05-19 08:15:14 -050028 # Set on local Disk
29 # -v /opt/app/cass:/var/lib/cassandra
Instrumental47786842018-05-11 12:08:58 -050030 echo "aaf_cass Starting"
Instrumentalc4867332018-05-11 13:15:28 -050031 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 -050032 if [ "`$DOCKER container logs aaf_cass | grep 'listening for CQL clients'`" == "" ]; then
Instrumental3926bb22018-05-19 08:15:14 -050033 echo "Sleep 10"
Instrumentalc4867332018-05-11 13:15:28 -050034 sleep 10
35 else
Instrumentalc4867332018-05-11 13:15:28 -050036 break
37 fi
38 done
Instrumental1cbf57f2018-05-14 14:37:59 -050039
40 echo "Running Phase 2 DInstall"
41 $DOCKER container ps
42
43 echo "Creating /opt/app/cass_init dir on aaf_cass"
44 $DOCKER exec aaf_cass mkdir -p /opt/app/cass_init
45 echo "cp the following files to /opt/app/cass_init dir on aaf_cass"
46 ls ../src/main/cql
47 $DOCKER cp "../src/main/cql/." aaf_cass:/opt/app/cass_init
48 echo "The following files are on /opt/app/cass_init dir on aaf_cass"
49 $DOCKER exec aaf_cass ls /opt/app/cass_init
50
Instrumental3926bb22018-05-19 08:15:14 -050051 if [ "`$DOCKER exec aaf_cass /usr/bin/cqlsh -e 'describe keyspaces' | grep authz`" == "" ]; then
52 echo "Docker Installed Basic Cassandra on aaf_cass. Executing the following "
53 echo "NOTE: This creator provided is only a Single Instance. For more complex Cassandra, create independently"
54 echo ""
55 echo " cd /opt/app/cass_init"
56 echo " cqlsh -f keyspace.cql"
57 echo " cqlsh -f init.cql"
58 echo " cqlsh -f osaaf.cql"
Instrumental9c8a8b02018-07-16 18:41:10 -050059 echo " cqlsh -f temp_identity.cql"
Instrumental3926bb22018-05-19 08:15:14 -050060 echo ""
61 echo "The following will give you a temporary identity with which to start working, or emergency"
62 echo " cqlsh -f temp_identity.cql"
63 echo "Create Keyspaces and Tables"
64 $DOCKER exec aaf_cass bash /usr/bin/cqlsh -f /opt/app/cass_init/keyspace.cql
65 $DOCKER exec aaf_cass bash /usr/bin/cqlsh -e 'describe keyspaces'
66 $DOCKER exec aaf_cass bash /usr/bin/cqlsh -f /opt/app/cass_init/init.cql
67 $DOCKER exec aaf_cass bash /usr/bin/cqlsh -f /opt/app/cass_init/osaaf.cql
68 $DOCKER exec aaf_cass bash /usr/bin/cqlsh -f /opt/app/cass_init/temp_identity.cql
69 fi
Instrumental1cbf57f2018-05-14 14:37:59 -050070else
71 $DOCKER start aaf_cass
72fi