summaryrefslogtreecommitdiffstats
path: root/auth/auth-cass
diff options
context:
space:
mode:
Diffstat (limited to 'auth/auth-cass')
-rw-r--r--auth/auth-cass/cass_init/.gitignore1
-rw-r--r--auth/auth-cass/cass_init/cmd.sh49
-rw-r--r--auth/auth-cass/cass_init/data.sh59
-rw-r--r--auth/auth-cass/cass_init/prep.sh17
-rw-r--r--auth/auth-cass/docker/Dockerfile.cass4
-rw-r--r--auth/auth-cass/docker/backup.sh13
-rw-r--r--auth/auth-cass/docker/dbash.sh11
-rw-r--r--auth/auth-cass/docker/dbuild.sh10
-rw-r--r--auth/auth-cass/docker/dcqlsh.sh9
-rw-r--r--auth/auth-cass/docker/dinstall.sh2
-rw-r--r--auth/auth-cass/docker/drun.sh18
11 files changed, 61 insertions, 132 deletions
diff --git a/auth/auth-cass/cass_init/.gitignore b/auth/auth-cass/cass_init/.gitignore
index ce22752c..3387bc3b 100644
--- a/auth/auth-cass/cass_init/.gitignore
+++ b/auth/auth-cass/cass_init/.gitignore
@@ -1 +1,2 @@
temp.cql
+/dats/*
diff --git a/auth/auth-cass/cass_init/cmd.sh b/auth/auth-cass/cass_init/cmd.sh
index d1e70515..970aef44 100644
--- a/auth/auth-cass/cass_init/cmd.sh
+++ b/auth/auth-cass/cass_init/cmd.sh
@@ -85,50 +85,11 @@ function install_cql {
}
function install_onap {
- install_cql initialized
-
- # Change date expiring dat files to more recent
- status Creating ONAP Identities
- ID_FILE=/opt/app/aaf/cass_init/sample.identities.dat
- if [ -e $ID_FILE ]; then
- DATE=$(date "+%Y-%m-%d %H:%M:%S.000+0000" -d "+6 months")
- echo $DATE
- CRED="/opt/app/aaf/cass_init/dats/cred.dat"
- # Enter for People
- echo "Default Passwords for Apps"
- for ID in $(grep '|a|' $ID_FILE | sed -e "s/|.*//"); do
- if [ "$ID" = "aaf" ]; then
- DOMAIN="aaf.osaaf.org";
- else
- DOMAIN="$ID.onap.org";
- fi
- unset FIRST
- for D in ${DOMAIN//./ }; do
- if [ -z "$FIRST" ]; then
- NS="$D"
- FIRST="N"
- else
- NS="$D.$NS"
- fi
- done
- echo "$ID@$DOMAIN|2|${DATE}|0xd993c5617486296f1b99d04de31633332b8ba1a550038e23860f9dbf0b2fcf95|Initial ID|$NS|53344|" >> $CRED
- done
-
- # Enter for People
- for ID in $(grep '|e|' $ID_FILE | sed -e "s/|.*//"); do
- echo "$ID@people.osaaf.org|2|${DATE}|0xd993c5617486296f1b99d04de31633332b8ba1a550038e23860f9dbf0b2fcf95|Initial ID|org.osaaf.people|53344|" >> $CRED
- done
-
- # Change UserRole
- status Setting up User Roles
- mv dats/user_role.dat tmp
- sed "s/\(^.*|\)\(.*|\)\(.*|\)\(.*\)/\1${DATE}|\3\4/" tmp > dats/user_role.dat
-
- # Remove ID File, which is marker for initializing Creds
- rm $ID_FILE
- fi
- status Pushing data to cassandra
- bash push.sh
+ install_cql initialized
+ status prep data for bootstrapping
+ bash prep.sh
+ status push data to cassandra
+ bash push.sh
status ready
}
diff --git a/auth/auth-cass/cass_init/data.sh b/auth/auth-cass/cass_init/data.sh
deleted file mode 100644
index 0374e619..00000000
--- a/auth/auth-cass/cass_init/data.sh
+++ /dev/null
@@ -1,59 +0,0 @@
-#!/bin/bash
-#
-# Copies of Repo data need to be added to "dats" dir for loading by push.sh
-#
-# Further, repo data has dates that are out of date. We need to update reasonable
-# expiration dates
-#
-
-DIR=/opt/app/aaf/cass_init
-cd $DIR/dats
-ID_FILE=$DIR/opt/app/aaf/cass_init/
-
- if [ -e $ID_FILE ]; then
- if [ "$(uname -s)" = "Darwin" ]; then
- DATE=$(date "+%Y-%m-%d %H:%M:%S.000+0000" -v "+6m")
- else
- DATE=$(date "+%Y-%m-%d %H:%M:%S.000+0000" -d "+6 months")
- fi
- echo $DATE
- CRED="cred.dat"
- # Enter for People
- echo "Default Passwords for People"
- for ID in $(grep '|a|' $ID_FILE | sed -e "s/|.*//"); do
- if [ "$ID" = "aaf" ]; then
- DOMAIN="aaf.osaaf.org";
- else
- DOMAIN="$ID.onap.org";
- fi
- unset FIRST
- for D in ${DOMAIN//./ }; do
- if [ -z "$FIRST" ]; then
- NS="$D"
- FIRST="N"
- else
- NS="$D.$NS"
- fi
- done
- echo "$ID@$DOMAIN|2|${DATE}|0xd993c5617486296f1b99d04de31633332b8ba1a550038e23860f9dbf0b2fcf95|Initial ID|$NS|53344|" >> $CRED
- done
-
- for ID in $(grep '|e|' $ID_FILE | sed -e "s/|.*//"); do
- echo "$ID@people.osaaf.org|2|${DATE}|0xd993c5617486296f1b99d04de31633332b8ba1a550038e23860f9dbf0b2fcf95|Initial ID|org.osaaf.people|53344|" >> $CRED
- done
-
- mv user_role.dat tmp
- sed "s/\(^.*|\)\(.*|\)\(.*|\)\(.*\)/\1${DATE}|\3\4/" tmp > user_role.dat
-
- for DAT in ns perm role ns_attrib user_role cred; do
- $DOCKER container cp $DAT.dat aaf_cass:/tmp/$DAT.dat
- $DOCKER exec aaf_cass bash /usr/bin/cqlsh -k authz -e "COPY authz.$DAT FROM '/tmp/$DAT.dat' WITH DELIMITER='|'"
- $DOCKER exec -t aaf_cass rm /tmp/$DAT.dat
- done
- rm $CRED
- mv tmp user_role.dat
- else
- echo DInstall requires access to 'identities.dat'
- fi
- cd -
-
diff --git a/auth/auth-cass/cass_init/prep.sh b/auth/auth-cass/cass_init/prep.sh
new file mode 100644
index 00000000..5639ca43
--- /dev/null
+++ b/auth/auth-cass/cass_init/prep.sh
@@ -0,0 +1,17 @@
+#/bin/bash
+
+cd dats
+export DATE=$(date "+%Y-%m-%d %H:%M:%S.000+0000" -d "+6 months")
+
+TEMP=$(mktemp)
+
+mv user_role.dat $TEMP
+cat $TEMP | awk -F '|' '{print $1"|"$2"|"ENVIRON["DATE"]"|"$4"|"$5}' > user_role.dat
+
+mv cred.dat $TEMP
+cat $TEMP | awk -F '|' '{print $1"|"$2"|"ENVIRON["DATE"]"|"$4"|"$5"|"$6"|"$7"|"$8}' > cred.dat
+
+rm $TEMP
+
+cd - > /dev/null
+
diff --git a/auth/auth-cass/docker/Dockerfile.cass b/auth/auth-cass/docker/Dockerfile.cass
index d4487f9d..16028eae 100644
--- a/auth/auth-cass/docker/Dockerfile.cass
+++ b/auth/auth-cass/docker/Dockerfile.cass
@@ -7,9 +7,7 @@ LABEL version=${AAF_VERSION}
COPY cass_init/*.cql /opt/app/aaf/cass_init/
COPY cass_init/*.sh /opt/app/aaf/cass_init/
-COPY cass_init/*.dat /opt/app/aaf/cass_init/
-COPY cass_data /opt/app/aaf/cass_init/dats/
-COPY sample.identities.dat /opt/app/aaf/cass_init/
+COPY cass_data/*.dat /opt/app/aaf/cass_init/dats/
ENTRYPOINT ["/bin/bash","/opt/app/aaf/cass_init/cmd.sh"]
CMD ["start"]
diff --git a/auth/auth-cass/docker/backup.sh b/auth/auth-cass/docker/backup.sh
index 78a5e64d..b533c3ef 100644
--- a/auth/auth-cass/docker/backup.sh
+++ b/auth/auth-cass/docker/backup.sh
@@ -1,4 +1,11 @@
-#mkdir -p $DIR
-docker container exec -it aaf_cass bash -e '/opt/app/aaf/cass_init/pull.sh'
-docker container cp aaf_cass:/opt/app/aaf/cass_init/dat.gz "dat$(date +%Y%m%d).gz"
+#!/bin/bash
+
+# Pull in AAF Env Variables from AAF install
+if [ -e ../../docker/d.props ]; then
+ . ../../docker/d.props
+fi
+DOCKER=${DOCKER:-docker}
+
+$DOCKER container exec -it aaf_cass bash -e '/opt/app/aaf/cass_init/pull.sh'
+$DOCKER container cp aaf_cass:/opt/app/aaf/cass_init/dat.gz "dat$(date +%Y%m%d).gz"
diff --git a/auth/auth-cass/docker/dbash.sh b/auth/auth-cass/docker/dbash.sh
index 38e43dd0..b352a35c 100644
--- a/auth/auth-cass/docker/dbash.sh
+++ b/auth/auth-cass/docker/dbash.sh
@@ -1,3 +1,10 @@
-#!/bin/bash
-docker exec -it aaf_cass bash
+#!/bin/bash
+
+# Pull in AAF Env Variables from AAF install
+if [ -e ../../docker/d.props ]; then
+ . ../../docker/d.props
+fi
+DOCKER=${DOCKER:-docker}
+
+$DOCKER exec -it aaf_cass bash
diff --git a/auth/auth-cass/docker/dbuild.sh b/auth/auth-cass/docker/dbuild.sh
index aeef3293..f483557c 100644
--- a/auth/auth-cass/docker/dbuild.sh
+++ b/auth/auth-cass/docker/dbuild.sh
@@ -5,9 +5,8 @@
# Pull in AAF Env Variables from AAF install
if [ -e ../../docker/d.props ]; then
. ../../docker/d.props
-else
- . ../../docker/d.props.init
fi
+DOCKER=${DOCKER:-docker}
echo "Building aaf_cass Container for aaf_cass:$VERSION"
@@ -18,9 +17,10 @@ cd ..
cp -Rf sample/cass_data auth-cass/cass_data
cp sample/data/sample.identities.dat auth-cass
-docker build -t ${ORG}/${PROJECT}/aaf_cass:${VERSION} auth-cass
-docker tag ${ORG}/${PROJECT}/aaf_cass:${VERSION} ${DOCKER_REPOSITORY}/${ORG}/${PROJECT}/aaf_cass:${VERSION}
-docker tag ${ORG}/${PROJECT}/aaf_cass:${VERSION} ${DOCKER_REPOSITORY}/${ORG}/${PROJECT}/aaf_cass:latest
+echo $DOCKER build -t ${ORG}/${PROJECT}/aaf_cass:${VERSION} auth-cass
+$DOCKER build -t ${ORG}/${PROJECT}/aaf_cass:${VERSION} auth-cass
+$DOCKER tag ${ORG}/${PROJECT}/aaf_cass:${VERSION} ${DOCKER_REPOSITORY}/${ORG}/${PROJECT}/aaf_cass:${VERSION}
+$DOCKER tag ${ORG}/${PROJECT}/aaf_cass:${VERSION} ${DOCKER_REPOSITORY}/${ORG}/${PROJECT}/aaf_cass:latest
cd -
rm Dockerfile
diff --git a/auth/auth-cass/docker/dcqlsh.sh b/auth/auth-cass/docker/dcqlsh.sh
index a6c08643..ce861dc2 100644
--- a/auth/auth-cass/docker/dcqlsh.sh
+++ b/auth/auth-cass/docker/dcqlsh.sh
@@ -1,3 +1,8 @@
-#!/bin/bash
-docker exec -it aaf_cass /usr/bin/cqlsh -k authz
+#!/bin/bash
+
+# Pull in AAF Env Variables from AAF install
+if [ -e ../../docker/d.props ]; then
+ . ../../docker/d.props
+fi
+${DOCKER:=docker} exec -it aaf_cass /usr/bin/cqlsh -k authz
diff --git a/auth/auth-cass/docker/dinstall.sh b/auth/auth-cass/docker/dinstall.sh
index ec82d8af..11bf6a15 100644
--- a/auth/auth-cass/docker/dinstall.sh
+++ b/auth/auth-cass/docker/dinstall.sh
@@ -6,7 +6,7 @@
echo "Waiting for Cass to be initialized"
for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 14; do
- docker exec -it aaf_cass bash aaf_cmd wait 2> /dev/null
+ $DOCKER exec -it aaf_cass bash aaf_cmd wait 2> /dev/null
if [ "$?" -ne "0" ]; then
echo "Container not ready... Sleep 10"
sleep 10
diff --git a/auth/auth-cass/docker/drun.sh b/auth/auth-cass/docker/drun.sh
index 081411b3..21de1ac4 100644
--- a/auth/auth-cass/docker/drun.sh
+++ b/auth/auth-cass/docker/drun.sh
@@ -1,26 +1,18 @@
-#!/bin/bash
+#!/bin/bash
# Pull in AAF Env Variables from AAF install
if [ -e ../../docker/d.props ]; then
. ../../docker/d.props
-else
- . ../../docker/d.props.init
-fi
-
-if [ -e /usr/bin/docker ]; then
- DOCKER=/usr/bin/docker
-elif [ -e /usr/local/bin/docker ]; then
- DOCKER=/usr/local/bin/docker
-else
- echo Docker not available in /usr/bin or /usr/local/bin
- exit
fi
+DOCKER=${DOCKER:-docker}
if [ "$($DOCKER volume ls | grep aaf_cass_data)" = "" ]; then
$DOCKER volume create aaf_cass_data
echo "Created Cassandra Volume aaf_cass_data"
fi
+# Optional mount instead of v
+# --mount 'type=volume,src=aaf_cass_data,dst=/var/lib/cassandra,volume-driver=local' \
if [ "`$DOCKER ps -a | grep aaf_cass`" == "" ]; then
echo "starting Cass from 'run'"
# NOTE: These HEAP Sizes are minimal. Not set for full organizations.
@@ -30,7 +22,7 @@ if [ "`$DOCKER ps -a | grep aaf_cass`" == "" ]; then
-e MAX_HEAP_SIZE=1024M \
-e CASSANDRA_DC=dc1 \
-e CASSANDRA_CLUSTER_NAME=osaaf \
- --mount 'type=volume,src=aaf_cass_data,dst=/var/lib/cassandra,volume-driver=local' \
+ -v "aaf_cass_data:/var/lib/cassandra" \
-d ${PREFIX}${ORG}/${PROJECT}/aaf_cass:${VERSION} "onap"
else
$DOCKER start aaf_cass