3 # Engage normal Cass Init, then check for data installation
5 DIR="/opt/app/aaf/status"
7 if [ ! -e /aaf_cmd ]; then
8 ln -s /opt/app/aaf/cass_init/cmd.sh /aaf_cmd
13 if [ -d "$DIR" ]; then
15 echo "$@" > $DIR/aaf_cass
21 status wait for cassandra to start
22 for CNT in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15; do
23 if [ -z "$(grep 'listening for CQL clients' /var/log/cassandra/system.log)" ]; then
24 echo "Waiting for Cassandra to start... Sleep 10"
33 status wait for keyspace to be initialized
34 for CNT in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15; do
35 if [ -n "$(/usr/bin/cqlsh -e 'describe keyspaces' | grep authz)" ]; then
38 echo "Waiting for Keyspaces to be loaded... Sleep 10"
44 function install_cql {
46 # Now, make sure data exists
47 if [ "$(/usr/bin/cqlsh -e 'describe keyspaces' | grep authz)" = "" ]; then
49 echo "Initializing Cassandra DB"
50 if [ "`/usr/bin/cqlsh -e 'describe keyspaces' | grep authz`" == "" ]; then
51 echo "Docker Installed Basic Cassandra on aaf_cass. Executing the following "
52 echo "NOTE: This creator provided is only a Single Instance. For more complex Cassandra, create independently"
54 echo " cd /opt/app/aaf/cass_init"
55 cd /opt/app/aaf/cass_init
56 echo " cqlsh -f keyspace.cql"
57 /usr/bin/cqlsh -f keyspace.cql
58 status keyspace installed
59 echo " cqlsh -f init.cql"
60 /usr/bin/cqlsh -f init.cql
61 status data initialized
63 echo "The following will give you a temporary identity with which to start working, or emergency"
64 echo " cqlsh -f temp_identity.cql"
70 function install_onap {
71 install_cql initialized
73 # Change date expiring dat files to more recent
74 status Creating ONAP Identities
75 ID_FILE=/opt/app/aaf/cass_init/sample.identities.dat
76 if [ -e $ID_FILE ]; then
77 DATE=$(date "+%Y-%m-%d %H:%M:%S.000+0000" -d "+6 months")
79 CRED="/opt/app/aaf/cass_init/dats/cred.dat"
81 echo "Default Passwords for Apps"
82 for ID in $(grep '|a|' $ID_FILE | sed -e "s/|.*//"); do
83 if [ "$ID" = "aaf" ]; then
84 DOMAIN="aaf.osaaf.org";
86 DOMAIN="$ID.onap.org";
89 for D in ${DOMAIN//./ }; do
90 if [ -z "$FIRST" ]; then
97 echo "$ID@$DOMAIN|2|${DATE}|0xd993c5617486296f1b99d04de31633332b8ba1a550038e23860f9dbf0b2fcf95|Initial ID|$NS|53344|" >> $CRED
101 for ID in $(grep '|e|' $ID_FILE | sed -e "s/|.*//"); do
102 echo "$ID@people.osaaf.org|2|${DATE}|0xd993c5617486296f1b99d04de31633332b8ba1a550038e23860f9dbf0b2fcf95|Initial ID|org.osaaf.people|53344|" >> $CRED
106 status Setting up User Roles
107 mv dats/user_role.dat tmp
108 sed "s/\(^.*|\)\(.*|\)\(.*|\)\(.*\)/\1${DATE}|\3\4/" tmp > dats/user_role.dat
110 # Remove ID File, which is marker for initializing Creds
113 status Pushing data to cassandra
120 # start install_cql in background, waiting for process to start
123 # Startup like normal
124 echo "Cassandra Startup"
125 /usr/local/bin/docker-entrypoint.sh
128 # Wait for initialization. This can be called from Docker only as a check to make sure it is ready
131 # Make sure Keyspace is loaded
134 # Wait for Data load?
138 # start install_onap (which calls install_cql first) in background, waiting for process to start
141 # Startup like normal
142 echo "Cassandra Startup"
143 /usr/local/bin/docker-entrypoint.sh