summaryrefslogtreecommitdiffstats
path: root/auth/sample/cass_data/scrub.sh
diff options
context:
space:
mode:
authorInstrumental <jonathan.gathman@att.com>2018-10-08 11:27:18 -0500
committerInstrumental <jonathan.gathman@att.com>2018-10-08 11:28:00 -0500
commit94053613671f7456ea5114a8421d0e6868bdbba0 (patch)
treef81e1585e9b9e76dd74a0c8381926ed7b1c6e8be /auth/sample/cass_data/scrub.sh
parent49525303bc07064d60b3dde3056b2e9e8a379435 (diff)
Artifacts to Bootstrap
Issue-ID: AAF-543 Change-Id: I95d11b11c21ddeb63e393528c2504af673d27a6f Signed-off-by: Instrumental <jonathan.gathman@att.com>
Diffstat (limited to 'auth/sample/cass_data/scrub.sh')
-rw-r--r--auth/sample/cass_data/scrub.sh93
1 files changed, 78 insertions, 15 deletions
diff --git a/auth/sample/cass_data/scrub.sh b/auth/sample/cass_data/scrub.sh
index 016b58a7..df4d670f 100644
--- a/auth/sample/cass_data/scrub.sh
+++ b/auth/sample/cass_data/scrub.sh
@@ -1,20 +1,83 @@
-> user_role.dat
-for ID in $(grep -v "#" ../data/sample.identities.dat | awk -F\| '{print $1}' | grep -v "^$"); do
- grep "$ID@" dats/user_role.dat >> user_role.dat
-done
+#!/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 and may have IDs not valid. We need to make
+# sure the important data is consistent with Identities.
+#
+# This is expected to be run from a controlling Machine data "authz/auth/sample/cass_data" when a backup
+# is created that is intended to be "Bootstrap Data"
+#
+# Date resets on key data load on the system at load time
+#
-for D in ns ns_attrib perm role config; do
- cp dats/$D.dat .
-done
+DIR=$(pwd)
+ID_FILE=../data/sample.identities.dat
-echo "Roles in TEST data not in sample.identities.dat (../data)"
-UR="$(mktemp)"
-DUR="$(mktemp)"
+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
-cat user_role.dat | awk -F\| '{print $1}' | sort -u > $UR
-cat dats/user_role.dat | awk -F\| '{print $1}' | sort -u > $DUR
-echo "Removed IDs from user_roles"
-diff $UR $DUR | grep "^>" | sort -u
+ #### CRED
+ # Enter for People
+ CRED="cred.dat"
+ echo "Create default Passwords for all Identities in $CRED"
+ 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
+
+
+ ##### USER_ROLE
+ echo "Scrubbing user_roles not in $ID_FILE"
+ > user_role.dat
+ for ID in $(grep -v "#" $ID_FILE | awk -F\| '{print $1}' | grep -v "^$"); do
+ grep "$ID@" dats/user_role.dat >> user_role.dat
+ done
+
+ for D in ns ns_attrib perm role config artifact; do
+ cp dats/$D.dat .
+ done
+
+ UR="$(mktemp)"
+ DUR="$(mktemp)"
+
+ cat user_role.dat | awk -F\| '{print $1}' | sort -u > $UR
+ cat dats/user_role.dat | awk -F\| '{print $1}' | sort -u > $DUR
+
+ echo "Removed IDs from user_roles"
+ diff $UR $DUR | grep "^>" | sort -u
+
+ rm "$UR" "$DUR"
+
+ mv user_role.dat tmp
+ sed "s/\(^.*|\)\(.*|\)\(.*|\)\(.*\)/\1${DATE}|\3\4/" tmp > user_role.dat
+ rm tmp
+
+else
+ echo $0 requires access to $ID_FILE
+fi
+
-rm "$UR" "$DUR"