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
19 function install_cql {
22 status wait for cassandra to start
23 # Now, make sure data exists
24 if [ "$(/usr/bin/cqlsh -e 'describe keyspaces' | grep authz)" = "" ]; then
25 for CNT in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15; do
26 if [ -z "$(grep 'listening for CQL clients' /var/log/cassandra/system.log)" ]; then
27 echo "Waiting for Cassandra to start... Sleep 10"
33 echo "Initializing Cassandra DB"
34 if [ "`/usr/bin/cqlsh -e 'describe keyspaces' | grep authz`" == "" ]; then
35 echo "Docker Installed Basic Cassandra on aaf_cass. Executing the following "
36 echo "NOTE: This creator provided is only a Single Instance. For more complex Cassandra, create independently"
38 echo " cd /opt/app/aaf/cass_init"
39 cd /opt/app/aaf/cass_init
40 echo " cqlsh -f keyspace.cql"
41 /usr/bin/cqlsh -f keyspace.cql
42 status keyspace installed
43 echo " cqlsh -f init.cql"
44 /usr/bin/cqlsh -f init.cql
45 status data initialized
47 echo "The following will give you a temporary identity with which to start working, or emergency"
48 echo " cqlsh -f temp_identity.cql"
54 function install_onap {
55 install_cql initialized
57 # Change date expiring dat files to more recent
58 status Creating ONAP Identities
59 ID_FILE=/opt/app/aaf/cass_init/sample.identities.dat
60 if [ -e $ID_FILE ]; then
61 DATE=$(date "+%Y-%m-%d %H:%M:%S.000+0000" -d "+6 months")
63 CRED="/opt/app/aaf/cass_init/dats/cred.dat"
65 echo "Default Passwords for Apps"
66 for ID in $(grep '|a|' $ID_FILE | sed -e "s/|.*//"); do
67 if [ "$ID" = "aaf" ]; then
68 DOMAIN="aaf.osaaf.org";
70 DOMAIN="$ID.onap.org";
73 for D in ${DOMAIN//./ }; do
74 if [ -z "$FIRST" ]; then
81 echo "$ID@$DOMAIN|2|${DATE}|0xd993c5617486296f1b99d04de31633332b8ba1a550038e23860f9dbf0b2fcf95|Initial ID|$NS|53344|" >> $CRED
85 for ID in $(grep '|e|' $ID_FILE | sed -e "s/|.*//"); do
86 echo "$ID@people.osaaf.org|2|${DATE}|0xd993c5617486296f1b99d04de31633332b8ba1a550038e23860f9dbf0b2fcf95|Initial ID|org.osaaf.people|53344|" >> $CRED
90 status Setting up User Roles
91 mv dats/user_role.dat tmp
92 sed "s/\(^.*|\)\(.*|\)\(.*|\)\(.*\)/\1${DATE}|\3\4/" tmp > dats/user_role.dat
94 # Remove ID File, which is marker for initializing Creds
97 status Pushing data to cassandra
104 # start install_cql in background, waiting for process to start
107 # Startup like normal
108 echo "Cassandra Startup"
109 /usr/local/bin/docker-entrypoint.sh
112 # start install_onap (which calls install_cql first) in background, waiting for process to start
115 # Startup like normal
116 echo "Cassandra Startup"
117 /usr/local/bin/docker-entrypoint.sh