Instrumental | 97083ef | 2018-04-25 15:22:38 -0500 | [diff] [blame] | 1 | #!/bin/bash |
Instrumental | 3926bb2 | 2018-05-19 08:15:14 -0500 | [diff] [blame] | 2 | if [ -e /usr/bin/docker ]; then |
| 3 | DOCKER=/usr/bin/docker |
| 4 | elif [ -e /usr/local/bin/docker ]; then |
| 5 | DOCKER=/usr/local/bin/docker |
| 6 | else |
| 7 | echo Docker not available in /usr/bin or /usr/local/bin |
| 8 | exit |
| 9 | fi |
Instrumental | 4ad4763 | 2018-07-13 15:49:26 -0500 | [diff] [blame] | 10 | |
| 11 | if [ "$($DOCKER volume ls | grep aaf_cass_data)" = "" ]; then |
| 12 | $DOCKER volume create aaf_cass_data |
| 13 | echo "Created Cassandra Volume aaf_cass_data" |
| 14 | fi |
| 15 | |
Instrumental | 1cbf57f | 2018-05-14 14:37:59 -0500 | [diff] [blame] | 16 | echo "Running DInstall" |
Instrumental | aab3128 | 2018-05-11 17:14:48 -0500 | [diff] [blame] | 17 | if [ "`$DOCKER ps -a | grep aaf_cass`" == "" ]; then |
Instrumental | 1cbf57f | 2018-05-14 14:37:59 -0500 | [diff] [blame] | 18 | echo "starting Cass from 'run'" |
Instrumental | 3926bb2 | 2018-05-19 08:15:14 -0500 | [diff] [blame] | 19 | # NOTE: These HEAP Sizes are minimal. Not set for full organizations. |
Instrumental | 4ad4763 | 2018-07-13 15:49:26 -0500 | [diff] [blame] | 20 | $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 |
Instrumental | 3926bb2 | 2018-05-19 08:15:14 -0500 | [diff] [blame] | 28 | # Set on local Disk |
| 29 | # -v /opt/app/cass:/var/lib/cassandra |
Instrumental | 4778684 | 2018-05-11 12:08:58 -0500 | [diff] [blame] | 30 | echo "aaf_cass Starting" |
Instrumental | c486733 | 2018-05-11 13:15:28 -0500 | [diff] [blame] | 31 | for CNT in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15; do |
Instrumental | aab3128 | 2018-05-11 17:14:48 -0500 | [diff] [blame] | 32 | if [ "`$DOCKER container logs aaf_cass | grep 'listening for CQL clients'`" == "" ]; then |
Instrumental | 3926bb2 | 2018-05-19 08:15:14 -0500 | [diff] [blame] | 33 | echo "Sleep 10" |
Instrumental | c486733 | 2018-05-11 13:15:28 -0500 | [diff] [blame] | 34 | sleep 10 |
| 35 | else |
Instrumental | c486733 | 2018-05-11 13:15:28 -0500 | [diff] [blame] | 36 | break |
| 37 | fi |
| 38 | done |
Instrumental | 1cbf57f | 2018-05-14 14:37:59 -0500 | [diff] [blame] | 39 | |
| 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 | |
Instrumental | 3926bb2 | 2018-05-19 08:15:14 -0500 | [diff] [blame] | 51 | 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" |
Instrumental | 9c8a8b0 | 2018-07-16 18:41:10 -0500 | [diff] [blame] | 59 | echo " cqlsh -f temp_identity.cql" |
Instrumental | 3926bb2 | 2018-05-19 08:15:14 -0500 | [diff] [blame] | 60 | 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 |
Instrumental | 1cbf57f | 2018-05-14 14:37:59 -0500 | [diff] [blame] | 70 | else |
| 71 | $DOCKER start aaf_cass |
| 72 | fi |