3 # Engage normal Cass Init, then check for data installation
5 DIR="/opt/app/aaf/status"
6 INSTALLED_VERSION=/var/lib/cassandra/AAF_VERSION
7 AAF_INIT_DATA=/var/lib/cassandra/AAF_INIT_DATA
9 if [ ! -e /aaf_cmd ]; then
10 ln -s /opt/app/aaf/cass_init/cmd.sh /aaf_cmd
14 # Always need startup status...
15 if [ ! -e "$DIR" ]; then
21 echo "$@" > $DIR/aaf_cass
26 status wait for cassandra to start
27 for CNT in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15; do
28 if [ -z "$(grep 'listening for CQL clients' /var/log/cassandra/system.log)" ]; then
29 echo "Waiting for Cassandra to start... Sleep 10"
39 status wait for keyspace to be initialized
40 for CNT in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15; do
41 if [ -n "$(/usr/bin/cqlsh -e 'describe keyspaces' | grep authz)" ]; then
44 echo "Waiting for Keyspaces to be loaded... Sleep 10"
51 status wait for cassandra to be fully ready
52 for CNT in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15; do
53 STATUS="$(cat $DIR/aaf_cass)"
54 if [ "$STATUS" = "ready" ]; then
57 echo "Waiting for Start, $STATUS... Sleep 10"
63 function install_cql {
65 # Now, make sure data exists
66 if [ ! -e $INSTALLED_VERSION ] && [ -n "$(/usr/bin/cqlsh -e 'describe keyspaces' | grep authz)" ]; then
67 /usr/bin/cqlsh -e 'DROP KEYSPACE authz'
69 if [ -z "`/usr/bin/cqlsh -e 'describe keyspaces' | grep authz`" ]; then
71 echo "Initializing Cassandra DB"
72 echo "Docker Installed Basic Cassandra on aaf_cass. Executing the following "
73 echo "NOTE: This creator provided is only a Single Instance. For more complex Cassandra, create independently"
75 echo " cd /opt/app/aaf/cass_init"
76 cd /opt/app/aaf/cass_init
77 echo " cqlsh -f keyspace.cql"
78 /usr/bin/cqlsh -f keyspace.cql
79 status keyspace installed
80 echo " cqlsh -f init.cql"
81 /usr/bin/cqlsh -f init.cql
82 status data initialized
84 echo "The following will give you a temporary identity with which to start working, or emergency"
85 echo " cqlsh -f temp_identity.cql"
86 echo "casablanca" > $INSTALLED_VERSION
88 echo "Cassandra DB already includes 'authz' keyspace"
93 function install_onap {
94 echo " cd /opt/app/aaf/cass_init"
95 install_cql initialized
96 if [ -e "$AAF_INIT_DATA" ]; then
97 echo "AAF Data already initialized on this Cassandra"
99 status prep data for bootstrapping
100 cd /opt/app/aaf/cass_init
103 status push data to cassandra
106 echo $(date) > $AAF_INIT_DATA
113 # start install_cql in background, waiting for process to start
116 # Startup like normal
117 echo "Cassandra Startup"
118 /usr/local/bin/docker-entrypoint.sh
121 # Wait for initialization. This can be called from Docker only as a check to make sure it is ready
126 cd /opt/app/aaf/cass_init
127 # start install_onap (which calls install_cql first) in background, waiting for process to start
130 # Startup like normal
131 echo "Cassandra Startup"
132 /usr/local/bin/docker-entrypoint.sh