Instrumental | bc299c0 | 2018-09-25 06:42:31 -0500 | [diff] [blame^] | 1 | #!/bin/bash |
| 2 | # |
| 3 | # Engage normal Cass Init, then check for data installation |
| 4 | # |
| 5 | if [ ! -e /aaf_cmd ]; then |
| 6 | ln -s /opt/app/aaf/cass_init/cmd.sh /aaf_cmd |
| 7 | chmod u+x /aaf_cmd |
| 8 | fi |
| 9 | |
| 10 | function install_cql { |
| 11 | # Now, make sure data exists |
| 12 | if [ "$(/usr/bin/cqlsh -e 'describe keyspaces' | grep authz)" = "" ]; then |
| 13 | for CNT in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15; do |
| 14 | if [ -z "$(grep 'listening for CQL clients' /var/log/cassandra/system.log)" ]; then |
| 15 | echo "Waiting for Cassandra to start... Sleep 10" |
| 16 | sleep 10 |
| 17 | else |
| 18 | break |
| 19 | fi |
| 20 | done |
| 21 | echo "Initializing Cassandra DB" |
| 22 | if [ "`/usr/bin/cqlsh -e 'describe keyspaces' | grep authz`" == "" ]; then |
| 23 | echo "Docker Installed Basic Cassandra on aaf_cass. Executing the following " |
| 24 | echo "NOTE: This creator provided is only a Single Instance. For more complex Cassandra, create independently" |
| 25 | echo "" |
| 26 | echo " cd /opt/app/aaf/cass_init" |
| 27 | cd /opt/app/aaf/cass_init |
| 28 | echo " cqlsh -f keyspace.cql" |
| 29 | /usr/bin/cqlsh -f keyspace.cql |
| 30 | echo " cqlsh -f init.cql" |
| 31 | /usr/bin/cqlsh -f init.cql |
| 32 | echo "" |
| 33 | echo "The following will give you a temporary identity with which to start working, or emergency" |
| 34 | echo " cqlsh -f temp_identity.cql" |
| 35 | fi |
| 36 | fi |
| 37 | } |
| 38 | |
| 39 | case "$1" in |
| 40 | start) |
| 41 | # Startup like normal |
| 42 | echo "Cassandra Startup" |
| 43 | /usr/local/bin/docker-entrypoint.sh |
| 44 | ;; |
| 45 | onap) |
| 46 | install_cql |
| 47 | |
| 48 | # Change date expiring dat files to more recent |
| 49 | ID_FILE=/opt/app/aaf/cass_init/sample.identities.dat |
| 50 | if [ -e $ID_FILE ]; then |
| 51 | DATE=$(date "+%Y-%m-%d %H:%M:%S.000+0000" -d "+6 months") |
| 52 | echo $DATE |
| 53 | CRED="/opt/app/aaf/cass_init/dats/cred.dat" |
| 54 | # Enter for People |
| 55 | echo "Default Passwords for Apps" |
| 56 | for ID in $(grep '|a|' $ID_FILE | sed -e "s/|.*//"); do |
| 57 | if [ "$ID" = "aaf" ]; then |
| 58 | DOMAIN="aaf.osaaf.org"; |
| 59 | else |
| 60 | DOMAIN="$ID.onap.org"; |
| 61 | fi |
| 62 | unset FIRST |
| 63 | for D in ${DOMAIN//./ }; do |
| 64 | if [ -z "$FIRST" ]; then |
| 65 | NS="$D" |
| 66 | FIRST="N" |
| 67 | else |
| 68 | NS="$D.$NS" |
| 69 | fi |
| 70 | done |
| 71 | echo "$ID@$DOMAIN|2|${DATE}|0xd993c5617486296f1b99d04de31633332b8ba1a550038e23860f9dbf0b2fcf95|Initial ID|$NS|53344|" >> $CRED |
| 72 | done |
| 73 | |
| 74 | # Enter for People |
| 75 | for ID in $(grep '|e|' $ID_FILE | sed -e "s/|.*//"); do |
| 76 | echo "$ID@people.osaaf.org|2|${DATE}|0xd993c5617486296f1b99d04de31633332b8ba1a550038e23860f9dbf0b2fcf95|Initial ID|org.osaaf.people|53344|" >> $CRED |
| 77 | done |
| 78 | |
| 79 | # Change UserRole |
| 80 | mv dats/user_role.dat tmp |
| 81 | sed "s/\(^.*|\)\(.*|\)\(.*|\)\(.*\)/\1${DATE}|\3\4/" tmp > dats/user_role.dat |
| 82 | |
| 83 | # Remove ID File, which is marker for initializing Creds |
| 84 | rm $ID_FILE |
| 85 | fi |
| 86 | bash push.sh |
| 87 | ;; |
| 88 | esac |
| 89 | |